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

/src/wrappers/gtk/library/gtk_status_bar.e

http://github.com/tybor/Liberty
Specman e | 247 lines | 136 code | 49 blank | 62 comment | 2 complexity | c04df00f71d54832e7bae0cb583c386b MD5 | raw file
  1indexing
  2	description: "Report messages of minor importance to the user"
  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	date: "$Date:$"
 22	revision: "$Revision:$"
 23
 24class GTK_STATUS_BAR
 25	-- A GtkStatusbar is usually placed along the bottom of an
 26	-- application's main GtkWindow. It may provide a regular
 27	-- commentary of the application's status (as is usually the case
 28	-- in a web browser, for example), or may be used to simply output
 29	-- a message when the status changes, (when an upload is complete
 30	-- in an FTP client, for example). It may also have a resize grip
 31	-- (a triangular area in the lower right corner) which can be
 32	-- clicked on to resize the window containing the statusbar.
 33
 34	-- Status bars in Gtk+ maintain a stack of messages. The message at
 35	-- the top of the each bar's stack is the one that will currently
 36	-- be displayed.
 37
 38	-- Any messages added to a statusbar's stack must specify a
 39	-- context_id that is used to uniquely identify the source of a
 40	-- message. This context_id can be generated by (unwrapped)
 41	-- gtk_statusbar_get_context_id(), given a message and the
 42	-- statusbar that it will be added to. Note that messages are
 43	-- stored in a stack, and when choosing which message to display,
 44	-- the stack structure is adhered to, regardless of the context
 45	-- identifier of a message.
 46
 47	-- Status bars are created using `make'.
 48	
 49	-- Messages are added to the bar's stack with `push'.
 50
 51	-- The message at the top of the stack can be removed using
 52	-- `pop'. A message can be removed from anywhere in the stack if
 53	-- its message_id was recorded at the time it was added. This is
 54	-- done using `remove'.
 55
 56inherit
 57	GTK_HBOX
 58		rename make as make_hbox
 59		export {} make_hbox
 60		redefine struct_size
 61		end 
 62
 63	-- TODO: GtkStatusbar implements AtkImplementorIface.
 64	
 65insert GTK_SHADOW_TYPE
 66	
 67creation make, from_external_pointer
 68	
 69feature -- size
 70	struct_size: INTEGER is
 71		external "C inline use <gtk/gtk.h>"
 72		alias "sizeof(GtkStatusBar)"
 73		end
 74
 75feature {} -- Creation
 76	make is
 77			-- Creates a new GtkStatusbar ready for messages.
 78		require gtk_initialized: gtk.is_initialized
 79		do
 80			from_external_pointer (gtk_statusbar_new)
 81		end
 82
 83feature -- Context ids
 84
 85	new_context_id (description: STRING) is
 86		require
 87			description /= Void
 88		do
 89			last_context_id := gtk_statusbar_get_context_id (handle, description.to_external)
 90		end
 91
 92	last_context_id: INTEGER
 93
 94feature -- Stack like behaviour
 95
 96	push (context_id: INTEGER; a_message: STRING) is
 97			-- Pushes `a_message' onto a statusbar's stack.
 98			-- `context_id' will be used
 99		require
