Re: Icon in a GtkTreeView




 
--- Neil Hodge <neh attbi com> wrote:
All:

I am trying to use an xpm file in a column by itself as an icon in a
GtkTreeView.  Does anyone have any hints or code on how to do this? 
Thanks.

Neil


_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


  Use :
store = gtk_list_store_new(NUM_COLUMNS,
                                GDK_TYPE_PIXBUF , ./* the the other columns
*/);

to build the model.

  Use the code to build the GtkTreeStore:

         renderer = gtk_cell_renderer_pixbuf_new();
        column = gtk_tree_view_column_new();
        gtk_tree_view_column_set_title(column, "   ");
        gtk_tree_view_column_pack_start (column,renderer, TRUE);
        gtk_tree_view_column_set_cell_data_func (column, renderer, set_pixbuf,
NULL, NULL);


  Where set_pixbuf is your defined function to be called when setting the
pixbuff.

static void set_pixbuf (GtkTreeViewColumn *tree_column,
                                GtkCellRenderer   *cell,
                                GtkTreeModel      *model,
                                GtkTreeIter       *iter,
                                gpointer           data)
{
    GdkPixbuf* icon_to_show = NULL;
    gtk_tree_model_get (model, iter, IDEX_COL_OF_PIXBUF, &icon_to_show, -1);
        g_object_set (GTK_CELL_RENDERER (cell),
                                        "pixbuf", icon_to_show, NULL);
}


 Hope this helps.


Harring.


   

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



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