1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2011, AdaCore                   -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  A Gtk_Radio_Action is similar to Gtk_Radio_Menu_Item. A number of radio 
  27. --  actions can be linked together so that only one may be active at any one 
  28. --  time. 
  29. -- 
  30. --  </description> 
  31. --  <group>Action-based menus</group> 
  32. --  <see>Gtk_Action</see> 
  33.  
  34. pragma Warnings (Off, "*is already use-visible*"); 
  35. with Glib;              use Glib; 
  36. with Glib.Properties;   use Glib.Properties; 
  37. with Glib.Types;        use Glib.Types; 
  38. with Gtk.Buildable;     use Gtk.Buildable; 
  39. with Gtk.Toggle_Action; use Gtk.Toggle_Action; 
  40. with Gtk.Widget;        use Gtk.Widget; 
  41.  
  42. package Gtk.Radio_Action is 
  43.  
  44.    type Gtk_Radio_Action_Record is new Gtk_Toggle_Action_Record with null record; 
  45.    type Gtk_Radio_Action is access all Gtk_Radio_Action_Record'Class; 
  46.  
  47.    ------------------ 
  48.    -- Constructors -- 
  49.    ------------------ 
  50.  
  51.    procedure Gtk_New 
  52.       (Action   : out Gtk_Radio_Action; 
  53.        Name     : UTF8_String; 
  54.        Label    : UTF8_String := ""; 
  55.        Tooltip  : UTF8_String := ""; 
  56.        Stock_Id : UTF8_String := ""; 
  57.        Value    : Gint); 
  58.    procedure Initialize 
  59.       (Action   : access Gtk_Radio_Action_Record'Class; 
  60.        Name     : UTF8_String; 
  61.        Label    : UTF8_String := ""; 
  62.        Tooltip  : UTF8_String := ""; 
  63.        Stock_Id : UTF8_String := ""; 
  64.        Value    : Gint); 
  65.    --  Creates a new Gtk.Radio_Action.Gtk_Radio_Action object. To add the 
  66.    --  action to a Gtk.Actiongroup.Gtk_Actiongroup and set the accelerator for 
  67.    --  the action, call Gtk.Action_Group.Add_Action_With_Accel. 
  68.    --  Since: gtk+ 2.4 
  69.    --  "name": A unique name for the action 
  70.    --  "label": The label displayed in menu items and on buttons, or null 
  71.    --  "tooltip": A tooltip for this action, or null 
  72.    --  "stock_id": The stock icon to display in widgets representing this 
  73.    --  action, or null 
  74.    --  "value": The value which Gtk.Radio_Action.Get_Current_Value should 
  75.    --  return if this action is selected. 
  76.  
  77.    function Get_Type return Glib.GType; 
  78.    pragma Import (C, Get_Type, "gtk_radio_action_get_type"); 
  79.  
  80.    ------------- 
  81.    -- Methods -- 
  82.    ------------- 
  83.  
  84.    function Get_Current_Value 
  85.       (Action : access Gtk_Radio_Action_Record) return Gint; 
  86.    procedure Set_Current_Value 
  87.       (Action        : access Gtk_Radio_Action_Record; 
  88.        Current_Value : Gint); 
  89.    --  Sets the currently active group member to the member with value 
  90.    --  property Current_Value. 
  91.    --  Since: gtk+ 2.10 
  92.    --  "current_value": the new value 
  93.  
  94.    function Get_Group 
  95.       (Action : access Gtk_Radio_Action_Record) 
  96.        return Gtk.Widget.Widget_SList.GSList; 
  97.    procedure Set_Group 
  98.       (Action : access Gtk_Radio_Action_Record; 
  99.        Group  : Gtk.Widget.Widget_SList.GSList); 
  100.    --  Sets the radio group for the radio action object. 
  101.    --  A common way to set up a group of radio group is the following: 
  102.    --       Group  : GSlist := null; 
  103.    --       Action : Gtk_Radio_Action; 
  104.    --       while ... loop 
  105.    --          Gtk_New (Action, ...); 
  106.    --          Set_Group (Action, Group); 
  107.    --          Group := Get_Group (Action); 
  108.    --       end loop; 
  109.    --  Since: gtk+ 2.4 
  110.    --  "group": a list representing a radio group 
  111.  
  112.    ---------------- 
  113.    -- Interfaces -- 
  114.    ---------------- 
  115.    --  This class implements several interfaces. See Glib.Types 
  116.    -- 
  117.    --  - "Buildable" 
  118.  
  119.    package Implements_Buildable is new Glib.Types.Implements 
  120.      (Gtk.Buildable.Gtk_Buildable, Gtk_Radio_Action_Record, Gtk_Radio_Action); 
  121.    function "+" 
  122.      (Widget : access Gtk_Radio_Action_Record'Class) 
  123.    return Gtk.Buildable.Gtk_Buildable 
  124.    renames Implements_Buildable.To_Interface; 
  125.    function "-" 
  126.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  127.    return Gtk_Radio_Action 
  128.    renames Implements_Buildable.To_Object; 
  129.  
  130.    ---------------- 
  131.    -- Properties -- 
  132.    ---------------- 
  133.    --  The following properties are defined for this widget. See 
  134.    --  Glib.Properties for more information on properties) 
  135.    -- 
  136.    --  Name: Current_Value_Property 
  137.    --  Type: Gint 
  138.    --  Flags: read-write 
  139.    --  The value property of the currently active member of the group to which 
  140.    --  this action belongs. 
  141.    -- 
  142.    --  Name: Group_Property 
  143.    --  Type: Gtk.Radio_Action.Gtk_Radio_Action 
  144.    --  Flags: write 
  145.    --  Sets a new group for a radio action. 
  146.    -- 
  147.    --  Name: Value_Property 
  148.    --  Type: Gint 
  149.    --  Flags: read-write 
  150.    --  The value is an arbitrary integer which can be used as a convenient way 
  151.    --  to determine which action in the group is currently active in an 
  152.    --  ::activate or ::changed signal handler. See 
  153.    --  Gtk.Radio_Action.Get_Current_Value and GtkRadioActionEntry for 
  154.    --  convenient ways to get and set this property. 
  155.  
  156.    Current_Value_Property : constant Glib.Properties.Property_Int; 
  157.    Group_Property : constant Glib.Properties.Property_Object; 
  158.    Value_Property : constant Glib.Properties.Property_Int; 
  159.  
  160.    ------------- 
  161.    -- Signals -- 
  162.    ------------- 
  163.    --  The following new signals are defined for this widget: 
  164.    -- 
  165.    --  "changed" 
  166.    --     procedure Handler 
  167.    --       (Self    : access Gtk_Radio_Action_Record'Class; 
  168.    --        Current : Gtk.Radio_Action.Gtk_Radio_Action); 
  169.    --    --  "current": the member of Action<!-- -->s group which has just been 
  170.    --    --  activated 
  171.    --  The ::changed signal is emitted on every member of a radio group when 
  172.    --  the active member is changed. The signal gets emitted after the 
  173.    --  ::activate signals for the previous and current active members. 
  174.  
  175.    Signal_Changed : constant Glib.Signal_Name := "changed"; 
  176.  
  177. private 
  178.    Current_Value_Property : constant Glib.Properties.Property_Int := 
  179.      Glib.Properties.Build ("current-value"); 
  180.    Group_Property : constant Glib.Properties.Property_Object := 
  181.      Glib.Properties.Build ("group"); 
  182.    Value_Property : constant Glib.Properties.Property_Int := 
  183.      Glib.Properties.Build ("value"); 
  184. end Gtk.Radio_Action;