summaryrefslogtreecommitdiffstats
path: root/menus.pm
diff options
context:
space:
mode:
Diffstat (limited to 'menus.pm')
-rwxr-xr-xmenus.pm67
1 files changed, 67 insertions, 0 deletions
diff --git a/menus.pm b/menus.pm
new file mode 100755
index 00000000..5fa4a2b3
--- /dev/null
+++ b/menus.pm
@@ -0,0 +1,67 @@
+#!/usr/bin/perl
+
+use Gtk;
+init Gtk;
+use POSIX;
+use Locale::GetText;
+
+setlocale (LC_ALL, "");
+Locale::GetText::textdomain ("DrakConf");
+import Locale::GetText I_;
+sub _ {
+ my $s = shift @_; my $t = I_($s);
+ $t && ref $t or return sprintf $t, @_;
+ my ($T, @p) = @$t;
+ sprintf $T, @_[@p];
+}
+
+my $_bindir = "/usr/bin/";
+$::isEmbedded = ($::XID, $::CCPID) = "@ARGV" =~ /--embedded (\w+) (\w+)/;
+my $window = $::isEmbedded ? new Gtk::Plug ($::XID) : new Gtk::Window -toplevel;
+$window->signal_connect ( delete_event => \&quit_global );
+my $vbox = new Gtk::VBox(0,0);
+$window->add($vbox);
+$vbox->pack_start(new Gtk::Label(_("Menu Configuration Center\n\nChoose which menu you want to configure")),0,0,5);
+$vbox->pack_start(new Gtk::HSeparator,0,0,5);
+my $table = new Gtk::Table (3,2, 0);
+$table->set_border_width(5);
+$table->set_row_spacings(5);
+$table->set_col_spacings(5);
+my $hbox = new Gtk::HBox(0,0);
+$vbox->pack_start($hbox,1,1,1);
+$hbox->pack_start($table,0,0,5);
+$table->attach (new Gtk::Label(_("System menu")), 0, 1, 0, 1, 'fill', 'fill', 0, 0);
+my $b1 = new Gtk::Button(_("Configure..."));
+$b1->signal_connect( clicked => sub { system("$_bindir/menudrake --systemmenu & "); } );
+$table->attach ($b1, 1, 2, 0, 1, 'fill', 'fill', 0, 0);
+$table->attach (new Gtk::Label(_("User menu")), 0, 1, 1, 2, 'fill', 'fill', 0, 0);
+my (@user_info, @usernames);
+setpwent();
+do { @user_info = getpwent();
+ my ($uname, $uid) = @user_info[0,2];
+ push (@usernames, $uname) if ($uid > 500);
+ } while (@user_info);
+my $combo = new Gtk::Combo;
+$combo->set_popdown_strings (@usernames, "root");
+$table->attach ($combo, 2, 3, 1, 2, 'fill', 'fill', 0, 0);
+my $b2 = new Gtk::Button(_("Configure..."));
+$b2->signal_connect( clicked => sub { my $a = $combo->entry->get_text();
+ $a eq "root" ?
+ system("$_bindir/menudrake --usermenu &") :
+ system(" su $a -c \"$_bindir/menudrake &\"");
+ } );
+$table->attach ($b2, 1, 2, 1, 2, 'fill', 'fill', 0, 0);
+$vbox->pack_start(new Gtk::HSeparator,0,0,5);
+my $bbox = new Gtk::HButtonBox;
+$vbox->pack_start($bbox,0,0,5);
+$bbox->set_layout(-end);
+my $button_ok = new Gtk::Button _("OK");
+$button_ok->signal_connect ( clicked => sub { $::isEmbedded ? kill(USR1, $::CCPID) : Gtk->exit(0); });
+$button_ok->can_default(1);
+$bbox->add($button_ok);
+
+$window->show_all;
+
+Gtk->main_iteration while Gtk->events_pending;
+$::isEmbedded and kill USR2, $::CCPID;
+Gtk->main;