PageRenderTime 21ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_radio_action.e

http://github.com/tybor/Liberty
Specman e | 144 lines | 64 code | 34 blank | 46 comment | 2 complexity | f866ff84bdafc6217e86df5270a12a1c MD5 | raw file
  1indexing
  2	description: "GtkRadioAction รข€” An action of which only one in a group can be active."
  3	copyright: "[
  4					Copyright (C) 2006 Paolo Redaelli, GTS team
  5					
  6					This library is free software; you can redistribute it and/or
  7					modify it under the terms of the GNU Lesser General Public License
  8					as published by the Free Software Foundation; either version 2.1 of
  9					the License, or (at your option) any later version.
 10					
 11					This library is distributed in the hope that it will be useful, but
 12					WITHOUT ANY WARRANTY; without even the implied warranty of
 13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14					Lesser General Public License for more details.
 15
 16					You should have received a copy of the GNU Lesser General Public
 17					License along with this library; if not, write to the Free Software
 18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 19					02110-1301 USA
 20			]"
 21
 22			-- Description: A GtkRadioAction is similar to
 23			-- GtkRadioMenuItem. A number of radio actions can be linked
 24			-- together so that only one may be active at any one time.
 25
 26class GTK_RADIO_ACTION
 27
 28inherit
 29	GTK_TOGGLE_ACTION
 30		rename make as make_toggle
 31		redefine struct_size
 32		end
 33
 34creation make, from_external_pointer
 35
 36feature  -- Creation
 37	make  (a_name, a_label, a_tooltip, a_stock_id: STRING; a_value: INTEGER) is
 38			-- Creates a new GtkRadioAction object. To add the action to
 39			-- a GtkActionGroup and set the accelerator for the action,
 40			-- call `GTK_ACTION_GROUP.add_action_with_accel'.
 41		require gtk_initialized: gtk.is_initialized
 42		do
 43			from_external_pointer (gtk_radio_action_new (a_name.to_external, a_label.to_external,
 44																		a_tooltip.to_external, a_stock_id.to_external, a_value))
 45		end
 46feature
 47	group: G_SLIST [GTK_RADIO_ACTION] is
 48			-- the list representing the radio group for this
 49			-- object. Note that the returned list is only valid until
 50			-- the next change to the group.
 51
 52			-- TODO: Eiffelize this example
 53			-- A common way to set up a group of radio group is the following:
 54		
 55			--   GSList *group = NULL;
 56			--   GtkRadioAction *action;
 57		
 58			--   while (/* more actions to add */) {
 59			--        action = gtk_radio_action_new (...);
 60			--        gtk_radio_action_set_group (action, group);
 61			--        group = gtk_radio_action_get_group (action);
 62			--   }
 63		do
 64			create {G_OBJECT_SLIST[GTK_RADIO_ACTION]} Result.from_external_pointer (gtk_radio_action_get_group(handle))
 65		end
 66
 67	set_group (a_group: G_SLIST [GTK_RADIO_ACTION]) is
 68			-- Sets the radio group for the radio action object.
 69		do
 70			gtk_radio_action_set_group (handle,a_group.handle)
 71		end	
 72
 73	current_value: INTEGER is
 74			-- the value of the currently active member of the group to which action belongs.
 75		do
 76			Result := gtk_radio_action_get_current_value(handle)
 77		end
 78
 79feature -- Properties
 80
 81--   "group"                GtkRadioAction        : Write
 82--   "value"                gint                  : Read / Write
 83
 84-- Signals
 85
 86-- "changed"   void        user_function      (GtkRadioAction *action,
 87--                                             GtkRadioAction *current,
 88--                                             gpointer        user_data)      : Run first / No recursion
 89
 90-- Property Details
 91-- The "group" property
 92
 93--   "group"                GtkRadioAction        : Write
 94
 95-- Sets a new group for a radio action.
 96
 97-- Since 2.4
 98-- The "value" property
 99
100--   "value"                gint                  : Read / Write
101
102-- The value is an arbitrary integer which can be used as a convenient way to determine which action in the group is currently active in an ::activate or ::changed signal handler. See gtk_radio_action_get_current_value() and GtkRadioActionEntry for convenient ways to get and set this property.
103
104-- Default value: 0
105
106-- Since 2.4
107-- Signal Details
108-- The "changed" signal
109
110-- void        user_function                  (GtkRadioAction *action,
111--                                             GtkRadioAction *current,
112--                                             gpointer        user_data)      : Run first / No recursion
113
114-- The ::changed signal is emitted on every member of a radio group when the active member is changed. The signal gets emitted after the ::activate signals for the previous and current active members.
115
116-- action : 	the action on which the signal is emitted
117-- current : 	the member of actions group which has just been activated
118-- user_data : 	user data set when the signal handler was connected.
119
120-- Since 2.4
121feature -- size
122
123	struct_size: INTEGER is
124		external "C inline use <gtk/gtk.h>"
125		alias "sizeof(GtkRadioAction)"
126		end
127
128feature {} -- External calls
129	gtk_radio_action_new (name_str,label_str,tooltip_str,stock_id_str: POINTER; a_value: INTEGER): POINTER is -- GtkRadioAction*
130		external "C use <gtk/gtk.h>"
131		end
132	
133	gtk_radio_action_get_group      (an_action: POINTER): POINTER is -- GSList*   
134		external "C use <gtk/gtk.h>"
135		end
136
137	gtk_radio_action_set_group      (an_action, gslist_group: POINTER) is
138		external "C use <gtk/gtk.h>"
139		end
140	
141	gtk_radio_action_get_current_value (an_action: POINTER): INTEGER is
142		external "C use <gtk/gtk.h>"
143		end
144end -- class GTK_RADIO_ACTION