1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  A Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button is a 
  26. --  Gtk.Tool_Item.Gtk_Tool_Item that contains a button and a small additional 
  27. --  button with an arrow. When clicked, the arrow button pops up a dropdown 
  28. --  menu. 
  29. -- 
  30. --  Use Gtk.Menu_Tool_Button.Gtk_New to create a new 
  31. --  Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button. Use 
  32. --  Gtk.Menu_Tool_Button.Gtk_New_From_Stock to create a new 
  33. --  Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button containing a stock item. 
  34. -- 
  35. --  == GtkMenuToolButton as GtkBuildable == 
  36. -- 
  37. --  The GtkMenuToolButton implementation of the GtkBuildable interface 
  38. --  supports adding a menu by specifying "menu" as the "type" attribute of a 
  39. --  <child> element. 
  40. -- 
  41. --  == A UI definition fragment with menus == 
  42. -- 
  43. --    <object class="GtkMenuToolButton"> 
  44. --    <child type="menu"> 
  45. --    <object class="GtkMenu"/> 
  46. --    </child> 
  47. --    </object> 
  48. --  </description> 
  49. pragma Ada_2005; 
  50.  
  51. pragma Warnings (Off, "*is already use-visible*"); 
  52. with Glib;            use Glib; 
  53. with Glib.Object;     use Glib.Object; 
  54. with Glib.Properties; use Glib.Properties; 
  55. with Glib.Types;      use Glib.Types; 
  56. with Glib.Variant;    use Glib.Variant; 
  57. with Gtk.Action;      use Gtk.Action; 
  58. with Gtk.Actionable;  use Gtk.Actionable; 
  59. with Gtk.Activatable; use Gtk.Activatable; 
  60. with Gtk.Buildable;   use Gtk.Buildable; 
  61. with Gtk.Menu;        use Gtk.Menu; 
  62. with Gtk.Tool_Button; use Gtk.Tool_Button; 
  63. with Gtk.Widget;      use Gtk.Widget; 
  64.  
  65. package Gtk.Menu_Tool_Button is 
  66.  
  67.    type Gtk_Menu_Tool_Button_Record is new Gtk_Tool_Button_Record with null record; 
  68.    type Gtk_Menu_Tool_Button is access all Gtk_Menu_Tool_Button_Record'Class; 
  69.  
  70.    ------------------ 
  71.    -- Constructors -- 
  72.    ------------------ 
  73.  
  74.    procedure Gtk_New 
  75.       (Menu        : out Gtk_Menu_Tool_Button; 
  76.        Icon_Widget : Gtk.Widget.Gtk_Widget := null; 
  77.        Label       : UTF8_String := ""); 
  78.    procedure Initialize 
  79.       (Menu        : not null access Gtk_Menu_Tool_Button_Record'Class; 
  80.        Icon_Widget : Gtk.Widget.Gtk_Widget := null; 
  81.        Label       : UTF8_String := ""); 
  82.    --  Creates a new Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button using 
  83.    --  Icon_Widget as icon and Label as label. 
  84.    --  Since: gtk+ 2.6 
  85.    --  "icon_widget": a widget that will be used as icon widget, or null 
  86.    --  "label": a string that will be used as label, or null 
  87.  
  88.    function Gtk_Menu_Tool_Button_New 
  89.       (Icon_Widget : Gtk.Widget.Gtk_Widget := null; 
  90.        Label       : UTF8_String := "") return Gtk_Menu_Tool_Button; 
  91.    --  Creates a new Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button using 
  92.    --  Icon_Widget as icon and Label as label. 
  93.    --  Since: gtk+ 2.6 
  94.    --  "icon_widget": a widget that will be used as icon widget, or null 
  95.    --  "label": a string that will be used as label, or null 
  96.  
  97.    procedure Gtk_New_From_Stock 
  98.       (Menu     : out Gtk_Menu_Tool_Button; 
  99.        Stock_Id : UTF8_String); 
  100.    procedure Initialize_From_Stock 
  101.       (Menu     : not null access Gtk_Menu_Tool_Button_Record'Class; 
  102.        Stock_Id : UTF8_String); 
  103.    --  Creates a new Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button. The new 
  104.    --  Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button will contain an icon and label 
  105.    --  from the stock item indicated by Stock_Id. 
  106.    --  Since: gtk+ 2.6 
  107.    --  "stock_id": the name of a stock item 
  108.  
  109.    function Gtk_Menu_Tool_Button_New_From_Stock 
  110.       (Stock_Id : UTF8_String) return Gtk_Menu_Tool_Button; 
  111.    --  Creates a new Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button. The new 
  112.    --  Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button will contain an icon and label 
  113.    --  from the stock item indicated by Stock_Id. 
  114.    --  Since: gtk+ 2.6 
  115.    --  "stock_id": the name of a stock item 
  116.  
  117.    function Get_Type return Glib.GType; 
  118.    pragma Import (C, Get_Type, "gtk_menu_tool_button_get_type"); 
  119.  
  120.    ------------- 
  121.    -- Methods -- 
  122.    ------------- 
  123.  
  124.    function Get_Menu 
  125.       (Button : not null access Gtk_Menu_Tool_Button_Record) 
  126.        return Gtk.Menu.Gtk_Menu; 
  127.    --  Gets the Gtk.Menu.Gtk_Menu associated with 
  128.    --  Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button. 
  129.    --  Since: gtk+ 2.6 
  130.  
  131.    procedure Set_Menu 
  132.       (Button : not null access Gtk_Menu_Tool_Button_Record; 
  133.        Menu   : not null access Gtk.Widget.Gtk_Widget_Record'Class); 
  134.    --  Sets the Gtk.Menu.Gtk_Menu that is popped up when the user clicks on 
  135.    --  the arrow. If Menu is NULL, the arrow button becomes insensitive. 
  136.    --  Since: gtk+ 2.6 
  137.    --  "menu": the Gtk.Menu.Gtk_Menu associated with 
  138.    --  Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button 
  139.  
  140.    procedure Set_Arrow_Tooltip_Markup 
  141.       (Button : not null access Gtk_Menu_Tool_Button_Record; 
  142.        Markup : UTF8_String); 
  143.    --  Sets the tooltip markup text to be used as tooltip for the arrow button 
  144.    --  which pops up the menu. See Gtk.Tool_Item.Set_Tooltip_Text for setting a 
  145.    --  tooltip on the whole Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button. 
  146.    --  Since: gtk+ 2.12 
  147.    --  "markup": markup text to be used as tooltip text for button's arrow 
  148.    --  button 
  149.  
  150.    procedure Set_Arrow_Tooltip_Text 
  151.       (Button : not null access Gtk_Menu_Tool_Button_Record; 
  152.        Text   : UTF8_String); 
  153.    --  Sets the tooltip text to be used as tooltip for the arrow button which 
  154.    --  pops up the menu. See Gtk.Tool_Item.Set_Tooltip_Text for setting a 
  155.    --  tooltip on the whole Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button. 
  156.    --  Since: gtk+ 2.12 
  157.    --  "text": text to be used as tooltip text for button's arrow button 
  158.  
  159.    --------------------------------------------- 
  160.    -- Inherited subprograms (from interfaces) -- 
  161.    --------------------------------------------- 
  162.    --  Methods inherited from the Buildable interface are not duplicated here 
  163.    --  since they are meant to be used by tools, mostly. If you need to call 
  164.    --  them, use an explicit cast through the "-" operator below. 
  165.  
  166.    function Get_Action_Name 
  167.       (Self : not null access Gtk_Menu_Tool_Button_Record) 
  168.        return UTF8_String; 
  169.  
  170.    procedure Set_Action_Name 
  171.       (Self        : not null access Gtk_Menu_Tool_Button_Record; 
  172.        Action_Name : UTF8_String); 
  173.  
  174.    function Get_Action_Target_Value 
  175.       (Self : not null access Gtk_Menu_Tool_Button_Record) 
  176.        return Glib.Variant.Gvariant; 
  177.  
  178.    procedure Set_Action_Target_Value 
  179.       (Self         : not null access Gtk_Menu_Tool_Button_Record; 
  180.        Target_Value : Glib.Variant.Gvariant); 
  181.  
  182.    procedure Set_Detailed_Action_Name 
  183.       (Self                 : not null access Gtk_Menu_Tool_Button_Record; 
  184.        Detailed_Action_Name : UTF8_String); 
  185.  
  186.    procedure Do_Set_Related_Action 
  187.       (Self   : not null access Gtk_Menu_Tool_Button_Record; 
  188.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  189.  
  190.    function Get_Related_Action 
  191.       (Self : not null access Gtk_Menu_Tool_Button_Record) 
  192.        return Gtk.Action.Gtk_Action; 
  193.  
  194.    procedure Set_Related_Action 
  195.       (Self   : not null access Gtk_Menu_Tool_Button_Record; 
  196.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  197.  
  198.    function Get_Use_Action_Appearance 
  199.       (Self : not null access Gtk_Menu_Tool_Button_Record) return Boolean; 
  200.  
  201.    procedure Set_Use_Action_Appearance 
  202.       (Self           : not null access Gtk_Menu_Tool_Button_Record; 
  203.        Use_Appearance : Boolean); 
  204.  
  205.    procedure Sync_Action_Properties 
  206.       (Self   : not null access Gtk_Menu_Tool_Button_Record; 
  207.        Action : access Gtk.Action.Gtk_Action_Record'Class); 
  208.  
  209.    ---------------- 
  210.    -- Properties -- 
  211.    ---------------- 
  212.    --  The following properties are defined for this widget. See 
  213.    --  Glib.Properties for more information on properties) 
  214.  
  215.    Menu_Property : constant Glib.Properties.Property_Object; 
  216.    --  Type: Gtk.Menu.Gtk_Menu 
  217.  
  218.    ------------- 
  219.    -- Signals -- 
  220.    ------------- 
  221.  
  222.    type Cb_Gtk_Menu_Tool_Button_Void is not null access procedure 
  223.      (Self : access Gtk_Menu_Tool_Button_Record'Class); 
  224.  
  225.    type Cb_GObject_Void is not null access procedure 
  226.      (Self : access Glib.Object.GObject_Record'Class); 
  227.  
  228.    Signal_Show_Menu : constant Glib.Signal_Name := "show-menu"; 
  229.    procedure On_Show_Menu 
  230.       (Self  : not null access Gtk_Menu_Tool_Button_Record; 
  231.        Call  : Cb_Gtk_Menu_Tool_Button_Void; 
  232.        After : Boolean := False); 
  233.    procedure On_Show_Menu 
  234.       (Self  : not null access Gtk_Menu_Tool_Button_Record; 
  235.        Call  : Cb_GObject_Void; 
  236.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  237.        After : Boolean := False); 
  238.    --  The ::show-menu signal is emitted before the menu is shown. 
  239.    -- 
  240.    --  It can be used to populate the menu on demand, using 
  241.    --  Gtk.Menu_Tool_Button.Set_Menu. 
  242.    -- 
  243.    --  Note that even if you populate the menu dynamically in this way, you 
  244.    --  must set an empty menu on the Gtk.Menu_Tool_Button.Gtk_Menu_Tool_Button 
  245.    --  beforehand, since the arrow is made insensitive if the menu is not set. 
  246.  
  247.    ---------------- 
  248.    -- Interfaces -- 
  249.    ---------------- 
  250.    --  This class implements several interfaces. See Glib.Types 
  251.    -- 
  252.    --  - "Actionable" 
  253.    -- 
  254.    --  - "Activatable" 
  255.    -- 
  256.    --  - "Buildable" 
  257.  
  258.    package Implements_Gtk_Actionable is new Glib.Types.Implements 
  259.      (Gtk.Actionable.Gtk_Actionable, Gtk_Menu_Tool_Button_Record, Gtk_Menu_Tool_Button); 
  260.    function "+" 
  261.      (Widget : access Gtk_Menu_Tool_Button_Record'Class) 
  262.    return Gtk.Actionable.Gtk_Actionable 
  263.    renames Implements_Gtk_Actionable.To_Interface; 
  264.    function "-" 
  265.      (Interf : Gtk.Actionable.Gtk_Actionable) 
  266.    return Gtk_Menu_Tool_Button 
  267.    renames Implements_Gtk_Actionable.To_Object; 
  268.  
  269.    package Implements_Gtk_Activatable is new Glib.Types.Implements 
  270.      (Gtk.Activatable.Gtk_Activatable, Gtk_Menu_Tool_Button_Record, Gtk_Menu_Tool_Button); 
  271.    function "+" 
  272.      (Widget : access Gtk_Menu_Tool_Button_Record'Class) 
  273.    return Gtk.Activatable.Gtk_Activatable 
  274.    renames Implements_Gtk_Activatable.To_Interface; 
  275.    function "-" 
  276.      (Interf : Gtk.Activatable.Gtk_Activatable) 
  277.    return Gtk_Menu_Tool_Button 
  278.    renames Implements_Gtk_Activatable.To_Object; 
  279.  
  280.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  281.      (Gtk.Buildable.Gtk_Buildable, Gtk_Menu_Tool_Button_Record, Gtk_Menu_Tool_Button); 
  282.    function "+" 
  283.      (Widget : access Gtk_Menu_Tool_Button_Record'Class) 
  284.    return Gtk.Buildable.Gtk_Buildable 
  285.    renames Implements_Gtk_Buildable.To_Interface; 
  286.    function "-" 
  287.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  288.    return Gtk_Menu_Tool_Button 
  289.    renames Implements_Gtk_Buildable.To_Object; 
  290.  
  291. private 
  292.    Menu_Property : constant Glib.Properties.Property_Object := 
  293.      Glib.Properties.Build ("menu"); 
  294. end Gtk.Menu_Tool_Button;