[gtkada] Gtk.Tree_Model.Nth_Child with Gtk.List_Store.Gtk_List_Store.

Pascal p.p14 at orange.fr
Fri Mar 11 08:43:45 CET 2016


Thanks Emmanuel for your answer.
You guess right that was exactly what I looking for.

I try to port RAPID from GTKAda 2 to GTKAda 3.
Well, "Transitioning from GtkAda 2 to GtkAda 3" from GTKAda documentation is quite useful.
But GTK 3 C examples on Internet are not so obvious to translate in GTKAda.

At present I'm stuck with conversion of Gtk_Tree_Iter in row number to implements the followings:
(The original GTK 2 was based on Gtk.List.Gtk_List and Gtk.Widget.Widget_List.Glist see http://svn.savannah.gnu.org/viewvc/trunk/gtk_peer/peer-gtk_list.adb?root=rapid&view=markup)
   ------------------------------------------------
   -- function Count
   -- get number of items in Gtk.Tree_View.Gtk_Tree_View
   ------------------------------------------------
   function Count (Obj : in Gtk.Tree_View.Gtk_Tree_View) return Natural;
   ------------------------------------------------
   -- procedure Select_Item
   -- Select number item in Gtk.Tree_View.Gtk_Tree_View
   -- Use 0 to select nothing.
   ------------------------------------------------
   procedure Select_Item (Obj : in Gtk.Tree_View.Gtk_Tree_View; Number : in Natural);
   ------------------------------------------------
   -- function Get_Selected
   -- return number of selected item, or 0 if
   -- nothing selected
   ------------------------------------------------
   function Get_Selected (Obj : in Gtk.Tree_View.Gtk_Tree_View) return Natural;

Any tips would be appreciated.

Thanks, Pascal.
http://blady.pagesperso-orange.fr


> Le 10 mars 2016 à 10:22, Emmanuel Briot <briot at adacore.com> a écrit :
> 
>> I want to do the same with GTKAda:
>>     function Remove (Store   : in Gtk.List_Store.Gtk_List_Store;
>>     N : in Natural) is
>>     Iter : Gtk.Tree_Model.Gtk_Tree_Iter := Gtk.Tree_Model.Nth_Child (Gtk.Tree_Model.Gtk_Tree_Model(Store), Gtk.Tree_Model.Null_Iter, Glib.Gint(N));
>> ...
>> 
>> But GNAT complains:
>> invalid conversion, not compatible with type "Gtk_List_Store" defined at gtk-list_store.ads:173
> 
> 
> Would help if you could quote the code correctly, this is really hard to read.
> 
> I assume the issue is
> 
>      Store : Gtk_List_Store;
>      Gtk_Tree_Model (Store)
> 
> and indeed these two types are not compatible (A Gtk_Tree_Model is a gtk+ interface, which is
> not mapped to an Ada interface for various reasons).
> 
> If you look at gtk-list_store.ads, there is a section named "Interfaces", which provides a "+"
> iterator to do the conversion.
> 
> So you can simply use
> 
>    +Store
> 
> to get a Gtk_Tree_Model
> 
> Emmanuel



More information about the gtkada mailing list