aboutsummaryrefslogtreecommitdiffstats
path: root/modules/rpmdragora
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2015-01-05 16:22:09 +0100
committerAngelo Naselli <anaselli@linux.it>2015-01-05 16:22:09 +0100
commitfdbb4a143f0f3d19c0af78314c4aecb64eb2c3d2 (patch)
treeb2b8015dfdf552b26dc818cd5aeeec431caa0931 /modules/rpmdragora
parente48803e33612a9133e2b1080e55df4f587b31bac (diff)
downloadmanatools-fdbb4a143f0f3d19c0af78314c4aecb64eb2c3d2.tar
manatools-fdbb4a143f0f3d19c0af78314c4aecb64eb2c3d2.tar.gz
manatools-fdbb4a143f0f3d19c0af78314c4aecb64eb2c3d2.tar.bz2
manatools-fdbb4a143f0f3d19c0af78314c4aecb64eb2c3d2.tar.xz
manatools-fdbb4a143f0f3d19c0af78314c4aecb64eb2c3d2.zip
tree mode is based on YItem index now instead of localized lable
Diffstat (limited to 'modules/rpmdragora')
-rwxr-xr-xmodules/rpmdragora/rpmdragora85
1 files changed, 27 insertions, 58 deletions
diff --git a/modules/rpmdragora/rpmdragora b/modules/rpmdragora/rpmdragora
index e24b3865..9bb93206 100755
--- a/modules/rpmdragora/rpmdragora
+++ b/modules/rpmdragora/rpmdragora
@@ -73,30 +73,30 @@ my $loc = AdminPanel::rpmdragora::locale();
my %elems;
-my $old_value;
-
-sub viewbox_callback {
+sub _viewbox_callback {
my ($selection, $options, $wanted_categories) = @_;
- my $val = $selection;
- $old_value="" if(!defined($old_value));
- return if $val eq $old_value; # workarounding gtk+ sending us sometimes twice events
+ state $old_value = -1;
+
+ # TODO add a check on selection type YItem
+ my $val = $selection->index();
+ return if $val == $old_value;
yui::YUI::app()->busyCursor();
$old_value = $val;
- $default_list_mode = $options->{rviews}{$val};
+ $default_list_mode = $options->{rviews}->[$val];
# NOTE an undef value assignment produces a an array containing undef that is not a valid value to pass to
# join into writeconf()
- @$mandrakeupdate_wanted_categories = $wanted_categories->{$options->{rviews}{$val}} ?
- @{$wanted_categories->{$options->{rviews}{$val}}} :
+ @$mandrakeupdate_wanted_categories = $wanted_categories->{$options->{rviews}->[$val]} ?
+ @{$wanted_categories->{$options->{rviews}->[$val]}} :
();
if ($options->{tree_mode} ne $val) {
- $tree_mode->[0] = $options->{tree_mode} = $options->{rviews}{$val};
+ $tree_mode->[0] = $options->{tree_mode} = $options->{rviews}->[$val];
$tree_flat->[0] = $options->{state}{flat};
reset_search();
- switch_pkg_list_mode($options->{rviews}{$val});
+ switch_pkg_list_mode($options->{rviews}->[$val]);
$options->{rebuild_tree}->();
}
@@ -587,8 +587,10 @@ sub run_treeview_dialog {
bugfix => $loc->N("Bugfixes updates"),
normal => $loc->N("General updates")
);
- my %rviews = reverse %views;
- $options->{rviews} = \%rviews;
+ my @ordered_views = (qw (all meta_pkgs gui_pkgs all_updates security normal) );
+ push @ordered_views, 'backports' if $is_backports;
+
+ $options->{rviews} = \@ordered_views;
my %default_mode = (install => 'all', # we want the new GUI by default instead of "non_installed"
remove => 'installed',
@@ -602,55 +604,22 @@ sub run_treeview_dialog {
);
my $view_box = $factory->createComboBox($hbox_top,"");
- $view_box->addItem($views{all});
- $view_box->addItem($views{meta_pkgs});
- $view_box->addItem($views{gui_pkgs});
- $view_box->addItem($views{all_updates});
- $view_box->addItem($views{security});
- $view_box->addItem($views{normal});
- $view_box->addItem($views{backports}) if($is_backports);
+ my $itemColl = new yui::YItemCollection;
+
+ $DB::single = 1;
+ foreach (@ordered_views) {
+ my $item = yui::YItem->new("$views{$_}", 0);
+ $item->setSelected(1) if defined($views{$default_list_mode}) && $_ eq $default_list_mode;
+ $itemColl->push($item);
+ $item->DISOWN();
+ }
+ $view_box->addItems($itemColl);
$view_box->setNotify(1);
$view_box->selectItem($view_box->findItem($views{$default_list_mode})) if(defined($views{$default_list_mode}));
$options->{tree_submode} ||= $default_list_mode;
$options->{tree_subflat} ||= $options->{state}{flat};
-=for comment
- * OLD *
- my $filter_box = gtknew(
- 'ComboBox',
- list => [ qw(all installed non_installed) ], text => $filters{$filter->[0]},
- format => sub { $filters{$_[0]} },
- tip => $loc->N("Filter"),
- 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 $view_callback = sub {
- my ($val) = @_;
- return if $val eq $old_value; # workarounding gtk+ sending us sometimes twice events
- $old_value = $val;
- return if $mode->[0] eq $val;
- $mode->[0] = $val;
- $tree_flat->[0] = $options->{state}{flat} = member($mode->[0], qw(flat by_leaves by_selection by_size));
-
- if ($options->{tree_mode} ne $val) {
- reset_search();
- $options->{rebuild_tree}->();
- }
- };
-=cut
my $filter_box = $factory->createComboBox($hbox_top,"");
$filter_box->addItem($filters{all});
$filter_box->addItem($filters{installed});
@@ -742,7 +711,7 @@ sub run_treeview_dialog {
my $NVR_string = $loc->N("/_Options") . "/" . $loc->N("Search in _full package names");
my $regexp_search_string = $loc->N("/_Options") . "/" . $loc->N("Use _regular expressions in searches");
- my $itemColl = new yui::YItemCollection;
+ $itemColl = new yui::YItemCollection;
# build File menu
my %fileMenu = (
widget => $factory->createMenuButton($headbar,$loc->N("File")),
@@ -1176,7 +1145,7 @@ print "Menu " . $menuLabel . " chosen\n";
do_action($options, $callback_action, $info);
}
elsif ($widget == $view_box) {
- viewbox_callback($view_box->selectedItem()->label(), \%$options, \%wanted_categories);
+ _viewbox_callback($view_box->selectedItem(), \%$options, \%wanted_categories);
}
elsif ($widget == $filter_box) {
filterbox_callback($filter_box->selectedItem()->label(), \%$options, \%rfilters);