summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordamien <damien@mandriva.com>2002-02-14 16:20:54 +0000
committerdamien <damien@mandriva.com>2002-02-14 16:20:54 +0000
commitb1ccaef1c38b7f13e5ddbdde8d9585e2e2b53ef3 (patch)
treebb9dea5b29ec9fb6f1e3395a19eec9e16b183a25
parent48665c6568dc03d7248c83ae59f51e7a1744e6ea (diff)
downloadcontrol-center-b1ccaef1c38b7f13e5ddbdde8d9585e2e2b53ef3.tar
control-center-b1ccaef1c38b7f13e5ddbdde8d9585e2e2b53ef3.tar.gz
control-center-b1ccaef1c38b7f13e5ddbdde8d9585e2e2b53ef3.tar.bz2
control-center-b1ccaef1c38b7f13e5ddbdde8d9585e2e2b53ef3.tar.xz
control-center-b1ccaef1c38b7f13e5ddbdde8d9585e2e2b53ef3.zip
code cleaning
-rwxr-xr-xcontrol-center336
1 files changed, 177 insertions, 159 deletions
diff --git a/control-center b/control-center
index 6bfd1202..9709e336 100755
--- a/control-center
+++ b/control-center
@@ -62,30 +62,30 @@ $::isWiz = -e "/usr/sbin/wizdrake"; #- $in->do_pkgs->is_installed(q(wizard));
my $exec_hash =
{
#- ("label") => [ "exec", gtk_plug? if not, then xplug, "exec_alternative" for when not embedded, or [ args for xplug ] ],
- _("Boot Disk") => [ "$_xbindir/drakfloppy.real", 1],
- _("Boot Config") => [ "$_sbindir/drakboot", 1 ],
- _("Auto Install") => [ "$_sbindir/drakautoinst", 1 ],
- _("Display") => [ "$_sbindir/XFdrake", 1 ],
- _("Hardware") => [ "$_sbindir/harddrake", 1 ],
- _("Mouse") => [ "$_sbindir/mousedrake", 1 ],
- _("Printer") => [ "$_sbindir/print.pm", 1 ],
- _("Keyboard") => [ "$_sbindir/keyboarddrake", 1 ],
- _("Hard Drives") => [ "$_sbindir/diskdrake --hd", 1 ],
- _("Removable disks") => [ "$_sbindir/diskdrake --removable", 1 ],
- _("NFS mount points") => [ "$_sbindir/diskdrake --nfs", 1 ],
- _("Samba mount points") => [ "$_sbindir/diskdrake --smb", 1 ],
- _("Connection") => [ "$_sbindir/draknet", 1 ],
- _("Connection Sharing") => [ "$_sbindir/drakgw", 1 ],
- _("Security Level") => [ "$_sbindir/draksec", 1 ],
- _("Firewalling") => [ "$_sbindir/tinyfirewall", 1 ],
- _("Menus") => [ "$_sbindir/menus.pm", 1 ],
- _("Services") => [ "$_sbindir/drakxservices", 1 ],
- _("Fonts") => [ "$_sbindir/drakfont", 1 ],
- _("Date & Time") => [ "$_sbindir/clock.pm", 1 ],
- _("Software Manager") => [ "$_bindir/rpmdrake", 1 ],
- _("Logs") => [ "$_sbindir/logdrake", 1 ],
- _("Console") => [ "$_xbindir/rxvt", 0, ["rxvt", "rxvt", 1] ],
- _("Servers") => [ "$_sbindir/wizdrake", 1 ],
+ _("Boot Disk") => [ "drakfloppy", "$_xbindir/drakfloppy.real", 1],
+ _("Boot Config") => [ "drakboot", "$_sbindir/drakboot", 1 ],
+ _("Auto Install") => [ "drakautoinst", "$_sbindir/drakautoinst", 1 ],
+ _("Display") => [ "XFdrake", "$_sbindir/XFdrake", 1 ],
+ _("Hardware") => [ "harddrake", "$_sbindir/harddrake", 1 ],
+ _("Mouse") => [ "mousedrake", "$_sbindir/mousedrake", 1 ],
+ _("Printer") => [ "printerdrake", "$_sbindir/printerdrake", 1, "_sbindir/printerdrake" ],
+ _("Keyboard") => [ "keyboarddrake", "$_sbindir/keyboarddrake", 1 ],
+ _("Hard Drives") => [ "diskdrake", "$_sbindir/diskdrake --hd", 1 ],
+ _("Removable disks") => [ "diskdrake", "$_sbindir/diskdrake --removable", 1 ],
+ _("NFS mount points") => [ "diskdrake", "$_sbindir/diskdrake --nfs", 1 ],
+ _("Samba mount points") => [ "diskdrake", "$_sbindir/diskdrake --smb", 1 ],
+ _("Connection") => [ "draknet", "$_sbindir/draknet", 1 ],
+ _("Connection Sharing") => [ "drakgw", "$_sbindir/drakgw", 1 ],
+ _("Security Level") => [ "draksec", "$_sbindir/draksec", 1 ],
+ _("Firewalling") => [ "tinyfirewall", "$_sbindir/tinyfirewall", 1 ],
+ _("Menus") => [ "menudrake", "$_sbindir/menus.pm", 1, "$_bindir/menusdrake" ],
+ _("Services") => [ "drakxservices", "$_sbindir/drakxservices", 1 ],
+ _("Fonts") => [ "drakfont", "$_sbindir/drakfont", 1 ],
+ _("Date & Time") => [ "clock", "$_sbindir/clock.pm", 1 ],
+ _("Software Manager") => [ "rpmdrake", "$_bindir/rpmdrake", 1 ],
+ _("Logs") => [ "logdrake", "$_sbindir/logdrake", 1 ],
+ _("Console") => [ "rxvt", "$_xbindir/rxvt", 0, ["rxvt", "rxvt", 1] ],
+ _("Servers") => [ "wizdrake", "$_sbindir/wizdrake", 1 ],
};
my @tree =
@@ -167,7 +167,7 @@ $back[1] = $back[0];
my $style_dflt = new Gtk::Style;
# fontsets *must* be used in order to allow proper font selection for non
# latin1 languages; never use a simple font, *always* load a fontset
-$style_dflt->font(Gtk::Gdk::Font->fontset_load(_("-*-times-bold-r-normal-*-14-*-*-*-p-*-iso8859-1,*-r-*")));
+# $style_dflt->font(Gtk::Gdk::Font->fontset_load(_("-*-times-bold-r-normal-*-14-*-*-*-p-*-iso8859-1,*-r-*")));
my $index = 0;
my $darea_left_sav;
foreach (@tree) {
@@ -243,94 +243,6 @@ my $emb_box;
my $emb_socket;
my @pid_launched;
-sub compute_exec_string {
- my ($arg) = @_;
- my ($exec, $gtkplug, $alternate) = @$arg;
- if ($embedded) {
- $notebook_global->hide;
- res_socket();
- $emb_box->show;
- $emb_socket->realize;
- my $exec = $exec . " --embedded " . $emb_socket->window->XWINDOW . " " . $$;
- if ($gtkplug) {
- my $pid;
- unless ($pid = fork) {
- splash_warning(_("cannot fork: %s", $~)) unless defined $pid;
- exec("$exec");
- }
- push @pid_launched, $pid;
- } else {
- $emb_socket->steal(launch_xapp($alternate));
- }
- } else {
- system("$exec &");
- }
- if($logs) {
- $exp_socket->realize;
- my $pid;
- unless ($pid = fork) {
- splash_warning(_("cannot fork: %s", $~)) unless defined $pid;
- exec("logdrake --explain=drakfloppy.real --embedded " . $exp_socket->window->XWINDOW . " " . $$);
- }
- push @pid_launched, $pid;
- }
- if ($embedded) {
- foreach (@darea_left_list) {
- $_->[1]->window->set_cursor($cursor_hand);
- if($_->[1]->{state} != 0) {
- $_->[1]->{state} = 0;
- $_->[1]->draw(undef);
- }
- }
- }
-}
-
-sub launch_xapp {
-# my ($exec, $grep, $num) = @_;
- my $b = "xwininfo -root -tree -int | grep '" . $_[0]->[1] . "'";
- my @before = split ('\n', `$b`);
- my $pid;
- unless ($pid = fork) {
- splash_warning(_("cannot fork: %s", $~)) unless defined $pid;
- exec($_[0]->[0]);
- }
- push @pid_launched, $pid;
- my $res = 0;
- while (!$res) {
- my @after = split ('\n', `$b`);
- while (@after ne ($_[0]->[2]+@before)) {
- @after = split ('\n', `$b`);
- }
- my $i = 0;
- my $c;
- foreach (@after) {
- $c = $after[$i] if !member($after[$i], @before);
- $i++;
- }
- $c =~ /\s*([0-9]*)\s*/;
- $res=$1;
- }
- $res;
-}
-
-sub clean_socket {
- $emb_box->hide;
- $logs and $exp_frame->hide;
- foreach (@pid_launched) {
- kill 'TERM', $_ if (defined $_);
- }
- @pid_launched = ();
- $emb_socket and $emb_socket->destroy();
- $exp_socket and $exp_socket->destroy();
- $logs and $exp_frame->show;
-}
-
-sub res_socket {
- clean_socket();
- gtkpack($emb_box, $emb_socket = new Gtk::Socket);
- $emb_socket->hide;
- $logs and gtkadd($exp_frame, $exp_socket = new Gtk::Socket);
-}
my ($rootheight, undef) = my_gtk::gtkroot()->get_size;
@@ -432,7 +344,7 @@ $darea1->signal_connect( expose_event => sub {
fill_tiled($darea1, $pix_dbl, $pixmap_back_right, 540, 460, $dx, $dy);
my $style_dflt = new Gtk::Style;
my $style = new Gtk::Style;
- $style_dflt->font(Gtk::Gdk::Font->fontset_load(_("-*-helvetica-medium-r-normal-*-*-100-*-*-p-*-iso8859-1,*-r-*")));
+# $style_dflt->font(Gtk::Gdk::Font->fontset_load(_("-*-helvetica-medium-r-normal-*-*-100-*-*-p-*-iso8859-1,*-r-*")));
$style->font(Gtk::Gdk::Font->fontset_load(_("-*-helvetica-medium-r-normal-*-*-190-*-*-p-*-iso8859-1,*-r-*")));
#_("-adobe-times-bold-r-normal--17-*-100-100-p-*-iso8859-*,*-r-*")));
$pix_dbl->draw_string($style->font, $darea1->style->black_gc, 80, 115, _("Welcome to the Mandrake Control Center") );
@@ -452,7 +364,7 @@ $darea1->signal_connect( expose_event => sub {
[_("Machine:"), $machine] ) {
$pix_dbl->draw_string($style_dflt->font, $darea1->style->black_gc, 80, 150+$i, $_->[0]);
$pix_dbl->draw_string($style_dflt->font, $darea1->style->black_gc, 81, 150+$i, $_->[0]);
- $pix_dbl->draw_string($style_dflt->font, $darea1->style->black_gc, 250, 150+$i, $_->[1]);
+ $pix_dbl->draw_string($style_dflt->font, $darea1->style->black_gc, 200, 150+$i, $_->[1]);
$i+=20;
}
}
@@ -495,34 +407,40 @@ my @anim;
$window_global->set_default_size(700, 505);
$window_global->set_position(1);
+
+$SIG{USR1} = \&sig_usr1;
+$SIG{USR2} = \&sig_usr2;
+$SIG{TERM} = \&quit_global; # embedded applications will send me that signal in order to quit the cc.
Gtk->main;
-$SIG{USR1} = sub {
+
+#---
+# signal handlers
+#---
+
+sub sig_usr1 { # embedded applications will send me that signal in order to "kill/hide" them}
+ print "USR1\n";
clean_socket();
$darea_left_sav->{state} = 2, $darea_left_sav->draw(undef);
$notebook_global->show;
-}; # embedded applications will send me that signal in order to "kill/hide" them
-$SIG{TERM} = \&quit_global; # embedded applications will send me that signal in order to quit the cc.
-my $global_vbox;
-my $global_time_tag;
-my $lock_time_tag;
-my $global_socket;
- $SIG{USR2} = sub {
- print " USR2 \n";
+}
+
+sub sig_usr2 {
+ print "USR2\n";
# Gtk->timeout_remove($lock_time_tag);
-# $$global_vbox->hide; Gtk->timeout_remove($global_time_tag); $$global_socket->show;
-# ${$tree_launched{$_}->[1]} and ${$tree_launched{$_}->[1]}->set_sensitive(1) foreach (keys %tree_launched);
-# my $a = $notebook_global->get_current_page;
-# $notebook_global->set_page(0);
-# $notebook_global->set_page($a);
- };
+# $$global_vbox->hide; Gtk->timeout_remove($global_time_tag); $$global_socket->show;
+# ${$tree_launched{$_}->[1]} and ${$tree_launched{$_}->[1]}->set_sensitive(1) foreach (keys %tree_launched);
+# my $a = $notebook_global->get_current_page;
+# $notebook_global->set_page(0);
+# $notebook_global->set_page($a);
+}
-#-------------------------------------------------------------
+#---
# i18n routines
# IMPORTANT: next two routines have to be redefined here to
# get correct namespace (drakconf instead of libDrakX)
# (This version is now UTF8 compliant - Sg 2001-08-18)
-#-------------------------------------------------------------
+#---
{
no warnings;
@@ -539,9 +457,106 @@ my $global_socket;
}
-#-------------------------------------------------------------
-# sub
-#-------------------------------------------------------------
+#---
+# launching applications
+#---
+
+sub compute_exec_string {
+ my ($arg) = @_;
+ my ($log_exp, $exec, $gtkplug, $alternate) = @$arg;
+ if ($embedded) {
+ $notebook_global->hide;
+ res_socket();
+ $emb_box->show_all;
+ $emb_socket->realize;
+ my $exec = $exec . " --embedded " . $emb_socket->window->XWINDOW . " " . $$;
+ if ($gtkplug) {
+ my $pid;
+ unless ($pid = fork) {
+ splash_warning(_("cannot fork: %s", $~)) unless defined $pid;
+ exec("$exec");
+ }
+ push @pid_launched, $pid;
+ } else {
+ $emb_socket->steal(launch_xapp($alternate));
+ }
+ } else {
+ system(($alternate ? $alternate : $exec) . " &");
+ }
+ if($logs) {
+ $exp_socket->realize;
+ my $pid;
+ unless ($pid = fork) {
+ splash_warning(_("cannot fork: %s", $~)) unless defined $pid;
+ exec("logdrake --explain=$log_exp --embedded " . $exp_socket->window->XWINDOW . " " . $$);
+ }
+ push @pid_launched, $pid;
+ }
+ if ($embedded) {
+ foreach (@darea_left_list) {
+ $_->[1]->window->set_cursor($cursor_hand);
+ if($_->[1]->{state} != 0) {
+ $_->[1]->{state} = 0;
+ $_->[1]->draw(undef);
+ }
+ }
+ }
+}
+
+sub launch_xapp {
+# my ($exec, $grep, $num) = @_;
+ my $b = "xwininfo -root -tree -int | grep '" . $_[0]->[1] . "'";
+ my @before = split ('\n', `$b`);
+ my $pid;
+ unless ($pid = fork) {
+ splash_warning(_("cannot fork: %s", $~)) unless defined $pid;
+ exec($_[0]->[0]);
+ }
+ push @pid_launched, $pid;
+ my $res = 0;
+ while (!$res) {
+ my @after = split ('\n', `$b`);
+ while (@after ne ($_[0]->[2]+@before)) {
+ @after = split ('\n', `$b`);
+ }
+ my $i = 0;
+ my $c;
+ foreach (@after) {
+ $c = $after[$i] if !member($after[$i], @before);
+ $i++;
+ }
+ $c =~ /\s*([0-9]*)\s*/;
+ $res=$1;
+ }
+ $res;
+}
+
+#---
+# socket handling
+#---
+
+sub clean_socket {
+ $emb_box->hide;
+ $logs and $exp_frame->hide;
+ foreach (@pid_launched) {
+ kill 'TERM', $_ if (defined $_);
+ }
+ @pid_launched = ();
+ $emb_socket and $emb_socket->destroy();
+ $exp_socket and $exp_socket->destroy();
+ $logs and $exp_frame->show;
+}
+
+sub res_socket {
+ clean_socket();
+ gtkpack($emb_box, $emb_socket = new Gtk::Socket);
+ $emb_socket->hide;
+ $logs and gtkadd($exp_frame, $exp_socket = new Gtk::Socket);
+}
+
+#---
+# exit
+#---
sub quit_global {
foreach(@pid_launched) {
@@ -554,6 +569,10 @@ sub quit_global {
Gtk->exit(0);
}
+#---
+# additional / info
+#---
+
sub splash_warning {
my ($label) = @_;
my $win_about = new Gtk::Dialog();
@@ -574,30 +593,6 @@ sub splash_warning {
$win_about->set_modal(1);
}
-
-#-------------------------------------------------------------
-# menu related functions
-#-------------------------------------------------------------
-
-sub connect_to_site {
- my ($link,$help)=@_;
- my $browser=$ENV{'BROWSER'};
- my $initial_user=$ENV{'INITIAL_USER'};
- my $user_current=$ENV{'USER'};
-
- if (!$browser) {splash_warning( " ". _("Warning: No browser specified") ." "); return;}
-
- if ($help) {
- system("$browser $link &");
- } else {
- if ($initial_user ne "root" && $initial_user ne undef) {
- system("su -m -l $initial_user -c \"$browser $link &\"");
- } else {
- splash_warning(" "._("Security Warning: I'm not allowed to connect to the internet as root user")." ");
- }
- }
-}
-
sub about_mdk_cc {
my $window_about = new Gtk::Dialog();
$window_about->set_position(1);
@@ -621,6 +616,29 @@ sub about_mdk_cc {
$window_about->set_modal(1);
}
+sub connect_to_site {
+ my ($link,$help)=@_;
+ my $browser=$ENV{'BROWSER'};
+ my $initial_user=$ENV{'INITIAL_USER'};
+ my $user_current=$ENV{'USER'};
+
+ if (!$browser) {splash_warning( " ". _("Warning: No browser specified") ." "); return;}
+
+ if ($help) {
+ system("$browser $link &");
+ } else {
+ if ($initial_user ne "root" && $initial_user ne undef) {
+ system("su -m -l $initial_user -c \"$browser $link &\"");
+ } else {
+ splash_warning(" "._("Security Warning: I'm not allowed to connect to the internet as root user")." ");
+ }
+ }
+}
+
+#---
+# menu related functions
+#---
+
sub display_logs {
$logs = $log_check_box->active;
update_exp();