diff options
author | Angelo Naselli <anaselli@mageia.org> | 2013-01-07 21:09:09 +0000 |
---|---|---|
committer | Angelo Naselli <anaselli@mageia.org> | 2013-01-07 21:09:09 +0000 |
commit | b9757c5baa8018598b3e4a4827426a2129b0a7a1 (patch) | |
tree | 7d98699c7008133a17cc64c62a3953b5fae13854 | |
parent | e822b14bab0e0d759c4647c725f94d362e984dbb (diff) | |
download | manatools-b9757c5baa8018598b3e4a4827426a2129b0a7a1.tar manatools-b9757c5baa8018598b3e4a4827426a2129b0a7a1.tar.gz manatools-b9757c5baa8018598b3e4a4827426a2129b0a7a1.tar.bz2 manatools-b9757c5baa8018598b3e4a4827426a2129b0a7a1.tar.xz manatools-b9757c5baa8018598b3e4a4827426a2129b0a7a1.zip |
added menu exit management (as an example of menu event)
-rwxr-xr-x | modules/rpmdragora/rpmdragora | 546 |
1 files changed, 277 insertions, 269 deletions
diff --git a/modules/rpmdragora/rpmdragora b/modules/rpmdragora/rpmdragora index 28138544..5924cfd3 100755 --- a/modules/rpmdragora/rpmdragora +++ b/modules/rpmdragora/rpmdragora @@ -101,35 +101,35 @@ sub do_search($$$$$$$) { last if $count++ > 2000; } } else { - my $searchstop; - #my $searchw = ugtk2->new(N("Software Management"), grab => 1, transient => $w->{real_window}); - my $searchw = $factory->createPopupDialog; - my $vbox = $factory->createVBox($searchw); - my $lblWIP = $factory->createLabel($vbox, N("Please wait, searching...")); - my $searchprogress = $factory->createProgressBar($vbox, 'ProgressBar'); - my $stop_button = $factory->createIconButton($vbox,"",N("Stop")); - - #gtkadd( - #$searchw->{window}, - #gtkpack__( - #gtknew('VBox', spacing => 5), - #gtknew('Label', text => N("Please wait, searching...")), - #my $searchprogress = gtknew('ProgressBar', width => 300), - #gtkpack__( - #gtknew('HButtonBox', layout => 'spread'), - #gtksignal_connect( - #Gtk2::Button->new(but(N("Stop"))), - #clicked => sub { $searchstop = 1 }, - #), - #), - #), - #); - #$searchw->sync; - $searchw->recalcLayout(); + my $searchstop; + #my $searchw = ugtk2->new(N("Software Management"), grab => 1, transient => $w->{real_window}); + my $searchw = $factory->createPopupDialog; + my $vbox = $factory->createVBox($searchw); + my $lblWIP = $factory->createLabel($vbox, N("Please wait, searching...")); + my $searchprogress = $factory->createProgressBar($vbox, 'ProgressBar'); + my $stop_button = $factory->createIconButton($vbox,"",N("Stop")); + + #gtkadd( + #$searchw->{window}, + #gtkpack__( + #gtknew('VBox', spacing => 5), + #gtknew('Label', text => N("Please wait, searching...")), + #my $searchprogress = gtknew('ProgressBar', width => 300), + #gtkpack__( + #gtknew('HButtonBox', layout => 'spread'), + #gtksignal_connect( + #Gtk2::Button->new(but(N("Stop"))), + #clicked => sub { $searchstop = 1 }, + #), + #), + #), + #); + #$searchw->sync; + $searchw->recalcLayout(); $searchw->doneMultipleChanges(); # should probably not account backports packages or find a way to search them: my $total_size = keys %$pkgs; - my $progresscount; + my $progresscount; my $update_search_pb = sub { $progresscount++; @@ -204,9 +204,9 @@ sub do_search($$$$$$$) { } end_search: - @search_results = uniq(@search_results); #- there can be multiple packages with same version/release for different arch's - @search_results = intersection(\@search_results, \@filtered_pkgs); - $searchw->destroy; + @search_results = uniq(@search_results); #- there can be multiple packages with same version/release for different arch's + @search_results = intersection(\@search_results, \@filtered_pkgs); + $searchw->destroy; } my $iter; @@ -215,12 +215,12 @@ sub do_search($$$$$$$) { print "RESULTS: @search_results\n"; $elems{$results_ok} = [ map { [ $_, $results_ok ] } @search_results ]; $iter = $options->{add_parent}->($results_ok); - $options->{add_nodes}->(map { [ $_, $results_ok . ($options->{tree_mode} eq 'by_presence' - ? '|' . ($pkgs->{$_}{pkg}->flag_installed ? N("Upgradable") : N("Addable")) - : ($options->{tree_mode} eq 'by_selection' - ? '|' . ($pkgs->{$_}{selected} ? N("Selected") : N("Not selected")) - : '')) - ] } @search_results); + $options->{add_nodes}->(map { [ $_, $results_ok . ($options->{tree_mode} eq 'by_presence' + ? '|' . ($pkgs->{$_}{pkg}->flag_installed ? N("Upgradable") : N("Addable")) + : ($options->{tree_mode} eq 'by_selection' + ? '|' . ($pkgs->{$_}{selected} ? N("Selected") : N("Not selected")) + : '')) + ] } @search_results); } else { $iter = $options->{add_parent}->($results_none); # clear package list: @@ -258,33 +258,33 @@ sub run_treeview_dialog { $::main_window = $my_win; $options = { - build_tree => sub { build_tree($tree, $tree_model, \%elems, $options, $force_rebuild, @_) }, - partialsel_unsel => sub { - my ($unsel, $sel) = @_; - @$sel = grep { exists $pkgs->{$_} } @$sel; - @$unsel < @$sel; - }, - get_status => sub { - N("Selected: %s / Free disk space: %s", formatXiB($size_selected), formatXiB($size_free*1024)); - }, - rebuild_tree => sub {}, + build_tree => sub { build_tree($tree, $tree_model, \%elems, $options, $force_rebuild, @_) }, + partialsel_unsel => sub { + my ($unsel, $sel) = @_; + @$sel = grep { exists $pkgs->{$_} } @$sel; + @$unsel < @$sel; + }, + get_status => sub { + N("Selected: %s / Free disk space: %s", formatXiB($size_selected), formatXiB($size_free*1024)); + }, + rebuild_tree => sub {}, }; my $vbox = $factory->createVBox($my_win); - my $hbox_headbar = $factory->createHBox($vbox); - my $head_align_left = $factory->createLeft($hbox_headbar); - my $headbar = $factory->createHBox($head_align_left); - my $hbox_top = $factory->createHBox($vbox); - my $hbox_middle = $factory->createHBox($vbox); - my $hbox_bottom = $factory->createHBox($vbox); - my $hbox_footbar = $factory->createHBox($vbox); + my $hbox_headbar = $factory->createHBox($vbox); + my $head_align_left = $factory->createLeft($hbox_headbar); + my $headbar = $factory->createHBox($head_align_left); + my $hbox_top = $factory->createHBox($vbox); + my $hbox_middle = $factory->createHBox($vbox); + my $hbox_bottom = $factory->createHBox($vbox); + my $hbox_footbar = $factory->createHBox($vbox); - $hbox_headbar->setWeight(1,10); - $hbox_top->setWeight(1,10); - $hbox_middle->setWeight(1,50); - $hbox_bottom->setWeight(1,30); - $hbox_footbar->setWeight(1,10); + $hbox_headbar->setWeight(1,10); + $hbox_top->setWeight(1,10); + $hbox_middle->setWeight(1,50); + $hbox_bottom->setWeight(1,30); + $hbox_footbar->setWeight(1,10); #OLD $tree_model = Gtk2::TreeStore->new("Glib::String", "Glib::String", "Gtk2::Gdk::Pixbuf"); #OLD $tree_model->set_sort_column_id($grp_columns{label}, 'ascending'); @@ -343,16 +343,16 @@ sub run_treeview_dialog { }), ); foreach my $col (@columns{@columns}) { - #OLD $detail_list->append_column( - # $col->{widget} = - # Gtk2::TreeViewColumn->new_with_attributes( - # ' ' . $col->{title} . ' ', - # $col->{renderer} = Gtk2::CellRendererText->new, - # ($col->{markup} ? (markup => $col->{markup}) : (text => $col->{text})), - # ) - # ); - #$col->{widget}->set_sort_column_id($col->{markup} || $col->{text}); - $detail_list_header->addColumn($col->{title}); + #OLD $detail_list->append_column( + # $col->{widget} = + # Gtk2::TreeViewColumn->new_with_attributes( + # ' ' . $col->{title} . ' ', + # $col->{renderer} = Gtk2::CellRendererText->new, + # ($col->{markup} ? (markup => $col->{markup}) : (text => $col->{text})), + # ) + # ); + #$col->{widget}->set_sort_column_id($col->{markup} || $col->{text}); + $detail_list_header->addColumn($col->{title}); } #OLD $columns{$_}{widget}->set_sizing('autosize') foreach @columns; @@ -377,18 +377,18 @@ sub run_treeview_dialog { $detail_list_header->addColumn(N("Status")); $detail_list = $factory->createTable($hbox_middle,$detail_list_header); - $detail_list->setWeight(0,50); + $detail_list->setWeight(0,50); #OLD compute_main_window_size($w); =comment my $cursor_to_restore; $_->signal_connect( - expose_event => sub { - $cursor_to_restore or return; - gtkset_mousecursor_normal($tree->window); - undef $cursor_to_restore; - },) foreach $tree, $detail_list; - + expose_event => sub { + $cursor_to_restore or return; + gtkset_mousecursor_normal($tree->window); + undef $cursor_to_restore; + },) foreach $tree, $detail_list; + $tree->currentItem(changed => sub { my ($model, $iter) = $_[0]->get_selected; return if !$iter; @@ -557,19 +557,19 @@ sub run_treeview_dialog { my $previous; foreach (N("in names"), N("in descriptions"), N("in summaries"), N("in file names")) { my ($name, $val) = ($_, $i); - #OLD $search_menu->append(gtksignal_connect(gtkshow( - # $previous = Gtk2::RadioMenuItem->new_with_label($previous, $name)), - # activate => sub { $current_search_type = $search_types[$val] })); - $search_menu->addItem($name); + #OLD $search_menu->append(gtksignal_connect(gtkshow( + # $previous = Gtk2::RadioMenuItem->new_with_label($previous, $name)), + # activate => sub { $current_search_type = $search_types[$val] })); + $search_menu->addItem($name); $i++; } - $find_entry = $factory->createInputField($hbox_top, ""); - my $find_button = $factory->createIconButton($hbox_top, "/usr/share/mcc/themes/default/logdrake-mdk.png", N("Search")); - $find_button->setWeight(0,6); - my $reset_search_button = $factory->createIconButton($hbox_top, "/usr/share/icons/gnome/22x22/actions/gtk-clear.png", N("Reset")); - $reset_search_button->setWeight(0,7); - $find_entry->setWeight(0,10); + $find_entry = $factory->createInputField($hbox_top, ""); + my $find_button = $factory->createIconButton($hbox_top, "/usr/share/mcc/themes/default/logdrake-mdk.png", N("Search")); + $find_button->setWeight(0,6); + my $reset_search_button = $factory->createIconButton($hbox_top, "/usr/share/icons/gnome/22x22/actions/gtk-clear.png", N("Reset")); + $reset_search_button->setWeight(0,7); + $find_entry->setWeight(0,10); #OLD my $info = Gtk2::Mdv::TextView->new; my $info = $factory->createMultiLineEdit($hbox_bottom,""); @@ -579,18 +579,18 @@ sub run_treeview_dialog { #OLD $info->set_right_margin(15); #- workaround when right elevator of scrolled window appears my $find_callback = sub { - do_search($find_entry, $tree, $tree_model, $options, $current_search_type, $urpm, $pkgs); + do_search($find_entry, $tree, $tree_model, $options, $current_search_type, $urpm, $pkgs); }; - my $select_all_button = $factory->createIconButton($hbox_footbar,"",N("Select all")); - $select_all_button->setWeight(0,6); + my $select_all_button = $factory->createIconButton($hbox_footbar,"",N("Select all")); + $select_all_button->setWeight(0,6); - my $apply_button = $factory->createIconButton($hbox_footbar,"",N("Apply")); - $apply_button->setWeight(0,6); + my $apply_button = $factory->createIconButton($hbox_footbar,"",N("Apply")); + $apply_button->setWeight(0,6); - my $QuitButton = $factory->createIconButton($hbox_footbar,"",N("Exit")); - $QuitButton->setWeight(0,6); - + my $QuitButton = $factory->createIconButton($hbox_footbar,"",N("Exit")); + $QuitButton->setWeight(0,6); + #my $hpaned = gtknew('HPaned', position => $typical_width*0.9, # child1 => gtknew('ScrolledWindow', child => $tree), @@ -662,48 +662,48 @@ sub run_treeview_dialog { my $help_menu = $factory->createMenuButton($headbar,N("Help")); my @items = ("Report bug", "Help", "About"); for my $item(@items) { - $help_menu->addItem(new yui::YMenuItem(N($item))); - } - $help_menu->rebuildMenuTree(); - - $statusbar = $factory->createLabel($hbox_footbar, ""); + $help_menu->addItem(new yui::YMenuItem(N($item))); + } + $help_menu->rebuildMenuTree(); + + $statusbar = $factory->createLabel($hbox_footbar, ""); =comment 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 { - if ($MODE ne 'remove') { + $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 { + 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->get_selection; - $tree_selection->select_path(Gtk2::TreePath->new_from_string('0')) if !$tree_selection->get_selected; - $tree_selection->signal_emit('changed'); - }, 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>', ], - #[ N("/_View"), undef, undef, undef, '<Branch>' ], - if_(!$>, - [ N("/_Options"), undef, undef, undef, '<Branch>' ], - [ $auto_select_string, undef, + $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->get_selection; + $tree_selection->select_path(Gtk2::TreePath->new_from_string('0')) if !$tree_selection->get_selected; + $tree_selection->signal_emit('changed'); + }, 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>', ], + #[ N("/_View"), undef, undef, undef, '<Branch>' ], + if_(!$>, + [ N("/_Options"), undef, undef, undef, '<Branch>' ], + [ $auto_select_string, undef, sub { my $box = $check_boxes{$auto_select_string}; $auto_select->[0] = $box->get_active; @@ -711,32 +711,32 @@ sub run_treeview_dialog { $urpm->{options}{auto} = $box->get_active; }, undef, '<CheckItem>' ], - [ $clean_cache_string, undef, + [ $clean_cache_string, 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 { + [ N("/_Options") . N("/_Media Manager"), undef, sub { require Rpmdragora::edit_urpm_sources; Rpmdragora::edit_urpm_sources::run() && $reload_db_and_clear_all->(); }, undef, '<Item>' ], - [ N("/_Options") . N("/_Show automatically selected packages"), undef, sub { - $dont_show_selections->[0] = !$checkbox_show_autoselect->get_active; - }, undef, '<CheckItem>' ], + [ N("/_Options") . N("/_Show automatically selected packages"), undef, sub { + $dont_show_selections->[0] = !$checkbox_show_autoselect->get_active; + }, undef, '<CheckItem>' ], - [ $updates_string, undef, sub { + [ $updates_string, undef, sub { $compute_updates->[0] = $check_boxes{$updates_string}->get_active; - }, undef, '<CheckItem>' ], - [ $NVR_string, undef, sub { + }, undef, '<CheckItem>' ], + [ $NVR_string, undef, sub { $NVR_searches->[0] = $check_boxes{$NVR_string}->get_active; - }, undef, '<CheckItem>' ], - [ $regexp_search_string, undef, sub { + }, undef, '<CheckItem>' ], + [ $regexp_search_string, undef, sub { $use_regexp->[0] = $check_boxes{$regexp_search_string}->get_active; - }, undef, '<CheckItem>' ], - ), - [ N("/_View"), undef, undef, undef, '<Branch>' ], + }, undef, '<CheckItem>' ], + ), + [ N("/_View"), undef, undef, undef, '<Branch>' ], (map { state ($idx, $previous); my $type = $idx ? join('/', N("/_View"), $previous) : '<RadioItem>'; @@ -746,9 +746,9 @@ sub run_treeview_dialog { 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"), undef, undef, undef, '<Branch>' ], [ N("/_Help") . N("/_Report Bug"), undef, sub { run_drakbug('rpmdragora') }, undef, '<Item>' ], - [ N("/_Help") . N("/_Help"), undef, sub { rpmdragora::open_help('') }, undef, '<Item>' ], + [ N("/_Help") . N("/_Help"), undef, sub { rpmdragora::open_help('') }, undef, '<Item>' ], [ N("/_Help") . N("/_About..."), undef, sub { my $license = formatAlaTeX(translate($::license)); $license =~ s/\n/\n\n/sg; # nicer formatting @@ -799,28 +799,28 @@ sub run_treeview_dialog { } $checkbox_show_autoselect = $factory->get_widget("<main>" . strip_first_underscore(N("/_Options"), N("/_Show automatically selected packages"))) - and $checkbox_show_autoselect->set_active(!$dont_show_selections->[0]); + and $checkbox_show_autoselect->set_active(!$dont_show_selections->[0]); my $accel = Gtk2::AccelGroup->new; $accel->connect(Gtk2::Gdk->keyval_from_name('F'), [ 'control-mask' ], [ 'visible' ], sub { $find_entry->grab_focus }); $w->{real_window}->add_accel_group($accel); gtkadd( - $w->{window}, - gtkpack_( - gtknew('VBox', spacing => 3), - 0, $menu, - if_(second(gtkroot()->get_size) >= 600, 0, getbanner()), - 1, gtkadd( - gtknew('Frame', border_width => 3, shadow_type => 'none'), - gtkpack_( - gtknew('VBox', spacing => 3), - 0, gtkpack_( - gtknew('HBox', spacing => 10), - 0, $view_box, - 0, $filter_box, - 0, gtknew('Label', text => N("Find:")), - 1, $find_entry = gtknew('Entry', width => 260, + $w->{window}, + gtkpack_( + gtknew('VBox', spacing => 3), + 0, $menu, + if_(second(gtkroot()->get_size) >= 600, 0, getbanner()), + 1, gtkadd( + gtknew('Frame', border_width => 3, shadow_type => 'none'), + gtkpack_( + gtknew('VBox', spacing => 3), + 0, gtkpack_( + gtknew('HBox', spacing => 10), + 0, $view_box, + 0, $filter_box, + 0, gtknew('Label', text => N("Find:")), + 1, $find_entry = gtknew('Entry', width => 260, primary_icon => 'gtk-find', secondary_icon => 'gtk-clear', tip => N("Please type in the string you want to search then press the <enter> key"), @@ -835,36 +835,36 @@ sub run_treeview_dialog { return if $pos ne 'primary'; $search_menu->popup(undef, undef, undef, undef, $event->button, $event->time); }, - key_press_event => sub { - member($_[1]->keyval, $Gtk2::Gdk::Keysyms{Return}, $Gtk2::Gdk::Keysyms{KP_Enter}) - and $find_callback->(); - }, + key_press_event => sub { + member($_[1]->keyval, $Gtk2::Gdk::Keysyms{Return}, $Gtk2::Gdk::Keysyms{KP_Enter}) + and $find_callback->(); + }, ), - ), - 1, $hpaned, - 0, $status, - 0, gtkpack_( - gtknew('HBox', spacing => 20), - 0, gtksignal_connect( - Gtk2::Button->new(but_(N("Select all"))), - clicked => sub { + ), + 1, $hpaned, + 0, $status, + 0, gtkpack_( + gtknew('HBox', spacing => 20), + 0, gtksignal_connect( + Gtk2::Button->new(but_(N("Select all"))), + clicked => sub { toggle_all($options, 1); }, - ), - 1, gtknew('Label'), - 0, my $action_button = gtksignal_connect( - Gtk2::Button->new(but_(N("Apply"))), - clicked => sub { do_action($options, $callback_action, $info) }, - ), - 0, gtksignal_connect( - Gtk2::Button->new(but_(N("Quit"))), - clicked => \&quit, - ), - ), - ), - ), - 0, $statusbar = Gtk2::Statusbar->new, - ), + ), + 1, gtknew('Label'), + 0, my $action_button = gtksignal_connect( + Gtk2::Button->new(but_(N("Apply"))), + clicked => sub { do_action($options, $callback_action, $info) }, + ), + 0, gtksignal_connect( + Gtk2::Button->new(but_(N("Quit"))), + clicked => \&quit, + ), + ), + ), + ), + 0, $statusbar = Gtk2::Statusbar->new, + ), ); $action_button->set_sensitive(0) if $>; $find_entry->grab_focus; @@ -904,96 +904,104 @@ sub run_treeview_dialog { #$w->{rwindow}->set_sensitive(1); $options->{widgets} = { - w => $my_win, - tree => $tree, - #tree_model => $tree_model, - #detail_list_model => $detail_list_model, - detail_list => $detail_list, - info => $info, - status => $status, + w => $my_win, + tree => $tree, + #tree_model => $tree_model, + #detail_list_model => $detail_list_model, + detail_list => $detail_list, + info => $info, + status => $status, }; $options->{init_callback} = $find_callback if $rpmdragora_options{search}; ask_browse_tree_given_widgets_for_rpmdragora($options); - ######## main loop #################### - while(1) { - my $event = $my_win->waitForEvent(); - - my $eventType = $event->eventType(); - - print $event->item()->label() if($event->item()); - - #event type checking - if ($eventType == $yui::YEvent::CancelEvent) { - quit(); - last; - } - elsif ($eventType == $yui::YEvent::WidgetEvent) { - # widget selected - my $widget = $event->widget(); - - if($widget == $reset_search_button) { - $find_entry->setValue(''); + ######## main loop #################### + while(1) { + my $event = $my_win->waitForEvent(); + + my $eventType = $event->eventType(); + + #event type checking + if ($eventType == $yui::YEvent::CancelEvent) { + quit(); + last; + } + elsif ($eventType == $yui::YEvent::WidgetEvent) { + # widget selected + my $widget = $event->widget(); + if($widget == $reset_search_button) { + $find_entry->setValue(''); + reset_search(); + } + elsif ($widget == $find_button) { + do_search($find_entry, $tree, $tree_model, $options, $current_search_type, $urpm, $pkgs); + } + elsif ($widget == $select_all_button) { + toggle_all($options, 1); + } + elsif ($widget == $apply_button) { + do_action($options, $callback_action, $info); + } + elsif ($widget == $view_box) { + my $val = $_[0]->get_text; + return if $val eq $old_value; # workarounding gtk+ sending us sometimes twice events + $old_value = $val; + $default_list_mode = $rviews{$val}; + if (my @cat = $wanted_categories{$rviews{$val}} && @{$wanted_categories{$rviews{$val}}}) { + @$mandrakeupdate_wanted_categories = @cat; + } + + if ($options->{tree_mode} ne $val) { + $tree_mode->[0] = $options->{tree_mode} = $rviews{$val}; + $tree_flat->[0] = $options->{state}{flat}; + reset_search(); + switch_pkg_list_mode($rviews{$val}); + $options->{rebuild_tree}->(); + } + } + 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(); - } - elsif ($widget == $find_button) { - do_search($find_entry, $tree, $tree_model, $options, $current_search_type, $urpm, $pkgs); - } - elsif ($widget == $select_all_button) { - toggle_all($options, 1); - } - elsif ($widget == $apply_button) { - do_action($options, $callback_action, $info); - } - elsif ($widget == $view_box) { - my $val = $_[0]->get_text; - return if $val eq $old_value; # workarounding gtk+ sending us sometimes twice events - $old_value = $val; - $default_list_mode = $rviews{$val}; - if (my @cat = $wanted_categories{$rviews{$val}} && @{$wanted_categories{$rviews{$val}}}) { - @$mandrakeupdate_wanted_categories = @cat; - } - - if ($options->{tree_mode} ne $val) { - $tree_mode->[0] = $options->{tree_mode} = $rviews{$val}; - $tree_flat->[0] = $options->{state}{flat}; - reset_search(); - switch_pkg_list_mode($rviews{$val}); - $options->{rebuild_tree}->(); - } - } - 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 || - ($event->item() && ($event->item() == $mnuItemExit))) { - quit(); - last; - } - } - } + $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()) { + print $event->item()->label() . "\n"; + # items + if ($event->item()->label() eq $mnuItemExit->label()) { + #menu File->Quit + quit(); + last; + } + } + } + } } |