[egg-list-box] add option to activate on double click
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [egg-list-box] add option to activate on double click
- Date: Fri, 1 Jun 2012 10:18:23 +0000 (UTC)
commit 6b6963465e576012015eb70198599ad5aea81519
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Fri Jun 1 11:28:57 2012 +0200
add option to activate on double click
egg-list-box.vala | 15 ++++++++++++++-
1 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/egg-list-box.vala b/egg-list-box.vala
index 5f61247..c7f03ba 100644
--- a/egg-list-box.vala
+++ b/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);
@@ -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) {
@@ -428,6 +434,10 @@ public class Egg.ListBox : Container {
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 ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]