[gnome-contacts] Add nicer looking entries for postal addresses



commit 4f51373bbbc1f3bb77d018e926512704b21d9f6d
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Aug 23 14:38:53 2011 +0200

    Add nicer looking entries for postal addresses

 data/gnome-contacts.css        |   15 +++++++++++++++
 src/contacts-contact-pane.vala |   24 +++++++++++++++++++++---
 2 files changed, 36 insertions(+), 3 deletions(-)
---
diff --git a/data/gnome-contacts.css b/data/gnome-contacts.css
index 4910e8c..37a468d 100644
--- a/data/gnome-contacts.css
+++ b/data/gnome-contacts.css
@@ -20,11 +20,26 @@ ContactsListPane GtkTreeView {
 .contact-entry {
     border-image: none;
     border-width: 1;
+    border-radius: 3;
     border-style: solid;
     border-color: #bbbeb7;
     background-image: none;
 }
 
+.contact-entry.contact-postal-entry {
+    border-radius: 0 0 0 0;
+    border-width: 1 1 0 1;
+}
+
+.contact-entry.contact-postal-entry:nth-child(first) {
+    border-radius: 3 3 0 0;
+}
+
+.contact-entry.contact-postal-entry:nth-child(last) {
+    border-radius: 0 0 3 3;
+    border-width: 1 1 1 1;
+}
+
 .contact-combo .button {
     border-image: none;
     border-width: 1;
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 6d20cb1..1eb23e0 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -39,6 +39,7 @@ class Contacts.DetailsLayout : Object {
   private bool expands;
   public Grid? current_row;
   Widget? last_label;
+  Box? detail_box;
 
   public void reset (bool full) {
     foreach (var w in fields_grid.get_children ()) {
@@ -83,8 +84,20 @@ class Contacts.DetailsLayout : Object {
     add_widget_label (l);
   }
 
+  public void begin_detail_box () {
+    var box = new Box (Orientation.VERTICAL, 0);
+    attach_detail (box);
+    detail_box = box;
+  }
+
+  public void end_detail_box () {
+    detail_box = null;
+  }
+
   public void attach_detail (Widget widget) {
-    if (last_label != null)
+    if (detail_box != null)
+      detail_box.add (widget);
+    else if (last_label != null)
       current_row.attach_next_to (widget, last_label, PositionType.BOTTOM, 1, 1);
     else
       current_row.add (widget);
@@ -426,6 +439,7 @@ public class Contacts.ContactPane : EventBox {
     string postal_part;
     detail.value.get (subproperty_name, out postal_part);
     var entry = layout.add_entry (postal_part);
+    entry.get_style_context ().add_class ("contact-postal-entry");
     if (placeholder_text != null)
       entry.set ("placeholder-text", placeholder_text);
 
@@ -437,7 +451,7 @@ public class Contacts.ContactPane : EventBox {
     return entry;
   }
 
-  private void add_detail_remove (Set<AbstractFieldDetails> detail_set,
+  private Button add_detail_remove (Set<AbstractFieldDetails> detail_set,
 				  AbstractFieldDetails detail,
 				  string property_name,
 				  bool at_top = true) {
@@ -449,6 +463,7 @@ public class Contacts.ContactPane : EventBox {
 	editing_persona.set (property_name, detail_set);
 	row.destroy ();
       });
+    return remove_button;
   }
 
   private void add_detail_editor (TypeSet type_set,
@@ -479,6 +494,7 @@ public class Contacts.ContactPane : EventBox {
     detail_set.add (detail);
     add_detail_combo (TypeSet.general, detail_set, detail, "postal_addresses");
 
+    layout.begin_detail_box ();
     for (int i = 0; i < props.length; i++) {
       add_detail_postal_entry (detail_set,
 			       detail,
@@ -486,7 +502,9 @@ public class Contacts.ContactPane : EventBox {
 			       "postal_addresses",
 			       nice[i]);
     }
-    add_detail_remove (detail_set, detail, "postal_addresses");
+    layout.end_detail_box ();
+    var button = add_detail_remove (detail_set, detail, "postal_addresses");
+    button.set_valign (Align.START);
   }
 
   private void update_edit_details (ContactFrame image_frame, Persona persona, bool new_contact) {



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