1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2000-2008, AdaCore                   -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. --  In recent versions of gtk+, this package has been deprecated in favor of 
  26. --  Gtk.UIManager. However, the subprograms have not been marked as such in the 
  27. --  C files themselves, so are still available in GtkAda as well. 
  28. --  </description> 
  29. --  <c_version>2.8.17</c_version> 
  30. --  <testgtk>create_item_factory.adb</testgtk> 
  31.  
  32. with Gdk.Types; 
  33. with Gtk.Accel_Group; 
  34. with Gtk.Widget; 
  35. with Gtk.Object; 
  36. with Gtkada.Types; 
  37.  
  38. package Gtk.Item_Factory is 
  39.    pragma Obsolescent; 
  40.  
  41.    type Gtk_Item_Factory_Record is new Object.Gtk_Object_Record with private; 
  42.    type Gtk_Item_Factory is access all Gtk_Item_Factory_Record'Class; 
  43.  
  44.    --  <doc_ignore> 
  45.  
  46.    type Item_Type_Enum is 
  47.      (Title, 
  48.       --  Create a title item 
  49.  
  50.       Item, 
  51.       --  Create a simple item 
  52.  
  53.       Image_Item, 
  54.       --  Create an item holding an image 
  55.  
  56.       Stock_Item, 
  57.       --  Create an item holding a stock image 
  58.  
  59.       Check_Item, 
  60.       --  Create a check item 
  61.  
  62.       Toggle_Item, 
  63.       --  Create a toggle item 
  64.  
  65.       Radio_Item, 
  66.       --  Create a radio item 
  67.  
  68.       Separator, 
  69.       --  Create a separator 
  70.  
  71.       Tearoff, 
  72.       --  Create a tearoff item 
  73.  
  74.       Branch, 
  75.       --  Create an item to hold sub items 
  76.  
  77.       Last_Branch 
  78.       --  Create a right justified item to hold sub items 
  79.      ); 
  80.    --  Identify the predefined item types used to create a 
  81.    --  Gtk_Item_Factory_Entry. 
  82.  
  83.    type Gtk_Item_Factory_Entry is private; 
  84.    type Gtk_Item_Factory_Entry_Array is array (Gint range <>) of 
  85.      Gtk_Item_Factory_Entry; 
  86.  
  87.    procedure Gtk_New 
  88.      (Ifactory       : out Gtk_Item_Factory; 
  89.       Container_Type : Gtk_Type; 
  90.       Path           : UTF8_String; 
  91.       Accel_Group    : Gtk.Accel_Group.Gtk_Accel_Group); 
  92.    procedure Initialize 
  93.      (Ifactory       : access Gtk_Item_Factory_Record'Class; 
  94.       Container_Type : Gtk_Type; 
  95.       Path           : UTF8_String := ""; 
  96.       Accel_Group    : Gtk.Accel_Group.Gtk_Accel_Group); 
  97.    --  Creates or initializes a new item factory. 
  98.    --  Possible values of Container_Type are: 
  99.    --    - Gtk.Option_Menu.Get_Type 
  100.    --    - Gtk.Menu_Bar.Get_Type 
  101.    --    - Gtk.Menu.Get_Type 
  102.  
  103.    function Get_Type return Gtk_Type; 
  104.    --  Return the internal value associated with a Gtk_Item_Factory 
  105.  
  106.    procedure Add_Foreign 
  107.      (Accel_Widget : access Gtk.Widget.Gtk_Widget_Record'Class; 
  108.       Full_Path    : UTF8_String; 
  109.       Accel_Group  : Gtk.Accel_Group.Gtk_Accel_Group; 
  110.       Keyval       : Guint; 
  111.       Modifiers    : Gdk.Types.Gdk_Modifier_Type); 
  112.  
  113.    function From_Widget 
  114.      (Widget : access Gtk.Widget.Gtk_Widget_Record'Class) 
  115.       return Gtk_Item_Factory; 
  116.  
  117.    function Path_From_Widget 
  118.      (Widget : access Gtk.Widget.Gtk_Widget_Record'Class) return UTF8_String; 
  119.  
  120.    function Get_Item 
  121.      (Ifactory : access Gtk_Item_Factory_Record; 
  122.       Path     : UTF8_String) return Gtk.Widget.Gtk_Widget; 
  123.  
  124.    function Get_Widget 
  125.      (Ifactory : access Gtk_Item_Factory_Record; 
  126.       Path     : UTF8_String) return Gtk.Widget.Gtk_Widget; 
  127.  
  128.    function Get_Widget_By_Action 
  129.      (Ifactory : access Gtk_Item_Factory_Record; 
  130.       Action   : Guint) return Gtk.Widget.Gtk_Widget; 
  131.  
  132.    function Get_Item_By_Action 
  133.      (Ifactory : access Gtk_Item_Factory_Record; 
  134.       Action   : Guint) return Gtk.Widget.Gtk_Widget; 
  135.  
  136.    procedure Delete_Item 
  137.      (Ifactory : access Gtk_Item_Factory_Record; 
  138.       Path     : UTF8_String); 
  139.  
  140.    procedure Delete_Entry 
  141.      (Ifactory : access Gtk_Item_Factory_Record; 
  142.       Ientry   : Gtk_Item_Factory_Entry); 
  143.  
  144.    procedure Delete_Entries 
  145.      (Ifactory  : access Gtk_Item_Factory_Record; 
  146.       Entries   : Gtk_Item_Factory_Entry_Array); 
  147.  
  148.    procedure Popup 
  149.      (Ifactory     : access Gtk_Item_Factory_Record; 
  150.       X            : Guint; 
  151.       Y            : Guint; 
  152.       Mouse_Button : Guint; 
  153.       Time         : Guint32); 
  154.  
  155.    generic 
  156.       type Data_Type (<>) is limited private; 
  157.    package Data_Item is 
  158.  
  159.       type Data_Type_Access is access all Data_Type; 
  160.  
  161.       type Gtk_Print_Func is access procedure 
  162.         (Func_Data : Data_Type_Access; 
  163.          Str       : String);  --  gchar* ??? 
  164.  
  165.       type Gtk_Translate_Func is access function 
  166.         (Path      : UTF8_String;  --  const gchar* ??? 
  167.          Func_Data : Data_Type_Access) return Gtkada.Types.Chars_Ptr; 
  168.       pragma Convention (C, Gtk_Translate_Func); 
  169.  
  170.       type Limited_Widget is limited private; 
  171.       Null_Widget : constant Limited_Widget; 
  172.  
  173.       function To_Widget 
  174.         (Widget : Limited_Widget) return Gtk.Widget.Gtk_Widget; 
  175.  
  176.       type Gtk_Item_Factory_Callback is access procedure 
  177.         (Callback_Data   : Data_Type_Access; 
  178.          Callback_Action : Guint; 
  179.          Widget          : Limited_Widget); 
  180.  
  181.       function Gtk_New 
  182.         (Path            : UTF8_String; 
  183.          Accelerator     : String := ""; 
  184.          Callback        : Gtk_Item_Factory_Callback := null; 
  185.          Item_Type       : Item_Type_Enum; 
  186.          Callback_Action : Guint := 0) return Gtk_Item_Factory_Entry; 
  187.       --  Create a Gtk_Item_Factory_Entry. 
  188.       --  It is up to you to call Free at an appropriate point to avoid memory 
  189.       --  leaks. 
  190.  
  191.       function Gtk_New 
  192.         (Path            : UTF8_String; 
  193.          Accelerator     : String := ""; 
  194.          Callback        : Gtk_Item_Factory_Callback := null; 
  195.          Item_Type       : String := ""; 
  196.          Callback_Action : Guint := 0) return Gtk_Item_Factory_Entry; 
  197.       --  Create a Gtk_Item_Factory_Entry. 
  198.       --  It is up to you to call Free at an appropriate point to avoid memory 
  199.       --  leaks. 
  200.  
  201.       function Gtk_New 
  202.         (Path            : UTF8_String; 
  203.          Accelerator     : String := ""; 
  204.          Stock_Id        : String; 
  205.          Callback        : Gtk_Item_Factory_Callback := null; 
  206.          Callback_Action : Guint := 0) return Gtk_Item_Factory_Entry; 
  207.       --  Create a Gtk_Item_Factory_Entry from a stock item. 
  208.       --  It is up to you to call Free at an appropriate point to avoid memory 
  209.       --  leaks. 
  210.  
  211.       function Gtk_New 
  212.         (Path            : UTF8_String; 
  213.          Accelerator     : String := ""; 
  214.          Callback        : Gtk_Item_Factory_Callback := null; 
  215.          Pixbuf          : access Guchar_Array; 
  216.          Callback_Action : Guint := 0) return Gtk_Item_Factory_Entry; 
  217.       --  Create a Gtk_Item_Factory_Entry from an inline pixbuf image. 
  218.       --  It is up to you to call Free at an appropriate point to avoid memory 
  219.       --  leaks. 
  220.  
  221.       procedure Free (Ientry : in out Gtk_Item_Factory_Entry); 
  222.       --  Free all the dynamic data associated with an item factory entry. 
  223.  
  224.       procedure Free (Ientries : in out Gtk_Item_Factory_Entry_Array); 
  225.       --  Free all the dynamic data associated with each item factory entry. 
  226.  
  227.       procedure Create_Item 
  228.         (Ifactory      : access Gtk_Item_Factory_Record'Class; 
  229.          Ientry        : Gtk_Item_Factory_Entry; 
  230.          Callback_Data : Data_Type_Access; 
  231.          Callback_Type : Guint); 
  232.       --  Callback_Type = 0 -> Gtk_Item_Factory_Callback 
  233.       --  Callback_Type = 1 -> Gtk_Item_Factory_Callback1 
  234.  
  235.       procedure Create_Items 
  236.         (Ifactory      : access Gtk_Item_Factory_Record'Class; 
  237.          Entries       : Gtk_Item_Factory_Entry_Array; 
  238.          Callback_Data : Data_Type_Access); 
  239.  
  240.       function Popup_Data 
  241.         (Ifactory : access Gtk_Item_Factory_Record'Class) 
  242.          return Data_Type_Access; 
  243.  
  244.       function Popup_Data_From_Widget 
  245.         (Widget : access Gtk.Widget.Gtk_Widget_Record'Class) 
  246.          return Data_Type_Access; 
  247.  
  248.       procedure Popup_With_Data 
  249.         (Ifactory     : access Gtk_Item_Factory_Record'Class; 
  250.          Popup_Data   : Data_Type_Access; 
  251.          Destroy      : System.Address; --  Gtk_Destroy_Notify ??? 
  252.          X            : Guint; 
  253.          Y            : Guint; 
  254.          Mouse_Button : Guint; 
  255.          Time         : Guint32); 
  256.  
  257.       procedure Set_Translate_Func 
  258.         (Ifactory : access Gtk_Item_Factory_Record'Class; 
  259.          Func     : Gtk_Translate_Func; 
  260.          Data     : Data_Type_Access; 
  261.          Notify   : System.Address);  --  Gtk_Destroy_Notify ??? 
  262.  
  263.    private 
  264.       type Limited_Widget is new System.Address; 
  265.       Null_Widget : constant Limited_Widget := 
  266.         Limited_Widget (System.Null_Address); 
  267.    end Data_Item; 
  268.  
  269.    --  </doc_ignore> 
  270.  
  271.    ---------------- 
  272.    -- Properties -- 
  273.    ---------------- 
  274.  
  275.    --  <properties> 
  276.    --  The following properties are defined for this widget. See 
  277.    --  Glib.Properties for more information on properties. 
  278.    -- 
  279.    --  </properties> 
  280.  
  281. private 
  282.    type Gtk_Item_Factory_Record is new Gtk.Object.Gtk_Object_Record 
  283.      with null record; 
  284.  
  285.    type Gtk_Item_Factory_Entry is record 
  286.       Path            : Gtkada.Types.Chars_Ptr; 
  287.       Accelerator     : Gtkada.Types.Chars_Ptr; 
  288.       Callback        : System.Address; 
  289.       Callback_Action : Guint; 
  290.       Item_Type       : Gtkada.Types.Chars_Ptr; 
  291.  
  292.       --  Extra data for some item types: 
  293.       --  Image_Item -> pointer to inline pixbuf 
  294.       --  Stock_Item -> name of stock item 
  295.  
  296.       Extra_Data      : Gtkada.Types.Chars_Ptr; 
  297.    end record; 
  298.    pragma Convention (C, Gtk_Item_Factory_Entry); 
  299.  
  300.    pragma Import (C, Get_Type, "gtk_item_factory_get_type"); 
  301.  
  302. end Gtk.Item_Factory; 
  303.  
  304. --  The following subprograms never had a binding, are now obsolescent: 
  305. --  No binding: gtk_item_factories_path_delete 
  306. --  No binding: gtk_item_factory_construct 
  307. --  No binding: gtk_item_factory_create_items_ac 
  308. --  No binding: gtk_item_factory_create_menu_entries 
  309. --  No binding: gtk_item_factory_from_path