diff options
author | Yves Duret <yduret@mandriva.com> | 2001-08-10 03:47:36 +0000 |
---|---|---|
committer | Yves Duret <yduret@mandriva.com> | 2001-08-10 03:47:36 +0000 |
commit | 89bbaaaf30a74d58106fc3ee0b4b3c0ae4310be4 (patch) | |
tree | 212ad42fa65ce0f7597729261f9ba6bbd21b430a | |
parent | 485f0d0c01674e87df6699c8eaa58025f21e7c7d (diff) | |
download | control-center-89bbaaaf30a74d58106fc3ee0b4b3c0ae4310be4.tar control-center-89bbaaaf30a74d58106fc3ee0b4b3c0ae4310be4.tar.gz control-center-89bbaaaf30a74d58106fc3ee0b4b3c0ae4310be4.tar.bz2 control-center-89bbaaaf30a74d58106fc3ee0b4b3c0ae4310be4.tar.xz control-center-89bbaaaf30a74d58106fc3ee0b4b3c0ae4310be4.zip |
many bug fixes
new menu scheme
remove some debugginf information
-rwxr-xr-x | control-center | 191 |
1 files changed, 69 insertions, 122 deletions
diff --git a/control-center b/control-center index c9918f04..60055176 100755 --- a/control-center +++ b/control-center @@ -74,32 +74,23 @@ my $vbox_global = new Gtk::VBox(0, 0); $window_global->add($vbox_global); ######### menus -my @item_factory_entries = ( - { - 'path' => _("/_File")._("/_Quit"), - 'accelerator' => _("<control>Q"), - 'action' => 1, - 'type' => '<Item>' - }, -# [_("/_Help")._("/_Help on line"), undef, 7], - [_("/_Help")._("/_Report Bug"), undef, 3 ], - - [_("/_Help"). "/_Sep1", undef, 0, "<Separator>"], - [_("/_Help")._("/Mandrake_Campus"), undef, 5], - [_("/_Help")._("/Mandrake_Expert"), undef, 6], - [_("/_Help"). "/_Sep2", undef, 0, "<Separator>"], - [_("/_Help")._("/_About..."), undef, 4 ], - ); - -my $accel_group = new Gtk::AccelGroup; -my $item_factory = new Gtk::ItemFactory('Gtk::MenuBar', "<main>", $accel_group); - -$accel_group->attach($window_global); -$item_factory->create_item($_, \&item_factory_cb) foreach (@item_factory_entries); - -$vbox_global->pack_start($item_factory->get_widget('<main>'), 0, 0, 0); -$vbox_global->pack_start(new Gtk::HSeparator, 0, 1, 0); +my @menu_items = ( + { path => _("/_File"), type => '<Branch>' }, + { path => _("/File")._("/_Quit"), accelerator => _("<control>Q"), callback => \&quit_global }, + { path => _("/_Help"),type => '<Branch>' }, +# { path => _("/Help")._("/_Help on line"), callback => sub { Gtk->exit(0) } }, + { path => _("/Help")._("/_Report Bug") , callback => sub {connect_to_site("https://qa.mandrakesoft.com/");}}, + { path => _("/Help/-"), type => '<Separator>' }, + { path => _("/Help")._("/Mandrake_Campus"), callback => sub {connect_to_site("https://www.mandrakecampus.com/");} }, + { path => _("/Help")._("/Mandrake_Expert"), callback => sub {connect_to_site("https://www.mandrakeexpert.com/");} }, + { path => _("/Help/-"), type => '<Separator>' }, + { path => _("/Help")._("/_About..."), callback => \&about_mdk_cc } + ); +my $menubar = get_main_menu( $window_global ); +$vbox_global->pack_start($menubar, 1, 1, 0); +######### menus end +$vbox_global->pack_start(new Gtk::HSeparator, 0, 1, 0); my $hpane_global = new Gtk::HPaned; $vbox_global->pack_start($hpane_global, 1, 1, 0); $hpane_global->border_width(5); @@ -248,31 +239,9 @@ sub quit_global { Gtk->exit(0); } -sub about_mdk_cc { - my $window_about = new Gtk::Dialog(); - $window_about->set_position(1); - - my $bbox1 = new Gtk::HButtonBox; - $window_about->action_area->pack_start($bbox1,0,0,0); - - my $button = new Gtk::Button(_("Close")); - $button->signal_connect_object("clicked",$window_about => 'destroy'); - $bbox1->add($button); - - my $label = new Gtk::Label( _("Mandrake Control Center %s \n \n Copyright (C) 2001 Mandrakesoft SA\n", $_version) ); - my $style1 = new Gtk::Style; - $style1->font(Gtk::Gdk::Font->fontset_load("-adobe-times-bold-r-normal--14-*-100-100-p-*-iso8859-*,*-r-*")); - $label->set_style($style1); - $window_about->vbox->pack_start( $label, 1, 1, 0 ); - - $window_about->vbox->pack_start( new Gtk::Label( _("Authors: ") . "\n\n Daouda Lo <daouda\@mandrakesoft.com> \n \n Damien Krotkine <dams\@mandrakesoft.com>\n"), 1, 1, 0 ); - - $window_about->show_all(); - $window_about->set_modal(1); -} sub splash_warning { - my $label = @_; + my ($label) = @_; my $win_about = new Gtk::Dialog(); $win_about->set_position(1); @@ -291,24 +260,6 @@ sub splash_warning { $win_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")." "); - } - } -} my $treeitem_old; @@ -455,7 +406,7 @@ sub exec_treeitem { sub launch_wait { my ($exec, $grep, $num, $zz) = @_; - print "{{ $exec }}\n"; +# print "{{ $exec }}\n"; my $b = "xwininfo -root -tree -int | grep '" . $grep . "'"; my @before = split ('\n', `$b`); unless ($pid = fork) { @@ -474,72 +425,68 @@ sub launch_wait { my $i = 0; my $c; foreach (@after) { - print "[[" . $after[$i] . "]]\n" if !member($after[$i], @before); +# print "[[" . $after[$i] . "]]\n" if !member($after[$i], @before); $c = $after[$i] if !member($after[$i], @before); $i++; } $c =~ /\s*([0-9]*)\s*/; $res=$1; - print "[" . $res . "]\n"; +# print "[" . $res . "]\n"; } $res; } -sub member { my $e = shift; foreach (@_) { $e eq $_ and return 1 } 0 } +#------------------------------------------------------------- +# menu related functions +#------------------------------------------------------------- -sub item_factory_cb { - my ($widget, $action, @data) = @_; - $action == 1 and quit_global(); - $action == 4 and about_mdk_cc(); - $action == 3 and connect_to_site("https://qa.mandrakesoft.com/",0); - $action == 5 and connect_to_site("http://www.mandrakecampus.com/",0); - $action == 6 and connect_to_site("http://www.mandrakeexpert.com/",0); - $action == 7 and system("./gecko.pm /usr/share/doc/HTML/index.html&"); -} +sub connect_to_site { + my ($link,$help)=@_; + my $browser=$ENV{'BROWSER'}; + my $initial_user=$ENV{'INITIAL_USER'}; + my $user_current=$ENV{'USER'}; -sub create_item_factory { - if (!defined $item_factory_window) { - my ($accel_group, $item_factory, $box1, $label, $box2); - my ($separator, $button, $dummy); - - $item_factory_window = new Gtk::Window('toplevel'); - signal_connect $item_factory_window destroy => \&destroy_window, \$item_factory_window; - signal_connect $item_factory_window "delete-event" => \&destroy_window, \$item_factory_window; - - $accel_group = new Gtk::AccelGroup; - $item_factory = new Gtk::ItemFactory('Gtk::MenuBar', "<main>", $accel_group); - - $accel_group->attach($item_factory_window); - foreach (@item_factory_entries) { - $item_factory->create_item($_, \&item_factory_cb); - } - - $item_factory_window->set_title(_("Item Factory")); - $item_factory_window->set_border_width(0); - - $box1 = new Gtk::VBox(0, 0); - $item_factory_window->add($box1); - $box1->pack_start($item_factory->get_widget('<main>'), 0, 0, 0); - - $label = new Gtk::Label( _("Type\n<alt>\nto start") ); - - $label->set_usize(200, 200); - $label->set_alignment(0.5, 0.5); - $box1->pack_start($label, 1, 1, 0); - - $separator = new Gtk::HSeparator; - $box1->pack_start($separator, 0, 1, 0); - - $box2 = new Gtk::VBox(0, 10); - $box2->set_border_width(10); - $box1->pack_start($box2, 0, 1, 0); - - $button = new Gtk::Button(_("Close")); - $button->signal_connect(clicked => sub {$item_factory_window->destroy;}); - $box2->pack_start($button, 1, 1, 0); - $button->can_default(1); - $button->grab_default; + 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); + + my $bbox1 = new Gtk::HButtonBox; + $window_about->action_area->pack_start($bbox1,0,0,0); + + my $button = new Gtk::Button(_("Close")); + $button->signal_connect_object("clicked",$window_about => 'destroy'); + $bbox1->add($button); + + my $label = new Gtk::Label( _("Mandrake Control Center %s \n \n Copyright (C) 2001 Mandrakesoft SA\n", $_version) ); + my $style1 = new Gtk::Style; + $style1->font(Gtk::Gdk::Font->fontset_load("-adobe-times-bold-r-normal--14-*-100-100-p-*-iso8859-*,*-r-*")); + $label->set_style($style1); + $window_about->vbox->pack_start( $label, 1, 1, 0 ); + + $window_about->vbox->pack_start( new Gtk::Label( _("Authors: ") . "\n\n Daouda Lo <daouda\@mandrakesoft.com> \n Damien Krotkine <dams\@mandrakesoft.com> \n Yves Duret <yduret\@mandrakesoft.com "), 1, 1, 0 ); + + $window_about->show_all(); + $window_about->set_modal(1); +} - (!visible $item_factory_window) ? show_all $item_factory_window : destroy $item_factory_window; +sub get_main_menu { + my ($window) = @_; + my $accel_group = new Gtk::AccelGroup(); + my $item_factory = new Gtk::ItemFactory( 'Gtk::MenuBar', '<main>', $accel_group ); + $item_factory->create_items( @menu_items ); + $window->add_accel_group( $accel_group ); + return ( $item_factory->get_widget( '<main>' ) ); } |