[gnome-contacts] Make Contacts.CellRendererShape use a struct for shapes
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Make Contacts.CellRendererShape use a struct for shapes
- Date: Tue, 16 Aug 2011 20:05:13 +0000 (UTC)
commit 7b76e5a003c3cb90d385193c41a1f7c56e332074
Author: Alexander Larsson <alexl redhat com>
Date: Tue Aug 16 21:43:00 2011 +0200
Make Contacts.CellRendererShape use a struct for shapes
This way we can extend it with more than the icon name.
src/contacts-list-pane.vala | 12 +++++++++---
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]