[gnome-contacts] Add generic has_child_focus tracking helper to FieldRow
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Add generic has_child_focus tracking helper to FieldRow
- Date: Mon, 19 Dec 2011 13:51:59 +0000 (UTC)
commit 6f38554599f4280e1ddaa52e231f459a737f5665
Author: Alexander Larsson <alexl redhat com>
Date: Mon Dec 19 11:26:05 2011 +0100
Add generic has_child_focus tracking helper to FieldRow
src/contacts-contact-pane.vala | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 0c458f4..1a44e41 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -23,6 +23,7 @@ using Gee;
public class Contacts.FieldRow : Contacts.Row {
Clickable clickable;
int start;
+ bool has_child_focus;
public FieldRow(RowGroup group) {
base (group);
@@ -133,6 +134,34 @@ public class Contacts.FieldRow : Contacts.Row {
return true;
}
+ public override void parent_set (Widget? old_parent) {
+ if (old_parent != null) {
+ var old_parent_container = (old_parent as Container);
+ old_parent_container.set_focus_child.disconnect (parent_set_focus_child);
+ }
+
+ var parent_container = (this.get_parent () as Container);
+ has_child_focus = parent_container != null && parent_container.get_focus_child () == this;
+ if (parent_container != null)
+ parent_container.set_focus_child.connect (parent_set_focus_child);
+ }
+
+ public virtual signal void lost_child_focus () {
+ }
+
+ public void parent_set_focus_child (Container container, Widget? widget) {
+ var old_has_child_focus = has_child_focus;
+ has_child_focus = widget == this;
+
+ if (old_has_child_focus && !has_child_focus) {
+ Idle.add(() => {
+ if (!has_child_focus)
+ lost_child_focus ();
+ return false;
+ });
+ }
+ }
+
public void pack (Widget w) {
this.attach (w, 1, start++);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]