xinlin hou
xinlin hou

Reputation: 11

gtk_tree_view_new How to display two icons within a new cell

enter image description here

I want to display the following effect, but I don't know what to do

Upvotes: 0

Views: 70

Answers (2)

Joel
Joel

Reputation: 2035

As @Brad Lanam wrote, you need to use gtk_cell_renderer_pixbuf_new to tell the column that you will display an image. Read the tutorial provide it to you about GtkTreeView, and try this:

  1. Make sure that your gtk_list_store uses GDK_TYPE_PIXBUF, for example: GtkListStore *store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF);
  2. Use gtk_cell_renderer_pixbuf_new, for example: GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new ();
  3. Add it to the GtkTreeView via GtkTreeViewColumn, for example: gtk_tree_view_insert_column_with_attributes (tv, -1, "column title", renderer, 0, "pixbuf", NULL); // 0: liststore position of the first pixbuf
  4. Set the pixbuf to the store, for example: GdkPixbuf * pixbuf = some_pixbuf_new (); gtk_list_store_set (model, &iter, 0, pixbuf, -1); This should give you on idea about your goal.

Upvotes: 0

Brad Lanam
Brad Lanam

Reputation: 5763

Initialize the renderer as a pixbuf.

renderer = gtk_cell_renderer_pixbuf_new ();

And add an attribute for that column as "pixbuf".

gtk_tree_view_column_add_attribute (column, renderer, "pixbuf", colnum);

When setting the value in the storage, pass in a pixbuf argument.

Hope these bits of information point you in the right direction.

Upvotes: 0

Related Questions