Gtk.Tree_Model_Filter API / usage

View: New views
2 Messages — Rating Filter:   Alert me  

Gtk.Tree_Model_Filter API / usage

by Damien Carbonne :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
_______________________________________________
gtkada mailing list
gtkada@...
http://lists.adacore.com/mailman/listinfo/gtkada

Re: Gtk.Tree_Model_Filter API / usage

by Dmitry A. Kazakov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 24 Dec 2007 15:24:44 +0100, you wrote:

> 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.

Hmm,

   Get_Model (Foo)

should work with Ada 95.

> 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) ?

No, I guess it is probably a problem with accessibility checks failing at
run time.

> 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?

Well, when it is declared abstract. (:-))

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
_______________________________________________
gtkada mailing list
gtkada@...
http://lists.adacore.com/mailman/listinfo/gtkada
LightInTheBox - Buy quality products at wholesale price