100			a_message /= Void
101		do
102			last_pushed := gtk_statusbar_push (handle, context_id,
103									  a_message.to_external)
104		end
105
106	last_pushed: INTEGER
107			-- Message id for the last message pushed
108
109	pop (context_id: INTEGER) is
110			-- Pop last message with current (i.e.: last) context id.
111		do
112			gtk_statusbar_pop (handle, context_id);
113			-- Removes the message at the top of a GtkStatusBar's stack.
114		end
115
116	remove_message (context_id, a_message_id: INTEGER) is
117			-- Forces the removal of a message from a statusbar's
118			-- stack. The exact `message_id' must be specified.
119		do
120			gtk_statusbar_remove (handle, context_id, a_message_id)
121		end
122
123	set_has_resize_grip (a_setting: BOOLEAN) is
124			-- Sets whether the statusbar has a resize grip. True by default.
125		do
126			gtk_statusbar_set_has_resize_grip(handle, a_setting.to_integer)
127		ensure set: a_setting = has_resize_grip
128		end			
129
130	has_resize_grip: BOOLEAN is
131			-- Does the statusbar have a resize grip?
132		do
133			Result := gtk_statusbar_get_has_resize_grip(handle).to_boolean
134		end
135
136feature -- Style Properties
137	shadow_type: INTEGER is
138			-- Style of bevel around the statusbar text. Note: in C it is a
139			-- GtkShadowType.  Default value: `gtk_shadow_in'.
140		do
141			print_shadow_type_notice
142			invoke_get_property (shadow_type_property_spec.owner_class, handle,
143										shadow_type_property_spec.param_id,
144										shadow_type_gvalue.handle,
145										shadow_type_property_spec.handle)
146			Result := shadow_type_gvalue.integer
147		ensure is_valid_gtk_shadow_type (Result)
148		end
149
150feature -- TODO: Signals
151
152	-- "text-popped" void user_function (GtkStatusbar *statusbar, guint
153	-- context_id, gchar *text, gpointer user_data) : Run last
154	
155	-- The "text-popped" signal
156	
157	-- void user_function (GtkStatusbar *statusbar, guint context_id,
158	-- gchar *text, gpointer user_data) : Run last
159
160	-- Is emitted whenever a new message is popped off a statusbar's stack.
161	-- statusbar : 	the object which received the signal.
162	-- context_id : 	the context id of the relevant message/statusbar.
163	-- text : 	the message that was just popped.
164	-- user_data : 	user data set when the signal handler was connected.
165
166
167	-- "text-pushed" void user_function (GtkStatusbar *statusbar, guint
168	-- context_id, gchar *text, gpointer user_data) : Run last
169
170	-- The "text-pushed" signal
171
172	-- void user_function (GtkStatusbar *statusbar, guint context_id,
173	-- gchar *text, gpointer user_data) : Run last
174
175	-- Is emitted whenever a new message gets pushed onto a statusbar's stack.
176	-- statusbar : 	the object which received the signal.
177	-- context_id : 	the context id of the relevant message/statusbar.
178	-- text : 	the message that was pushed.
179	-- user_data : 	user data set when the signal handler was connected.
180
181feature {} -- Implementation
182	shadow_type_property_name: STRING is "shadow-type"
183
184	shadow_type_property_spec: G_PARAM_SPEC is
185		once
186			Result:=find_property(shadow_type_property_name)
187		ensure not_void: Result /= Void
188		end
189
190	shadow_type_gvalue: G_VALUE
191	
192	print_shadow_type_notice is
193		once
194			print ("[
195					  Note: GTK_STATUS_BAR's shadow_type feature relies on the assumption that a GValue
196					  can hold an enum value and that can ben handled like an integer.
197					  If you are reading this note after an application crash, please report the bug to
198					  the Eiffel Wrapper Libraries Collection project at https://gna.org/projects/eiffel-libraries/ 
199					  ]")
200		end
201
202feature {} -- External calls 
203
204	gtk_statusbar_new: POINTER is
205		external "C use <gtk/gtk.h>"
206		end
207	
208	gtk_statusbar_get_context_id (a_statusbar, a_context_description: POINTER): INTEGER  is
209			-- Note Result shall be NATURAL since it's a guint
210		external "C use <gtk/gtk.h>"
211		ensure positive: Result > 0
212		end
213	
214	gtk_statusbar_push (a_statusbar: POINTER; a_context_id: INTEGER;
215							  a_text: POINTER): INTEGER  is
216		require
217			-- Note: `a_context_id' is a guint and shall be a NATURAL
218			positive_context_id: a_context_id >= 0 
219		external "C use <gtk/gtk.h>"
220		ensure positive: Result > 0
221		end
222
223	gtk_statusbar_pop (a_statusbar: POINTER; a_context_id: INTEGER)  is
224		require
225			-- Note: `a_context_id' is a guint and shall be a NATURAL
226			positive_context_id: a_context_id >= 0 
227		external "C use <gtk/gtk.h>"
228		end
229
230	gtk_statusbar_remove (a_statusbar: POINTER; a_context_id,
231								 a_message_id: INTEGER)  is
232		require
233			-- Note: `a_context_id' and `a_message_id' are guint and shall be NATURAL
234			positive_context_id: a_context_id >= 0 
235			positive_message_id: a_message_id >= 0 
236		external "C use <gtk/gtk.h>"
237		end
238
239	gtk_statusbar_set_has_resize_grip (a_statusbar: POINTER; a_setting: INTEGER) is
240		external "C use <gtk/gtk.h>"
241		end
242	
243	gtk_statusbar_get_has_resize_grip (a_statusbar: POINTER): INTEGER is
244		external "C use <gtk/gtk.h>"
245		end
246
247end