[gtkada] Need help overloading Show_All

Preben Randhol randhol at pvv.org
Mon May 13 18:28:19 CEST 2002


Hi

I'm trying to overload the Show_All routine, but I have problems with
it. 

What I have:

I'm making a collection of easy to use, customisable dialogs for Ada and
GtkAda. I have defined :


package Common_Dialog is

   type Base_Dialog_Record is abstract new
      Gtk.Dialog.Gtk_Dialog_Record with private;

   type Base_Dialog_Access is access all Base_Dialog_Record'Class;

   procedure Add_Button
      (Dialog  : access Base_Dialog_Record'Class;
       Button  : access Gtk.Button.Gtk_Button_Record'Class);

   procedure Show_All
      (Dialog : access Base_Dialog_Record'Class);

[...]

The body of the Show_All looks like:

   procedure Show_All
      (Dialog : access Base_Dialog_Record'Class)
   is
   begin
      Gtk.Widget.Show_All (Gtk_Widget (Dialog));
      Gtk.Main.Main;
   end Show_All;

So you see why I want to overload, because I need to do a Gtk.Main.Main
as the buttons the user add will get an extra callback with
Gtk.Main.Main_Quit and it the wrong Show_All is called the whole program
will exit.

I have then defined this child package for some plain dialogs:

package Common_Dialog.Plain is

   type Plain_Dialog_Record is new Base_Dialog_Record with private;

   type Plain_Dialog_Access is access all Plain_Dialog_Record'Class;

   procedure Gtk_New (Dialog :    out Plain_Dialog_Access;
                      Title  : in     String := "";
                      Widget : access Gtk.Widget.Gtk_Widget_Record'Class);

[...]


If I now call:

   Show_All (Some_Plain_Dialog);

I will call the Show_All defined in Gtk.Widget even if I do:

with Common_Dialog.Plain; use Common_Dialog.Plain;

why is this? Only if I write:

Common_Dialog.Show_All (Some_Plain_Dialog); 
then the correct Show_All will be called.

If I do:

with Common_Dialog; use Common_Dialog;

then I get:

dialogs.adb:99:07: ambiguous expression (cannot resolve "Show_All")
dialogs.adb:99:07: possible interpretation at common_dialog-plain.ads:8
dialogs.adb:99:07: possible interpretation at common_dialog.ads:18
gnatmake: "dialogs.adb" compilation error

I guess there is something I have missed, but can somebody point me to
how I should do this so I get it right.

Thanks for any hints in advance!

-- 
Preben Randhol ------------------- http://www.pvv.org/~randhol/ --
                 «For me, Ada95 puts back the joy in programming.»




More information about the gtkada mailing list