[gnome-contacts/new-design] Track for focus outside editing row => exit editing



commit 554dd144fd272475f448ea04567ea9deb80799fd
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Dec 14 00:40:38 2011 +0100

    Track for focus outside editing row => exit editing

 src/contacts-contact-pane.vala |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 4220bd5..869544d 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -666,6 +666,7 @@ public abstract class Contacts.FieldSet : Grid {
 
 public abstract class Contacts.DataFieldRow : FieldRow {
   public FieldSet field_set;
+  ulong set_focus_child_id;
 
   public DataFieldRow (FieldSet field_set) {
     base (field_set.sheet.pane.row_group);
@@ -697,9 +698,25 @@ public abstract class Contacts.DataFieldRow : FieldRow {
       if (!w.get_data<bool> ("original-widget"))
 	w.show_all ();
     }
+
+    var parent_container = (this.get_parent () as Container);
+    var pane = field_set.sheet.pane;
+    var row = this;
+    set_focus_child_id = parent_container.set_focus_child.connect ( (widget) => {
+	if (parent_container.get_focus_child () != row) {
+	  Idle.add(() => {
+	      if (pane.editing_row == row)
+		pane.exit_edit_mode (true);
+	      return false;
+	    });
+	}
+      });
   }
 
   public void exit_edit_mode (bool save) {
+    var parent_container = (this.get_parent () as Container);
+    parent_container.disconnect (set_focus_child_id);
+
     var changed = finish_edit_widgets (save);
 
     foreach (var w in this.get_children ()) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]