gtktreeview / multiple cell renderers



Hi everybody,

I am trying to build a tree_view on top of a GtkTreeModel I made and I would like to see in each cell an icon of the gtk stock by giving its stock-id and a text.

Both the text and the icon must depend on the cell.
Finally, the icon should be added to the layout of the cell with the expand parameter of the ..._pack_start method set to FALSE for a correct display.

What is the correct code to do that ?
Should I implement my own cell renderer ? (hopfully no...)
I attached the code I have currently : it works partially : the pixbuf_cell_renderer is added to the layout with expand = TRUE which is not what I want and I get theses messages on the standard output : GLib-GObject-WARNING **: IA__g_object_set_property: object class `GtkCellRendererPixbuf' has no property named `text'

I looked at many examples but never found one where both the icon and the text were computed with the content of the cell :-(

Thank you by advance for your help,

Denis

PS : The code :

tree_view = gtk_tree_view_new();
gtk_tree_view_set_model(GTK_TREE_VIEW(tree_view), GTK_TREE_MODEL(file_tree_model));

  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_view),
                    FALSE);
    txt_cell_renderer = gtk_cell_renderer_text_new();
  pixbuf_cell_renderer = gtk_cell_renderer_pixbuf_new();
    gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(tree_view),
                         0,                        // Position
                         "Title",            // Title
                         pixbuf_cell_renderer,
                         filetree_model_data_func,
                         NULL,                     // data
                         NULL);                    // dnotify
    col = gtk_tree_view_get_column (GTK_TREE_VIEW(tree_view),
                  0);
  gtk_tree_view_column_clear_attributes(col,
                    pixbuf_cell_renderer);
    gtk_tree_view_column_pack_start(col, txt_cell_renderer, TRUE);
  gtk_tree_view_column_add_attribute(col,
                     txt_cell_renderer,
                     "text",
                     0);



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