[gnome-contacts] Make persona buttons look like mockup in edit mode



commit 59815202323a42fc0f51edaa54de121ff801a638
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Aug 23 13:34:01 2011 +0200

    Make persona buttons look like mockup in edit mode

 data/gnome-contacts.css        |    7 +--
 src/contacts-contact-pane.vala |   91 +++++++++++++++++++++++++---------------
 2 files changed, 60 insertions(+), 38 deletions(-)
---
diff --git a/data/gnome-contacts.css b/data/gnome-contacts.css
index a688b4c..7d119f4 100644
--- a/data/gnome-contacts.css
+++ b/data/gnome-contacts.css
@@ -18,11 +18,10 @@ ContactsListPane GtkTreeView {
 }
 
 .contact-button {
-    border-color: #bbbeb7;
     border-image: none;
-    border-style: solid;
-    border-radius: 1;
-    border-width: 1;
+    border-width: 0;
+    border-style: none;
+    -adwaita-focus-border-radius: 8;
     padding: 0;
     background-color: #ffffff;
     background-image: none;
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index c3c198e..d5724f5 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -261,6 +261,60 @@ public class Contacts.ContactFrame : Frame {
   }
 }
 
+public class Contacts.PersonaButton : RadioButton {
+  private Widget create_image (AvatarDetails? details, int size) {
+    var image = new Image ();
+    image.set_padding (2, 2);
+
+    Gdk.Pixbuf pixbuf = null;
+    if (details != null &&
+	details.avatar != null) {
+      try {
+	var stream = details.avatar.load (size, null);
+	pixbuf = new Gdk.Pixbuf.from_stream_at_scale (stream, size, size, true);
+      }
+      catch {
+      }
+    }
+
+    if (pixbuf == null) {
+      pixbuf = Contact.draw_fallback_avatar (size, null);
+    }
+
+    if (pixbuf != null) {
+      image.set_from_pixbuf (Contact.frame_icon (pixbuf));
+    }
+
+    image.draw.connect ( (cr) => {
+	if (this.get_active ()) {
+	  cr.save ();
+	  cr.set_source_rgba (0x74/255.0, 0xa0/255.0, 0xd0/255.0, 0.5);
+	  Utils.cairo_rounded_box (cr, 0, 0, size+4, size+4, 4+2);
+	  Utils.cairo_rounded_box (cr, 2, 2, size, size, 4);
+	  cr.set_fill_rule (Cairo.FillRule.EVEN_ODD);
+	  cr.fill ();
+	  cr.restore ();
+	}
+	return false;
+      });
+
+    return image;
+  }
+
+
+  public PersonaButton (RadioButton? group, AvatarDetails? avatar, int size) {
+    if (group != null)
+      join_group (group);
+
+    get_style_context ().add_class ("contact-button");
+    set_can_default (false);
+    var image = create_image (avatar, size);
+    add (image);
+    set_mode (false);
+  }
+}
+
+
 public class Contacts.ContactPane : EventBox {
   private enum DisplayMode {
     INITIAL,
@@ -290,32 +344,6 @@ public class Contacts.ContactPane : EventBox {
 
   private signal void save_data ();
 
-  private Widget create_image (AvatarDetails? details, Contact? contact, int size) {
-    var image = new Image ();
-    image.set_size_request (size, size);
-
-    Gdk.Pixbuf pixbuf = null;
-    if (details != null &&
-	details.avatar != null) {
-      try {
-        var stream = details.avatar.load (size, null);
-        pixbuf = new Gdk.Pixbuf.from_stream_at_scale (stream, size, size, true);
-      }
-      catch {
-      }
-    }
-
-    if (pixbuf == null) {
-      pixbuf = Contact.draw_fallback_avatar (size, contact);
-    }
-
-    if (pixbuf != null) {
-      image.set_from_pixbuf (pixbuf);
-    }
-
-    return image;
-  }
-
   private void update_edit_detail_type (Set<AbstractFieldDetails> detail_set,
 					AbstractFieldDetails detail,
 					TypeCombo combo,
@@ -799,20 +827,15 @@ public class Contacts.ContactPane : EventBox {
       });
 
     var personas = new Grid ();
-    personas.set_row_spacing (4);
+    personas.set_row_spacing (0);
     personas.set_halign (Align.START);
     personas.set_valign (Align.END);
     personas.set_vexpand (true);
 
-    RadioButton button = null;
+    PersonaButton button = null;
     foreach (var p in contact.individual.personas) {
 
-      button = new RadioButton.from_widget (button);
-      button.get_style_context ().add_class ("contact-button");
-      button.set_can_default (false);
-      var image = create_image (p as AvatarDetails, null, 48);
-      button.add (image);
-      button.set_mode (false);
+      button = new PersonaButton (button, p as AvatarDetails, 48);
       personas.add (button);
 
       if (p == persona) {



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