aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xrpmdrake149
1 files changed, 95 insertions, 54 deletions
diff --git a/rpmdrake b/rpmdrake
index daa0c8a9..59c4b9fc 100755
--- a/rpmdrake
+++ b/rpmdrake
@@ -583,83 +583,123 @@ sub run_treeview_dialog {
my $updates_string = N("_Compute updates on startup");
my $NVR_string = N("Search in _full package names");
my $regexp_search_string = N("Use _regular expressions in searches");
- my ($menu, $factory) = create_factory_menu(
- $w->{real_window},
- [ N("_File"), undef, undef, undef, '<Branch>' ],
- if_(
- ! $>,
- [ N("_File") . N("_Update media"), undef, sub {
- update_sources_interactive($urpm, transient => $w->{real_window})
- and $reload_db_and_clear_all->();
- }, undef, '<Item>' ]
- ),
- [ N("_File") . N("_Reset the selection"), undef, sub { reset_selection($tree) }, undef, '<Item>' ],
- [ N("_File") . N("Reload the _packages list"), undef, $reload_db_and_clear_all, undef, '<Item>' ],
- [ N("_File") . N("_Quit"), N("<control>Q"), \&quit, undef, '<Item>', ],
- if_(!$>,
- [ N("_Options"), undef, undef, undef, '<Branch>' ],
- [ $auto_select_string, undef,
+
+ my @radio_labels = qw(flat by_group by_leaves by_presence by_selection by_size by_source);
+ my @radios = map {
+ my $val = $_;
+ [ $_, undef, $modes{$_}, undef, undef, sub { $view_callback->($val) } ];
+ } @radio_labels;
+
+ my $ui = gtknew('UIManager',
+ actions => [
+ # [name, stock_id, value, label, accelerator, tooltip, callback]
+ [ 'FileMenu', undef, N("_File") ],
+ if_(! $>,
+ [ 'Update media', undef, N("_Update media"), undef, undef, sub {
+ update_sources_interactive($urpm, transient => $w->{real_window})
+ and $reload_db_and_clear_all->();
+ } ]
+ ),
+ [ 'Reset_the_selection', undef, N("_Reset the selection"), undef, undef, sub { reset_selection($tree) } ],
+ [ 'Reload_the_packages_list', undef, N("Reload the _packages list"), undef, undef, $reload_db_and_clear_all ],
+ [ 'Quit', undef, N("_Quit"), N("<control>Q"), undef, \&quit ],
+
+ if_(! $>,
+ [ 'OptionsMenu', undef, N("_Options") ],
+ [ 'Media_Manager', undef, N("_Media Manager"), undef, undef, sub {
+ require Rpmdrake::edit_urpm_sources;
+ Rpmdrake::edit_urpm_sources::run() && $reload_db_and_clear_all->();
+ }, ],
+ ),
+
+ [ 'ViewMenu', undef, N("_View") ],
+
+ [ 'HelpMenu', undef, N("_Help") ],
+ [ 'Report_Bug', undef, N("_Report Bug"), undef, undef, sub { run_drakbug('rpmdrake') } ],
+ [ 'Help', undef, N("_Help"), undef, undef, sub { rpmdrake::open_help('') } ],
+ [ 'About', undef, N("_About..."), undef, undef, \&show_about_dlg ],
+
+ ],
+ radio_actions => [ [ \@radios, undef, # +default choice
+ $view_callback
+ ] ],
+ toggle_actions => [
+ [ 'Auto_select', undef, $auto_select_string, undef, undef,
sub {
my $box = $check_boxes{$auto_select_string};
$auto_select_opt->[0] = $box->get_active;
$::rpmdrake_options{auto} = $box->get_active;
$urpm->{options}{auto} = $box->get_active;
- },
- undef, '<CheckItem>' ],
- [ $clean_cache_string, undef,
+ } ],
+ [ 'Clean_Cache', undef, $clean_cache_string, undef, undef,
sub {
$clean_cache->[0] =
$check_boxes{$clean_cache_string}->get_active;
$::noclean = !$clean_cache->[0];
- },
- undef, '<CheckItem>' ],
- [ N("_Options") . N("_Media Manager"), undef, sub {
- require Rpmdrake::edit_urpm_sources;
- Rpmdrake::edit_urpm_sources::run() && $reload_db_and_clear_all->();
- }, undef, '<Item>' ],
- [ N("_Options") . N("_Show automatically selected packages"), undef, sub {
+ } ],
+
+ [ 'Show_auto_selected_pkgs', undef, N("_Show automatically selected packages"), undef, undef, sub {
$dont_show_selections->[0] = !$checkbox_show_autoselect->get_active;
- }, undef, '<CheckItem>' ],
+ } ],
- [ $updates_string, undef, sub {
+ [ 'Compute_updates_on_startup', undef, $updates_string, undef, undef, sub {
$compute_updates->[0] = $check_boxes{$updates_string}->get_active;
- }, undef, '<CheckItem>' ],
- [ $NVR_string, undef, sub {
+ } ],
+ [ 'NVR_search', undef, $NVR_string, undef, undef, sub {
$NVR_searches->[0] = $check_boxes{$NVR_string}->get_active;
- }, undef, '<CheckItem>' ],
- [ $regexp_search_string, undef, sub {
+ } ],
+ [ 'Use_RE_in_searches', undef, $regexp_search_string, undef, undef, sub {
$use_regexp->[0] = $check_boxes{$regexp_search_string}->get_active;
- }, undef, '<CheckItem>' ],
- ),
- [ N("_View"), undef, undef, undef, '<Branch>' ],
- (map {
- state ($idx, $previous);
- my $type = $idx ? join('/', N("_View"), $previous) : '<RadioItem>';
- $type =~ s/_//g; # gtk+ retrieve widgets by their path w/o any shortcut marks
- $previous = $modes{$_};
- $idx++;
- my $val = $_;
- [ N("_View") . '/' . $modes{$_}, undef, sub { $view_callback->($val) }, 0, $type ];
- } qw(flat by_group by_leaves by_presence by_selection by_size by_source)),
- [ N("_Help"), undef, undef, undef, '<Branch>' ],
- [ N("_Help") . N("_Report Bug"), undef, sub { run_drakbug('rpmdrake') }, undef, '<Item>' ],
- [ N("_Help") . N("_Help"), undef, sub { rpmdrake::open_help('') }, undef, '<Item>' ],
- [ N("_Help") . N("_About..."), undef, \&show_about_dlg, undef, '<Item>'
- ]
-
- );
+ } ],
+ ],
+ string =>
+ join("\n",
+ qq(<ui>
+ <menubar name='MenuBar'>
+ <menu action='FileMenu'>),
+ if_(! $>, "<menuitem action='Update_media'/>"),
+ qq(
+ <menuitem action='Reset_selection'/>
+ <menuitem action='Reload_the_packages_list'/>
+ <menuitem action='Quit'/>
+ </menu>),
+ if_(!$>, qq(
+ <menu action='OptionsMenu'>
+ <menuitem action='Auto_select'/>
+ <menuitem action='Clean_Cache'/>
+ <menuitem action='Media_Manager'/>
+ <menuitem action='Show_auto_selected_pkgs'/>
+ <menuitem action='Compute_updates_on_startup'/>
+ <menuitem action='NVR_search'/>
+ <menuitem action='Use_RE_in_searches'/>
+ </menu>
+)),
+ "<menu action='ViewMenu'>",
+ (map { "<menuitem action='$_'/>" } @radio_labels),
+qq(
+ </menu>
+
+ <menu action='HelpMenu'>
+ <menuitem action='Help'/>
+ <menuitem action='Report_Bug'/>
+ <menuitem action='About'/>
+ </menu>
+ </menubar>
+</ui>)));
+
+ my $menu = $ui->get_widget('/MenuBar');
# to retrieve a path, one must prevent "accelerators completion":
my $get_path = sub { return join('', map { my $i = $_; $i =~ s/_//g; $i } @_) };
- if (my $widget = $factory->get_item('<main>' . $get_path->(N("_View") . '/' . $modes{$mode->[0]}))) {
+ if (my $widget = $ui->get_widget('/MenuBar/ViewMenu/' . $modes{$mode->[0]})) {
$widget->set_active(1);
} else {
warn "Impossible to set $mode->[0] view as default\n";
}
%check_boxes = map {
- $_ => $factory->get_widget("<main>" . $get_path->($_));
+ $_ => $ui->get_widget('/MenuBar/OptionsMenu' . $_);
} ($auto_select_string,
$clean_cache_string,
$NVR_string,
@@ -674,7 +714,7 @@ sub run_treeview_dialog {
$check_boxes{$clean_cache_string}->set_active($clean_cache->[0]);
}
- $checkbox_show_autoselect = $factory->get_widget("<main>" . strip_first_underscore(N("_Options"), N("_Show automatically selected packages")))
+ $checkbox_show_autoselect = $ui->get_widget('/MenuBar/OptionsMenu/Auto_select')
and $checkbox_show_autoselect->set_active(!$dont_show_selections->[0]);
my $accel = Gtk3::AccelGroup->new;
@@ -762,6 +802,7 @@ sub run_treeview_dialog {
# so that we can shrink back:
$w->{real_window}->set_default_size($rpmdrake_width->[0], $rpmdrake_height->[0]);
}
+ $w->{rwindow}->add_accel_group($ui->get_accel_group);
$w->{rwindow}->show_all;
$w->{rwindow}->set_sensitive(0);