[gtkada] GNOME.App_Helper patch

Aidan Skinner aidan at velvet.net
Mon Feb 18 02:16:09 CET 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here's a second patch, this ones a lot bigger.

It does two things:

  Firstly, it changes all instances of access UI_Info_Array to be a
  library level access type UI_Info_Array_Access.

  Secondly it provides implementations for:
    Create_Menus
    Create_Toolbar
    Fill_Toolbar
    Insert_Menus
    Install_Menu_Hints
    Install_Statusbar_Menu_Hints

It might make more sense to split the patch out, but I don't really
feel awake enough to do that at this point in time, so I'm sending it
as-is.

I'll clean it up tommorrow if anybody wants it split.

Oh, and I've only compiled this, not thoroughly tested. 8)

- - Aidan

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (OpenBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE8cFXcmixMyT7EdeERAhaxAKCELGc90SwL82LVgQSLABuyPXgi3ACdE7MM
ZFM2VgDsQzlABjnXg+XdQZc=
=8YP6
-----END PGP SIGNATURE-----

-------------- next part --------------
Index: src/gnome/gnome-app_helper.adb
===================================================================
RCS file: /anoncvs/GtkAda.cvs/src/gnome/gnome-app_helper.adb,v
retrieving revision 1.3
diff -C3 -r1.3 gnome-app_helper.adb
*** src/gnome/gnome-app_helper.adb	2002/01/04 14:02:13	1.3
--- src/gnome/gnome-app_helper.adb	2002/02/18 01:06:57
***************
*** 103,112 ****
  
     procedure Create_Menus
       (App  : access Gnome_App_Record'Class;
!       Info : access UI_Info_Array)
     is
     begin
!       raise Program_Error;
     end Create_Menus;
  
     --------------------
--- 103,118 ----
  
     procedure Create_Menus
       (App  : access Gnome_App_Record'Class;
!       Info : UI_Info_Array_Access)
     is
+ 
+       procedure Internal
+         (App          : System.Address;
+          Info         : System.Address);
+       pragma Import (C, Internal, "gnome_app_create_menus");
+ 
     begin
!       Internal (Get_Object(App), Info.all'Address);
     end Create_Menus;
  
     --------------------
***************
*** 115,124 ****
  
     procedure Create_Toolbar
       (App : access Gnome_App_Record'Class;
!       Info : access UI_Info_Array)
     is
     begin
!       raise Program_Error;
     end Create_Toolbar;
  
     ---------------
--- 121,135 ----
  
     procedure Create_Toolbar
       (App : access Gnome_App_Record'Class;
!       Info : UI_Info_Array_Access)
     is
+       procedure Internal
+         (App          : System.Address;
+          Info         : System.Address);
+       pragma Import (C, Internal, "gnome_app_create_toolbar");
+ 
     begin
!       Internal (Get_Object(App), Info.all'Address);
     end Create_Toolbar;
  
     ---------------
***************
*** 127,133 ****
  
     procedure Fill_Menu
       (Menu_Shell   : access Gtk_Menu_Shell_Record'Class;
!       Info         : access UI_Info_Array;
        Accel_Group  : Gtk_Accel_Group := null;
        Uline_Accels : Boolean := False;
        Pos          : Gint := 0;
--- 138,144 ----
  
     procedure Fill_Menu
       (Menu_Shell   : access Gtk_Menu_Shell_Record'Class;
!       Info         : UI_Info_Array_Access;
        Accel_Group  : Gtk_Accel_Group := null;
        Uline_Accels : Boolean := False;
        Pos          : Gint := 0;
***************
*** 195,205 ****
  
     procedure Fill_Toolbar
       (Toolbar     : access Gtk_Toolbar_Record'Class;
!       Info        : access UI_Info_Array;
        Accel_Group : Gtk_Accel_Group := null)
     is
     begin
!       raise Program_Error;
     end Fill_Toolbar;
  
     -------------------
--- 206,222 ----
  
     procedure Fill_Toolbar
       (Toolbar     : access Gtk_Toolbar_Record'Class;
!       Info        : UI_Info_Array_Access;
        Accel_Group : Gtk_Accel_Group := null)
     is
+       procedure Internal
+         (Toolbar   : System.Address;
+          Info      : System.Address;
+          Accel_Group : Gtk_Accel_Group);
+       pragma Import (C, Internal, "gnome_app_fill_toolbar");
+ 
     begin
!       Internal(Get_Object(Toolbar), Info.all'Address, Accel_Group);
     end Fill_Toolbar;
  
     -------------------
***************
*** 249,258 ****
     procedure Insert_Menus
       (App       : access Gnome_App_Record'Class;
        Path      : String;
!       Menu_Info : access UI_Info_Array)
     is
     begin
!       raise Program_Error;
     end Insert_Menus;
  
     ------------------------
--- 266,281 ----
     procedure Insert_Menus
       (App       : access Gnome_App_Record'Class;
        Path      : String;
!       Menu_Info : UI_Info_Array_Access)
     is
+       procedure Internal
+         (App   : System.Address;
+          Path  : String;
+          Menu_Info : System.Address);
+       pragma Import (C, Internal, "gnome_app_fill_toolbar");
+ 
     begin
!       Internal (Get_Object(App), Path & ASCII.NUL, Menu_Info.all'Address);
     end Insert_Menus;
  
     ------------------------
***************
*** 260,268 ****
     ------------------------
  
     procedure Install_Menu_Hints
!      (App : Gnome_App; Info : access UI_Info_Array) is
     begin
!       raise Program_Error;
     end Install_Menu_Hints;
  
     ----------------------------------
--- 283,297 ----
     ------------------------
  
     procedure Install_Menu_Hints
!      (App : Gnome_App; Info : UI_Info_Array_Access) is
! 
!       procedure Internal
!         (App   : System.Address;
!          Info  : System.Address);
!       pragma Import (C, Internal, "gnome_app_install_menu_hints");
! 
     begin
!       Internal (Get_Object(App), Info.all'Address);
     end Install_Menu_Hints;
  
     ----------------------------------
***************
*** 271,280 ****
  
     procedure Install_Statusbar_Menu_Hints
       (Bar  : Gtk_Statusbar;
!       Info : access UI_Info_Array)
     is
     begin
!       raise Program_Error;
     end Install_Statusbar_Menu_Hints;
  
     -----------------------
--- 300,314 ----
  
     procedure Install_Statusbar_Menu_Hints
       (Bar  : Gtk_Statusbar;
!       Info : UI_Info_Array_Access)
     is
+       procedure Internal
+         (Statusbar : System.Address;
+          Info      : System.Address);
+       pragma Import (C, Internal, "gnome_app_install_statusbar_menu_hints");
+ 
     begin
!       Internal(Get_Object(Bar), Info.all'Address);
     end Install_Statusbar_Menu_Hints;
  
     -----------------------
***************
*** 459,465 ****
     ----------------------------
  
     function UI_Info_Menu_Edit_Tree
!      (Tree : access UI_Info_Array) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_Edit"), Null_Ptr,
--- 493,499 ----
     ----------------------------
  
     function UI_Info_Menu_Edit_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_Edit"), Null_Ptr,
***************
*** 502,508 ****
     ----------------------------
  
     function UI_Info_Menu_File_Tree
!      (Tree : access UI_Info_Array) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_File"), Null_Ptr,
--- 536,542 ----
     ----------------------------
  
     function UI_Info_Menu_File_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_File"), Null_Ptr,
***************
*** 515,521 ****
     -----------------------------
  
     function UI_Info_Menu_Files_Tree
!      (Tree : access UI_Info_Array) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"Fi_les"), Null_Ptr,
--- 549,555 ----
     -----------------------------
  
     function UI_Info_Menu_Files_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"Fi_les"), Null_Ptr,
***************
*** 558,564 ****
     ----------------------------
  
     function UI_Info_Menu_Game_Tree
!      (Tree : access UI_Info_Array) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_Game"), Null_Ptr,
--- 592,598 ----
     ----------------------------
  
     function UI_Info_Menu_Game_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_Game"), Null_Ptr,
***************
*** 571,577 ****
     ----------------------------
  
     function UI_Info_Menu_Help_Tree
!      (Tree : access UI_Info_Array) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_Help"), Null_Ptr,
--- 605,611 ----
     ----------------------------
  
     function UI_Info_Menu_Help_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_Help"), Null_Ptr,
***************
*** 631,637 ****
     ------------------------------
  
     function UI_Info_Menu_New_Subtree
!      (Tree : access UI_Info_Array) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_New"), Null_Ptr,
--- 665,671 ----
     ------------------------------
  
     function UI_Info_Menu_New_Subtree
!      (Tree : UI_Info_Array_Access) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_New"), Null_Ptr,
***************
*** 900,906 ****
     --------------------------------
  
     function UI_Info_Menu_Settings_Tree
!      (Tree : access UI_Info_Array) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_Settings"), Null_Ptr,
--- 934,940 ----
     --------------------------------
  
     function UI_Info_Menu_Settings_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_Settings"), Null_Ptr,
***************
*** 942,948 ****
     ----------------------------
  
     function UI_Info_Menu_View_Tree
!      (Tree : access UI_Info_Array) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_View"), Null_Ptr,
--- 976,982 ----
     ----------------------------
  
     function UI_Info_Menu_View_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_View"), Null_Ptr,
***************
*** 955,961 ****
     -------------------------------
  
     function UI_Info_Menu_Windows_Tree
!      (Tree : access UI_Info_Array) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_Windows"), Null_Ptr,
--- 989,995 ----
     -------------------------------
  
     function UI_Info_Menu_Windows_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info is
     begin
        return
          (UI_Subtree_Stock, New_String (-"_Windows"), Null_Ptr,
***************
*** 985,991 ****
  
     function UI_Info_Subtree
       (Label : String;
!       Tree  : access UI_Info_Array) return UI_Info is
     begin
        return
          (UI_Subtree, New_String (Label), Null_Ptr,
--- 1019,1025 ----
  
     function UI_Info_Subtree
       (Label : String;
!       Tree  : UI_Info_Array_Access) return UI_Info is
     begin
        return
          (UI_Subtree, New_String (Label), Null_Ptr,
***************
*** 1000,1006 ****
     function UI_Info_Subtree_Hint
       (Label : String;
        Hint  : String;
!       Tree  : access UI_Info_Array) return UI_Info is
     begin
        return
          (UI_Subtree, New_String (Label), New_String (Hint),
--- 1034,1040 ----
     function UI_Info_Subtree_Hint
       (Label : String;
        Hint  : String;
!       Tree  : UI_Info_Array_Access) return UI_Info is
     begin
        return
          (UI_Subtree, New_String (Label), New_String (Hint),
***************
*** 1014,1020 ****
  
     function UI_Info_Subtree_Stock
       (Label    : String;
!       Tree     : access UI_Info_Array;
        Stock_Id : String) return UI_Info is
     begin
        return
--- 1048,1054 ----
  
     function UI_Info_Subtree_Stock
       (Label    : String;
!       Tree     : UI_Info_Array_Access;
        Stock_Id : String) return UI_Info is
     begin
        return
***************
*** 1082,1088 ****
  
     function UI_New_Subtree
       (Label           : String;
!       Info            : access UI_Info_Array;
        Pixmap_Type     : UI_Pixmap_Type := Pixmap_None;
        Pixmap_Info     : String := "";
        Accelerator_Key : Gdk_Key_Type := 0;
--- 1116,1122 ----
  
     function UI_New_Subtree
       (Label           : String;
!       Info            : UI_Info_Array_Access;
        Pixmap_Type     : UI_Pixmap_Type := Pixmap_None;
        Pixmap_Info     : String := "";
        Accelerator_Key : Gdk_Key_Type := 0;
Index: src/gnome/gnome-app_helper.ads
===================================================================
RCS file: /anoncvs/GtkAda.cvs/src/gnome/gnome-app_helper.ads,v
retrieving revision 1.5
diff -C3 -r1.5 gnome-app_helper.ads
*** src/gnome/gnome-app_helper.ads	2001/02/12 14:54:39	1.5
--- src/gnome/gnome-app_helper.ads	2002/02/18 01:06:58
***************
*** 106,111 ****
--- 106,113 ----
     --  needed to create menus or toolbars. The most convenient way to create
     --  such a structure is to use the UI_Info_* functions provided below.
  
+    type UI_Info_Array_Access is access UI_Info_Array;
+ 
     type Generic_Callback is access
       procedure (Widget : access Gtk_Widget_Record'Class);
  
***************
*** 131,137 ****
  
     function UI_New_Subtree
       (Label           : String;
!       Info            : access UI_Info_Array;
        Pixmap_Type     : UI_Pixmap_Type := Pixmap_None;
        Pixmap_Info     : String := "";
        Accelerator_Key : Gdk_Key_Type := 0;
--- 133,139 ----
  
     function UI_New_Subtree
       (Label           : String;
!       Info            : UI_Info_Array_Access;
        Pixmap_Type     : UI_Pixmap_Type := Pixmap_None;
        Pixmap_Info     : String := "";
        Accelerator_Key : Gdk_Key_Type := 0;
***************
*** 194,211 ****
  
     function UI_Info_Subtree
       (Label : String;
!       Tree  : access UI_Info_Array) return UI_Info;
     --  Insert a subtree (submenu)
  
     function UI_Info_Subtree_Hint
       (Label : String;
        Hint  : String;
!       Tree  : access UI_Info_Array) return UI_Info;
     --  Insert a subtree with a hint
  
     function UI_Info_Subtree_Stock
       (Label    : String;
!       Tree     : access UI_Info_Array;
        Stock_Id : String) return UI_Info;
     --  Insert a subtree (submenu) with a stock icon
  
--- 196,213 ----
  
     function UI_Info_Subtree
       (Label : String;
!       Tree  : UI_Info_Array_Access) return UI_Info;
     --  Insert a subtree (submenu)
  
     function UI_Info_Subtree_Hint
       (Label : String;
        Hint  : String;
!       Tree  : UI_Info_Array_Access) return UI_Info;
     --  Insert a subtree with a hint
  
     function UI_Info_Subtree_Stock
       (Label    : String;
!       Tree     : UI_Info_Array_Access;
        Stock_Id : String) return UI_Info;
     --  Insert a subtree (submenu) with a stock icon
  
***************
*** 236,242 ****
        Callback  : Generic_Callback) return UI_Info;
  
     function UI_Info_Menu_New_Subtree
!      (Tree : access UI_Info_Array) return UI_Info;
     --  If you have more than one new type, use this tree
  
     function UI_Info_Menu_Open_Item
--- 238,244 ----
        Callback  : Generic_Callback) return UI_Info;
  
     function UI_Info_Menu_New_Subtree
!      (Tree : UI_Info_Array_Access) return UI_Info;
     --  If you have more than one new type, use this tree
  
     function UI_Info_Menu_Open_Item
***************
*** 350,377 ****
     --  Some standard menus
  
     function UI_Info_Menu_File_Tree
!      (Tree : access UI_Info_Array) return UI_Info;
  
     function UI_Info_Menu_Edit_Tree
!      (Tree : access UI_Info_Array) return UI_Info;
  
     function UI_Info_Menu_View_Tree
!      (Tree : access UI_Info_Array) return UI_Info;
  
     function UI_Info_Menu_Settings_Tree
!      (Tree : access UI_Info_Array) return UI_Info;
  
     function UI_Info_Menu_Files_Tree
!      (Tree : access UI_Info_Array) return UI_Info;
  
     function UI_Info_Menu_Windows_Tree
!      (Tree : access UI_Info_Array) return UI_Info;
  
     function UI_Info_Menu_Help_Tree
!      (Tree : access UI_Info_Array) return UI_Info;
  
     function UI_Info_Menu_Game_Tree
!      (Tree : access UI_Info_Array) return UI_Info;
  
     --  These are strings to be used for paths when working with the menus
     --  stuff
--- 352,379 ----
     --  Some standard menus
  
     function UI_Info_Menu_File_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info;
  
     function UI_Info_Menu_Edit_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info;
  
     function UI_Info_Menu_View_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info;
  
     function UI_Info_Menu_Settings_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info;
  
     function UI_Info_Menu_Files_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info;
  
     function UI_Info_Menu_Windows_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info;
  
     function UI_Info_Menu_Help_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info;
  
     function UI_Info_Menu_Game_Tree
!      (Tree : UI_Info_Array_Access) return UI_Info;
  
     --  These are strings to be used for paths when working with the menus
     --  stuff
***************
*** 397,403 ****
  
     procedure Fill_Menu
       (Menu_Shell   : access Gtk_Menu_Shell_Record'Class;
!       Info         : access UI_Info_Array;
        Accel_Group  : Gtk_Accel_Group := null;
        Uline_Accels : Boolean := False;
        Pos          : Gint := 0;
--- 399,405 ----
  
     procedure Fill_Menu
       (Menu_Shell   : access Gtk_Menu_Shell_Record'Class;
!       Info         : UI_Info_Array_Access;
        Accel_Group  : Gtk_Accel_Group := null;
        Uline_Accels : Boolean := False;
        Pos          : Gint := 0;
***************
*** 413,431 ****
     --  (similarly to what is done in Object_Connect).
  
     procedure Create_Menus
!      (App : access Gnome_App_Record'Class; Info : access UI_Info_Array);
     --  Construct a menu bar and attach it to the specified application window
  
     procedure Fill_Toolbar
       (Toolbar     : access Gtk_Toolbar_Record'Class;
!       Info        : access UI_Info_Array;
        Accel_Group : Gtk_Accel_Group := null);
     --  Fill the specified toolbar with buttons created from the specified info.
     --  If Accel_Group is not null, then the items' accelerator keys are put
     --  into it.
  
     procedure Create_Toolbar
!      (App : access Gnome_App_Record'Class; Info : access UI_Info_Array);
     --  Construct a toolbar and attach it to the specified application window
  
     function Find_Menu_Pos
--- 415,433 ----
     --  (similarly to what is done in Object_Connect).
  
     procedure Create_Menus
!      (App : access Gnome_App_Record'Class; Info : UI_Info_Array_Access);
     --  Construct a menu bar and attach it to the specified application window
  
     procedure Fill_Toolbar
       (Toolbar     : access Gtk_Toolbar_Record'Class;
!       Info        : UI_Info_Array_Access;
        Accel_Group : Gtk_Accel_Group := null);
     --  Fill the specified toolbar with buttons created from the specified info.
     --  If Accel_Group is not null, then the items' accelerator keys are put
     --  into it.
  
     procedure Create_Toolbar
!      (App : access Gnome_App_Record'Class; Info : UI_Info_Array_Access);
     --  Construct a toolbar and attach it to the specified application window
  
     function Find_Menu_Pos
***************
*** 464,484 ****
     procedure Insert_Menus
       (App       : access Gnome_App_Record'Class;
        Path      : String;
!       Menu_Info : access UI_Info_Array);
     --  what does it do ???
  
     --  procedure Install_Appbar_Menu_Hints
     --    (Appbar : Gnome_App_Bar;
!    --     Info   : access UI_Info_Array);
     --  Activate the menu item hints, displaying in the given appbar.
     --  This can't be automatic since we can't reliably find the
     --  appbar.
     --  Really? Why can't it be automatic?
  
     procedure Install_Statusbar_Menu_Hints
!      (Bar : Gtk_Status_Bar; Info : access UI_Info_Array);
  
!    procedure Install_Menu_Hints (App : Gnome_App; Info : access UI_Info_Array);
  
  private
     type UI_Info_Type is
--- 466,486 ----
     procedure Insert_Menus
       (App       : access Gnome_App_Record'Class;
        Path      : String;
!       Menu_Info : UI_Info_Array_Access);
     --  what does it do ???
  
     --  procedure Install_Appbar_Menu_Hints
     --    (Appbar : Gnome_App_Bar;
!    --     Info   : UI_Info_Array_Access);
     --  Activate the menu item hints, displaying in the given appbar.
     --  This can't be automatic since we can't reliably find the
     --  appbar.
     --  Really? Why can't it be automatic?
  
     procedure Install_Statusbar_Menu_Hints
!      (Bar : Gtk_Status_Bar; Info : UI_Info_Array_Access);
  
!    procedure Install_Menu_Hints (App : Gnome_App; Info : UI_Info_Array_Access);
  
  private
     type UI_Info_Type is


More information about the gtkada mailing list