summaryrefslogtreecommitdiffstats
path: root/menus_launcher.pl
blob: 3bb744422807c88ad8c24c54efea3f147f545197 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl

use strict;
use lib qw(/usr/lib/libDrakX);
use common;
# i18n : IMPORTANT to get correct namespace (drakconf instead of libDrakX)
BEGIN { unshift @::textdomains, 'drakconf' }
use ugtk3 qw(:helpers :wrappers);
use interactive;
use standalone;

sub gtkcan_default {
    $_[0]->get_can_default($_->[1]);
    $_[0];
}

my $bindir = "/usr/bin/";
my $my_win = ugtk3->new('print_launcher');
$my_win->{rwindow}->set_title(N("Menu Configuration Center")) unless $::isEmbedded;
$my_win->{window}->signal_connect(delete_event => sub {
    ugtk3->exit(0);
});
my $table = Gtk3::Table->new(3, 2, 0);
$table->set_border_width(5);
$table->set_row_spacings(5);
$table->set_col_spacings(5);
$table->attach(Gtk3::Label->new(N("System menu")), 0, 1, 0, 1, 'fill', 'fill', 0, 0);
my $b1 = gtksignal_connect(Gtk3::Button->new(N("Configure...")), clicked => sub { system("$bindir/menudrake --systemmenu &") });
$table->attach($b1, 1, 2, 0, 1, 'fill', 'fill', 0, 0);
$table->attach(Gtk3::Label->new(N("User menu")), 0, 1, 1, 2, 'fill', 'fill', 0, 0);

my $combo = Gtk3::OptionMenu->new;
$combo->set_popdown_strings("root", sort(list_users()));
$table->attach($combo, 2, 3, 1, 2, 'fill', 'fill', 0, 0);
my $b2 = gtksignal_connect(Gtk3::Button->new(N("Configure...")),
                  clicked => sub { my $a = $combo->entry->get_text(); system($a eq "root" ? "$bindir/menudrake --usermenu &" : " su $a -c \"$bindir/menudrake\" &") });
$table->attach($b2, 1, 2, 1, 2, 'fill', 'fill', 0, 0);

$my_win->{window}->add(gtkpack(Gtk3::VBox->new(0, 0),
                               Gtk3::Label->new(N("Menu Configuration Center") . N("\n\nChoose which menu you want to configure")),
                               Gtk3::HSeparator->new,
                               $table,
                               Gtk3::HSeparator->new,
                               gtkpack(gtkset_layout(Gtk3::HButtonBox->new, 'end'),
                                       gtkcan_default(gtksignal_connect(Gtk3::Button->new_from_stock('gtk-close'), clicked => sub { ugtk3->exit(0) }), 1)
                                      ),
                              ),
                      );


$my_win->{window}->show_all;
$my_win->main;
ugtk3->exit(0);