[gnome-contacts] Don't unlink as "edit mode"



commit 693b5e9bad51d1f4e3cd852f10eed56d61602ee0
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Jan 23 17:17:11 2012 +0100

    Don't unlink as "edit mode"

 src/contacts-contact-pane.vala |   89 ++++++++++++++--------------------------
 1 files changed, 31 insertions(+), 58 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 94535a8..9f4b303 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -201,9 +201,11 @@ public class Contacts.FieldRow : Contacts.Row {
     pack (l);
   }
 
-  public Grid pack_header_in_grid (string s) {
+  public Grid pack_header_in_grid (string s, out Label label) {
     var grid = new Grid ();
+    grid.set_column_spacing (4);
     var l = new Label (s);
+    label = l;
     l.set_markup (
       "<span font='24px'>%s</span>".printf (s));
     l.set_halign (Align.START);
@@ -418,56 +420,6 @@ public abstract class Contacts.FieldSet : Grid {
   }
 }
 
-public class Contacts.TitleFieldRow : FieldRow {
-  PersonaSheet sheet;
-  Grid grid;
-
-  public TitleFieldRow (PersonaSheet sheet, string text) {
-    base (sheet.pane.row_group);
-    this.sheet = sheet;
-    set_can_focus (true);
-
-    grid = pack_header_in_grid (text);
-
-    if (!sheet.persona.store.is_primary_store ||
-	sheet.pane.contact.individual.personas.size > 1)
-      show_as_editable = true;
-  }
-
-  Button? unlink_button;
-  public override bool enter_edit_mode () {
-    if (!show_as_editable)
-      return false;
-
-    this.set_can_focus (false);
-
-    this.reset ();
-    var b = new Button.with_label("Unlink");
-    unlink_button = b;
-    b.show ();
-    grid.add (b);
-    b.set_halign (Align.END);
-    b.clicked.connect ( () => {
-	unlink_persona.begin (sheet.pane.contact, sheet.persona, (obj, result) => {
-	    unlink_persona.end (result);
-	  });
-      });
-
-    return true;
-  }
-
-  public override void lost_child_focus () {
-    if (sheet.pane.editing_row == this)
-      sheet.pane.exit_edit_mode (true);
-  }
-
-  public override void exit_edit_mode (bool save) {
-    unlink_button.destroy ();
-
-    this.set_can_focus (true);
-  }
-}
-
 public abstract class Contacts.DataFieldRow : FieldRow {
   public FieldSet field_set;
   protected Button? delete_button;
@@ -1309,21 +1261,42 @@ public class Contacts.PersonaSheet : Grid {
       Contact.persona_has_writable_property (persona, "phone-numbers") &&
       Contact.persona_has_writable_property (persona, "postal-addresses");
 
-    if (!persona.store.is_primary_store) {
-      header = new TitleFieldRow (this, Contact.format_persona_store_name_for_contact (persona));
-      this.attach (header, 0, row_nr++, 1, 1);
+    if (!persona.store.is_primary_store || row_nr > 0) {
+      header = new FieldRow (pane.row_group);
 
-      header.clicked.connect ( () => {
-	  this.pane.enter_edit_mode (header);
-	});
+      Label label;
+      var grid = header.pack_header_in_grid (Contact.format_persona_store_name_for_contact (persona), out label);
 
       if (!editable) {
 	var image = new Image.from_icon_name ("changes-prevent-symbolic", IconSize.MENU);
 
+	label.set_hexpand (false);
 	image.get_style_context ().add_class ("dim-label");
+	image.set_hexpand (true);
+	image.set_halign (Align.START);
 	image.set_valign (Align.CENTER);
-	header.left_add (image);
+	grid.add (image);
       }
+
+      if (!persona.store.is_primary_store || row_nr > 0) {
+	var b = new Button.with_label("Unlink");
+	grid.add (b);
+
+	b.clicked.connect ( () => {
+	    unlink_persona.begin (pane.contact, persona, (obj, result) => {
+		unlink_persona.end (result);
+		/* TODO: Support undo */
+		/* TODO: Ensure we don't get suggestion for this linkage again */
+	      });
+	  });
+      }
+
+      this.attach (header, 0, row_nr++, 1, 1);
+
+      header.clicked.connect ( () => {
+	  this.pane.enter_edit_mode (header);
+	});
+
     }
 
     for (int i = 0; i < field_set_types.length; i++) {



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