summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-09-23 23:30:54 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-09-23 23:30:54 +0000
commit041bce7f1ab685a4290865e4eb2c2f5d2aaac285 (patch)
treed7305d5a8fb789cffc0c4795cc3ff7eff2b8585f /Makefile
parent61b38e21c24cb2537b7105f5867745d0a569ec6f (diff)
downloaddrakx-041bce7f1ab685a4290865e4eb2c2f5d2aaac285.tar
drakx-041bce7f1ab685a4290865e4eb2c2f5d2aaac285.tar.gz
drakx-041bce7f1ab685a4290865e4eb2c2f5d2aaac285.tar.bz2
drakx-041bce7f1ab685a4290865e4eb2c2f5d2aaac285.tar.xz
drakx-041bce7f1ab685a4290865e4eb2c2f5d2aaac285.zip
no_comment
Diffstat (limited to 'Makefile')
0 files changed, 0 insertions, 0 deletions
'n115' href='#n115'>115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
package harddrake::ui;

use strict;

use harddrake::data;
use harddrake::sound;
use common;
use ugtk qw(:helpers :wrappers :various);
use my_gtk qw(:helpers :wrappers);
use interactive;


# { field => [ short_translation, full_description] }
my %fields = 
    (
	"Model" => [_("Model"), _("hard disk model")],
	"channel" => [_("Channel"), _("EIDE/SCSI channel")],
	"bus" => 
	[ _("Bus"), 
	  _("this is the physical bus on which the device is plugged (eg: PCI, USB, ...)")],
	"driver" => [ _("Module"), _("the module of the GNU/Linux kernel that handle that device")],
	"media_type" => [ _("Media class"), _("class of hardware device")],
	"description" => [ _("Description"), _("this field describe the device")],
	"bus_id" => 
	[ _("Bus identification"), 
	  _("- PCI and USB devices: this list the vendor, device, subvendor and subdevice PCI/USB ids")],
	"bus_location" => 
	[ _("Location on the bus"), 
	  _("- pci devices: this gives the PCI slot, device and function of this card
- eide devices: the device is either a slave or a master device
- scsi devices: the scsi bus and the scsi device ids")],
	"device" => [ _("Old device file"),
			    _("old static device name used in dev package")],
	"devfs_device" => [ _("New devfs device"),  
					_("new dinamic device name generated by incore kernel devfs")],
	"nbuttons" => [ _("Number of buttons"), "the number of buttons the mouse have"],
	"Vendor" => [ _("Vendor"), _("the vendor name of the device")],
	"alternative_drivers" => [ _("Alternative drivers"),
						  _("the list of alternative drivers for this sound card")]
	);


our $license = 'Copyright (C) 1999-2002 MandrakeSoft by tvignaud@mandrakesoft.com

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
';

my ($in, %IDs, $pid, $w);

my @menu_items = ( { path => _("/_File"), type => '<Branch>' },
			    { path => _("/_File")._("/_Quit"), accelerator => _("<control>Q"), callback => \&quit_global	},
			    { path => _("/_Help"), type => '<Branch>' },
			    { path => _("/_Help")._("/_Help..."), callback => sub {
				   $in->ask_warn(_("Harddrake help"), 
							  _("Description of the fields:\n\n")
							  . join("\n\n", map { "$fields{$_}[0]: $fields{$_}[1]"} keys %fields));
			    }
			  },
			    { path => _("/_Help")._("/_About..."), callback => sub {
				   $in->ask_warn(_("About Harddrake"), 
							  join ("", _("This is HardDrake, a Mandrake hardware configuration tool.\nVersion:"), " $harddrake::data::version\n", 
								   _("Author:"), " Thierry Vignaud <tvignaud\@mandrakesoft.com> \n\n" ,
								   formatAlaTeX($license)));
			    }
			  },
			    );

sub new {
    my $sig_id;
    $in = 'interactive'->vnew('su', 'default');
    add_icon_path('/usr/share/pixmaps/harddrake2/');
    $w = my_gtk->new((_("Harddrake2 version ") . $harddrake::data::version));
    $w->{window}->set_usize(760, 550) unless $::isEmbedded;
    $w->{window}->add( 
		 my $main_vbox = gtkadd(gtkadd($::isEmbedded ? new Gtk::VBox(0, 0) :
								 gtkadd(new Gtk::VBox(0, 0),
									   my $menubar = ugtk::create_factory_menu($w->{rwindow}, @menu_items)),
								 my $hpaned = new Gtk::HPaned),
						    my $statusbar = new Gtk::Statusbar));
    $main_vbox->set_child_packing($statusbar, 0, 0, 0, 'start');
    if ($::isEmbedded) {
	   $main_vbox->add(gtksignal_connect(my $but = new Gtk::Button(_("Quit")),
								  'clicked' => \&quit_global));
	   $main_vbox->set_child_packing($but, 0, 0, 0, 'start');
    } else { $main_vbox->set_child_packing($menubar, 0, 0, 0, 'start') }

    $hpaned->pack1(gtkadd(new Gtk::Frame(_("Detected hardware")), createScrolledWindow(my $tree = new Gtk::CTree(1, 0))), 1, 1);
    $hpaned->pack2(my $vbox = gtkadd(gtkadd(gtkadd(new Gtk::VBox,
										 gtkadd(new Gtk::Frame(_("Information")),
											   gtkadd(new Gtk::HBox, 
													createScrolledWindow(my $text = new Gtk::Text)))), 
								    my $module_cfg_button = new Gtk::Button(_("Configure module"))),
							  my $config_button = new Gtk::Button(_("Run config tool"))), 1, 1);
    $vbox->set_child_packing($config_button, 0, 0, 0, 'start');
    $vbox->set_child_packing($module_cfg_button, 0, 0, 0, 'start');

    my $wait = $in->wait_message(_("Please wait"), _("Detection in progress"));

    my $cmap = Gtk::Gdk::Colormap->get_system;
    my $color = { 'red' => 0x3100, 'green' => 0x6400, 'blue' => 0xbc00 };
    $cmap->color_alloc($color);
    my $wcolor = { 'red' => 0xFFFF, 'green' => 0x6400, 'blue' => 0x6400 };
    $cmap->color_alloc($wcolor);
    $tree->set_column_auto_resize(0, 1);
    my $curr = $tree->node_nth(0); #- default value
    $tree->signal_connect( 'select_row', sub {
	   my ( $ctree, $row, $column, $event ) = @_;
	   my $node = $ctree->node_nth( $row );
	   my ($name, undef) = $tree->node_get_pixtext($node,0);
	   my $data = $tree->{data}{$name};

	   if ($data) {
		  $text->hide;
		  $text->backward_delete($text->get_point);
		  foreach my $i (sort keys %$data) {
			 $text->insert("", $text->style->black, "", ($fields{$i}[0] ? $fields{$i}[0] : $i) . ": ");
			 if ($i eq 'driver' && $data->{$i} eq 'unknown') {
				$text->insert("", $wcolor, "", "$data->{$i}\n\n");
			 } else { $text->insert("", $color, "", "$data->{$i}\n\n") }
		  }
		  disconnect($module_cfg_button, 'module');
		  if (exists $data->{driver} &&  $data->{driver} !~ /(unknown|.*\|.*)/ &&  $data->{driver} !~ /^Card:/) {
			 $module_cfg_button->show;
			 $IDs{module} = $module_cfg_button->signal_connect(clicked => sub {
				require modules;
				modules::mergein_conf('/etc/modules.conf');
				my %conf = modules::get_parameters($data->{driver});
				require modparm;
				my @l;
				foreach (modparm::parameters($data->{driver})) {
				    my ($name, $format, $description) = @$_;
				    push @l, { label => $name, help => "$description\n[$format]", val => \$conf{$name} };
				}
				if ($in->ask_from("Module configuration", _("You can configure each parameter of the module here."), \@l)) {
				    my $options = join(' ', map { if_($conf{$_}, "$_=$conf{$_}") } keys %conf);
				    if ($options) {
					   modules::set_options($_->{driver}, $options);
						modules::write_conf;
					 }
				}
				gtkset_mousecursor_normal();
			 });
		  }
		  disconnect($config_button, 'tool');
		  $text->show;
		  my $configurator = $tree->{configurator}{$name};

		  return unless -x $configurator;
		  $IDs{tool} = $config_button->signal_connect(clicked => sub {
			 return if defined $pid;
			 if ($pid = fork()) {
				$sig_id = $statusbar->push($statusbar->get_context_id("id"), _("Running \"%s\" ...", $configurator));
			 } else { exec($configurator) or die "$configurator missing\n" }
		  }) ;
		  $config_button->show;
	   } else {
		  $text->backward_delete($text->get_point); # erase all previous text
		  $config_button->hide;
		  $module_cfg_button->hide;
	   }
    });

    foreach (@harddrake::data::tree) {
	   my ($Ident, $title, $icon, $configurator, $detector) = @$_;
	   next if (ref($detector) ne "CODE"); #skip class witouth detector
	   print _("Probing %s class\n", $Ident);
	   next if $Ident =~ /(MODEM|PRINTER)/ && "@ARGV" =~ /test/;
	   my @devices = &$detector;
	   next if (!listlength(@devices)); # Skip empty class (no devices)
	   my $hw_class_tree = $tree->insert_node(undef, undef, [$title], 5, (gtkcreate_png($icon)) x 2, 0, ($title =~ /Unknown/ ? 0 : 1));