1------------------------------------------------------------------------------ 2-- -- 3-- Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet -- 4-- Copyright (C) 2000-2015, 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> 32pragma Ada_2005; 33 34pragma Warnings (Off, "*is already use-visible*"); 35with Glib; use Glib; 36with Glib.Object; use Glib.Object; 37with Glib.Properties; use Glib.Properties; 38with Glib.Types; use Glib.Types; 39with Gtk.Buildable; use Gtk.Buildable; 40with Gtk.Toggle_Action; use Gtk.Toggle_Action; 41with Gtk.Widget; use Gtk.Widget; 42 43package 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 pragma Obsolescent (Get_Current_Value); 106 -- Obtains the value property of the currently active member of the group 107 -- to which Action belongs. 108 -- Since: gtk+ 2.4 109 -- Deprecated since 3.10, 1 110 111 procedure Set_Current_Value 112 (Action : not null access Gtk_Radio_Action_Record; 113 Current_Value : Gint); 114 pragma Obsolescent (Set_Current_Value); 115 -- Sets the currently active group member to the member with value 116 -- property Current_Value. 117 -- Since: gtk+ 2.10 118 -- Deprecated since 3.10, 1 119 -- "current_value": the new value 120 121 function Get_Group 122 (Action : not null access Gtk_Radio_Action_Record) 123 return Gtk.Widget.Widget_SList.GSlist; 124 pragma Obsolescent (Get_Group); 125 -- Returns the list representing the radio group for this object. Note 126 -- that the returned list is only valid until the next change to the group. 127 -- A common way to set up a group of radio group is the following: |[<!-- 128 -- language="C" --> GSList *group = NULL; GtkRadioAction *action; while ( 129 -- ...more actions to add... /) { action = gtk_radio_action_new (...); 130 -- gtk_radio_action_set_group (action, group); group = 131 -- gtk_radio_action_get_group (action); } ]| 132 -- Since: gtk+ 2.4 133 -- Deprecated since 3.10, 1 134 135 procedure Set_Group 136 (Action : not null access Gtk_Radio_Action_Record; 137 Group : Gtk.Widget.Widget_SList.GSlist); 138 pragma Obsolescent (Set_Group); 139 -- Sets the radio group for the radio action object. 140 -- A common way to set up a group of radio group is the following: 141 -- Group : GSlist := null; 142 -- Action : Gtk_Radio_Action; 143 -- while ... loop 144 -- Gtk_New (Action, ...); 145 -- Set_Group (Action, Group); 146 -- Group := Get_Group (Action); 147 -- end loop; 148 -- Since: gtk+ 2.4 149 -- Deprecated since 3.10, 1 150 -- "group": a list representing a radio group, or null 151 152 procedure Join_Group 153 (Action : not null access Gtk_Radio_Action_Record; 154 Group_Source : access Gtk_Radio_Action_Record'Class); 155 pragma Obsolescent (Join_Group); 156 -- Joins a radio action object to the group of another radio action 157 -- object. 158 -- Use this in language bindings instead of the Gtk.Radio_Action.Get_Group 159 -- and Gtk.Radio_Action.Set_Group methods 160 -- A common way to set up a group of radio actions is the following: 161 -- |[<!-- language="C" --> GtkRadioAction *action; GtkRadioAction 162 -- *last_action; while ( ...more actions to add... /) { action = 163 -- gtk_radio_action_new (...); gtk_radio_action_join_group (action, 164 -- last_action); last_action = action; } ]| 165 -- Since: gtk+ 3.0 166 -- Deprecated since 3.10, 1 167 -- "group_source": a radio action object whos group we are joining, or 168 -- null to remove the radio action from its group 169 170 ---------------- 171 -- Properties -- 172 ---------------- 173 -- The following properties are defined for this widget. See 174 -- Glib.Properties for more information on properties) 175 176 Current_Value_Property : constant Glib.Properties.Property_Int; 177 -- The value property of the currently active member of the group to which 178 -- this action belongs. 179 180 Group_Property : constant Glib.Properties.Property_Object; 181 -- Type: Gtk_Radio_Action 182 -- Flags: write 183 -- Sets a new group for a radio action. 184 185 Value_Property : constant Glib.Properties.Property_Int; 186 -- The value is an arbitrary integer which can be used as a convenient way 187 -- to determine which action in the group is currently active in an 188 -- ::activate or ::changed signal handler. See 189 -- Gtk.Radio_Action.Get_Current_Value and Gtk_Radio_Action_Entry for 190 -- convenient ways to get and set this property. 191 192 ------------- 193 -- Signals -- 194 ------------- 195 196 type Cb_Gtk_Radio_Action_Gtk_Radio_Action_Void is not null access procedure 197 (Self : access Gtk_Radio_Action_Record'Class; 198 Current : not null access Gtk_Radio_Action_Record'Class); 199 200 type Cb_GObject_Gtk_Radio_Action_Void is not null access procedure 201 (Self : access Glib.Object.GObject_Record'Class; 202 Current : not null access Gtk_Radio_Action_Record'Class); 203 204 Signal_Changed : constant Glib.Signal_Name := "changed"; 205 procedure On_Changed 206 (Self : not null access Gtk_Radio_Action_Record; 207 Call : Cb_Gtk_Radio_Action_Gtk_Radio_Action_Void; 208 After : Boolean := False); 209 procedure On_Changed 210 (Self : not null access Gtk_Radio_Action_Record; 211 Call : Cb_GObject_Gtk_Radio_Action_Void; 212 Slot : not null access Glib.Object.GObject_Record'Class; 213 After : Boolean := False); 214 -- The ::changed signal is emitted on every member of a radio group when 215 -- the active member is changed. The signal gets emitted after the 216 -- ::activate signals for the previous and current active members. 217 218 ---------------- 219 -- Interfaces -- 220 ---------------- 221 -- This class implements several interfaces. See Glib.Types 222 -- 223 -- - "Buildable" 224 225 package Implements_Gtk_Buildable is new Glib.Types.Implements 226 (Gtk.Buildable.Gtk_Buildable, Gtk_Radio_Action_Record, Gtk_Radio_Action); 227 function "+" 228 (Widget : access Gtk_Radio_Action_Record'Class) 229 return Gtk.Buildable.Gtk_Buildable 230 renames Implements_Gtk_Buildable.To_Interface; 231 function "-" 232 (Interf : Gtk.Buildable.Gtk_Buildable) 233 return Gtk_Radio_Action 234 renames Implements_Gtk_Buildable.To_Object; 235 236private 237 Value_Property : constant Glib.Properties.Property_Int := 238 Glib.Properties.Build ("value"); 239 Group_Property : constant Glib.Properties.Property_Object := 240 Glib.Properties.Build ("group"); 241 Current_Value_Property : constant Glib.Properties.Property_Int := 242 Glib.Properties.Build ("current-value"); 243end Gtk.Radio_Action; 244