PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/gtk/library/gtk_accel_label.e

http://github.com/tybor/Liberty
Specman e | 168 lines | 65 code | 33 blank | 70 comment | 3 complexity | cd225b39bca1b0cbcad4e8f6cd6804af MD5 | raw file
  1indexing
  2	description: "GtkAccelLabel รข€” A label which displays an accelerator key on the right of the text."
  3	copyright: "[
  4					Copyright (C) 2006 Paolo Redaelli, 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 hopeOA 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_ACCEL_LABEL
 23	-- The GtkAccelLabel widget is a subclass of GtkLabel that also
 24	-- displays an accelerator key on the right of the label text,
 25	-- e.g. 'Ctl+S'. It is commonly used in menus to show the keyboard
 26	-- short-cuts for commands.
 27
 28	-- The accelerator key to display is not set explicitly. Instead,
 29	-- the GtkAccelLabel displays the accelerators which have been
 30	-- added to a particular widget. This widget is set by calling
 31	-- gtk_accel_label_set_accel_widget().
 32
 33	-- For example, a GtkMenuItem widget may have an accelerator added
 34	-- to emit the "activate" signal when the 'Ctl+S' key combination
 35	-- is pressed. A GtkAccelLabel is created and added to the
 36	-- GtkMenuItem, and gtk_accel_label_set_accel_widget() is called
 37	-- with the GtkMenuItem as the second argument. The GtkAccelLabel
 38	-- will now display 'Ctl+S' after its label.
 39
 40	-- Note that creating a GtkMenuItem with
 41	-- gtk_menu_item_new_with_label() (or one of the similar functions
 42	-- for GtkCheckMenuItem and GtkRadioMenuItem) automatically adds a
 43	-- GtkAccelLabel to the GtkMenuItem and calls
 44	-- gtk_accel_label_set_accel_widget() to set it up for you.
 45
 46	-- A GtkAccelLabel will only display accelerators which have
 47	-- GTK_ACCEL_VISIBLE set (see GtkAccelFlags). A GtkAccelLabel
 48	-- can display multiple accelerators and even signal names,
 49	-- though it is almost always used to display just one
 50	-- accelerator key.
 51
 52	-- Example 1. Creating a simple menu item with an accelerator key.
 53			
 54	--   GtkWidget *save_item;
 55	--   GtkAccelGroup *accel_group;
 56			
 57	--   /* Create a GtkAccelGroup and add it to the window. */
 58	--   accel_group = gtk_accel_group_new ();
 59	--   gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
 60			
 61	--   /* Create the menu item using the convenience function. */
 62	--   save_item = gtk_menu_item_new_with_label ("Save");
 63	--   gtk_widget_show (save_item);
 64	--   gtk_container_add (GTK_CONTAINER (menu), save_item);
 65			
 66	--   /* Now add the accelerator to the GtkMenuItem. Note that
 67	--   since we called gtk_menu_item_new_with_label() to create
 68	--   the GtkMenuItem the GtkAccelLabel is automatically set
 69	--   up to display the GtkMenuItem accelerators. We just need
 70	--   to make sure we use GTK_ACCEL_VISIBLE here. */
 71	--   gtk_widget_add_accelerator (save_item, "activate",
 72	--   accel_group, GDK_s, GDK_CONTROL_MASK,
 73	--   GTK_ACCEL_VISIBLE);
 74
 75inherit
 76	GTK_LABEL
 77		redefine
 78			struct_size
 79		end
 80	-- TODO: GtkAccelLabel implements AtkImplementorIface.
 81
 82insert
 83	GTK_ACCEL_LABEL_EXTERNALS
 84	G_OBJECT_FACTORY [GTK_WIDGET]
 85	
 86creation make, from_external_pointer
 87
 88feature {} -- Creation
 89	make (a_label: STRING) is
 90			-- Creates a new GtkAccelLabel with `a_label'.
 91		require label_not_void: a_label /= Void
 92		do
 93			from_external_pointer(gtk_accel_label_new(a_label.to_external))
 94		end
 95
 96feature 
 97	-- TODO: void gtk_accel_label_set_accel_closure (GtkAccelLabel
 98	-- *accel_label, GClosure *accel_closure);
 99
100	-- Sets the closure to be monitored by this accelerator label. The closure must be connected to an accelerator group; see gtk_accel_group_connect().
101	
102	-- accel_label : 	a GtkAccelLabel
103	-- accel_closure : 	the closure to monitor for accelerator 
104	-- changes.
105
106	accel_widget: GTK_WIDGET is
107			-- Fetches the widget monitored by this accelerator
108			-- label. Can be Void. See `set_accel_widget'.
109		local ptr: POINTER
110		do
111			ptr:=gtk_accel_label_get_accel_widget(handle)
112			if ptr.is_not_null then
113				Result:=wrapper(ptr)
114			end
115		end
116
117	set_accel_widget (a_widget: GTK_WIDGET) is
118			-- Sets the widget to be monitored by this accelerator label.
119		do
120			gtk_accel_label_set_accel_widget (handle, a_widget.handle)
121		end
122
123	accel_width: INTEGER is
124			-- the width needed to display the accelerator key(s). This
125			-- is used by menus to align all of the GtkMenuItem widgets,
126			-- and shouldn't be needed by applications.
127		do
128			Result:=gtk_accel_label_get_accel_width (handle)
129		end
130
131	refetch is
132			-- Recreates the string representing the accelerator
133			-- keys. This should not be needed since the string is
134			-- automatically updated whenever accelerators are added or
135			-- removed from the associated widget.
136		local int: INTEGER
137		do
138			int:=gtk_accel_label_refetch(handle)
139			check
140				-- gtk_accel_label_refetch always returns FALSE.
141				int=0
142			end
143		end
144
145feature -- TODO, if necessary: Properties
146	
147	--   "accel-closure"        GClosure              : Read / Write
148	--   "accel-widget"         GtkWidget             : Read / Write
149
150	-- Property Details
151	-- The "accel-closure" property
152
153	--   "accel-closure" GClosure : Read / Write
154
155	-- The closure to be monitored for accelerator changes.
156	
157	-- The "accel-widget" property
158
159	-- "accel-widget" GtkWidget : Read / Write
160
161	-- The widget to be monitored for accelerator changes.
162	
163feature -- size
164	struct_size: INTEGER is
165		external "C inline use <gtk/gtk.h>"
166		alias "sizeof(GtkAccelLabel)"
167		end
168end -- GTK_ACCEL_LABEL