[gtkada] How to set the pixbuf attribute of a gtk_cell_renderer_pixbuf

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Sun Aug 24 14:45:10 CEST 2008


On Sun, 24 Aug 2008 12:36:12 +0200, you wrote:

> How do you set the pixbuf property of a Gtk_Cell_Renderer_Pixbuf ?
> The property type is a Glib.Properties.Property_Object, but a Pixbuf is 
> derived from Glib.C_Proxy.
> 
> So, the compiler won't accept a call to Glib.Properties.Set_Attribute 
> with a Pixbuf as parameter, and there are no type conversions that make 
> sense

Hmm, Set_Property or Add_Attribute? There is no Set_Attribute.

What are you going to achieve? Normally, you create a renderer, pack it
into a column and then add an attribute to bind the column, the renderer
and a model column containing the image or its name together. Sort of:

   declare
      Column_No : GInt;
      Column    : Gtk_Tree_View_Column;
      Icon      : Gtk_Cell_Renderer_Pixbuf;
   begin
       -- The first visible column will be an image of the model's column 0
      Gtk_New (Column);
      Set_Title (Column, "Icon");
      Gtk_New (Icon);
      Pack_Start (Column, Icon, True);
      Add_Attribute (Column, Icon, "pixbuf", 0);
      Column_No := Append_Column (Tree_View, Column);
      ...

Usually you never need to set this property manually. It is the job of the
tree view widget. It will permanently reset this property when it needs to
render the column. So it makes little or no sense to set or query it.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



More information about the gtkada mailing list