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: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_statusbar_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- gtk_statusbar_get_message_area
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gtk.Box
49  * 	- gtk.Widget
50  * structWrap:
51  * 	- GtkWidget* -> Widget
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gtk.Statusbar;
58 
59 public  import gtkc.gtktypes;
60 
61 private import gtkc.gtk;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 private import gobject.Signals;
66 public  import gtkc.gdktypes;
67 private import glib.Str;
68 private import gtk.Box;
69 private import gtk.Widget;
70 
71 
72 private import gtk.Box;
73 
74 /**
75  * A GtkStatusbar is usually placed along the bottom of an application's
76  * main GtkWindow. It may provide a regular commentary of the application's
77  * status (as is usually the case in a web browser, for example), or may be
78  * used to simply output a message when the status changes, (when an upload
79  * is complete in an FTP client, for example).
80  *
81  * Status bars in GTK+ maintain a stack of messages. The message at
82  * the top of the each bar's stack is the one that will currently be displayed.
83  *
84  * Any messages added to a statusbar's stack must specify a
85  * context id that is used to uniquely identify
86  * the source of a message. This context id can be generated by
87  * gtk_statusbar_get_context_id(), given a message and the statusbar that
88  * it will be added to. Note that messages are stored in a stack, and when
89  * choosing which message to display, the stack structure is adhered to,
90  * regardless of the context identifier of a message.
91  *
92  * One could say that a statusbar maintains one stack of messages for
93  * display purposes, but allows multiple message producers to maintain
94  * sub-stacks of the messages they produced (via context ids).
95  *
96  * Status bars are created using gtk_statusbar_new().
97  *
98  * Messages are added to the bar's stack with gtk_statusbar_push().
99  *
100  * The message at the top of the stack can be removed using
101  * gtk_statusbar_pop(). A message can be removed from anywhere in the
102  * stack if its message id was recorded at the time it was added. This
103  * is done using gtk_statusbar_remove().
104  */
105 public class Statusbar : Box
106 {
107 	
108 	/** the main Gtk struct */
109 	protected GtkStatusbar* gtkStatusbar;
110 	
111 	
112 	/** Get the main Gtk struct */
113 	public GtkStatusbar* getStatusbarStruct()
114 	{
115 		return gtkStatusbar;
116 	}
117 	
118 	
119 	/** the main Gtk struct as a void* */
120 	protected override void* getStruct()
121 	{
122 		return cast(void*)gtkStatusbar;
123 	}
124 	
125 	/**
126 	 * Sets our main struct and passes it to the parent class
127 	 */
128 	public this (GtkStatusbar* gtkStatusbar)
129 	{
130 		super(cast(GtkBox*)gtkStatusbar);
131 		this.gtkStatusbar = gtkStatusbar;
132 	}
133 	
134 	protected override void setStruct(GObject* obj)
135 	{
136 		super.setStruct(obj);
137 		gtkStatusbar = cast(GtkStatusbar*)obj;
138 	}
139 	
140 	/**
141 	 * Retrieves the box containing the label widget.
142 	 * Since 2.20
143 	 * Returns: a GtkBox. [transfer none]
144 	 */
145 	public Box getMessageArea()
146 	{
147 		// GtkWidget * gtk_statusbar_get_message_area (GtkStatusbar *statusbar);
148 		auto p = gtk_statusbar_get_message_area(gtkStatusbar);
149 		if(p is null)
150 		{
151 			return null;
152 		}
153 		return new Box(cast(GtkBox*) p);
154 	}
155 	
156 	/**
157 	 */
158 	int[string] connectedSignals;
159 	
160 	void delegate(guint, string, Statusbar)[] onTextPoppedListeners;
161 	/**
162 	 * Is emitted whenever a new message is popped off a statusbar's stack.
163 	 */
164 	void addOnTextPopped(void delegate(guint, string, Statusbar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
165 	{
166 		if ( !("text-popped" in connectedSignals) )
167 		{
168 			Signals.connectData(
169 			getStruct(),
170 			"text-popped",
171 			cast(GCallback)&callBackTextPopped,
172 			cast(void*)this,
173 			null,
174 			connectFlags);
175 			connectedSignals["text-popped"] = 1;
176 		}
177 		onTextPoppedListeners ~= dlg;
178 	}
179 	extern(C) static void callBackTextPopped(GtkStatusbar* statusbarStruct, guint contextId, gchar* text, Statusbar _statusbar)
180 	{
181 		foreach ( void delegate(guint, string, Statusbar) dlg ; _statusbar.onTextPoppedListeners )
182 		{
183 			dlg(contextId, Str.toString(text), _statusbar);
184 		}
185 	}
186 	
187 	void delegate(guint, string, Statusbar)[] onTextPushedListeners;
188 	/**
189 	 * Is emitted whenever a new message gets pushed onto a statusbar's stack.
190 	 */
191 	void addOnTextPushed(void delegate(guint, string, Statusbar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
192 	{
193 		if ( !("text-pushed" in connectedSignals) )
194 		{
195 			Signals.connectData(
196 			getStruct(),
197 			"text-pushed",
198 			cast(GCallback)&callBackTextPushed,
199 			cast(void*)this,
200 			null,
201 			connectFlags);
202 			connectedSignals["text-pushed"] = 1;
203 		}
204 		onTextPushedListeners ~= dlg;
205 	}
206 	extern(C) static void callBackTextPushed(GtkStatusbar* statusbarStruct, guint contextId, gchar* text, Statusbar _statusbar)
207 	{
208 		foreach ( void delegate(guint, string, Statusbar) dlg ; _statusbar.onTextPushedListeners )
209 		{
210 			dlg(contextId, Str.toString(text), _statusbar);
211 		}
212 	}
213 	
214 	
215 	/**
216 	 * Creates a new GtkStatusbar ready for messages.
217 	 * Throws: ConstructionException GTK+ fails to create the object.
218 	 */
219 	public this ()
220 	{
221 		// GtkWidget * gtk_statusbar_new (void);
222 		auto p = gtk_statusbar_new();
223 		if(p is null)
224 		{
225 			throw new ConstructionException("null returned by gtk_statusbar_new()");
226 		}
227 		this(cast(GtkStatusbar*) p);
228 	}
229 	
230 	/**
231 	 * Returns a new context identifier, given a description
232 	 * of the actual context. Note that the description is
233 	 * not shown in the UI.
234 	 * Params:
235 	 * contextDescription = textual description of what context
236 	 * the new message is being used in
237 	 * Returns: an integer id
238 	 */
239 	public uint getContextId(string contextDescription)
240 	{
241 		// guint gtk_statusbar_get_context_id (GtkStatusbar *statusbar,  const gchar *context_description);
242 		return gtk_statusbar_get_context_id(gtkStatusbar, Str.toStringz(contextDescription));
243 	}
244 	
245 	/**
246 	 * Pushes a new message onto a statusbar's stack.
247 	 * Params:
248 	 * contextId = the message's context id, as returned by
249 	 * gtk_statusbar_get_context_id()
250 	 * text = the message to add to the statusbar
251 	 * Returns: a message id that can be used with gtk_statusbar_remove().
252 	 */
253 	public uint push(uint contextId, string text)
254 	{
255 		// guint gtk_statusbar_push (GtkStatusbar *statusbar,  guint context_id,  const gchar *text);
256 		return gtk_statusbar_push(gtkStatusbar, contextId, Str.toStringz(text));
257 	}
258 	
259 	/**
260 	 * Removes the first message in the GtkStatusbar's stack
261 	 * with the given context id.
262 	 * Note that this may not change the displayed message, if
263 	 * the message at the top of the stack has a different
264 	 * context id.
265 	 * Params:
266 	 * contextId = a context identifier
267 	 */
268 	public void pop(uint contextId)
269 	{
270 		// void gtk_statusbar_pop (GtkStatusbar *statusbar,  guint context_id);
271 		gtk_statusbar_pop(gtkStatusbar, contextId);
272 	}
273 	
274 	/**
275 	 * Forces the removal of a message from a statusbar's stack.
276 	 * The exact context_id and message_id must be specified.
277 	 * Params:
278 	 * contextId = a context identifier
279 	 * messageId = a message identifier, as returned by gtk_statusbar_push()
280 	 */
281 	public void remove(uint contextId, uint messageId)
282 	{
283 		// void gtk_statusbar_remove (GtkStatusbar *statusbar,  guint context_id,  guint message_id);
284 		gtk_statusbar_remove(gtkStatusbar, contextId, messageId);
285 	}
286 	
287 	/**
288 	 * Forces the removal of all messages from a statusbar's
289 	 * stack with the exact context_id.
290 	 * Since 2.22
291 	 * Params:
292 	 * contextId = a context identifier
293 	 */
294 	public void removeAll(uint contextId)
295 	{
296 		// void gtk_statusbar_remove_all (GtkStatusbar *statusbar,  guint context_id);
297 		gtk_statusbar_remove_all(gtkStatusbar, contextId);
298 	}
299 }