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