aboutsummaryrefslogtreecommitdiffstats
path: root/userdrake2
diff options
context:
space:
mode:
authorDaouda Lo <daouda@mandriva.com>2003-06-12 16:04:37 +0000
committerDaouda Lo <daouda@mandriva.com>2003-06-12 16:04:37 +0000
commit37ba8f42aaf45b1f6462077da895233456fedd34 (patch)
tree2796fbe39a4cd4ec8177dbb316bdd3a95296e7c3 /userdrake2
parent5f0c41f1cd42ca8de75e9b5af5f0107b1e77eb1c (diff)
downloaduserdrake-37ba8f42aaf45b1f6462077da895233456fedd34.tar
userdrake-37ba8f42aaf45b1f6462077da895233456fedd34.tar.gz
userdrake-37ba8f42aaf45b1f6462077da895233456fedd34.tar.bz2
userdrake-37ba8f42aaf45b1f6462077da895233456fedd34.tar.xz
userdrake-37ba8f42aaf45b1f6462077da895233456fedd34.zip
- select at first click
Diffstat (limited to 'userdrake2')
-rwxr-xr-xuserdrake247
1 files changed, 28 insertions, 19 deletions
diff --git a/userdrake2 b/userdrake2
index aaa3f50..af4d5da 100755
--- a/userdrake2
+++ b/userdrake2
@@ -457,7 +457,7 @@ sub Edit {
my $model = Gtk2::ListStore->new(Gtk2::GType->OBJECT, Gtk2::GType->STRING, Gtk2::GType->INT);
my $tree = Gtk2::TreeView->new_with_model($model); my %g; my %u; my $groupname;
my @pix = ($pixdir.'selected.png', $pixdir.'unselected.png');
- $tree->get_selection->set_mode('single');
+ $tree->get_selection->set_mode('browse');
$tree->append_column(my $check = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererPixbuf->new, 'pixbuf' => 0));
$tree->append_column(my $col = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 1));
$tree->set_headers_visible(0);
@@ -512,12 +512,12 @@ sub Edit {
1, create_scrolled_window($tree)), gtkshow(Gtk2::Label->new(N("Group Users"))));
$groupname = GetNameEntFromIter($grouptree, $gtree_model, 0); $us->{o}->{groupname}->set_text($groupname);
my $groupEnt = $ctx->LookupGroupByName($groupname);
- my $users = $ctx->UsersEnumerate(); #sort(@$users);
+ my $users = $ctx->UsersEnumerate(); my @susers = sort(@$users);
my $members = $ctx->EnumerateUsersByGroup($groupname);
- foreach my $user (@$users) {
+ foreach my $user (@susers) {
if (any { $_ eq $user } @$members) {
- $model->append_set([ 0 => gtkcreate_pixbuf($pixdir.'selected.png'), 1 => $user, 2 => 1]);
- } else { $model->append_set([ 0 => gtkcreate_pixbuf($pixdir.'unselected.png'), 1 => $user, 2 => 0]); }
+ $model->append_set([ 0 => gtkcreate_pixbuf($pix[0]), 1 => $user, 2 => 1]);
+ } else { $model->append_set([ 0 => gtkcreate_pixbuf($pix[1]), 1 => $user, 2 => 0]); }
}
}
gtkadd($w->{window},
@@ -535,15 +535,17 @@ sub Edit {
$g{groupname} = $us->{o}->{groupname}->get_text(); $error = 0;
if (!valid($g{groupname})) { raiseerror($us->{error}); $error = 1 };
if (!$error && $groupname ne $g{groupname}) {$ctx->GroupName($g{groupname})}
- my $val;
+
+ my $members = $ctx->EnumerateUsersByGroup($g->groupname);
+ my $ch; my $name;
$model->foreach(sub {
my ($mod, $path, $iter) = @_;
- my $ch = $mod->get($iter, 2);
- my $name = $mod->get($iter, 1);
- print "\n~~~$name : $ch ~~~\t";
+ $ch = $mod->get($iter, 2);
+ $name = $mod->get($iter, 1);
+
$iter->free;
- return 0,
- }, $val);
+ return 0;
+ }, undef);
}
}
!$error and Gtk2->main_quit; $error = 0; })
@@ -556,14 +558,21 @@ sub Edit {
my ($returns, $path, $column) = $tree->get_path_at_pos($_[1]->x, $_[1]->y);
print "####### $returns ########";
if ($returns) {
- if (Gtk2->equals($column, $check)) {
- $tree->get_selection->select_path($path);
- Gtk2->update_ui;
- my (undef, $iter) = $tree->get_selection->get_selected;
- my $cp = $model->get($iter, 2);
- $model->set($iter, [0 => gtkcreate_pixbuf($pix[!$cp])]);
- $model->set($iter, [2 => !$cp]);
- $iter and $iter->free;
+ my $eq = Gtk2->equals($check, $column);
+ if ($eq) {
+ my $iter = Gtk2::TreeIter->new;
+ $iter = $model->get_iter($path);
+ if ($iter) {
+ my $cp = $model->get($iter, 2);
+ if ($cp == 0) {
+ $model->set($iter, [0 => gtkcreate_pixbuf($pix[0])]);
+ $model->set($iter, [2 => 1]);
+ } elsif ($cp == 1) {
+ $model->set($iter, [0 => gtkcreate_pixbuf($pix[1])]);
+ $model->set($iter, [2 => 0]);
+ }
+ $iter->free;
+ }
}
$path->free;
}