Re: Text next to pixbuf in single column
- From: Chris Vine <chris cvine freeserve co uk>
- To: gtkmm-list gnome org
- Cc:
- Subject: Re: Text next to pixbuf in single column
- Date: Mon, 29 Aug 2005 11:38:54 +0100
On Monday 29 August 2005 11:37, Chris Vine wrote:
> On Saturday 27 August 2005 09:05, Igor Jovanovic wrote:
> > Hello everyone.
> >
> > I found an example how to put icons in cells, but I want my text to
> > appear in a same cell as pixbuf.
> >
> > I'm not sure how custom cellrenderers can be used for packing multiple
> > data type in a single cell of a TreeView.
> > That segfaults killing me :)
> >
> > If anyone have some example please help.
>
> You don't need a custom renderer just to display a pixbuf icon and text in
> the same tree view cell. You can pack two cell renderers (say one for a
> text model column and one for a pixbuf model column) in the same tree view
> column using gtk_tree_view_column_pack_start()/
> gtk_tree_view_column_pack_end(), and then call
> gtk_tree_view_column_add_attribute() or
> gtk_tree_view_column_set_attributes() for each of the renderers to connect
> it to their respective model columns. (Tree model columns are just data
> points.)
>
> You can do something like this:
>
> GtkTreeModel *tree_store = GTK_TREE_MODEL(gtk_tree_store_new(2,
>
> GDK_TYPE_PIXBUF, G_TYPE_STRING)); GtkTreeViewColumn *column =
> gtk_tree_view_column_new();
> gtk_tree_view_column_set_title(column, "My column");
>
> GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
> gtk_tree_view_column_pack_start(column, renderer, FALSE);
> gtk_tree_view_column_set_attributes(column, renderer,
> "pixbuf", 0,
> NULL);
>
> renderer = gtk_cell_renderer_text_new();
> gtk_tree_view_column_pack_start(column, renderer, TRUE);
> gtk_tree_view_column_set_attributes(column_p, renderer,
> "text", 1,
> NULL);
>
> GtkWidget *tree_view = gtk_tree_view_new_with_model(tree_store);
> gtk_tree_view_append_column(tree_view, column);
Sorry, I just realised this is on the gtkmm list. Do the same in gtkmm (there
is one-to-one correspondence with the GTK+ equivalent).
Chris
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]