From a849af24f5a5bf900cdd0e11ed327de1a6c43bf4 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Sat, 23 Aug 2003 22:11:20 +0000 Subject: - disable up button when selected rule is the first one - disable down button when selected rule is the latest one or when next rule is non editable --- perl-install/standalone/drakperm | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'perl-install/standalone') diff --git a/perl-install/standalone/drakperm b/perl-install/standalone/drakperm index 06121b7f1..ab7324504 100755 --- a/perl-install/standalone/drakperm +++ b/perl-install/standalone/drakperm @@ -80,11 +80,14 @@ sub move_callback { return if !$iter2 || $model->get($iter2, 0); $model->swap($iter, $iter2); $modified = 1; + hide_up_button_iffirst_item($path); + hide_down_button_iflast_item($path); $permList->get_selection->select_iter($iter); $permList->queue_draw; } my $combo_sig = $combo_perm->entry->signal_connect(changed => sub { display_perm($rev_perm_l10n{$combo_perm->entry->get_text} , @_) }); + $permList->signal_connect(button_press_event => sub { return unless $editable; my (undef, $event) = @_; @@ -133,13 +136,32 @@ $combo_perm->entry->set_text($perm_l10n{$default_perm_level}); $permList->get_selection->signal_connect('changed' => sub { my ($select) = @_; my (undef, $iter) = $select->get_selected; - sensitive_buttons($iter ? $editable && !$treeModel->get($iter, 0) : 0); + return if !$iter; + my $locked = $treeModel->get($iter, 0); + sensitive_buttons($iter ? $editable && !$locked : 0); + return if $locked; + my $curr_path = $treeModel->get_path($iter); + hide_up_button_iffirst_item($curr_path); + hide_down_button_iflast_item($curr_path); }); $w->main; ugtk2->exit; +sub hide_up_button_iffirst_item { + my ($curr_path) = @_; + my $first_path = $treeModel->get_path($treeModel->get_iter_first); + $buttons[0]->set_sensitive($first_path && $first_path->compare($curr_path)); +} + +sub hide_down_button_iflast_item { + my ($curr_path) = @_; + $curr_path->next; + my $next_item = $treeModel->get_iter($curr_path); + $buttons[1]->set_sensitive($next_item && !$treeModel->get($next_item, 0)); +} + sub check_save() { $modified or return 0; my $sav_ = $in->ask_okcancel('Warning', 'your changed will be lost do you wish to continue?'); -- cgit v1.2.1