From ce4379b0ea99f1546f6d8c517000082cecee7e6e Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Sun, 6 Jul 2014 00:12:41 +0200 Subject: Fixed File and Help menu events --- modules/rpmdragora/rpmdragora | 155 ++++++++++++++++++++++-------------------- 1 file changed, 83 insertions(+), 72 deletions(-) diff --git a/modules/rpmdragora/rpmdragora b/modules/rpmdragora/rpmdragora index f5e5b52c..7f21e84a 100755 --- a/modules/rpmdragora/rpmdragora +++ b/modules/rpmdragora/rpmdragora @@ -776,19 +776,20 @@ sub run_treeview_dialog { my $regexp_search_string = N("/_Options") . "/" . N("Use _regular expressions in searches"); # build File menu - my $file_menu = $factory->createMenuButton($headbar,N("File")); - my $mnuItemExit = new yui::YMenuItem(N("Quit")); - my $mnuItemUpdateMedia = new yui::YMenuItem(N("Update media")); - my $mnuItemResetSelection = new yui::YMenuItem(N("Reset the selection")); - my $mnuItemReloadPackagesList = new yui::YMenuItem(N("Reload the packages list")); - - $file_menu->addItem($mnuItemExit); - $file_menu->addItem($mnuItemUpdateMedia); - $file_menu->addItem($mnuItemResetSelection); - $file_menu->addItem($mnuItemReloadPackagesList); - - $file_menu->rebuildMenuTree(); - + my %fileMenu = ( + widget => $factory->createMenuButton($headbar,N("File")), + update => new yui::YMenuItem(N("Update media")), + reset_sel => new yui::YMenuItem(N("Reset the selection")), + reload => new yui::YMenuItem(N("Reload the packages list")), + quit => new yui::YMenuItem(N("&Quit")), + ); + + my @ordered_menu_lines = qw(update reset_sel reload quit); + foreach (@ordered_menu_lines) { + $fileMenu{ widget }->addItem($fileMenu{ $_ }); + } + $fileMenu{ widget }->rebuildMenuTree(); + # build View menu my $view_menu = $factory->createMenuButton($headbar,N("View")); @@ -808,12 +809,18 @@ sub run_treeview_dialog { $option_menu->rebuildMenuTree(); # build help menu - my $help_menu = $factory->createMenuButton($headRight,N("Help")); - my @items = ("Report bug", "Help", "About"); - for my $item(@items) { - $help_menu->addItem(new yui::YMenuItem(N($item))); + my %helpMenu = ( + widget => $factory->createMenuButton($headRight, N("&Help")), + help => new yui::YMenuItem(N("Manual")), + report_bug => new yui::YMenuItem(N("Report Bug")), + about => new yui::YMenuItem(N("&About")), + ); + @ordered_menu_lines = qw(help report_bug about); + foreach (@ordered_menu_lines) { + $helpMenu{ widget }->addItem($helpMenu{ $_ }); } - $help_menu->rebuildMenuTree(); + $helpMenu{ widget }->rebuildMenuTree(); + $statusbar = $factory->createLabel($hbox_footbar, ""); =comment @@ -1077,6 +1084,63 @@ sub run_treeview_dialog { quit(); last; } + elsif ($eventType == $yui::YEvent::MenuEvent) { + ### MENU ### + my $item = $event->item(); + my $menuLabel = $item->label(); + if ($menuLabel eq $fileMenu{ quit }->label()) { + #menu File->Quit + quit(); + last; + } + elsif ($menuLabel eq $fileMenu{ update }->label()) { + update_sources_interactive($urpm, transient => $my_win) + and $reload_db_and_clear_all->(); + } + elsif ($menuLabel eq $fileMenu{ reset_sel }->label()) { + if ($MODE ne 'remove') { + my $db = eval { open_rpm_db() }; + if (!ref($db)) { + statusbar_msg(N("Reset aborted (RPM DB is locked by another process)"), 1); + return; + } + $urpm->disable_selected( + $db, $urpm->{state}, + map { if_($pkgs->{$_}{selected}, $pkgs->{$_}{pkg}) } keys %$pkgs,); + } + undef $pkgs->{$_}{selected} foreach keys %$pkgs; + reset_search(); + $size_selected = 0; + $force_displaying_group = 1; + my $tree_selection = $tree->currentItem(); + } + elsif ($menuLabel eq $fileMenu{ reload }->label()) { + $reload_db_and_clear_all->(); + } + elsif ($menuLabel eq $helpMenu{ about }->label()) { + my $translators = N("_: Translator(s) name(s) & email(s)\n"); + $translators =~ s/\/\>\;/g; + my $sh_gui = AdminPanel::Shared::GUI->new(); + $sh_gui->AboutDialog({ name => "Rpmdragora", + version => "TODO", + credits => N("Copyright (C) %s Mageia community", '2013-2014'), + license => N("GPLv2"), + description => N("Rpmdragora is the Mageia package management tool."), + authors => N("

Developers

+ +

Translators

+ ", + "Angelo Naselli <anaselli\@linux.it>", + "Matteo Pasotti <matteo.pasotti\@gmail.com>", + $translators + ), + } + ); + } + } elsif ($eventType == $yui::YEvent::WidgetEvent) { # widget selected my $widget = $event->widget(); @@ -1108,65 +1172,12 @@ sub run_treeview_dialog { detaillist_callback($detail_list->selectedItem(), $info, \%$options); detaillist_changeditem_callback($detail_list, \%$options); } - elsif ($widget == $file_menu && $mnuItemUpdateMedia) { - update_sources_interactive($urpm, transient => $my_win) - and $reload_db_and_clear_all->(); - } - elsif ($widget == $file_menu && $mnuItemResetSelection) { - if ($MODE ne 'remove') { - my $db = eval { open_rpm_db() }; - if (!ref($db)) { - statusbar_msg(N("Reset aborted (RPM DB is locked by another process)"), 1); - return; - } - $urpm->disable_selected( - $db, $urpm->{state}, - map { if_($pkgs->{$_}{selected}, $pkgs->{$_}{pkg}) } keys %$pkgs,); - } - undef $pkgs->{$_}{selected} foreach keys %$pkgs; - reset_search(); - $size_selected = 0; - $force_displaying_group = 1; - my $tree_selection = $tree->currentItem(); - } - elsif ($widget == $file_menu && $mnuItemReloadPackagesList) { - $reload_db_and_clear_all->(); - } elsif ($widget == $QuitButton) { quit(); last; } } - else { - ### any other events - if ($event->item()) { - # items - my $itemLabel = $event->item()->label(); - #print "----- " . $itemLabel . "\n"; - if ($itemLabel eq $mnuItemExit->label()) { - #menu File->Quit - quit(); - last; - } - elsif ($itemLabel eq N("About")) { - my $license = formatAlaTeX(translate($::license)); - $license =~ s/\n/\n\n/sg; # nicer formatting - AboutDialog({ name => N("Rpmdragora"), - version => $Rpmdragora::init::version, - copyright => N("Copyright (C) %s by Mandriva", '2002-2009'), - license => $license, - comments => N("Rpmdragora is the Mageia package management tool."), - website => 'http://www.mageia.org', - website_label => N("Mageia"), - authors => 'Thierry Vignaud \nAngelo Naselli \nMatteo Pasotti ', - artists => 'Hélène Durosini ', - translator_credits => - #-PO: put here name(s) and email(s) of translator(s) (eg: "John Smith ") - N("_: Translator(s) name(s) & email(s)\n")} - ); - } - } - } + } } -- cgit v1.2.1