Re: GtkCellRendererPixbuf question.



OK, now a different problem. I don't want the image
and text to appear in  different columns, I want them
in the same column. I tried the example in 
http://mail.gnome.org/archives/gtk-app-devel-list/2002-August/msg00334.html
In this example

Thanks and Regards
Deekshit M

--- Iago Rubio <iago rubio hispalinux es> wrote:
On Sat, 2005-03-19 at 11:33 -0800, Deekshit M wrote:
Hi all,
  I wanted to have some images on the tree nodes.
I
created my column like

GtkCellRenderer *renderer_image;

renderer_image = gtk_cell_renderer_pixbuf_new();

column = gtk_tree_view_column_new();




gtk_tree_view_column_pack_start(column,renderer_image,FALSE);
gtk_tree_view_column_add_attribute(column,
                                   renderer_image,
                                   "pixbuf",0);

How did you defined the model ?

I wanted to create root node like,

GdkPixbuf *pb;
gtk_tree_store_append (GTK_TREE_STORE (model),
&iter,
NULL);
pb = get_pixbuf("play.xpm");
gtk_tree_store_set(GTK_TREE_STORE (model),&iter,
                            0,pb,-1);

But I get like 

GLib-GObject-WARNING **: unable to set property
`pixbuf' of type `GdkPixbuf' from value of type
`gchararray'

Can anybody help me to solve the problem....

What does the function get_pixbuf returns ?

Is there any example of using images in TreeStore

  treeview = gtk_tree_view_new ();
  gtk_widget_show (treeview);
  gtk_container_add (GTK_CONTAINER (the_container),
treeview);

  text_renderer = gtk_cell_renderer_text_new();
  image_renderer = gtk_cell_renderer_pixbuf_new();

  store = gtk_tree_store_new(2, GDK_TYPE_PIXBUF,
G_TYPE_STRING);  

  image_col =
gtk_tree_view_column_new_with_attributes ("Image",
                                                    
 image_renderer,
                                                    
 "pixbuf", 0,
                                                    
  NULL);

  text_col =
gtk_tree_view_column_new_with_attributes ("Text",
                                                    
 text_renderer,
                                                    
 "text", 1,
                                                    
  NULL);

  gtk_tree_view_set_model (GTK_TREE_VIEW (treeview),

                           GTK_TREE_MODEL (store));
  gtk_tree_view_insert_column (
GTK_TREE_VIEW(treeview), image_col, 0);
  gtk_tree_view_insert_column (
GTK_TREE_VIEW(treeview), text_col, 1);

  // this is yours
  gtk_tree_store_append (GTK_TREE_STORE (store),
&iter,NULL);
  pb = get_pixbuf("play.xpm"); // does it returns a
GdkPixbuf ?
  gtk_tree_store_set(GTK_TREE_STORE (model), &iter,
0, pb,-1);


-- 
Iago Rubio
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org

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




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