[gtkada] gtkada Digest, Vol 115, Issue 1

Emmanuel Briot briot at adacore.com
Fri Aug 29 15:22:58 CEST 2014


> Hello, I'm working with a GtkTreeView widget and I want to use a
> GtkComboRender but I don't understand how to se the model and the
> values for the combo widget of each cell of the column, I've tried
> with the type Gobject but doesn't work and with Ginterfaces but the
> model the compiler said me that is an invalid type.
> 
> I'm using GPS GPL 2014 with GtkAda v3.8, so, misspellings are not a possibility.
> 
> If someone had worked with a list like this please help me, I'll be
> very gratefull with any hint.

Hello,

GPS itself uses such a construct in its "Scenarios" view. The code in the GPS sources
is in scenario_views.adb, if you want to look at them, but here is a brief summary:

The type set in the model for the column is Gtk.Tree_Model.Get_Type. For us, it is
column 2.

We then create the renderer as:

      Combo : Gtk_Cell_Renderer_Combo;

      Gtk_New (Combo);
      Col.Pack_Start (Combo, True);
      Set_Property (Combo, Text_Column_Property, 0);  --  in combo's model
      Col.Add_Attribute (Combo, "text", 1);
      Col.Add_Attribute (Combo, "model", 2);    --  the one described above
      Col.Add_Attribute (Combo, "editable", 3);  --  whether user can edit
      Set_Property (Combo, Has_Entry_Property, False);


For each row, we then call something like:

      List : Gtk_List_Store;
      Gtk_New (List, (0 => GType_String));   --  0 is same as above
      --  fill as usual

      Val : GValue;
      Init (Val, Gtk.List_Store.Get_Type);
      Set_Object (Val, List);
      Model.Set_Value (Iter, 2, Val);    --  2 is same as when we created Combo
      Unset (Val);


Hope this helps

Emmanuel       





More information about the gtkada mailing list