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