[gnome-contacts] Centralize small avatar size
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Centralize small avatar size
- Date: Fri, 20 Jan 2012 14:50:43 +0000 (UTC)
commit cbff9bac369c423112946e0649366a006b4def87
Author: Alexander Larsson <alexl redhat com>
Date: Fri Jan 20 14:35:21 2012 +0100
Centralize small avatar size
src/contacts-cell-renderer-shape.vala | 7 ++++---
src/contacts-contact.vala | 16 +++++++++-------
src/contacts-link-dialog.vala | 2 +-
src/contacts-view.vala | 2 +-
4 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/contacts-cell-renderer-shape.vala b/src/contacts-cell-renderer-shape.vala
index e86f451..f01e559 100644
--- a/src/contacts-cell-renderer-shape.vala
+++ b/src/contacts-cell-renderer-shape.vala
@@ -30,6 +30,7 @@ public class Contacts.CellRendererShape : Gtk.CellRenderer {
public bool is_phone { get; set; }
public bool show_presence { get; set; }
const int default_width = 60;
+ int renderer_height = Contact.SMALL_AVATAR_SIZE;
private struct IconShape {
string icon;
@@ -279,7 +280,7 @@ public class Contacts.CellRendererShape : Gtk.CellRenderer {
if (presence_layout != null)
Gtk.render_layout (context, cr,
cell_area.x + presence_x_offset,
- cell_area.y + presence_y_offset + 48 - 11 - presence_layout.get_baseline () / Pango.SCALE,
+ cell_area.y + presence_y_offset + renderer_height - 11 - presence_layout.get_baseline () / Pango.SCALE,
presence_layout);
cr.restore ();
@@ -302,8 +303,8 @@ public class Contacts.CellRendererShape : Gtk.CellRenderer {
int ypad;
get_padding (null, out ypad);
- minimum_height = 48 + ypad;
- natural_height = 48 + ypad;
+ minimum_height = renderer_height + ypad;
+ natural_height = renderer_height + ypad;
}
public override void get_preferred_height (Widget widget,
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index dfd6f7d..fcc4c88 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -106,6 +106,8 @@ public class Contacts.ContactPresence : Grid {
public class Contacts.Contact : GLib.Object {
+ public const int SMALL_AVATAR_SIZE = 48;
+
public Store store;
public bool is_main;
public PresenceType presence_type;
@@ -125,9 +127,9 @@ public class Contacts.Contact : GLib.Object {
public Gdk.Pixbuf small_avatar {
get {
if (_small_avatar == null) {
- var pixbuf = load_icon (individual.avatar, 48);
+ var pixbuf = load_icon (individual.avatar, SMALL_AVATAR_SIZE);
if (pixbuf == null)
- pixbuf = draw_fallback_avatar (48, this);
+ pixbuf = draw_fallback_avatar (SMALL_AVATAR_SIZE, this);
_small_avatar = frame_icon (pixbuf);
}
return _small_avatar;
@@ -947,10 +949,10 @@ public class Contacts.Contact : GLib.Object {
return Gdk.pixbuf_get_from_surface (cst, 0, 0, w, h);
}
- private static Gdk.Pixbuf? fallback_pixbuf_48;
+ private static Gdk.Pixbuf? fallback_pixbuf_default;
public static Gdk.Pixbuf draw_fallback_avatar (int size, Contact? contact) {
- if (size == 48 && fallback_pixbuf_48 != null)
- return fallback_pixbuf_48;
+ if (size == SMALL_AVATAR_SIZE && fallback_pixbuf_default != null)
+ return fallback_pixbuf_default;
Gdk.Pixbuf pixbuf = null;
try {
@@ -974,8 +976,8 @@ public class Contacts.Contact : GLib.Object {
} catch {
}
- if (size == 48)
- fallback_pixbuf_48 = pixbuf;
+ if (size == SMALL_AVATAR_SIZE)
+ fallback_pixbuf_default = pixbuf;
if (pixbuf != null)
return pixbuf;
diff --git a/src/contacts-link-dialog.vala b/src/contacts-link-dialog.vala
index 4c9e219..1d6dc00 100644
--- a/src/contacts-link-dialog.vala
+++ b/src/contacts-link-dialog.vala
@@ -42,7 +42,7 @@ public class Contacts.LinkDialog : Dialog {
if (selected_contact == null)
return;
- var image_frame = new ContactFrame (48);
+ var image_frame = new ContactFrame (Contact.SMALL_AVATAR_SIZE);
image_frame.set_image (selected_contact as AvatarDetails);
image_frame.set_hexpand (false);
persona_grid.attach (image_frame, 0, 0, 1, 2);
diff --git a/src/contacts-view.vala b/src/contacts-view.vala
index bf0df70..4d997b3 100644
--- a/src/contacts-view.vala
+++ b/src/contacts-view.vala
@@ -430,7 +430,7 @@ public class Contacts.ViewWidget : TreeView {
icon.set_padding (0, row_padding);
icon.xalign = 0.0f;
icon.yalign = 0.0f;
- icon.width = 48 + 2;
+ icon.width = Contact.SMALL_AVATAR_SIZE + 2;
column.pack_start (icon, false);
column.set_cell_data_func (icon, (column, cell, model, iter) => {
Contact contact;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]