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. --  Gtk.Tool_Button.Gtk_Tool_Button<!-- -->s are Gtk_Tool_Items containing 
  26. --  buttons. 
  27. -- 
  28. --  Use Gtk.Tool_Button.Gtk_New to create a new 
  29. --  Gtk.Tool_Button.Gtk_Tool_Button. Use Gtk.Tool_Button.Gtk_New_From_Stock to 
  30. --  create a Gtk.Tool_Button.Gtk_Tool_Button containing a stock item. 
  31. -- 
  32. --  The label of a Gtk.Tool_Button.Gtk_Tool_Button is determined by the 
  33. --  properties Gtk.Tool_Button.Gtk_Tool_Button:label-widget, 
  34. --  Gtk.Tool_Button.Gtk_Tool_Button:label, and 
  35. --  Gtk.Tool_Button.Gtk_Tool_Button:stock-id. If 
  36. --  Gtk.Tool_Button.Gtk_Tool_Button:label-widget is non-null, then that widget 
  37. --  is used as the label. Otherwise, if Gtk.Tool_Button.Gtk_Tool_Button:label 
  38. --  is non-null, that string is used as the label. Otherwise, if 
  39. --  Gtk.Tool_Button.Gtk_Tool_Button:stock-id is non-null, the label is 
  40. --  determined by the stock item. Otherwise, the button does not have a label. 
  41. -- 
  42. --  The icon of a Gtk.Tool_Button.Gtk_Tool_Button is determined by the 
  43. --  properties Gtk.Tool_Button.Gtk_Tool_Button:icon-widget and 
  44. --  Gtk.Tool_Button.Gtk_Tool_Button:stock-id. If 
  45. --  Gtk.Tool_Button.Gtk_Tool_Button:icon-widget is non-null, then that widget 
  46. --  is used as the icon. Otherwise, if Gtk.Tool_Button.Gtk_Tool_Button:stock-id 
  47. --  is non-null, the icon is determined by the stock item. Otherwise, the 
  48. --  button does not have a icon. 
  49. -- 
  50. --  </description> 
  51. pragma Ada_2005; 
  52.  
  53. pragma Warnings (Off, "*is already use-visible*"); 
  54. with Glib;            use Glib; 
  55. with Glib.Object;     use Glib.Object; 
  56. with Glib.Properties; use Glib.Properties; 
  57. with Glib.Types;      use Glib.Types; 
  58. with Glib.Variant;    use Glib.Variant; 
  59. with Gtk.Action;      use Gtk.Action; 
  60. with Gtk.Actionable;  use Gtk.Actionable; 
  61. with Gtk.Activatable; use Gtk.Activatable; 
  62. with Gtk.Buildable;   use Gtk.Buildable; 
  63. with Gtk.Tool_Item;   use Gtk.Tool_Item; 
  64. with Gtk.Widget;      use Gtk.Widget; 
  65.  
  66. package Gtk.Tool_Button is 
  67.  
  68.    type Gtk_Tool_Button_Record is new Gtk_Tool_Item_Record with null record; 
  69.    type Gtk_Tool_Button is access all Gtk_Tool_Button_Record'Class; 
  70.  
  71.    ------------------ 
  72.    -- Constructors -- 
  73.    ------------------ 
  74.  
  75.    procedure Gtk_New 
  76.       (Button      : out Gtk_Tool_Button; 
  77.        Icon_Widget : Gtk.Widget.Gtk_Widget := null; 
  78.        Label       : UTF8_String := ""); 
  79.    procedure Initialize 
  80.       (Button      : not null access Gtk_Tool_Button_Record'Class; 
  81.        Icon_Widget : Gtk.Widget.Gtk_Widget := null; 
  82.        Label       : UTF8_String := ""); 
  83.    --  Creates a new GtkToolButton using Icon_Widget as contents and Label as 
  84.    --  label. 
  85.    --  Since: gtk+ 2.4 
  86.    --  "icon_widget": a widget that will be used as the button contents, or 
  87.    --  null 
  88.    --  "label": a string that will be used as label, or null 
  89.  
  90.    function Gtk_Tool_Button_New 
  91.       (Icon_Widget : Gtk.Widget.Gtk_Widget := null; 
  92.        Label       : UTF8_String := "") return Gtk_Tool_Button; 
  93.    --  Creates a new GtkToolButton using Icon_Widget as contents and Label as 
  94.    --  label. 
  95.    --  Since: gtk+ 2.4 
  96.    --  "icon_widget": a widget that will be used as the button contents, or 
  97.    --  null 
  98.    --  "label": a string that will be used as label, or null 
  99.  
  100.    procedure Gtk_New_From_Stock 
  101.       (Button   : out Gtk_Tool_Button; 
  102.        Stock_Id : UTF8_String); 
  103.    procedure Initialize_From_Stock 
  104.       (Button   : not null access Gtk_Tool_Button_Record'Class; 
  105.        Stock_Id : UTF8_String); 
  106.    --  Creates a new Gtk.Tool_Button.Gtk_Tool_Button containing the image and 
  107.    --  text from a stock item. Some stock ids have preprocessor macros like 
  108.    --  GTK_STOCK_OK and GTK_STOCK_APPLY. 
  109.    --  It is an error if Stock_Id is not a name of a stock item. 
  110.    --  Since: gtk+ 2.4 
  111.    --  "stock_id": the name of the stock item 
  112.  
  113.    function Gtk_Tool_Button_New_From_Stock 
  114.       (Stock_Id : UTF8_String) return Gtk_Tool_Button; 
  115.    --  Creates a new Gtk.Tool_Button.Gtk_Tool_Button containing the image and 
  116.    --  text from a stock item. Some stock ids have preprocessor macros like 
  117.    --  GTK_STOCK_OK and GTK_STOCK_APPLY. 
  118.    --  It is an error if Stock_Id is not a name of a stock item. 
  119.    --  Since: gtk+ 2.4 
  120.    --  "stock_id": the name of the stock item 
  121.  
  122.    function Get_Type return Glib.GType; 
  123.    pragma Import (C, Get_Type, "gtk_tool_button_get_type"); 
  124.  
  125.    ------------- 
  126.    -- Methods -- 
  127.    ------------- 
  128.  
  129.    function Get_Icon_Name 
  130.       (Button : not null access Gtk_Tool_Button_Record) return UTF8_String; 
  131.    --  Returns the name of the themed icon for the tool button, see 
  132.    --  Gtk.Tool_Button.Set_Icon_Name. 
  133.    --  Since: gtk+ 2.8 
  134.  
  135.    procedure Set_Icon_Name 
  136.       (Button    : not null access Gtk_Tool_Button_Record; 
  137.        Icon_Name : UTF8_String := ""); 
  138.    --  Sets the icon for the tool button from a named themed icon. See the 
  139.    --  docs for Gtk.Icon_Theme.Gtk_Icon_Theme for more details. The "icon_name" 
  140.    --  property only has an effect if not overridden by non-null "label", 
  141.    --  "icon_widget" and "stock_id" properties. 
  142.    --  Since: gtk+ 2.8 
  143.    --  "icon_name": the name of the themed icon 
  144.  
  145.    function Get_Icon_Widget 
  146.       (Button : not null access Gtk_Tool_Button_Record) 
  147.        return Gtk.Widget.Gtk_Widget; 
  148.    --  Return the widget used as icon widget on Button. See 
  149.    --  Gtk.Tool_Button.Set_Icon_Widget. 
  150.    --  Since: gtk+ 2.4 
  151.  
  152.    procedure Set_Icon_Widget 
  153.       (Button      : not null access Gtk_Tool_Button_Record; 
  154.        Icon_Widget : access Gtk.Widget.Gtk_Widget_Record'Class); 
  155.    --  Sets Icon as the widget used as icon on Button. If Icon_Widget is null 
  156.    --  the icon is determined by the "stock_id" property. If the "stock_id" 
  157.    --  property is also null, Button will not have an icon. 
  158.    --  Since: gtk+ 2.4 
  159.    --  "icon_widget": the widget used as icon, or null 
  160.  
  161.    function Get_Label 
  162.       (Button : not null access Gtk_Tool_Button_Record) return UTF8_String; 
  163.    --  Returns the label used by the tool button, or null if the tool button 
  164.    --  doesn't have a label. or uses a the label from a stock item. The 
  165.    --  returned string is owned by GTK+, and must not be modified or freed. 
  166.    --  Since: gtk+ 2.4 
  167.  
  168.    procedure Set_Label 
  169.       (Button : not null access Gtk_Tool_Button_Record; 
  170.        Label  : UTF8_String := ""); 
  171.    --  Sets Label as the label used for the tool button. The "label" property 
  172.    --  only has an effect if not overridden by a non-null "label_widget" 
  173.    --  property. If both the "label_widget" and "label" properties are null, 
  174.    --  the label is determined by the "stock_id" property. If the "stock_id" 
  175.    --  property is also null, Button will not have a label. 
  176.    --  Since: gtk+ 2.4 
  177.    --  "label": a string that will be used as label, or null. 
  178.  
  179.    function Get_Label_Widget 
  180.       (Button : not null access Gtk_Tool_Button_Record) 
  181.        return Gtk.Widget.Gtk_Widget; 
  182.    --  Returns the widget used as label on Button. See 
  183.    --  Gtk.Tool_Button.Set_Label_Widget. 
  184.    --  Since: gtk+ 2.4 
  185.  
  186.    procedure Set_Label_Widget 
  187.       (Button       : not null access Gtk_Tool_Button_Record; 
  188.        Label_Widget : access Gtk.Widget.Gtk_Widget_Record'Class); 
  189.    --  Sets Label_Widget as the widget that will be used as the label for 
  190.    --  Button. If Label_Widget is null the "label" property is used as label. 
  191.    --  If "label" is also null, the label in the stock item determined by the 
  192.    --  "stock_id" property is used as label. If "stock_id" is also null, Button 
  193.    --  does not have a label. 
  194.    --  Since: gtk+ 2.4 
  195.    --  "label_widget": the widget used as label, or null 
  196.  
  197.    function Get_Stock_Id 
  198.       (Button : not null access Gtk_Tool_Button_Record) return UTF8_String; 
  199.    --  Returns the name of the stock item. See Gtk.Tool_Button.Set_Stock_Id. 
  200.    --  The returned string is owned by GTK+ and must not be freed or modifed. 
  201.    --  Since: gtk+ 2.4 
  202.  
  203.    procedure Set_Stock_Id 
  204.       (Button   : not null access Gtk_Tool_Button_Record; 
  205.        Stock_Id : UTF8_String := ""); 
  206.    --  Sets the name of the stock item. See 
  207.    --  Gtk.Tool_Button.Gtk_New_From_Stock. The stock_id property only has an 
  208.    --  effect if not overridden by non-null "label" and "icon_widget" 
  209.    --  properties. 
  210.    --  Since: gtk+ 2.4 
  211.    --  "stock_id": a name of a stock item, or null 
  212.  
  213.    function Get_Use_Underline 
  214.       (Button : not null access Gtk_Tool_Button_Record) return Boolean; 
  215.    --  Returns whether underscores in the label property are used as mnemonics 
  216.    --  on menu items on the overflow menu. See 
  217.    --  Gtk.Tool_Button.Set_Use_Underline. 
  218.    --  Since: gtk+ 2.4 
  219.  
  220.    procedure Set_Use_Underline 
  221.       (Button        : not null access Gtk_Tool_Button_Record; 
  222.        Use_Underline : Boolean); 
  223.    --  If set, an underline in the label property indicates that the next 
  224.    --  character should be used for the mnemonic accelerator key in the 
  225.    --  overflow menu. For example, if the label property is "_Open" and 
  226.    --  Use_Underline is True, the label on the tool button will be "Open" and 
  227.    --  the item on the overflow menu will have an underlined 'O'. 
  228.    --  Labels shown on tool buttons never have mnemonics on them; this 
  229.    --  property only affects the menu item on the overflow menu. 
  230.    --  Since: gtk+ 2.4 
  231.    --  "use_underline": whether the button label has the form "_Open" 
  232.  
  233.    --------------------------------------------- 
  234.    -- Inherited subprograms (from interfaces) -- 
  235.    --------------------------------------------- 
  236.    --  Methods inherited from the Buildable interface are not duplicated here 
  237.    --  since they are meant to be used by tools, mostly. If you need to call 
  238.    --  them, use an explicit cast through the "-" operator below. 
  239.  
  240.    function Get_Action_Name 
  241.       (Self : not null access Gtk_Tool_Button_Record) return UTF8_String; 
  242.  
  243.    procedure Set_Action_Name 
  244.       (Self        : not null access Gtk_Tool_Button_Record; 
  245.        Action_Name : UTF8_String); 
  246.  
  247.    function Get_Action_Target_Value 
  248.       (Self : not null access Gtk_Tool_Button_Record) 
  249.        return Glib.Variant.Gvariant; 
  250.  
  251.    procedure Set_Action_Target_Value 
  252.       (Self         : not null access Gtk_Tool_Button_Record; 
  253.        Target_Value : Glib.Variant.Gvariant); 
  254.  
  255.    procedure Set_Detailed_Action_Name 
  256.       (Self                 : not null access Gtk_Tool_Button_Record; 
  257.        Detailed_Action_Name : UTF8_String); 
  258.  
  259.    procedure Do_Set_Related_Action 
  260.       (Self   : not null access Gtk_Tool_Button_Record; 
  261.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  262.  
  263.    function Get_Related_Action 
  264.       (Self : not null access Gtk_Tool_Button_Record) 
  265.        return Gtk.Action.Gtk_Action; 
  266.  
  267.    procedure Set_Related_Action 
  268.       (Self   : not null access Gtk_Tool_Button_Record; 
  269.        Action : not null access Gtk.Action.Gtk_Action_Record'Class); 
  270.  
  271.    function Get_Use_Action_Appearance 
  272.       (Self : not null access Gtk_Tool_Button_Record) return Boolean; 
  273.  
  274.    procedure Set_Use_Action_Appearance 
  275.       (Self           : not null access Gtk_Tool_Button_Record; 
  276.        Use_Appearance : Boolean); 
  277.  
  278.    procedure Sync_Action_Properties 
  279.       (Self   : not null access Gtk_Tool_Button_Record; 
  280.        Action : access Gtk.Action.Gtk_Action_Record'Class); 
  281.  
  282.    ---------------- 
  283.    -- Properties -- 
  284.    ---------------- 
  285.    --  The following properties are defined for this widget. See 
  286.    --  Glib.Properties for more information on properties) 
  287.  
  288.    Icon_Name_Property : constant Glib.Properties.Property_String; 
  289.    --  The name of the themed icon displayed on the item. This property only 
  290.    --  has an effect if not overridden by "label", "icon_widget" or "stock_id" 
  291.    --  properties. 
  292.  
  293.    Icon_Widget_Property : constant Glib.Properties.Property_Object; 
  294.    --  Type: Gtk.Widget.Gtk_Widget 
  295.  
  296.    Label_Property : constant Glib.Properties.Property_String; 
  297.  
  298.    Label_Widget_Property : constant Glib.Properties.Property_Object; 
  299.    --  Type: Gtk.Widget.Gtk_Widget 
  300.  
  301.    Stock_Id_Property : constant Glib.Properties.Property_String; 
  302.  
  303.    Use_Underline_Property : constant Glib.Properties.Property_Boolean; 
  304.  
  305.    ------------- 
  306.    -- Signals -- 
  307.    ------------- 
  308.  
  309.    type Cb_Gtk_Tool_Button_Void is not null access procedure 
  310.      (Self : access Gtk_Tool_Button_Record'Class); 
  311.  
  312.    type Cb_GObject_Void is not null access procedure 
  313.      (Self : access Glib.Object.GObject_Record'Class); 
  314.  
  315.    Signal_Clicked : constant Glib.Signal_Name := "clicked"; 
  316.    procedure On_Clicked 
  317.       (Self  : not null access Gtk_Tool_Button_Record; 
  318.        Call  : Cb_Gtk_Tool_Button_Void; 
  319.        After : Boolean := False); 
  320.    procedure On_Clicked 
  321.       (Self  : not null access Gtk_Tool_Button_Record; 
  322.        Call  : Cb_GObject_Void; 
  323.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  324.        After : Boolean := False); 
  325.    --  This signal is emitted when the tool button is clicked with the mouse 
  326.    --  or activated with the keyboard. 
  327.  
  328.    ---------------- 
  329.    -- Interfaces -- 
  330.    ---------------- 
  331.    --  This class implements several interfaces. See Glib.Types 
  332.    -- 
  333.    --  - "Actionable" 
  334.    -- 
  335.    --  - "Activatable" 
  336.    -- 
  337.    --  - "Buildable" 
  338.  
  339.    package Implements_Gtk_Actionable is new Glib.Types.Implements 
  340.      (Gtk.Actionable.Gtk_Actionable, Gtk_Tool_Button_Record, Gtk_Tool_Button); 
  341.    function "+" 
  342.      (Widget : access Gtk_Tool_Button_Record'Class) 
  343.    return Gtk.Actionable.Gtk_Actionable 
  344.    renames Implements_Gtk_Actionable.To_Interface; 
  345.    function "-" 
  346.      (Interf : Gtk.Actionable.Gtk_Actionable) 
  347.    return Gtk_Tool_Button 
  348.    renames Implements_Gtk_Actionable.To_Object; 
  349.  
  350.    package Implements_Gtk_Activatable is new Glib.Types.Implements 
  351.      (Gtk.Activatable.Gtk_Activatable, Gtk_Tool_Button_Record, Gtk_Tool_Button); 
  352.    function "+" 
  353.      (Widget : access Gtk_Tool_Button_Record'Class) 
  354.    return Gtk.Activatable.Gtk_Activatable 
  355.    renames Implements_Gtk_Activatable.To_Interface; 
  356.    function "-" 
  357.      (Interf : Gtk.Activatable.Gtk_Activatable) 
  358.    return Gtk_Tool_Button 
  359.    renames Implements_Gtk_Activatable.To_Object; 
  360.  
  361.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  362.      (Gtk.Buildable.Gtk_Buildable, Gtk_Tool_Button_Record, Gtk_Tool_Button); 
  363.    function "+" 
  364.      (Widget : access Gtk_Tool_Button_Record'Class) 
  365.    return Gtk.Buildable.Gtk_Buildable 
  366.    renames Implements_Gtk_Buildable.To_Interface; 
  367.    function "-" 
  368.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  369.    return Gtk_Tool_Button 
  370.    renames Implements_Gtk_Buildable.To_Object; 
  371.  
  372. private 
  373.    Use_Underline_Property : constant Glib.Properties.Property_Boolean := 
  374.      Glib.Properties.Build ("use-underline"); 
  375.    Stock_Id_Property : constant Glib.Properties.Property_String := 
  376.      Glib.Properties.Build ("stock-id"); 
  377.    Label_Widget_Property : constant Glib.Properties.Property_Object := 
  378.      Glib.Properties.Build ("label-widget"); 
  379.    Label_Property : constant Glib.Properties.Property_String := 
  380.      Glib.Properties.Build ("label"); 
  381.    Icon_Widget_Property : constant Glib.Properties.Property_Object := 
  382.      Glib.Properties.Build ("icon-widget"); 
  383.    Icon_Name_Property : constant Glib.Properties.Property_String := 
  384.      Glib.Properties.Build ("icon-name"); 
  385. end Gtk.Tool_Button;