aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaouda Lo <daouda@mandriva.com>2004-05-26 12:16:58 +0000
committerDaouda Lo <daouda@mandriva.com>2004-05-26 12:16:58 +0000
commit2e3a939c9c5a6e8bf1ad876edfdb532f7190d85d (patch)
tree7e6b832e59acf7d8a4a093fa535d71f83353d98e
parent29bc78c9942083e4b2939befccb023d177795ba3 (diff)
downloaduserdrake-2e3a939c9c5a6e8bf1ad876edfdb532f7190d85d.tar
userdrake-2e3a939c9c5a6e8bf1ad876edfdb532f7190d85d.tar.gz
userdrake-2e3a939c9c5a6e8bf1ad876edfdb532f7190d85d.tar.bz2
userdrake-2e3a939c9c5a6e8bf1ad876edfdb532f7190d85d.tar.xz
userdrake-2e3a939c9c5a6e8bf1ad876edfdb532f7190d85d.zip
- right mouse click on Treeview to access menu (feature)
- don't allow more than 16 char to be consistent with groupadd (tvignaud)
-rwxr-xr-xuserdrake19
1 files changed, 18 insertions, 1 deletions
diff --git a/userdrake b/userdrake
index e450c99..ff01bff 100755
--- a/userdrake
+++ b/userdrake
@@ -587,13 +587,30 @@ sub CreateTree {
$tree->set_headers_visible(1);
$tree->set_rules_hint(1);
$tree->get_selection->signal_connect('changed' => sub { foreach ($tbedit, $tbdel, $buttorcheck{edit}, $buttorcheck{delete}) { $_->set_sensitive(1) } });
+ my $menu_treeview = Gtk2::Menu->new;
+ my @menu_treeview_actions = ([ 'edit', N("Edit") ], [ 'delete', N("Delete") ]);
+ foreach (@menu_treeview_actions) {
+ my ($action, $text) = @$_;
+ my %actions; %actions = (
+ edit => sub {
+ my (undef, $iter) = $tree->get_selection->get_selected;
+ $iter and Edit()
+ },
+ delete => sub {
+ my (undef, $iter) = $tree->get_selection->get_selected;
+ $iter and Delete();
+ }
+ );
+ $menu_treeview->append(gtksignal_connect(gtkshow(Gtk2::MenuItem->new_with_label($text)), activate => sub { $actions{$action}->() }));
+ }
$tree->signal_connect(button_press_event => sub {
my (undef, $event) = @_;
my (undef, $iter) = $tree->get_selection->get_selected;
return unless $iter;
foreach ($tbedit, $tbdel, $buttorcheck{edit}, $buttorcheck{delete}) { $_->set_sensitive(1) };
Edit() if $event->type eq '2button-press';
- });
+ $_[1]->button == 3 and $menu_treeview->popup(undef, undef, undef, undef, $_[1]->button, $_[1]->time)
+ });
$tree->signal_connect(key_press_event => sub {
my (undef, $event) = @_;
my (undef, $iter) = $tree->get_selection->get_selected;