Re: Proper way to show unique icon in treeview <--with code



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, Dec 17, 2006 at 11:06:14PM -0500, Tony Freeman wrote:
Hello,


[...]

void build_server_list (GtkWidget *treeview)
{
      GtkListStore *liststore;
      GtkTreeIter iter;
      GtkCellRenderer *text_renderer;
      GtkCellRenderer *icon_renderer;
      gint i = 0;
      gint count = 0;
      

      icon_renderer = gtk_cell_renderer_pixbuf_new();
      gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(treeview),
                                               0,      
                                               " ",  
                                               icon_renderer,
                                               NULL);
      
      text_renderer = gtk_cell_renderer_text_new();
      gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW(treeview),
                                               1,      
                                               " ",  
                                               text_renderer,
                                               NULL);
      
      liststore = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
      
      /* workstations */
      count = g_strv_length(workstations);
      g_object_set(icon_renderer, "stock-id", "gtk-close", NULL);
      for (i=0; i<count; i++) {
              gtk_list_store_append(liststore, &iter);
              gtk_list_store_set(liststore, &iter,
                      0, icon_renderer,
                           ^^^^^^^^^^^^^

So the icon slot of each row in the store points to the same icon
renderer. Hm. I don't have the ref ready (I'd expect an image to go
here, not a renderer), but it's no surprise that the image in each row
is equal. You'd have to put a different image in each row's image slot.

Regards
- -- tomÃs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFFhlkJBcgs9XrR2kYRAlrHAJsFB6HUMXA3GFIBLXXR8bCQwk126ACfUaxZ
MzBdhBoejyd/8bqr4nabwjU=
=Xtxq
-----END PGP SIGNATURE-----




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