summaryrefslogtreecommitdiff
path: root/src/contacts-list-pane.vala
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2011-08-16 21:43:00 +0200
committerAlexander Larsson <alexl@redhat.com>2011-08-16 21:48:37 +0200
commit7b76e5a003c3cb90d385193c41a1f7c56e332074 (patch)
tree2319a29a6c933fd9d500bf5823cecce87be21f8a /src/contacts-list-pane.vala
parent3b8584c49f0941680f79ba4dab8cda8ad856da77 (diff)
downloadgnome-contacts-7b76e5a003c3cb90d385193c41a1f7c56e332074.tar.gz
Make Contacts.CellRendererShape use a struct for shapes
This way we can extend it with more than the icon name.
Diffstat (limited to 'src/contacts-list-pane.vala')
-rw-r--r--src/contacts-list-pane.vala12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala
index f92e712..e775c84 100644
--- a/src/contacts-list-pane.vala
+++ b/src/contacts-list-pane.vala
@@ -31,6 +31,10 @@ public class Contacts.CellRendererShape : Gtk.CellRenderer {
public bool is_phone { get; set; }
public int wrap_width { get; set; default=-1;}
+ private struct IconShape {
+ string icon;
+ }
+
Gdk.Pixbuf? create_symbolic_pixbuf (Widget widget, string icon_name, int size) {
var screen = widget. get_screen ();
var icon_theme = Gtk.IconTheme.get_for_screen (screen);
@@ -78,7 +82,9 @@ public class Contacts.CellRendererShape : Gtk.CellRenderer {
str += "\xE2\x80\xA8*";
Pango.Rectangle r = { 0, -CellRendererShape.IMAGE_SIZE*1024*9/10,
CellRendererShape.IMAGE_SIZE*1024, CellRendererShape.IMAGE_SIZE*1024 };
- a = new Pango.AttrShape<string>.with_data (r, r, iconname, string.dup);
+ IconShape icon_shape = IconShape();
+ icon_shape.icon = iconname;
+ a = new Pango.AttrShape<IconShape?>.with_data (r, r, icon_shape, (s) => { return s;} );
a.start_index = str.length - 1;
a.end_index = a.start_index + 1;
attr_list.insert ((owned) a);
@@ -278,8 +284,8 @@ public class Contacts.CellRendererShape : Gtk.CellRenderer {
}
public void render_shape (Cairo.Context cr, Pango.AttrShape attr, bool do_path) {
- unowned Pango.AttrShape<string> sattr = (Pango.AttrShape<string>)attr;
- var pixbuf = create_symbolic_pixbuf (current_widget, sattr.data, IMAGE_SIZE);
+ unowned Pango.AttrShape<IconShape?> sattr = (Pango.AttrShape<IconShape?>)attr;
+ var pixbuf = create_symbolic_pixbuf (current_widget, sattr.data.icon, IMAGE_SIZE);
if (pixbuf != null) {
double x, y;
cr.get_current_point (out x, out y);