[gtkada] attribute must be discrete type

Stephen Leake stephen_leake at acm.org
Wed Sep 15 02:49:48 CEST 2004


Matthias Teege <matthias-gtkada at mteege.de> writes:

> Moin,
> 
> I use glade to create a treeview and add a signal on row_activated.
> Glade create the following callback:
> 
> procedure On_Treeview1_Row_Activated
> 	    (Object : access Gtk_Tree_View_Record'Class;
>              Params : Gtk.Arguments.Gtk_Args)
> is
>       Arg1 : Gtk_Tree_Path := Gtk_Tree_Path'Val (To_Gint (Params, 1));
>       Arg2 : Gtk_Tree_View_Column := Gtk_Tree_View_Column'Val (To_Gint (Params, 2));
> begin
>       null;
> end On_Treeview1_Row_Activated;
> 
> This code doesnt compile because of:
> 
> gnatgcc -c -g -I/usr/lib/ada/adainclude/gtkada -gnatq -gnatQ window1_pkg-callbacks.adb
> window1_pkg-callbacks.adb:69:31: prefix of "Val" attribute must be discrete type
> window1_pkg-callbacks.adb:70:38: prefix of "Val" attribute must be discrete type
> gnatmake: "window1_pkg-callbacks.adb" compilation error
> 
> What is the problem here?

As the compiler is so nicely telling you, Gtk_Tree_Path is _not_ a
discrete type, and 'Val only works for discrete types (integers and
enumerals).

Let's see what Gtk_Tree_Path is: it's declared in gtk-tree_model.ads,
derived from Glib.C_Proxy. That's declared in glib.ads, as an access
type.

What are you expecting this code to do? Apparently you are passing a
Gtk_Tree_Path as the first marshalled argument. I've never done
unmarshalling code myself, but I suspect you need an instantiation of
Unchecked_Conversion. 


-- 
-- Stephe




More information about the gtkada mailing list