PageRenderTime 82ms CodeModel.GetById 78ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_radio_menu_item.e

http://github.com/tybor/Liberty
Specman e | 208 lines | 128 code | 32 blank | 48 comment | 2 complexity | 35af7b4daf699a10687b72d361d8d5e6 MD5 | raw file
  1indexing
  2	description: "GtkRadioMenuItem -- A choice from multiple check menu items."
  3	copyright: "[
  4					Copyright (C) 2006 eiffel-libraries team, GTK+ 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					
 22class GTK_RADIO_MENU_ITEM
 23	-- A radio menu item is a check menu item that belongs to a
 24	-- group. At each instant exactly one of the radio menu items from
 25	-- a group is selected.
 26					
 27	-- The group list does not need to be freed, as each
 28	-- GtkRadioMenuItem will remove itself and its list item when it is
 29	-- destroyed.
 30
 31	-- The correct way to create a group of radio menu items is
 32	-- approximatively this:
 33	
 34	-- TODO: Eiffelize this example 
 35	-- Example 3. How to create a group of radio menu items.
 36
 37	--  GSList *group = NULL;
 38	--  GtkWidget *item;
 39	--  gint i;
 40					
 41	--  for (i = 0; i < 5; i++) {
 42	--    item = gtk_radio_menu_item_new_with_label (group, "This is an example");
 43	--    group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item));
 44	--    if (i == 1)
 45	--      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
 46	--  }
 47
 48inherit
 49	GTK_MENU_ITEM
 50		rename
 51			with_mnemonic as as_menu_item_with_mnemomic
 52		export
 53			{}  as_menu_item_with_mnemomic
 54		redefine
 55			struct_size
 56		end
 57	
 58	-- TODO: GtkRadioMenuItem implements AtkImplementorIface.
 59
 60creation 
 61	from_group, with_group_label, with_mnemonic, from_widget,
 62	with_label_from_widget, with_mnemonic_from_widget,
 63	from_external_pointer
 64
 65feature {} -- Creation
 66	from_group (a_group: G_SLIST [GTK_RADIO_MENU_ITEM]) is
 67			-- Creates a new GtkRadioMenuItem; the radio menu item is to
 68			-- attached to `a_group'. If `a_group' is Void a new group 
 69			-- is made.
 70		require gtk_initialized: gtk.is_initialized
 71		do
 72			from_external_pointer (gtk_radio_menu_item_new (null_or(a_group)))
 73		end
 74
 75	with_group_label (a_group: G_SLIST [GTK_RADIO_MENU_ITEM]; a_label: STRING) is
 76			-- Creates a new GtkRadioMenuItem whose child is
 77			-- `a_label'. The radio menu item is to be attached to
 78			-- `a_group'. If `a_group' is Void a new group will be
 79			-- created.
 80		require
 81			gtk_initialized: gtk.is_initialized
 82			label_not_void: a_label/=Void
 83		do
 84			from_external_pointer (gtk_radio_menu_item_new_with_label
 85										  (null_or(a_group), a_label.to_external))
 86		end
 87
 88	with_mnemonic (a_group: G_SLIST [GTK_RADIO_MENU_ITEM]; a_label: STRING) is
 89			-- Creates a new GtkRadioMenuItem containing `a_label'. An
 90			-- underscores in label indicate the mnemonic for the menu
 91			-- item. The menu item will be added to `a_group'; if it is
 92			-- Void a new group will be created.
 93		require
 94			gtk_initialized: gtk.is_initialized
 95			label_not_void: a_label/=Void
 96		do
 97			from_external_pointer (gtk_radio_menu_item_new_with_mnemonic
 98										  (null_or(a_group), a_label.to_external))
 99		end
