diff options
-rwxr-xr-x | MandrivaUpdate | 1 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | Rpmdrake/gui.pm | 17 | ||||
-rwxr-xr-x | rpmdrake | 35 | ||||
-rw-r--r-- | rpmdrake.pm | 4 |
5 files changed, 50 insertions, 9 deletions
diff --git a/MandrivaUpdate b/MandrivaUpdate index 2c77f94d..490a0c03 100755 --- a/MandrivaUpdate +++ b/MandrivaUpdate @@ -210,6 +210,7 @@ sub run_treeview_dialog { $w->{rwindow}->show_all; $w->{rwindow}->set_sensitive(0); + $filter->[0] = 'all'; # default filter: availlable updates $Rpmdrake::pkg::probe_only_for_updates = 1; # faster startup pkgs_provider({}, 'all_updates', pure_updates => 1); # default mode @@ -1,3 +1,5 @@ +- split filters (all, installed, non installed) from views (GUI, meta + packages, updates, ...) - update GUI package list Version 4.6.2 - 14 March 2008, Thierry Vignaud diff --git a/Rpmdrake/gui.pm b/Rpmdrake/gui.pm index ff24e6be..90963552 100644 --- a/Rpmdrake/gui.pm +++ b/Rpmdrake/gui.pm @@ -71,7 +71,7 @@ our @EXPORT = qw( toggle_nodes ); -our ($descriptions, @filtered_pkgs, %filter_methods, $force_displaying_group, $force_rebuild, @initial_selection, $pkgs, $size_free, $size_selected, $urpm); +our ($descriptions, %filters, @filtered_pkgs, %filter_methods, $force_displaying_group, $force_rebuild, @initial_selection, $pkgs, $size_free, $size_selected, $urpm); our %grp_columns = ( label => 0, @@ -520,10 +520,13 @@ sub pkgs_provider { my $h = &get_pkgs($options); # was given (1, @_) for updates ($urpm, $descriptions) = @$h{qw(urpm update_descr)}; $pkgs = $h->{all_pkgs}; + %filters = ( + non_installed => $h->{installable}, + installed => $h->{installed}, + all => [ keys %$pkgs ], + ); my %tmp_filter_methods = ( all => sub { @filtered_pkgs = keys %$pkgs }, - installed => sub { @filtered_pkgs = @{$h->{installed}} }, - non_installed => sub { @filtered_pkgs = @{$h->{installable}} }, all_updates => sub { @filtered_pkgs = @{$h->{updates}}; # potential "updates" from media not tagged as updates: @@ -544,7 +547,13 @@ sub pkgs_provider { }; } - %filter_methods = %tmp_filter_methods; + undef %filter_methods; + foreach my $type (keys %tmp_filter_methods) { + $filter_methods{$type} = sub { + $force_rebuild = 1; # force rebuilding tree since we changed filter (FIXME: switch to SortModel) + @filtered_pkgs = intersection($filters{$filter->[0]}, [ $tmp_filter_methods{$type}->() ]); + }; + } switch_pkg_list_mode($mode); } @@ -339,9 +339,16 @@ sub run_treeview_dialog { #$options->{state}{flat} = 1; my $is_backports = get_inactive_backport_media(fast_open_urpmi_db()); + + my %filters = (all => N("All"), + installed => N("Installed"), + non_installed => N("Not installed"), + ); + + my %rfilters = reverse %filters; + + my %modes = (all => N("All"), - installed => N("Installed"), - non_installed => N("Not installed"), if_(0, # let's keep the translated strings (to be resurected as sorting the treeview): N("All packages, alphabetical"), by_presence => N("All packages, by update availability"), @@ -377,8 +384,8 @@ sub run_treeview_dialog { my $old_value; my $cbox = gtksignal_connect( Gtk2::ComboBox->new_with_strings([ - @modes{'all', - qw(meta_pkgs gui_pkgs installed non_installed all_updates security bugfix normal), + @modes{ + qw(meta_pkgs gui_pkgs all_updates security bugfix normal), if_($is_backports, 'backports') } ], $modes{$default_mode{$MODE} || 'all'}), @@ -413,6 +420,25 @@ sub run_treeview_dialog { $options->{tree_submode} ||= $default_radio; $options->{tree_subflat} ||= $options->{state}{flat}; + + my $fbox = gtksignal_connect( + Gtk2::ComboBox->new_with_strings([ + @filters{qw(all installed non_installed)} ], $filters{$filter->[0]}), + changed => sub { + state $oldval; + my $val = $_[0]->get_text; + return if $val eq $oldval; # workarounding gtk+ sending us sometimes twice events + $oldval = $val; + $val = $rfilters{$val}; + if ($filter->[0] ne $val) { + $filter->[0] = $val; + reset_search(); + slow_func($::main_window->window, sub { switch_pkg_list_mode($default_list_mode) }); + $options->{rebuild_tree}->(); + } + } + ); + my @search_types = qw(normal descriptions summaries files); my $current_search_type = $search_types[0]; my $search_menu = Gtk2::Menu->new; @@ -547,6 +573,7 @@ sub run_treeview_dialog { 0, gtkpack_( gtknew('HBox', spacing => 10), 0, $cbox, + 0, $fbox, 1, gtkset_size_request(Gtk2::Alignment->new(0, 0, 0, 0), 100, 1), 0, gtknew('Label', text => N("Find:")), 0, $find_entry = gtknew('Sexy_IconEntry', clear_button => 1, width => 260, diff --git a/rpmdrake.pm b/rpmdrake.pm index 4f9b90cb..9be62aed 100644 --- a/rpmdrake.pm +++ b/rpmdrake.pm @@ -47,6 +47,7 @@ our $VERSION = '2.27'; our @EXPORT = qw( $already_splashed $changelog_first_config + $filter $dont_show_selections $mandrakeupdate_wanted_categories $max_info_in_descr @@ -147,7 +148,7 @@ my ($root) = grep { $_->[2] == 0 } list_passwd(); $ENV{HOME} = $> == 0 ? $root->[7] : $ENV{HOME} || '/root'; our $configfile = "$ENV{HOME}/.rpmdrake"; -our ($already_splashed, $changelog_first_config, $max_info_in_descr, $tree_flat, $tree_mode); +our ($already_splashed, $changelog_first_config, $filter, $max_info_in_descr, $tree_flat, $tree_mode); our ($mandrakeupdate_wanted_categories, $offered_to_add_sources, $no_confirmation); our %config = ( mandrakeupdate_wanted_categories => { var => \$mandrakeupdate_wanted_categories, default => [ qw(security) ] }, @@ -159,6 +160,7 @@ our %config = ( tree_flat => { var => \$tree_flat, default => [ 0 ] }, changelog_first_config => { var => \$changelog_first_config, default => [ 0 ] }, 'no-confirmation' => { var => \$no_confirmation, default => [ 0 ] }, + filter => { var => \$filter, default => [ 'all' ] }, ); sub readconf() { |