[gtkada] Gtk.Tree_Model_Filter API / usage

Damien Carbonne aetdcarbonne at free.fr
Mon Dec 24 15:24:44 CET 2007


Hi,

I had problems using Gtk.Tree_Model_Filter API.
The problem is with functions like:
   function Get_Model
     (Filter : access Gtk_Tree_Model_Filter_Record)
      return Gtk.Tree_Model.Gtk_Tree_Model;
   --  Returns a pointer to the child model of Filter.

In my application, I create a new filter type (e.g. Foo_Filter_Record) 
by deriving Gtk.Tree_Model_Filter_Record.
   type Foo_Filter_record is new Gtk.Tree_Model_Filter_record with ...
   type Foo_Filter is access all Foo_Filter_Record'Class;
   ...

With this context:
   Foo : Foo_Filter;
   XXX : Gtk.Tree_Model.Gtk_Tree_Model;

With Ada05 notation, I can write:
   XXX := Foo.Get_Model;

It compiles and runs as expected.

With Ada95 notation, I can not write:
   XXX := Get_Model (Foo);

I have to write:
   XXX := Get_Model (Gtk_Tree_Model_Filter_Record (Foo.all)'Access);
Which works, but is quite "heavy" to use.

Notice that with GNAT GPL 2007, when I write:
   XXX := Get_Model (Gtk_Tree_Model_Filter (Foo));
this compiles (:-(), but raises an exception at runtime, which is really 
disappointing.

Is this  problem in my way of writing things (using Ada95 notation) ?

Is this function really intended to be overridden?
Shouldn't it be written like this:
   function Get_Model
     (Filter : access Gtk_Tree_Model_Filter_Record'Class) -- Added 'Class
      return Gtk.Tree_Model.Gtk_Tree_Model;
   --  Returns a pointer to the child model of Filter.

Is there any way to know, from gtk doc/src, when a function is intended 
to be overridden or not?

Best regards (and wishes)

Damien Carbonne



More information about the gtkada mailing list