summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-03-04 12:49:34 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-03-04 12:49:34 +0000
commit7956955445d0172847070d10cb91323202d72e5f (patch)
tree8dd3ea7c08de6e35eb8cf3c79409bcec20ac7e17 /perl-install
parent5701d5e0c8f2a8f74a9a764554c2cad49249b0c3 (diff)
downloaddrakx-backup-do-not-use-7956955445d0172847070d10cb91323202d72e5f.tar
drakx-backup-do-not-use-7956955445d0172847070d10cb91323202d72e5f.tar.gz
drakx-backup-do-not-use-7956955445d0172847070d10cb91323202d72e5f.tar.bz2
drakx-backup-do-not-use-7956955445d0172847070d10cb91323202d72e5f.tar.xz
drakx-backup-do-not-use-7956955445d0172847070d10cb91323202d72e5f.zip
- fix #1776 (part one): make up and down button be usefull instead of
nop (this need an updated perl-GTK2 though) - let up, down, delete and edit buttons be insensitive when selection is destroyed or when there's no selection
Diffstat (limited to 'perl-install')
-rwxr-xr-xperl-install/standalone/drakperm56
1 files changed, 43 insertions, 13 deletions
diff --git a/perl-install/standalone/drakperm b/perl-install/standalone/drakperm
index c032243b4..d601900ca 100755
--- a/perl-install/standalone/drakperm
+++ b/perl-install/standalone/drakperm
@@ -67,28 +67,43 @@ sub edit_callback {
row_setting_dialog($iter);
}
+my @buttons;
+
sub del_callback {
my ($tree, $iter) = $permList->get_selection->get_selected();
$tree->remove($iter);
+ sensitive_buttons(0);
$modified++;
}
sub down_callback {
- #- broken
- # my $row = ${$CURENT{clicked}}{row};
- # $permList->row_move($row, $row+1);
- # $permList->unselect_all;
- # $permList->select_row($row+1,0);
- # $CURENT{clicked}{row} = $row+1;
+ my ($model, $iter) = $permList->get_selection->get_selected;
+ return unless $iter;
+ my $new_iter = $model->iter_next($iter);
+ return unless $new_iter;
+ $model->move_after($iter, $new_iter);
+ $model->move_after($iter, $new_iter);
+ $permList->get_selection->select_iter($iter);
+ $permList->queue_draw;
+ $new_iter->free;
+ $iter->free;
}
sub up_callback {
- #- broken
- # my $row = ${$CURENT{clicked}}{row};
- # $permList->row_move($row, $row-1);
- # $permList->unselect_all;
- # $permList->select_row($row-1,0);
- # $CURENT{clicked}{row} = $row-1;
+ my ($model, $iter) = $permList->get_selection->get_selected;
+ return unless $iter;
+ my $path = $model->get_path($iter);
+ return unless $path;
+ $path->prev;
+ my $prev_iter = $model->get_iter($path);
+ $path->free;
+ return unless $prev_iter;
+ $model->move_before($iter, $prev_iter);
+ $model->move_before($iter, $prev_iter);
+ $permList->get_selection->select_iter($iter);
+ $permList->queue_draw;
+ $prev_iter->free;
+ $iter->free;
}
my $combo_sig = $combo_perm->entry->signal_connect( changed => sub { display_perm($combo_perm->entry->get_text , @_) });
@@ -110,7 +125,7 @@ $W->add(gtkpack_(Gtk2::VBox->new(0,5),
$combo_perm
),
1, create_scrolled_window($permList),
- 0, my $up_down_box = gtkadd(Gtk2::HBox->new(0, 5),
+ 0, my $up_down_box = gtkadd(Gtk2::HBox->new(0, 5), @buttons =
map {
gtkset_tip($tips,
gtksignal_connect(Gtk2::Button->new($_->[0]), clicked => $_->[2]),
@@ -134,6 +149,14 @@ $w->{rwindow}->set_position('center') unless $::isEmbedded;
display_perm($default_perm_level);
$combo_perm->entry->set_text($default_perm_level);
+$permList->get_selection()->signal_connect('changed' => sub {
+ my ($select) = @_;
+ my ($model, $iter) = $select->get_selected();
+ my $editable = $editable;
+ $editable = 0 unless $model;
+ sensitive_buttons($editable);
+ });
+
$w->main;
ugtk2->exit;
@@ -173,6 +196,7 @@ sub display_perm {
}
close F;
$up_down_box->set_sensitive($editable);
+ sensitive_buttons(0) if $editable;
$prec_txt = $perm_level;
undef(%CURENT);
@@ -369,3 +393,9 @@ sub get_right {
$right - 1 >= 0 and $rght{execute}=1 and $right = $right-1;
return %rght;
}
+
+sub sensitive_buttons {
+ foreach my $i (0, 1, 3, 4) {
+ $buttons[$i]->set_sensitive($_[0]);
+ }
+}