Add custom renderer browser
authorPhilip Chimento <philip.chimento@gmail.com>
Thu, 21 Jul 2011 20:58:05 +0000 (22:58 +0200)
committerPhilip Chimento <philip.chimento@gmail.com>
Thu, 21 Jul 2011 20:58:05 +0000 (22:58 +0200)
player/browser.c
player/chimara.ui

index 24d9eb63f311433480a3e97b2ce7c86b9a6b3392..51dc6e7b33e0f1ce124644f543f9409c78e0f270 100644 (file)
@@ -32,6 +32,7 @@
 #include <glib-object.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <glib-object.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
 #include "browser.h"
 #include "app.h"
 #include "util.h"
 #include "browser.h"
 #include "app.h"
 #include "util.h"
@@ -79,6 +80,20 @@ chimara_browser_class_init(ChimaraBrowserClass *klass)
        g_type_class_add_private(klass, sizeof(ChimaraBrowserPrivate));
 }
 
        g_type_class_add_private(klass, sizeof(ChimaraBrowserPrivate));
 }
 
+static void
+text_function(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
+{
+       char *title, *author, *rendered_string;
+       unsigned year;
+       gtk_tree_model_get(model, iter,
+               1, &title,
+               2, &author,
+               3, &year,
+               -1);
+       rendered_string = g_strdup_printf("<big><big><b><i>%s</i></b></big>\nby %s</big> (%d)", title, author, year);
+       g_object_set(cell, "markup", rendered_string, NULL);
+}
+
 static void
 chimara_browser_init(ChimaraBrowser *self)
 {
 static void
 chimara_browser_init(ChimaraBrowser *self)
 {
@@ -116,6 +131,10 @@ chimara_browser_init(ChimaraBrowser *self)
        priv->library_model = GTK_LIST_STORE(load_object(builder, "library-model"));
        g_object_ref(priv->library_model);
 
        priv->library_model = GTK_LIST_STORE(load_object(builder, "library-model"));
        g_object_ref(priv->library_model);
 
+       GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN(load_object(builder, "library-text-column"));
+       GtkCellRenderer *renderer = GTK_CELL_RENDERER(load_object(builder, "library-text-renderer"));
+       gtk_tree_view_column_set_cell_data_func(column, renderer, (GtkTreeCellDataFunc)text_function, NULL, NULL);
+
        /* Make up some fake library data */
        GdkPixbuf *fake_cover_art = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 120, 120);
        gdk_pixbuf_fill(fake_cover_art, 0xA4000000);
        /* Make up some fake library data */
        GdkPixbuf *fake_cover_art = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 120, 120);
        gdk_pixbuf_fill(fake_cover_art, 0xA4000000);
index 1f2856c96e20daa2f132a7ac603f5dadc61a1b11..db3d886e9b9063973e53095485138ca89d1b689f 100644 (file)
@@ -304,6 +304,9 @@ Philip Chimento</property>
           <object class="GtkTreeViewColumn" id="library-text-column">
             <property name="title" translatable="yes">Text</property>
             <property name="expand">True</property>
           <object class="GtkTreeViewColumn" id="library-text-column">
             <property name="title" translatable="yes">Text</property>
             <property name="expand">True</property>
+            <child>
+              <object class="GtkCellRendererText" id="library-text-renderer"/>
+            </child>
           </object>
         </child>
         <child>
           </object>
         </child>
         <child>