From b908a9dfd6810b690c9e43b9f31267de0cfc723f Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 3 Dec 2013 11:35:08 +0100 Subject: switch from factory to UIManager --- control-center | 98 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 57 insertions(+), 41 deletions(-) (limited to 'control-center') diff --git a/control-center b/control-center index deae04d3..85ceea07 100755 --- a/control-center +++ b/control-center @@ -619,43 +619,6 @@ my ($steps, $view); my $release = mageia_release_info(); -my @menu_items = ( - [ N("/_File"), undef, undef, undef, '' ], - [ N("/_File") . N("/_Quit"), - #-PO: "" must _NOT_ be translated. This is a keyboard shortcut for "Quit". - #-PO: you just have to select the proper letter for your language (eg: english: "Quit" => "Q") - N("Q"), \&quit_global, undef, '', N("Quit") ], - [ N("/_Options"), undef, undef, undef, '' ], - [ join('', @{$options{show_log}}), undef, - sub { - $option_values{show_log} = $check_boxes{show_log}->get_active; - if ($option_values{show_log}) { - start_logdrake(); - } else { - kill_logdrake(); - } - }, - undef, '' - ], - - if_(0 && $isWiz, - [ join('', @{$options{wiz_expert}}), undef, - sub { $option_values{expert_wizard} = $check_boxes{wiz_expert}->get_active }, - undef, '', - ], - ), - [ N("/_Help"), undef, undef, undef, '' ], - [ N("/_Help") . N("/_Help"), undef, \&run_help, undef, '', N("Help") ], - [ N("/_Help") . N("/_Release notes"), undef, sub { run_browser('Release_Notes') }, undef, '', N("Help") ], - [ N("/_Help") . N("/What's _New?"), undef, sub { run_browser("What's New?") }, undef, '', N("Help") ], - [ N("/_Help") . N("/_Errata"), undef, sub { run_browser('Errata') }, undef, '', N("Help") ], - [ N("/_Help") . N("/_Report Bug"), undef, sub { - run_program::raw({ detach => 1, as_user => 1 }, 'drakbug', '--report', (split(/\s/, $pending_app))[0] || 'drakconf'); - }, undef, '' ], - [ N("/_Help") . N("/_About..."), undef, \&about_mga_cc, undef, '' ] - ); - - sub run_help() { run_program::raw({ detach => 1, as_user => 1 }, 'drakhelp', '--id', $help_on_context); } @@ -666,13 +629,65 @@ sub run_browser { run_program::raw({ detach => 1, as_user => 1 }, '/usr/bin/www-browser', $url); } -my ($menu, $factory) = create_factory_menu($window_global, @menu_items); +my $ui = gtknew('UIManager', actions => [ + # [name, stock_id, value, label, accelerator, tooltip, callback] + [ 'FileMenu', undef, N("_File") ], + [ 'Quit', undef, N("_Quit"), + #-PO: "" must _NOT_ be translated. This is a keyboard shortcut for "Quit". + #-PO: you just have to select the proper letter for your language (eg: english: "Quit" => "Q") + N("Q"), undef, \&quit_global ], + [ 'OptionsMenu', undef, '_Options' ], + [ 'show_log', undef, N("Display _Logs") ], + [ 'HelpMenu', undef, '_Help' ], + [ 'Help', undef, N("_Help"), N("H"), undef, \&run_help ], + [ 'Release_notes', undef, N("_Release notes"), undef, undef, sub { run_browser('Release_Notes') } ], + [ 'What s New', undef, N("What's _New?"), undef, undef, sub { run_browser("What's New?") } ], + [ 'Errata', undef, N("_Errata"), undef, undef, sub { run_browser('Errata') } ], + [ 'Report Bug', undef, N("_Report Bug"), undef, undef, sub { + run_program::raw({ detach => 1, as_user => 1 }, 'drakbug', '--report', (split(/\s/, $pending_app))[0] || 'drakconf'); + } ], + [ 'About', undef, N("_About..."), '', undef, \&about_mga_cc ], + ], + toggle_actions => [ + [ 'Show_Logs', undef, N("Display _Logs"), undef, undef, sub { + $option_values{show_log} = $check_boxes{show_log}->get_active; + if ($option_values{show_log}) { + start_logdrake(); + } else { + kill_logdrake(); + } + } ], + + if_(0 && $isWiz, + [ 'Expert_Wizard', undef, N("Expert mode in _wizards"), undef, undef, + sub { $option_values{expert_wizard} = $check_boxes{wiz_expert}->get_active }, + ], + ), -# to retrieve a path, one must prevent "accelerators completion": -sub get_path { join('', map { my $i = $_; $i =~ s/_//g; $i } @_) } + ], + string => + qq( + + + + + + + + + + + + + + + + +)); +my $menu = $ui->get_widget('/MenuBar'); %check_boxes = map { - $_ => $factory->get_widget("
" . get_path(@{$options{$_}})); + $_ => $ui->get_widget('/MenuBar/OptionsMenu/' . $_); } ('show_log', if_(0 && $isWiz, "wiz_expert")); my @buttons; @@ -727,6 +742,7 @@ gtkadd($window_global, $view->set_size_request(-1, -1); $window_global->signal_connect(delete_event => \&quit_global); +$window_global->add_accel_group($ui->get_accel_group); my $accel = Gtk3::AccelGroup->new; $accel->connect(Gtk3::Gdk::keyval_from_name('F1'), [], ['visible'], \&run_help); -- cgit v1.2.1