Re: gtktreeview / multiple cell renderers



Martyn Russell wrote:

On Thu, 2005-02-10 at 14:46 +0100, Denis wrote:
Hi everybody,

Hi,

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.

Instead of using the "pixbuf" property you can use the "stock-id"
property and just specify a string - e.g. GTK_STOCK_YES.
This is what I do

What is the correct code to do that ?
Should I implement my own cell renderer ? (hopfully no...)

No.
Cool !

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'

This error basically says you have tried to associate the "text"
attribute with the pixbuf cell renderer.
The "text" attribute should be associated with the GtkCellRendererText
and the "pixbuf" or "stock-id" attribute associated with the
GtkCellRendererPixbuf.

I understand that.

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

Have a look at these posts:
http://mail.gnome.org/archives/gtk-app-devel-list/2002-
September/msg00086.html
http://mail.gnome.org/archives/gtk-app-devel-list/2003-
July/msg00301.html
They do not answer my question, let me reask it more clearly :

I implement my own GtkTreeModel.
I want to have 2 cell renderers : pixbuf (not expandable in layout) and text (expandable in layout). Each cell icon and text must be dependent on the content of the cell => I have to use a GtkTreeCellDataFunc.

So now, I understood that if I use a GtkTreeCellDataFunc, I can check in it for which cell renderer I have to put the property (I can test as the cell renderer is passed as argument).

Then my problem is to be able to add the pixbuf cell renderer as the first one and not being expandable... Indeed, the only function I see to set my GtkTreeCellDataFunc is gtk_tree_view_column_set_cell_data_func(...) AND I do not see any way to say add this renderer WITHOUT it being EXPANDABLE :-(

Thank you again,

Denis



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