summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2012-06-04 13:41:54 +0200
committerAlexander Larsson <alexl@redhat.com>2012-06-04 13:41:54 +0200
commit02af984feb0ea943b923a083649a8e43b995596f (patch)
treeb04c775c29ec7acf62d75dee1b967ca96320c66e /src
parent5eda582b89dd05db42cf4237e3c137fc3030a7ab (diff)
parent6b6963465e576012015eb70198599ad5aea81519 (diff)
downloadgnome-contacts-02af984feb0ea943b923a083649a8e43b995596f.tar.gz
Import latest listbox '6b6963465e576012015eb70198599ad5aea81519'
Diffstat (limited to 'src')
-rw-r--r--src/listbox/egg-list-box.vala43
1 files changed, 35 insertions, 8 deletions
diff --git a/src/listbox/egg-list-box.vala b/src/listbox/egg-list-box.vala
index 9506597..c7f03ba 100644
--- a/src/listbox/egg-list-box.vala
+++ b/src/listbox/egg-list-box.vala
@@ -47,6 +47,7 @@ public class Egg.ListBox : Container {
private unowned ChildInfo active_child;
private SelectionMode selection_mode;
private Adjustment? adjustment;
+ private bool activate_single_click;
construct {
set_can_focus (true);
@@ -54,6 +55,7 @@ public class Egg.ListBox : Container {
set_redraw_on_allocate (true);
selection_mode = SelectionMode.SINGLE;
+ activate_single_click = true;
children = new Sequence<ChildInfo>();
child_hash = new HashTable<unowned Widget, unowned ChildInfo> (GLib.direct_hash, GLib.direct_equal);
@@ -139,7 +141,7 @@ public class Egg.ListBox : Container {
if (info == null)
return;
- var prev_next = get_previous_visible (info.iter);
+ var prev_next = get_next_visible (info.iter);
if (sort_func != null) {
children.sort_changed (info.iter, do_sort);
@@ -154,6 +156,10 @@ public class Egg.ListBox : Container {
}
+ public void set_activate_on_single_click (bool single) {
+ activate_single_click = single;
+ }
+
/****** Implementation ***********/
private int do_sort (ChildInfo a, ChildInfo b) {
@@ -425,9 +431,13 @@ public class Egg.ListBox : Container {
if (event.button == 1) {
unowned ChildInfo? child = find_child_at_y ((int)event.y);
if (child != null) {
- active_child = child;
- active_child_active = true;
- queue_draw ();
+ active_child = child;
+ active_child_active = true;
+ queue_draw ();
+
+ if (event.type == Gdk.EventType.2BUTTON_PRESS &&
+ !activate_single_click && child.widget != null)
+ child_activated (child.widget);
}
/* TODO: Should mark as active while down, and handle grab breaks */
@@ -438,7 +448,10 @@ public class Egg.ListBox : Container {
public override bool button_release_event (Gdk.EventButton event) {
if (event.button == 1) {
if (active_child != null && active_child_active)
- select_and_activate (active_child);
+ if (activate_single_click)
+ select_and_activate (active_child);
+ else
+ update_selected (active_child);
active_child = null;
active_child_active = false;
queue_draw ();
@@ -784,16 +797,28 @@ public class Egg.ListBox : Container {
apply_filter (widget);
if (this.get_visible ()) {
- var prev_next = get_next_visible (iter);
update_separator (iter);
update_separator (get_next_visible (iter));
- update_separator (prev_next);
+ }
+
+ widget.notify["visible"].connect (child_visibility_changed);
+ }
+
+ private void child_visibility_changed (Object object, ParamSpec pspec) {
+ if (this.get_visible ()) {
+ unowned ChildInfo? info = lookup_info (object as Widget);
+ if (info != null) {
+ update_separator (info.iter);
+ update_separator (get_next_visible (info.iter));
+ }
}
}
public override void remove (Widget widget) {
bool was_visible = widget.get_visible ();
+ widget.notify["visible"].disconnect (child_visibility_changed);
+
unowned ChildInfo? info = lookup_info (widget);
if (info == null) {
info = separator_hash.get (widget);
@@ -840,8 +865,10 @@ public class Egg.ListBox : Container {
public override void forall_internal (bool include_internals,
Gtk.Callback callback) {
- for (var iter = children.get_begin_iter (); !iter.is_end (); iter = iter.next ()) {
+ var iter = children.get_begin_iter ();
+ while (!iter.is_end ()) {
unowned ChildInfo child_info = iter.get ();
+ iter = iter.next();
if (child_info.separator != null && include_internals)
callback (child_info.separator);
callback (child_info.widget);