From 4b3e7506909380c640d83959b862fa0211038eaa Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 22 Nov 2013 18:40:33 +0100 Subject: convert to UIManager --- bin/draknfs | 44 ++++++++++++++++++++--------------- bin/draksambashare | 67 ++++++++++++++++++++++++++++++++---------------------- 2 files changed, 66 insertions(+), 45 deletions(-) diff --git a/bin/draknfs b/bin/draknfs index f23b74e..21ee663 100755 --- a/bin/draknfs +++ b/bin/draknfs @@ -64,20 +64,6 @@ my $userid_data = { my @yesno = qw(yes no); -sub get_items() { - my @items = ( - [ N("/_File"), undef, undef, undef, '', ], - [ N("/_File") . N("/_Write conf"), undef, \&write_conf, 1, '', ], - [ N("/_File") . N("/_Quit"), N("Q"), \&quit_all, 1, '', ], - - - [ N("/_NFS Server"), undef, undef, undef, '', ], - [ N("/_NFS Server") . N("/_Restart"), undef, \&restart_dialog, 1, '', ], - [ N("/_NFS Server") . N("/R_eload"), undef, \&reload_dialog, 1, '', ], - ); - return @items; -} - sub quit_all() { ugtk3->exit; } @@ -572,10 +558,32 @@ $treeview->signal_connect(button_press_event => sub { }); # create menu -my @items = get_items(); -my $factory = Gtk3::ItemFactory->new('Gtk3::MenuBar', '
', undef); -$factory->create_items('menu', @items); -my $menu = $factory->get_widget('
'); +my $ui = gtknew('UIManager', actions => [ + # [name, stock_id, value, label, accelerator, tooltip, callback] + [ 'FileMenu', undef, N("_File") ], + [ 'Write_conf', undef, N("_Write conf"), undef, undef, \&write_conf ], + [ 'Quit', undef, N("_Quit"), N("Q"), undef, sub { ugtk3->exit(0) } ], + [ 'NFSMenu', undef, N("_NFS Server") ], + [ 'Restart', undef, N("_Restart"), undef, undef, \&restart_dialog ], + [ 'Reload', undef, N("R_eload"), undef, undef, \&reload_dialog ], + + + ], + string => qq( + + + + + + + + + + +)); +$window->{rwindow}->add_accel_group($ui->get_accel_group); + +my $menu = $ui->get_widget('/MenuBar'); my $okcancel = create_okcancel({ cancel_clicked => sub { ugtk3->exit }, diff --git a/bin/draksambashare b/bin/draksambashare index a44987a..81851ea 100755 --- a/bin/draksambashare +++ b/bin/draksambashare @@ -171,28 +171,6 @@ my %adv_options = ( my $window; -sub get_items() { - my @items = ( - [ N("/_File"), undef, undef, undef, '', ], - [ N("/_File") . N("/_Write conf"), undef, \&write_conf, 1, '', ], - [ N("/_File") . N("/_Quit"), N("Q"), \&quit_all, 1, '', ], - - [ N("/_Samba Server"), undef, undef, undef, '', ], - [ N("/_Samba Server") . N("/_Configure"), undef, \&launch_samba_wizard, 1, '', ], - [ N("/_Samba Server") . N("/_Restart"), undef, \&restart_dialog, 1, '', ], - [ N("/_Samba Server") . N("/R_eload"), undef, \&reload_dialog, 1, '', ], - - [ N("/_Help") . N("/_Samba Documentation"), undef, sub { - $in->do_pkgs->ensure_is_installed('samba-doc', '/usr/share/doc/samba-doc'); - run_program::raw({ detach => 1 }, 'www-browser', '/usr/share/doc/samba-doc/htmldocs/index.html'); - }, - 1, '', ], - - [ N("/_About") . N("/_Report Bug"), undef, sub { run_program::raw({ detach => 1 }, 'drakbug', '--report', 'draksambashare') }, 1, '', ], - [ N("/_About") . N("/_About..."), undef, \&about_dialog, 1, '', ], - ); - return @items; -} sub quit_all() { ugtk3->exit; @@ -1357,10 +1335,45 @@ $display_share->signal_connect(key_press_event => sub { }); # create menu -my @items = get_items(); -my $factory = Gtk3::ItemFactory->new('Gtk3::MenuBar', '
', undef); -$factory->create_items('menu', @items); -my $menu = $factory->get_widget('
'); +my $ui = gtknew('UIManager', actions => [ + # [name, stock_id, value, label, accelerator, tooltip, callback] + [ 'FileMenu', undef, N("_File") ], + [ 'Write_conf', undef, N("_Write conf"), undef, undef, \&write_conf ], + [ 'Quit', undef, N("_Quit"), N("Q"), undef, \&quit_all ], + + [ 'Samba_Menu', undef, N("_Samba Server") ], + [ 'Configure', undef, N("_Configure"), undef, undef, \&launch_samba_wizard ], + [ 'Restart', undef, N("_Restart"), undef, undef, \&restart_dialog ], + [ 'Reload', undef, N("R_eload"), undef, undef, \&reload_dialog ], + + [ 'Help_Menu', undef, N("_Help") ], + [ 'Documentation', undef, N("_Samba Documentation"), undef, undef, sub { + $in->do_pkgs->ensure_is_installed('samba-doc', '/usr/share/doc/samba-doc'); + run_program::raw({ detach => 1 }, 'www-browser', '/usr/share/doc/samba-doc/htmldocs/index.html'); + } ], + [ 'Report_Bug', undef, N("_Report Bug"), undef, undef, sub { run_program::raw({ detach => 1 }, 'drakbug', '--report', 'draksambashare') } ], + [ 'About', undef, N("_About..."), undef, undef, \&about_dialog ], + + ], + string => qq( + + + + + + + + + + + + + + + + +)); +$window->{rwindow}->add_accel_group($ui->get_accel_group); my $okcancel = create_okcancel({ cancel_clicked => sub { ugtk3->exit }, @@ -1487,7 +1500,7 @@ sub check_first_launch() { # main interface $W->add(gtkpack_(Gtk3::VBox->new(0,0), - 0, $menu, + 0, $ui->get_widget('/MenuBar'), 0, Gtk3::Banner->new($sambaicon, N("DrakSamba manage Samba shares")), #if_($::isEmbedded, 0, Gtk3::Label->new("Here you can add, remove and alter Samba shares.")), 1, $nb, -- cgit v1.2.1