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-2013, 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. -- As a special exception, if other files instantiate generics from  -- 
  23. -- this unit, or you link this unit with other files to produce an   -- 
  24. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  25. -- executable to be covered by the GNU General Public License. This  -- 
  26. -- exception does not however invalidate any other reasons why the   -- 
  27. -- executable file  might be covered by the  GNU Public License.     -- 
  28. ----------------------------------------------------------------------- 
  29.  
  30. --  <description> 
  31. --  A Gtk_Radio_Action is similar to Gtk_Radio_Menu_Item. A number of radio 
  32. --  actions can be linked together so that only one may be active at any one 
  33. --  time. 
  34. -- 
  35. --  </description> 
  36. --  <group>Action-based menus</group> 
  37. --  <see>Gtk_Action</see> 
  38.  
  39. pragma Warnings (Off, "*is already use-visible*"); 
  40. with Glib;              use Glib; 
  41. with Glib.Properties;   use Glib.Properties; 
  42. with Glib.Types;        use Glib.Types; 
  43. with Gtk.Buildable;     use Gtk.Buildable; 
  44. with Gtk.Toggle_Action; use Gtk.Toggle_Action; 
  45. with Gtk.Widget;        use Gtk.Widget; 
  46.  
  47. package Gtk.Radio_Action is 
  48.  
  49.    type Gtk_Radio_Action_Record is new Gtk_Toggle_Action_Record with null record; 
  50.    type Gtk_Radio_Action is access all Gtk_Radio_Action_Record'Class; 
  51.  
  52.    ------------------ 
  53.    -- Constructors -- 
  54.    ------------------ 
  55.  
  56.    procedure Gtk_New 
  57.       (Action   : out Gtk_Radio_Action; 
  58.        Name     : UTF8_String; 
  59.        Label    : UTF8_String := ""; 
  60.        Tooltip  : UTF8_String := ""; 
  61.        Stock_Id : UTF8_String := ""; 
  62.        Value    : Gint); 
  63.    procedure Initialize 
  64.       (Action   : access Gtk_Radio_Action_Record'Class; 
  65.        Name     : UTF8_String; 
  66.        Label    : UTF8_String := ""; 
  67.        Tooltip  : UTF8_String := ""; 
  68.        Stock_Id : UTF8_String := ""; 
  69.        Value    : Gint); 
  70.    --  Creates a new Gtk.Radio_Action.Gtk_Radio_Action object. To add the 
  71.    --  action to a Gtk.Actiongroup.Gtk_Actiongroup and set the accelerator for 
  72.    --  the action, call Gtk.Action_Group.Add_Action_With_Accel. 
  73.    --  Since: gtk+ 2.4 
  74.    --  "name": A unique name for the action 
  75.    --  "label": The label displayed in menu items and on buttons, or null 
  76.    --  "tooltip": A tooltip for this action, or null 
  77.    --  "stock_id": The stock icon to display in widgets representing this 
  78.    --  action, or null 
  79.    --  "value": The value which Gtk.Radio_Action.Get_Current_Value should 
  80.    --  return if this action is selected. 
  81.  
  82.    function Get_Type return Glib.GType; 
  83.    pragma Import (C, Get_Type, "gtk_radio_action_get_type"); 
  84.  
  85.    ------------- 
  86.    -- Methods -- 
  87.    ------------- 
  88.  
  89.    function Get_Current_Value 
  90.       (Action : access Gtk_Radio_Action_Record) return Gint; 
  91.    procedure Set_Current_Value 
  92.       (Action        : access Gtk_Radio_Action_Record; 
  93.        Current_Value : Gint); 
  94.    --  Sets the currently active group member to the member with value 
  95.    --  property Current_Value. 
  96.    --  Since: gtk+ 2.10 
  97.    --  "current_value": the new value 
  98.  
  99.    function Get_Group 
  100.       (Action : access Gtk_Radio_Action_Record) 
  101.        return Gtk.Widget.Widget_SList.GSlist; 
  102.    procedure Set_Group 
  103.       (Action : access Gtk_Radio_Action_Record; 
  104.        Group  : Gtk.Widget.Widget_SList.GSlist); 
  105.    --  Sets the radio group for the radio action object. 
  106.    --  A common way to set up a group of radio group is the following: 
  107.    --       Group  : GSlist := null; 
  108.    --       Action : Gtk_Radio_Action; 
  109.    --       while ... loop 
  110.    --          Gtk_New (Action, ...); 
  111.    --          Set_Group (Action, Group); 
  112.    --          Group := Get_Group (Action); 
  113.    --       end loop; 
  114.    --  Since: gtk+ 2.4 
  115.    --  "group": a list representing a radio group 
  116.  
  117.    ---------------- 
  118.    -- Interfaces -- 
  119.    ---------------- 
  120.    --  This class implements several interfaces. See Glib.Types 
  121.    -- 
  122.    --  - "Buildable" 
  123.  
  124.    package Implements_Buildable is new Glib.Types.Implements 
  125.      (Gtk.Buildable.Gtk_Buildable, Gtk_Radio_Action_Record, Gtk_Radio_Action); 
  126.    function "+" 
  127.      (Widget : access Gtk_Radio_Action_Record'Class) 
  128.    return Gtk.Buildable.Gtk_Buildable 
  129.    renames Implements_Buildable.To_Interface; 
  130.    function "-" 
  131.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  132.    return Gtk_Radio_Action 
  133.    renames Implements_Buildable.To_Object; 
  134.  
  135.    ---------------- 
  136.    -- Properties -- 
  137.    ---------------- 
  138.    --  The following properties are defined for this widget. See 
  139.    --  Glib.Properties for more information on properties) 
  140.    -- 
  141.    --  Name: Current_Value_Property 
  142.    --  Type: Gint 
  143.    --  Flags: read-write 
  144.    --  The value property of the currently active member of the group to which 
  145.    --  this action belongs. 
  146.    -- 
  147.    --  Name: Group_Property 
  148.    --  Type: Gtk_Radio_Action 
  149.    --  Flags: write 
  150.    --  Sets a new group for a radio action. 
  151.    -- 
  152.    --  Name: Value_Property 
  153.    --  Type: Gint 
  154.    --  Flags: read-write 
  155.    --  The value is an arbitrary integer which can be used as a convenient way 
  156.    --  to determine which action in the group is currently active in an 
  157.    --  ::activate or ::changed signal handler. See 
  158.    --  Gtk.Radio_Action.Get_Current_Value and GtkRadioActionEntry for 
  159.    --  convenient ways to get and set this property. 
  160.  
  161.    Current_Value_Property : constant Glib.Properties.Property_Int; 
  162.    Group_Property : constant Glib.Properties.Property_Object; 
  163.    Value_Property : constant Glib.Properties.Property_Int; 
  164.  
  165.    ------------- 
  166.    -- Signals -- 
  167.    ------------- 
  168.    --  The following new signals are defined for this widget: 
  169.    -- 
  170.    --  "changed" 
  171.    --     procedure Handler 
  172.    --       (Self    : access Gtk_Radio_Action_Record'Class; 
  173.    --        Current : Gtk_Radio_Action); 
  174.    --    --  "current": the member of Action<!-- -->s group which has just been 
  175.    --    --  activated 
  176.    --  The ::changed signal is emitted on every member of a radio group when 
  177.    --  the active member is changed. The signal gets emitted after the 
  178.    --  ::activate signals for the previous and current active members. 
  179.  
  180.    Signal_Changed : constant Glib.Signal_Name := "changed"; 
  181.  
  182. private 
  183.    Current_Value_Property : constant Glib.Properties.Property_Int := 
  184.      Glib.Properties.Build ("current-value"); 
  185.    Group_Property : constant Glib.Properties.Property_Object := 
  186.      Glib.Properties.Build ("group"); 
  187.    Value_Property : constant Glib.Properties.Property_Int := 
  188.      Glib.Properties.Build ("value"); 
  189. end Gtk.Radio_Action;