From ca6a026a23f723a74dab9a7d3afc11c2a43c01f2 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Sun, 3 Nov 2013 15:04:02 +0100 Subject: convert to UIManager --- perl-install/standalone/drakboot | 18 +++++++--- perl-install/standalone/drakfloppy | 18 +++++++--- perl-install/standalone/harddrake2 | 71 ++++++++++++++++++++++---------------- perl-install/standalone/logdrake | 31 +++++++++-------- 4 files changed, 85 insertions(+), 53 deletions(-) diff --git a/perl-install/standalone/drakboot b/perl-install/standalone/drakboot index e9f6cf348..375b0b4d1 100755 --- a/perl-install/standalone/drakboot +++ b/perl-install/standalone/drakboot @@ -85,10 +85,20 @@ sub run_boot_window { $window->set_border_width(2); ### menus definition # the menus are not shown but they provides shiny shortcut like C-q - my @menu_items = ([ N("/_File"), undef, undef, undef, '' ], - [ N("/File/_Quit"), N("Q"), sub { ugtk3->exit(0) }, undef, '' ], - ); - create_factory_menu($w->{rwindow}, @menu_items); + my $ui = gtknew('UIManager', actions => [ + # [name, stock_id, value, label, accelerator, tooltip, callback] + [ 'FileMenu', undef, N("_File") ], + [ 'Quit', undef, N("_Quit"), N("Q"), undef, sub { ugtk3->exit(0) } ], + ], + string => qq( + + + + + +)); + $w->{rwindow}->add_accel_group($ui->get_accel_group); + ######### menus end } gtkadd($window, gtknew('VBox', children => [ diff --git a/perl-install/standalone/drakfloppy b/perl-install/standalone/drakfloppy index 9154d40a3..efb2104df 100755 --- a/perl-install/standalone/drakfloppy +++ b/perl-install/standalone/drakfloppy @@ -43,11 +43,19 @@ unless ($::isEmbedded) { ### menus definition # the menus are not shown but they provides shiny shortcut like C-q - create_factory_menu($window->{rwindow}, ( - { path => N("/_File"), item_type => '' }, - { path => N("/File/_Quit"), accelerator => N("Q"), callback => sub { ugtk3->exit(0) } }, - ) - ); + my $ui = gtknew('UIManager', actions => [ + # [name, stock_id, value, label, accelerator, tooltip, callback] + [ 'FileMenu', undef, N("_File") ], + [ 'Quit', undef, N("_Quit"), N("Q"), undef, sub { ugtk3->exit(0) } ], + ], + string => qq( + + + + + +)); + $window->{rwindow}->add_accel_group($ui->get_accel_group); } diff --git a/perl-install/standalone/harddrake2 b/perl-install/standalone/harddrake2 index 3862a0614..08a81b913 100755 --- a/perl-install/standalone/harddrake2 +++ b/perl-install/standalone/harddrake2 @@ -175,16 +175,9 @@ my ($current_device, $current_class, $current_configurator); my %sysh = distrib(); my $distro_name = $sysh{system}; -my %menus = ( - 'options' => - #-PO: please keep all "/" characters !!! - N("/_Options"), - 'help' => N("/_Help") - ); - my %menu_options = ( - 'MODEMS_DETECTION' => [ $menus{options}, N("/Autodetect _modems") ], - 'PARALLEL_ZIP_DETECTION' => [ $menus{options}, N("/Autodetect parallel _zip drives") ], + 'MODEMS_DETECTION' => N("Autodetect _modems"), + 'PARALLEL_ZIP_DETECTION' => N("Autodetect parallel _zip drives"), ); $ugtk3::wm_icon = "harddrake"; @@ -192,24 +185,42 @@ $w = ugtk3->new(N("Hardware Configuration")); # fake diagnostics pragma: local $::main_window = $w->{real_window}; -my @menu_items = - ( - [ N("/_File"), undef, undef, undef, '' ], - [ N("/_File") . N("/_Quit"), N("Q"), \&quit_global, undef, '' ], - [ join('', @{$menu_options{MODEMS_DETECTION}}), undef, \&handle_modem_option, undef, '' ], - [ join('', @{$menu_options{PARALLEL_ZIP_DETECTION}}), undef, \&handle_zip_option, undef, '' ], - [ $menus{help}, undef, undef, undef, '' ], - if_(-x "/usr/sbin/drakhelp_inst", - [ $menus{help} . N("/_Help"), undef, \&run_help, undef, '' ], - ), - [ $menus{help} . N("/_Fields description"), undef, \&fields_help, undef, '' - ], - if_(!-e "/etc/sysconfig/oem", - [ $menus{help} . N("/_Report Bug"), undef, \&run_drakbug, undef, '' ], - ), - [ $menus{help} . N("/_About..."), undef, \&about, undef, '' - ] - ); +my $has_help = -x "/usr/sbin/drakhelp_inst"; +my $ui = gtknew('UIManager', actions => [ + # [name, stock_id, value, label, accelerator, tooltip, callback] + [ 'FileMenu', undef, N("_File") ], + [ 'Quit', undef, N("_Quit"), N("Q"), undef, \&quit_global ], + [ 'OptionsMenu', undef, '_Options' ], + [ 'HelpMenu', undef, '_Help' ], + if_($has_help, [ 'Help', undef, N("_Help"), N("Q"), undef, \&run_help ]), + [ 'Fields description', undef, N("_Fields description"), undef, undef, \&fields_help ], + [ 'Report Bug', undef, N("_Report Bug"), undef, undef, \&run_drakbug ], + [ 'About', undef, N("_About..."), '', undef, \&about ], + ], + toggle_actions => [ + [ 'MODEMS_DETECTION', undef, $menu_options{MODEMS_DETECTION}, undef, undef, \&handle_modem_option ], + [ 'PARALLEL_ZIP_DETECTION', undef, $menu_options{PARALLEL_ZIP_DETECTION}, undef, undef, \&handle_zip_option ], + ], + string => + join("\n", + qq( + + + + + + + + + ), + if_($has_help, ""), + qq( + + + + + +))); $in = 'interactive'->vnew('su'); #require_root_capability(); @@ -221,7 +232,7 @@ add_icon_path('/usr/share/pixmaps/harddrake2/'); $::noborderWhenEmbedded = 1; -my ($menubar, $factory) = create_factory_menu($w->{real_window}, @menu_items); +my $menubar = $ui->get_widget('/MenuBar'); $w->{window}->set_size_request(805, 550) if !$::isEmbedded; my $tree_model = Gtk3::TreeStore->new("Gtk3::Gdk::Pixbuf", "Glib::String", "Glib::Int"); @@ -338,6 +349,7 @@ $tree->get_selection->signal_connect('changed' => sub { $module_cfg_button->hide; }); +$w->{rwindow}->add_accel_group($ui->get_accel_group); # show the main window earlier (so that sub dialogs can use main # window's icon and so that no Gtk+ critical message got displayed): $w->{rwindow}->show_all; @@ -473,9 +485,8 @@ $w->{rwindow}->signal_connect(delete_event => \&quit_global); $w->{rwindow}->set_position('center') unless $::isEmbedded; foreach (keys %menu_options) { - my $title = strip_first_underscore(@{$menu_options{$_}}); $options{$_} = 0 unless defined($options{$_}); # force detection by default - $check_boxes{$_} = $factory->get_widget("
" . $title); + $check_boxes{$_} = $ui->get_widget('/MenuBar/OptionsMenu/' . $_); $check_boxes{$_}->set_active($options{$_}); # restore saved values } diff --git a/perl-install/standalone/logdrake b/perl-install/standalone/logdrake index 94315750a..8ad314f0f 100755 --- a/perl-install/standalone/logdrake +++ b/perl-install/standalone/logdrake @@ -72,20 +72,23 @@ my $cal_butt = gtksignal_connect(Gtk3::CheckButton->new(N("Show only for the sel ### menus definition # the menus are not shown # but they provides shiny shortcut like C-q (Broken: FIXME) -my @menu_items = ( - { path => N("/_File"), item_type => '' }, - { path => N("/File/_New"), accelerator => N("N") }, - { path => N("/File/_Open"), accelerator => N("O") }, - { path => N("/File/_Save"), accelerator => N("S"), callback => \&save }, - { path => N("/File/Save _As") }, - { path => N("/File/-"), item_type => '' }, - { path => N("/File/_Quit"), accelerator => N("Q"), callback => \&quit }, - { path => N("/_Options"), item_type => '' }, - { path => N("/Options/Test") }, - { path => N("/_Help"), item_type => '' }, - { path => N("/Help/_About...") } - ); -my $_menubar = $::isEmbedded ? create_factory_menu($my_win->{rwindow}, @menu_items) : undef; +if ($::isEmbedded) { + my $ui = gtknew('UIManager', actions => [ + # [name, stock_id, value, label, accelerator, tooltip, callback] + [ 'FileMenu', undef, N("_File") ], + [ 'Save', undef, N("_Quit"), N("Q"), undef, \&save ], + [ 'Quit', undef, N("_Quit"), N("Q"), undef, \&quit ], + ], + string => qq( + + + + + + +)); + $my_win->{rwindow}->add_accel_group($ui->get_accel_group); +} ######### menus end -- cgit v1.2.1