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.Toggle_Action.Gtk_Toggle_Action corresponds roughly to a 
  26. --  Gtk.Check_Menu_Item.Gtk_Check_Menu_Item. It has an "active" state 
  27. --  specifying whether the action has been checked or not. 
  28. -- 
  29. --  </description> 
  30. pragma Ada_2005; 
  31.  
  32. pragma Warnings (Off, "*is already use-visible*"); 
  33. with Glib;            use Glib; 
  34. with Glib.Object;     use Glib.Object; 
  35. with Glib.Properties; use Glib.Properties; 
  36. with Glib.Types;      use Glib.Types; 
  37. with Gtk.Action;      use Gtk.Action; 
  38. with Gtk.Buildable;   use Gtk.Buildable; 
  39.  
  40. package Gtk.Toggle_Action is 
  41.  
  42.    type Gtk_Toggle_Action_Record is new Gtk_Action_Record with null record; 
  43.    type Gtk_Toggle_Action is access all Gtk_Toggle_Action_Record'Class; 
  44.  
  45.    ------------------ 
  46.    -- Constructors -- 
  47.    ------------------ 
  48.  
  49.    procedure Gtk_New 
  50.       (Action   : out Gtk_Toggle_Action; 
  51.        Name     : UTF8_String; 
  52.        Label    : UTF8_String := ""; 
  53.        Tooltip  : UTF8_String := ""; 
  54.        Stock_Id : UTF8_String := ""); 
  55.    procedure Initialize 
  56.       (Action   : not null access Gtk_Toggle_Action_Record'Class; 
  57.        Name     : UTF8_String; 
  58.        Label    : UTF8_String := ""; 
  59.        Tooltip  : UTF8_String := ""; 
  60.        Stock_Id : UTF8_String := ""); 
  61.    --  Creates a new Gtk.Toggle_Action.Gtk_Toggle_Action object. To add the 
  62.    --  action to a Gtk.Action_Group.Gtk_Action_Group and set the accelerator 
  63.    --  for the action, call Gtk.Action_Group.Add_Action_With_Accel. 
  64.    --  Since: gtk+ 2.4 
  65.    --  "name": A unique name for the action 
  66.    --  "label": The label displayed in menu items and on buttons, or null 
  67.    --  "tooltip": A tooltip for the action, or null 
  68.    --  "stock_id": The stock icon to display in widgets representing the 
  69.    --  action, or null 
  70.  
  71.    function Gtk_Toggle_Action_New 
  72.       (Name     : UTF8_String; 
  73.        Label    : UTF8_String := ""; 
  74.        Tooltip  : UTF8_String := ""; 
  75.        Stock_Id : UTF8_String := "") return Gtk_Toggle_Action; 
  76.    --  Creates a new Gtk.Toggle_Action.Gtk_Toggle_Action object. To add the 
  77.    --  action to a Gtk.Action_Group.Gtk_Action_Group and set the accelerator 
  78.    --  for the action, call Gtk.Action_Group.Add_Action_With_Accel. 
  79.    --  Since: gtk+ 2.4 
  80.    --  "name": A unique name for the action 
  81.    --  "label": The label displayed in menu items and on buttons, or null 
  82.    --  "tooltip": A tooltip for the action, or null 
  83.    --  "stock_id": The stock icon to display in widgets representing the 
  84.    --  action, or null 
  85.  
  86.    function Get_Type return Glib.GType; 
  87.    pragma Import (C, Get_Type, "gtk_toggle_action_get_type"); 
  88.  
  89.    ------------- 
  90.    -- Methods -- 
  91.    ------------- 
  92.  
  93.    function Get_Active 
  94.       (Action : not null access Gtk_Toggle_Action_Record) return Boolean; 
  95.    --  Returns the checked state of the toggle action. 
  96.    --  Since: gtk+ 2.4 
  97.  
  98.    procedure Set_Active 
  99.       (Action    : not null access Gtk_Toggle_Action_Record; 
  100.        Is_Active : Boolean); 
  101.    --  Sets the checked state on the toggle action. 
  102.    --  Since: gtk+ 2.4 
  103.    --  "is_active": whether the action should be checked or not 
  104.  
  105.    function Get_Draw_As_Radio 
  106.       (Action : not null access Gtk_Toggle_Action_Record) return Boolean; 
  107.    --  Returns whether the action should have proxies like a radio action. 
  108.    --  Since: gtk+ 2.4 
  109.  
  110.    procedure Set_Draw_As_Radio 
  111.       (Action        : not null access Gtk_Toggle_Action_Record; 
  112.        Draw_As_Radio : Boolean); 
  113.    --  Sets whether the action should have proxies like a radio action. 
  114.    --  Since: gtk+ 2.4 
  115.    --  "draw_as_radio": whether the action should have proxies like a radio 
  116.    --  action 
  117.  
  118.    procedure Toggled (Action : not null access Gtk_Toggle_Action_Record); 
  119.    --  Emits the "toggled" signal on the toggle action. 
  120.    --  Since: gtk+ 2.4 
  121.  
  122.    ---------------- 
  123.    -- Properties -- 
  124.    ---------------- 
  125.    --  The following properties are defined for this widget. See 
  126.    --  Glib.Properties for more information on properties) 
  127.  
  128.    Active_Property : constant Glib.Properties.Property_Boolean; 
  129.    --  Whether the toggle action should be active. 
  130.  
  131.    Draw_As_Radio_Property : constant Glib.Properties.Property_Boolean; 
  132.    --  Whether the proxies for this action look like radio action proxies. 
  133.    -- 
  134.    --  This is an appearance property and thus only applies if 
  135.    --  Gtk.Activatable.Gtk_Activatable:use-action-appearance is True. 
  136.  
  137.    ------------- 
  138.    -- Signals -- 
  139.    ------------- 
  140.  
  141.    type Cb_Gtk_Toggle_Action_Void is not null access procedure 
  142.      (Self : access Gtk_Toggle_Action_Record'Class); 
  143.  
  144.    type Cb_GObject_Void is not null access procedure 
  145.      (Self : access Glib.Object.GObject_Record'Class); 
  146.  
  147.    Signal_Toggled : constant Glib.Signal_Name := "toggled"; 
  148.    procedure On_Toggled 
  149.       (Self  : not null access Gtk_Toggle_Action_Record; 
  150.        Call  : Cb_Gtk_Toggle_Action_Void; 
  151.        After : Boolean := False); 
  152.    procedure On_Toggled 
  153.       (Self  : not null access Gtk_Toggle_Action_Record; 
  154.        Call  : Cb_GObject_Void; 
  155.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  156.        After : Boolean := False); 
  157.    --  Should be connected if you wish to perform an action whenever the 
  158.    --  Gtk.Toggle_Action.Gtk_Toggle_Action state is changed. 
  159.  
  160.    ---------------- 
  161.    -- Interfaces -- 
  162.    ---------------- 
  163.    --  This class implements several interfaces. See Glib.Types 
  164.    -- 
  165.    --  - "Buildable" 
  166.  
  167.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  168.      (Gtk.Buildable.Gtk_Buildable, Gtk_Toggle_Action_Record, Gtk_Toggle_Action); 
  169.    function "+" 
  170.      (Widget : access Gtk_Toggle_Action_Record'Class) 
  171.    return Gtk.Buildable.Gtk_Buildable 
  172.    renames Implements_Gtk_Buildable.To_Interface; 
  173.    function "-" 
  174.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  175.    return Gtk_Toggle_Action 
  176.    renames Implements_Gtk_Buildable.To_Object; 
  177.  
  178. private 
  179.    Draw_As_Radio_Property : constant Glib.Properties.Property_Boolean := 
  180.      Glib.Properties.Build ("draw-as-radio"); 
  181.    Active_Property : constant Glib.Properties.Property_Boolean := 
  182.      Glib.Properties.Build ("active"); 
  183. end Gtk.Toggle_Action;