1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = GtkStatusbar.html
27  * outPack = gtk
28  * outFile = Statusbar
29  * strct   = GtkStatusbar
30  * realStrct=
31  * ctorStrct=
32  * clss    = Statusbar
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_statusbar_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gtk.Widget
49  * structWrap:
50  * 	- GtkWidget* -> Widget
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gtk.Statusbar;
57 
58 public  import gtkc.gtktypes;
59 
60 private import gtkc.gtk;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 private import gobject.Signals;
65 public  import gtkc.gdktypes;
66 
67 private import glib.Str;
68 private import gtk.Widget;
69 
70 
71 
72 private import gtk.HBox;
73 
74 /**
75  * Description
76  * A GtkStatusbar is usually placed along the bottom of an application's main
77  * GtkWindow. It may provide a regular commentary of the application's status
78  * (as is usually the case in a web browser, for example), or may be used to
79  * simply output a message when the status changes, (when an upload is complete
80  * in an FTP client, for example).
81  * It may also have a resize grip (a triangular area in the lower right corner)
82  * which can be clicked on to resize the window containing the statusbar.
83  * Status bars in GTK+ maintain a stack of messages. The message at
84  * the top of the each bar's stack is the one that will currently be displayed.
85  * Any messages added to a statusbar's stack must specify a context
86  * id that is used to uniquely identify the source of a message.
87  * This context id can be generated by gtk_statusbar_get_context_id(), given a
88  * message and the statusbar that it will be added to. Note that messages are
89  * stored in a stack, and when choosing which message to display, the stack
90  * structure is adhered to, regardless of the context identifier of a message.
91  * One could say that a statusbar maintains one stack of messages for display
92  * purposes, but allows multiple message producers to maintain sub-stacks of
93  * the messages they produced (via context ids).
94  * Status bars are created using gtk_statusbar_new().
95  * Messages are added to the bar's stack with gtk_statusbar_push().
96  * The message at the top of the stack can be removed using gtk_statusbar_pop().
97  * A message can be removed from anywhere in the stack if its message_id was
98  * recorded at the time it was added. This is done using gtk_statusbar_remove().
99  */
100 public class Statusbar : HBox
101 {
102 	
103 	/** the main Gtk struct */
104 	protected GtkStatusbar* gtkStatusbar;
105 	
106 	
107 	public GtkStatusbar* getStatusbarStruct()
108 	{
109 		return gtkStatusbar;
110 	}
111 	
112 	
113 	/** the main Gtk struct as a void* */
114 	protected override void* getStruct()
115 	{
116 		return cast(void*)gtkStatusbar;
117 	}
118 	
119 	/**
120 	 * Sets our main struct and passes it to the parent class
121 	 */
122 	public this (GtkStatusbar* gtkStatusbar)
123 	{
124 		super(cast(GtkHBox*)gtkStatusbar);
125 		this.gtkStatusbar = gtkStatusbar;
126 	}
127 	
128 	protected override void setStruct(GObject* obj)
129 	{
130 		super.setStruct(obj);
131 		gtkStatusbar = cast(GtkStatusbar*)obj;
132 	}
133 	
134 	/**
135 	 */
136 	int[string] connectedSignals;
137 	
138 	void delegate(guint, string, Statusbar)[] onTextPoppedListeners;
139 	/**
140 	 * Is emitted whenever a new message is popped off a statusbar's stack.
141 	 */
142 	void addOnTextPopped(void delegate(guint, string, Statusbar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
143 	{
144 		if ( !("text-popped" in connectedSignals) )
145 		{
146 			Signals.connectData(
147 			getStruct(),
148 			"text-popped",
149 			cast(GCallback)&callBackTextPopped,
150 			cast(void*)this,
151 			null,
152 			connectFlags);
153 			connectedSignals["text-popped"] = 1;
154 		}
155 		onTextPoppedListeners ~= dlg;
156 	}
157 	extern(C) static void callBackTextPopped(GtkStatusbar* statusbarStruct, guint contextId, gchar* text, Statusbar _statusbar)
158 	{
159 		foreach ( void delegate(guint, string, Statusbar) dlg ; _statusbar.onTextPoppedListeners )
160 		{
161 			dlg(contextId, Str.toString(text), _statusbar);
162 		}
163 	}
164 	
165 	void delegate(guint, string, Statusbar)[] onTextPushedListeners;
166 	/**
167 	 * Is emitted whenever a new message gets pushed onto a statusbar's stack.
168 	 */
169 	void addOnTextPushed(void delegate(guint, string, Statusbar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
170 	{
171 		if ( !("text-pushed" in connectedSignals) )
172 		{
173 			Signals.connectData(
174 			getStruct(),
175 			"text-pushed",
176 			cast(GCallback)&callBackTextPushed,
177 			cast(void*)this,
178 			null,
179 			connectFlags);
180 			connectedSignals["text-pushed"] = 1;
181 		}
182 		onTextPushedListeners ~= dlg;
183 	}
184 	extern(C) static void callBackTextPushed(GtkStatusbar* statusbarStruct, guint contextId, gchar* text, Statusbar _statusbar)
185 	{
186 		foreach ( void delegate(guint, string, Statusbar) dlg ; _statusbar.onTextPushedListeners )
187 		{
188 			dlg(contextId, Str.toString(text), _statusbar);
189 		}
190 	}
191 	
192 	
193 	/**
194 	 * Creates a new GtkStatusbar ready for messages.
195 	 * Throws: ConstructionException GTK+ fails to create the object.
196 	 */
197 	public this ()
198 	{
199 		// GtkWidget * gtk_statusbar_new (void);
200 		auto p = gtk_statusbar_new();
201 		if(p is null)
202 		{
203 			throw new ConstructionException("null returned by gtk_statusbar_new()");
204 		}
205 		this(cast(GtkStatusbar*) p);
206 	}
207 	
208 	/**
209 	 * Returns a new context identifier, given a description
210 	 * of the actual context. Note that the description is
211 	 * not shown in the UI.
212 	 * Params:
213 	 * contextDescription = textual description of what context
214 	 * the new message is being used in
215 	 * Returns: an integer id
216 	 */
217 	public uint getContextId(string contextDescription)
218 	{
219 		// guint gtk_statusbar_get_context_id (GtkStatusbar *statusbar,  const gchar *context_description);
220 		return gtk_statusbar_get_context_id(gtkStatusbar, Str.toStringz(contextDescription));
221 	}
222 	
223 	/**
224 	 * Pushes a new message onto a statusbar's stack.
225 	 * Params:
226 	 * contextId = the message's context id, as returned by
227 	 * gtk_statusbar_get_context_id()
228 	 * text = the message to add to the statusbar
229 	 * Returns: a message id that can be used with gtk_statusbar_remove().
230 	 */
231 	public uint push(uint contextId, string text)
232 	{
233 		// guint gtk_statusbar_push (GtkStatusbar *statusbar,  guint context_id,  const gchar *text);
234 		return gtk_statusbar_push(gtkStatusbar, contextId, Str.toStringz(text));
235 	}
236 	
237 	/**
238 	 * Removes the first message in the GtkStatusBar's stack
239 	 * with the given context id.
240 	 * Note that this may not change the displayed message, if
241 	 * the message at the top of the stack has a different
242 	 * context id.
243 	 * Params:
244 	 * contextId = a context identifier
245 	 */
246 	public void pop(uint contextId)
247 	{
248 		// void gtk_statusbar_pop (GtkStatusbar *statusbar,  guint context_id);
249 		gtk_statusbar_pop(gtkStatusbar, contextId);
250 	}
251 	
252 	/**
253 	 * Forces the removal of a message from a statusbar's stack.
254 	 * The exact context_id and message_id must be specified.
255 	 * Params:
256 	 * contextId = a context identifier
257 	 * messageId = a message identifier, as returned by gtk_statusbar_push()
258 	 */
259 	public void remove(uint contextId, uint messageId)
260 	{
261 		// void gtk_statusbar_remove (GtkStatusbar *statusbar,  guint context_id,  guint message_id);
262 		gtk_statusbar_remove(gtkStatusbar, contextId, messageId);
263 	}
264 	
265 	/**
266 	 * Forces the removal of all messages from a statusbar's
267 	 * stack with the exact context_id.
268 	 * Since 2.22
269 	 * Params:
270 	 * contextId = a context identifier
271 	 */
272 	public void removeAll(uint contextId)
273 	{
274 		// void gtk_statusbar_remove_all (GtkStatusbar *statusbar,  guint context_id);
275 		gtk_statusbar_remove_all(gtkStatusbar, contextId);
276 	}
277 	
278 	/**
279 	 * Sets whether the statusbar has a resize grip.
280 	 * TRUE by default.
281 	 * Params:
282 	 * setting = TRUE to have a resize grip
283 	 */
284 	public void setHasResizeGrip(int setting)
285 	{
286 		// void gtk_statusbar_set_has_resize_grip (GtkStatusbar *statusbar,  gboolean setting);
287 		gtk_statusbar_set_has_resize_grip(gtkStatusbar, setting);
288 	}
289 	
290 	/**
291 	 * Returns whether the statusbar has a resize grip.
292 	 * Returns: TRUE if the statusbar has a resize grip.
293 	 */
294 	public int getHasResizeGrip()
295 	{
296 		// gboolean gtk_statusbar_get_has_resize_grip (GtkStatusbar *statusbar);
297 		return gtk_statusbar_get_has_resize_grip(gtkStatusbar);
298 	}
299 	
300 	/**
301 	 * Retrieves the box containing the label widget.
302 	 * Since 2.20
303 	 * Returns: a GtkBox. [transfer none]
304 	 */
305 	public Widget getMessageArea()
306 	{
307 		// GtkWidget * gtk_statusbar_get_message_area (GtkStatusbar *statusbar);
308 		auto p = gtk_statusbar_get_message_area(gtkStatusbar);
309 		
310 		if(p is null)
311 		{
312 			return null;
313 		}
314 		
315 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
316 	}
317 }