[tracker/gtk3: 5/7] tracker-needle: Make the taglist use Gtk.CellRendererText



commit 7a1061bd7b8cd0f4d2b5176aba3a22c86f32872f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Apr 27 12:43:12 2011 +0200

    tracker-needle: Make the taglist use Gtk.CellRendererText

 src/tracker-needle/tracker-taglist.vala |   26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)
---
diff --git a/src/tracker-needle/tracker-taglist.vala b/src/tracker-needle/tracker-taglist.vala
index c690c2c..57a7823 100644
--- a/src/tracker-needle/tracker-taglist.vala
+++ b/src/tracker-needle/tracker-taglist.vala
@@ -59,10 +59,9 @@ public class Tracker.TagList : ScrolledWindow {
 //		col.pack_start (renderer, false);
 //		col.add_attribute (renderer, "active", 0);
 
-		renderer = new Tracker.CellRendererText ();
+		renderer = new CellRendererText ();
 		col.pack_start (renderer, true);
-		col.add_attribute (renderer, "text", 1);
-		col.add_attribute (renderer, "subtext", 2);
+		col.set_cell_data_func (renderer, text_renderer_func);
 
 		renderer = new CellRendererText ();
 		renderer.xpad = 5;
@@ -85,6 +84,27 @@ public class Tracker.TagList : ScrolledWindow {
 		get_tags.begin ();
 	}
 
+	private void text_renderer_func (CellLayout   cell_layout,
+	                                 CellRenderer cell,
+	                                 TreeModel    tree_model,
+	                                 TreeIter     iter) {
+		string text, subtext;
+		string markup = null;
+		int n_children;
+
+		tree_model.get (iter, 1, out text, 2, out subtext, -1);
+
+		if (text != null) {
+			markup = Markup.escape_text (text);
+
+			if (subtext != null) {
+				markup += "\n<small><span color='grey'>%s</span></small>".printf (Markup.escape_text (subtext));
+			}
+		}
+
+		cell.set ("markup", markup);
+	}
+
 	private async void get_tags () {
 		string query = @"
 		               SELECT 



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