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.Radio_Action.Gtk_Radio_Action is similar to 
  26. --  Gtk.Radio_Menu_Item.Gtk_Radio_Menu_Item. A number of radio actions can be 
  27. --  linked together so that only one may be active at any one time. 
  28. -- 
  29. --  </description> 
  30. --  <group>Action-based menus</group> 
  31. --  <see>Gtk_Action</see> 
  32. pragma Ada_2005; 
  33.  
  34. pragma Warnings (Off, "*is already use-visible*"); 
  35. with Glib;              use Glib; 
  36. with Glib.Object;       use Glib.Object; 
  37. with Glib.Properties;   use Glib.Properties; 
  38. with Glib.Types;        use Glib.Types; 
  39. with Gtk.Buildable;     use Gtk.Buildable; 
  40. with Gtk.Toggle_Action; use Gtk.Toggle_Action; 
  41. with Gtk.Widget;        use Gtk.Widget; 
  42.  
  43. package Gtk.Radio_Action is 
  44.  
  45.    type Gtk_Radio_Action_Record is new Gtk_Toggle_Action_Record with null record; 
  46.    type Gtk_Radio_Action is access all Gtk_Radio_Action_Record'Class; 
  47.  
  48.    ------------------ 
  49.    -- Constructors -- 
  50.    ------------------ 
  51.  
  52.    procedure Gtk_New 
  53.       (Action   : out Gtk_Radio_Action; 
  54.        Name     : UTF8_String; 
  55.        Label    : UTF8_String := ""; 
  56.        Tooltip  : UTF8_String := ""; 
  57.        Stock_Id : UTF8_String := ""; 
  58.        Value    : Gint); 
  59.    procedure Initialize 
  60.       (Action   : not null access Gtk_Radio_Action_Record'Class; 
  61.        Name     : UTF8_String; 
  62.        Label    : UTF8_String := ""; 
  63.        Tooltip  : UTF8_String := ""; 
  64.        Stock_Id : UTF8_String := ""; 
  65.        Value    : Gint); 
  66.    --  Creates a new Gtk.Radio_Action.Gtk_Radio_Action object. To add the 
  67.    --  action to a Gtk.Action_Group.Gtk_Action_Group and set the accelerator 
  68.    --  for the action, call Gtk.Action_Group.Add_Action_With_Accel. 
  69.    --  Since: gtk+ 2.4 
  70.    --  "name": A unique name for the action 
  71.    --  "label": The label displayed in menu items and on buttons, or null 
  72.    --  "tooltip": A tooltip for this action, or null 
  73.    --  "stock_id": The stock icon to display in widgets representing this 
  74.    --  action, or null 
  75.    --  "value": The value which Gtk.Radio_Action.Get_Current_Value should 
  76.    --  return if this action is selected. 
  77.  
  78.    function Gtk_Radio_Action_New 
  79.       (Name     : UTF8_String; 
  80.        Label    : UTF8_String := ""; 
  81.        Tooltip  : UTF8_String := ""; 
  82.        Stock_Id : UTF8_String := ""; 
  83.        Value    : Gint) return Gtk_Radio_Action; 
  84.    --  Creates a new Gtk.Radio_Action.Gtk_Radio_Action object. To add the 
  85.    --  action to a Gtk.Action_Group.Gtk_Action_Group and set the accelerator 
  86.    --  for the action, call Gtk.Action_Group.Add_Action_With_Accel. 
  87.    --  Since: gtk+ 2.4 
  88.    --  "name": A unique name for the action 
  89.    --  "label": The label displayed in menu items and on buttons, or null 
  90.    --  "tooltip": A tooltip for this action, or null 
  91.    --  "stock_id": The stock icon to display in widgets representing this 
  92.    --  action, or null 
  93.    --  "value": The value which Gtk.Radio_Action.Get_Current_Value should 
  94.    --  return if this action is selected. 
  95.  
  96.    function Get_Type return Glib.GType; 
  97.    pragma Import (C, Get_Type, "gtk_radio_action_get_type"); 
  98.  
  99.    ------------- 
  100.    -- Methods -- 
  101.    ------------- 
  102.  
  103.    function Get_Current_Value 
  104.       (Action : not null access Gtk_Radio_Action_Record) return Gint; 
  105.    --  Obtains the value property of the currently active member of the group 
  106.    --  to which Action belongs. 
  107.    --  Since: gtk+ 2.4 
  108.  
  109.    procedure Set_Current_Value 
  110.       (Action        : not null access Gtk_Radio_Action_Record; 
  111.        Current_Value : Gint); 
  112.    --  Sets the currently active group member to the member with value 
  113.    --  property Current_Value. 
  114.    --  Since: gtk+ 2.10 
  115.    --  "current_value": the new value 
  116.  
  117.    function Get_Group 
  118.       (Action : not null access Gtk_Radio_Action_Record) 
  119.        return Gtk.Widget.Widget_SList.GSlist; 
  120.    --  Returns the list representing the radio group for this object. Note 
  121.    --  that the returned list is only valid until the next change to the group. 
  122.    --  A common way to set up a group of radio group is the following: |[ 
  123.    --  GSList *group = NULL; GtkRadioAction *action; while (/* more actions to 
  124.    --  add */) { action = gtk_radio_action_new (...); 
  125.    --  gtk_radio_action_set_group (action, group); group = 
  126.    --  gtk_radio_action_get_group (action); } ]| 
  127.    --  Since: gtk+ 2.4 
  128.  
  129.    procedure Set_Group 
  130.       (Action : not null access Gtk_Radio_Action_Record; 
  131.        Group  : Gtk.Widget.Widget_SList.GSlist); 
  132.    --  Sets the radio group for the radio action object. 
  133.    --  A common way to set up a group of radio group is the following: 
  134.    --       Group  : GSlist := null; 
  135.    --       Action : Gtk_Radio_Action; 
  136.    --       while ... loop 
  137.    --          Gtk_New (Action, ...); 
  138.    --          Set_Group (Action, Group); 
  139.    --          Group := Get_Group (Action); 
  140.    --       end loop; 
  141.    --  Since: gtk+ 2.4 
  142.    --  "group": a list representing a radio group 
  143.  
  144.    procedure Join_Group 
  145.       (Action       : not null access Gtk_Radio_Action_Record; 
  146.        Group_Source : access Gtk_Radio_Action_Record'Class); 
  147.    --  Joins a radio action object to the group of another radio action 
  148.    --  object. 
  149.    --  Use this in language bindings instead of the Gtk.Radio_Action.Get_Group 
  150.    --  and Gtk.Radio_Action.Set_Group methods 
  151.    --  A common way to set up a group of radio actions is the following: |[ 
  152.    --  GtkRadioAction *action; GtkRadioAction *last_action; while (/* more 
  153.    --  actions to add */) { action = gtk_radio_action_new (...); 
  154.    --  gtk_radio_action_join_group (action, last_action); last_action = action; 
  155.    --  } ]| 
  156.    --  Since: gtk+ 3.0 
  157.    --  "group_source": a radio action object whos group we are joining, or 
  158.    --  null to remove the radio action from its group 
  159.  
  160.    ---------------- 
  161.    -- Properties -- 
  162.    ---------------- 
  163.    --  The following properties are defined for this widget. See 
  164.    --  Glib.Properties for more information on properties) 
  165.  
  166.    Current_Value_Property : constant Glib.Properties.Property_Int; 
  167.    --  The value property of the currently active member of the group to which 
  168.    --  this action belongs. 
  169.  
  170.    Group_Property : constant Glib.Properties.Property_Object; 
  171.    --  Type: Gtk_Radio_Action 
  172.    --  Flags: write 
  173.    --  Sets a new group for a radio action. 
  174.  
  175.    Value_Property : constant Glib.Properties.Property_Int; 
  176.    --  The value is an arbitrary integer which can be used as a convenient way 
  177.    --  to determine which action in the group is currently active in an 
  178.    --  ::activate or ::changed signal handler. See 
  179.    --  Gtk.Radio_Action.Get_Current_Value and Gtk_Radio_Action_Entry for 
  180.    --  convenient ways to get and set this property. 
  181.  
  182.    ------------- 
  183.    -- Signals -- 
  184.    ------------- 
  185.  
  186.    type Cb_Gtk_Radio_Action_Gtk_Radio_Action_Void is not null access procedure 
  187.      (Self    : access Gtk_Radio_Action_Record'Class; 
  188.       Current : not null access Gtk_Radio_Action_Record'Class); 
  189.  
  190.    type Cb_GObject_Gtk_Radio_Action_Void is not null access procedure 
  191.      (Self    : access Glib.Object.GObject_Record'Class; 
  192.       Current : not null access Gtk_Radio_Action_Record'Class); 
  193.  
  194.    Signal_Changed : constant Glib.Signal_Name := "changed"; 
  195.    procedure On_Changed 
  196.       (Self  : not null access Gtk_Radio_Action_Record; 
  197.        Call  : Cb_Gtk_Radio_Action_Gtk_Radio_Action_Void; 
  198.        After : Boolean := False); 
  199.    procedure On_Changed 
  200.       (Self  : not null access Gtk_Radio_Action_Record; 
  201.        Call  : Cb_GObject_Gtk_Radio_Action_Void; 
  202.        Slot  : not null access Glib.Object.GObject_Record'Class; 
  203.        After : Boolean := False); 
  204.    --  The ::changed signal is emitted on every member of a radio group when 
  205.    --  the active member is changed. The signal gets emitted after the 
  206.    --  ::activate signals for the previous and current active members. 
  207.  
  208.    ---------------- 
  209.    -- Interfaces -- 
  210.    ---------------- 
  211.    --  This class implements several interfaces. See Glib.Types 
  212.    -- 
  213.    --  - "Buildable" 
  214.  
  215.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  216.      (Gtk.Buildable.Gtk_Buildable, Gtk_Radio_Action_Record, Gtk_Radio_Action); 
  217.    function "+" 
  218.      (Widget : access Gtk_Radio_Action_Record'Class) 
  219.    return Gtk.Buildable.Gtk_Buildable 
  220.    renames Implements_Gtk_Buildable.To_Interface; 
  221.    function "-" 
  222.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  223.    return Gtk_Radio_Action 
  224.    renames Implements_Gtk_Buildable.To_Object; 
  225.  
  226. private 
  227.    Value_Property : constant Glib.Properties.Property_Int := 
  228.      Glib.Properties.Build ("value"); 
  229.    Group_Property : constant Glib.Properties.Property_Object := 
  230.      Glib.Properties.Build ("group"); 
  231.    Current_Value_Property : constant Glib.Properties.Property_Int := 
  232.      Glib.Properties.Build ("current-value"); 
  233. end Gtk.Radio_Action;