100
101	from_widget (a_widget: GTK_RADIO_MENU_ITEM) is
102			-- Creates a new GtkRadioMenuItem adding it to the same group
103			-- of `a_widget'.
104		require
105			gtk_initialized: gtk.is_initialized
106			widget_not_void: a_widget /= Void
107		do
108			from_external_pointer (gtk_radio_menu_item_new_from_widget (a_widget.handle))
109		end
110
111
112	with_label_from_widget (a_widget: GTK_RADIO_MENU_ITEM; a_label: STRING) is
113			-- Creates a new GtkRadioMenuItem whose child is a simple
114			-- GtkLabel with `a_label' as text. The new GtkRadioMenuItem
115			-- is added to the same group of `a_widget'.
116		require
117			gtk_initialized: gtk.is_initialized
118			widget_not_void: a_widget /= Void
119			label_not_void: a_label /= Void
120		do
121			handle:=(gtk_radio_menu_item_new_with_label_from_widget
122						(a_widget.handle, a_label.to_external))
123			store_eiffel_wrapper
124		end
125
126	with_mnemonic_from_widget (a_widget: GTK_RADIO_MENU_ITEM; a_label: STRING) is
127			-- Creates a new GtkRadioMenuItem containing a label. An
128			-- underscore in `a_label' indicates the mnemonic for the
129			-- menu item. The new GtkRadioMenuItem is added to the same
130			-- group of `a_widget'.
131		require
132			gtk_initialized: gtk.is_initialized
133			widget_not_void: a_widget /= Void
134			label_not_void: a_label /= Void
135		do
136			handle:=(gtk_radio_menu_item_new_with_mnemonic_from_widget
137						(a_widget.handle, a_label.to_external))
138			store_eiffel_wrapper
139		end
140
141feature 
142	set_group (a_group: G_SLIST [GTK_RADIO_MENU_ITEM]) is
143			--    Sets the group of a radio menu item, or changes it.		
144		do
145			gtk_radio_menu_item_set_group (handle, a_group.handle)
146		end
147
148	group: G_SLIST [GTK_RADIO_MENU_ITEM] is
149			--    Returns the group to which the radio menu item belongs, as a GList of
150			--    GtkRadioMenuItem. The list belongs to GTK+ and should not be freed.
151		do
152			create {G_OBJECT_SLIST[GTK_RADIO_MENU_ITEM]} Result.from_external_pointer 
153			(gtk_radio_menu_item_get_group (handle))
154			-- gtk_radio_menu_item_get_group returns the group to which
155			-- the radio menu item belongs, as a GList of
156			-- GtkRadioMenuItem. The list belongs to GTK+ and should not
157			-- be freed. Therefore
158			-- Result.set_shared
159		end
160
161feature -- TODO:  The "group-changed" signal
162	group_changed_signal_name: STRING is "group-changed"
163	
164	on_group_changed is do  end
165
166	enable_on_group_changed is
167		do
168			connect (Current, group_changed_signal_name, $on_group_changed)
169		end
170
171feature -- size
172	struct_size: INTEGER is
173		external "C inline use <gtk/gtk.h>"
174		alias "sizeof(GtkRadioMenuItem)"
175		end
176
177feature {} -- External calls
178	gtk_radio_menu_item_new (a_group: POINTER): POINTER is
179		external "C use <gtk/gtk.h>"
180		end
181	gtk_radio_menu_item_new_with_label (a_group, a_label: POINTER): POINTER is -- GtkWidget*
182		external "C use <gtk/gtk.h>"
183		end
184
185	gtk_radio_menu_item_new_with_mnemonic (a_group, a_label: POINTER): POINTER is -- GtkWidget*
186		external "C use <gtk/gtk.h>"
187		end
188
189	gtk_radio_menu_item_new_from_widget (a_gtkradiomenuitem: POINTER): POINTER is -- GtkWidget*
190		external "C use <gtk/gtk.h>"
191		end
192	
193	gtk_radio_menu_item_new_with_label_from_widget (a_gtkradiomenuitem, a_label: POINTER): POINTER is -- GtkWidget*
194		external "C use <gtk/gtk.h>"
195		end
196	
197	gtk_radio_menu_item_new_with_mnemonic_from_widget (a_gtkradiomenuitem, a_label: POINTER): POINTER is -- GtkWidget*
198		external "C use <gtk/gtk.h>"
199		end
200
201	gtk_radio_menu_item_set_group (radio_menu_item, a_group: POINTER) is
202		external "C use <gtk/gtk.h>"
203		end
204	
205	gtk_radio_menu_item_get_group (a_radio_menu_item: POINTER): POINTER is -- GSList*
206		external "C use <gtk/gtk.h>"
207		end
208end