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  = GtkInfoBar.html
27  * outPack = gtk
28  * outFile = InfoBar
29  * strct   = GtkInfoBar
30  * realStrct=
31  * ctorStrct=GtkWidget
32  * clss    = InfoBar
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_info_bar_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- gtk_info_bar_get_action_area
45  * 	- gtk_info_bar_get_content_area
46  * omit signals:
47  * imports:
48  * 	- glib.Str
49  * 	- gtk.Button
50  * 	- gtk.HBox;
51  * 	- gtk.VButtonBox
52  * 	- gtk.Widget
53  * structWrap:
54  * 	- GtkWidget* -> Widget
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gtk.InfoBar;
61 
62 public  import gtkc.gtktypes;
63 
64 private import gtkc.gtk;
65 private import glib.ConstructionException;
66 private import gobject.ObjectG;
67 
68 private import gobject.Signals;
69 public  import gtkc.gdktypes;
70 private import glib.Str;
71 private import gtk.Button;
72 private import gtk.HBox;;
73 private import gtk.VButtonBox;
74 private import gtk.Widget;
75 
76 
77 private import gtk.Box;
78 
79 /**
80  * GtkInfoBar is a widget that can be used to show messages to
81  * the user without showing a dialog. It is often temporarily shown
82  * at the top or bottom of a document. In contrast to GtkDialog, which
83  * has a action area at the bottom, GtkInfoBar has an action area
84  * at the side.
85  *
86  * The API of GtkInfoBar is very similar to GtkDialog, allowing you
87  * to add buttons to the action area with gtk_info_bar_add_button() or
88  * gtk_info_bar_new_with_buttons(). The sensitivity of action widgets
89  * can be controlled with gtk_info_bar_set_response_sensitive().
90  * To add widgets to the main content area of a GtkInfoBar, use
91  * gtk_info_bar_get_content_area() and add your widgets to the container.
92  *
93  * Similar to GtkMessageDialog, the contents of a GtkInfoBar can by
94  * classified as error message, warning, informational message, etc,
95  * by using gtk_info_bar_set_message_type(). GTK+ may use the message type
96  * to determine how the message is displayed.
97  *
98  * $(DDOC_COMMENT example)
99  *
100  * GtkInfoBar as GtkBuildable
101  *
102  * The GtkInfoBar implementation of the GtkBuildable interface exposes
103  * the content area and action area as internal children with the names
104  * "content_area" and "action_area".
105  *
106  * GtkInfoBar supports a custom <action-widgets> element, which
107  * can contain multiple <action-widget> elements. The "response"
108  * attribute specifies a numeric response, and the content of the element
109  * is the id of widget (which should be a child of the dialogs action_area).
110  */
111 public class InfoBar : Box
112 {
113 	
114 	/** the main Gtk struct */
115 	protected GtkInfoBar* gtkInfoBar;
116 	
117 	
118 	/** Get the main Gtk struct */
119 	public GtkInfoBar* getInfoBarStruct()
120 	{
121 		return gtkInfoBar;
122 	}
123 	
124 	
125 	/** the main Gtk struct as a void* */
126 	protected override void* getStruct()
127 	{
128 		return cast(void*)gtkInfoBar;
129 	}
130 	
131 	/**
132 	 * Sets our main struct and passes it to the parent class
133 	 */
134 	public this (GtkInfoBar* gtkInfoBar)
135 	{
136 		super(cast(GtkBox*)gtkInfoBar);
137 		this.gtkInfoBar = gtkInfoBar;
138 	}
139 	
140 	protected override void setStruct(GObject* obj)
141 	{
142 		super.setStruct(obj);
143 		gtkInfoBar = cast(GtkInfoBar*)obj;
144 	}
145 	
146 	/** */
147 	public this(string[] buttonsText, ResponseType[] responses)
148 	{
149 		this();
150 		
151 		for ( int i=0 ; i<buttonsText.length && i<responses.length ; i++)
152 		{
153 			addButton(buttonsText[i], responses[i]);
154 		}
155 	}
156 	
157 	/** */
158 	public this(StockID[] stockIDs, ResponseType[] responses)
159 	{
160 		this();
161 		
162 		for ( int i=0 ; i<stockIDs.length && i<responses.length ; i++)
163 		{
164 			addButton(stockIDs[i], responses[i]);
165 		}
166 	}
167 	
168 	/** */
169 	public Button addButton(StockID stockID, int responseId)
170 	{
171 		auto p = gtk_info_bar_add_button(gtkInfoBar, Str.toStringz(StockDesc[stockID]), responseId);
172 		
173 		if ( p is null )
174 		{
175 			return null;
176 		}
177 		
178 		return new Button(cast(GtkButton*)p);
179 	}
180 	
181 	/** */
182 	public void addButtons(string[] buttonsText, ResponseType[] responses)
183 	{
184 		for ( int i=0 ; i<buttonsText.length && i<responses.length ; i++)
185 		{
186 			addButton(buttonsText[i], responses[i]);
187 		}
188 	}
189 	
190 	/** */
191 	public void addButtons(StockID[] stockIDs, ResponseType[] responses)
192 	{
193 		for ( int i=0 ; i<stockIDs.length && i<responses.length ; i++)
194 		{
195 			addButton(stockIDs[i], responses[i]);
196 		}
197 	}
198 	
199 	/**
200 	 * Returns the action area of info_bar.
201 	 * Since 2.18
202 	 * Returns: the action area.
203 	 */
204 	public VButtonBox getActionArea()
205 	{
206 		// GtkWidget * gtk_info_bar_get_action_area (GtkInfoBar *info_bar);
207 		auto p = gtk_info_bar_get_action_area(gtkInfoBar);
208 		if(p is null)
209 		{
210 			return null;
211 		}
212 		return new VButtonBox(cast(GtkVButtonBox*) p);
213 	}
214 	
215 	/**
216 	 * Returns the content area of info_bar.
217 	 * Since 2.18
218 	 * Returns: the content area.
219 	 */
220 	public HBox getContentArea()
221 	{
222 		// GtkWidget * gtk_info_bar_get_content_area (GtkInfoBar *info_bar);
223 		auto p = gtk_info_bar_get_content_area(gtkInfoBar);
224 		if(p is null)
225 		{
226 			return null;
227 		}
228 		return new HBox(cast(GtkHBox*) p);
229 	}
230 	
231 	/**
232 	 */
233 	int[string] connectedSignals;
234 	
235 	void delegate(InfoBar)[] onCloseListeners;
236 	/**
237 	 * The ::close signal is a
238 	 * keybinding signal
239 	 * which gets emitted when the user uses a keybinding to dismiss
240 	 * the info bar.
241 	 * The default binding for this signal is the Escape key.
242 	 * Since 2.18
243 	 */
244 	void addOnClose(void delegate(InfoBar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
245 	{
246 		if ( !("close" in connectedSignals) )
247 		{
248 			Signals.connectData(
249 			getStruct(),
250 			"close",
251 			cast(GCallback)&callBackClose,
252 			cast(void*)this,
253 			null,
254 			connectFlags);
255 			connectedSignals["close"] = 1;
256 		}
257 		onCloseListeners ~= dlg;
258 	}
259 	extern(C) static void callBackClose(GtkInfoBar* arg0Struct, InfoBar _infoBar)
260 	{
261 		foreach ( void delegate(InfoBar) dlg ; _infoBar.onCloseListeners )
262 		{
263 			dlg(_infoBar);
264 		}
265 	}
266 	
267 	void delegate(gint, InfoBar)[] onResponseListeners;
268 	/**
269 	 * Emitted when an action widget is clicked or the application programmer
270 	 * calls gtk_dialog_response(). The response_id depends on which action
271 	 * widget was clicked.
272 	 * Since 2.18
273 	 * See Also
274 	 * GtkStatusbar, GtkMessageDialog
275 	 */
276 	void addOnResponse(void delegate(gint, InfoBar) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
277 	{
278 		if ( !("response" in connectedSignals) )
279 		{
280 			Signals.connectData(
281 			getStruct(),
282 			"response",
283 			cast(GCallback)&callBackResponse,
284 			cast(void*)this,
285 			null,
286 			connectFlags);
287 			connectedSignals["response"] = 1;
288 		}
289 		onResponseListeners ~= dlg;
290 	}
291 	extern(C) static void callBackResponse(GtkInfoBar* infoBarStruct, gint responseId, InfoBar _infoBar)
292 	{
293 		foreach ( void delegate(gint, InfoBar) dlg ; _infoBar.onResponseListeners )
294 		{
295 			dlg(responseId, _infoBar);
296 		}
297 	}
298 	
299 	
300 	/**
301 	 * Creates a new GtkInfoBar object.
302 	 * Since 2.18
303 	 * Throws: ConstructionException GTK+ fails to create the object.
304 	 */
305 	public this ()
306 	{
307 		// GtkWidget * gtk_info_bar_new (void);
308 		auto p = gtk_info_bar_new();
309 		if(p is null)
310 		{
311 			throw new ConstructionException("null returned by gtk_info_bar_new()");
312 		}
313 		this(cast(GtkInfoBar*) p);
314 	}
315 	
316 	/**
317 	 * Add an activatable widget to the action area of a GtkInfoBar,
318 	 * connecting a signal handler that will emit the "response"
319 	 * signal on the message area when the widget is activated. The widget
320 	 * is appended to the end of the message areas action area.
321 	 * Since 2.18
322 	 * Params:
323 	 * child = an activatable widget
324 	 * responseId = response ID for child
325 	 */
326 	public void addActionWidget(Widget child, int responseId)
327 	{
328 		// void gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,  GtkWidget *child,  gint response_id);
329 		gtk_info_bar_add_action_widget(gtkInfoBar, (child is null) ? null : child.getWidgetStruct(), responseId);
330 	}
331 	
332 	/**
333 	 * Adds a button with the given text and sets things up so that
334 	 * clicking the button will emit the "response" signal with the given
335 	 * response_id. The button is appended to the end of the info bars's
336 	 * action area. The button widget is returned, but usually you don't
337 	 * need it.
338 	 * Since 2.18
339 	 * Params:
340 	 * buttonText = text of button
341 	 * responseId = response ID for the button
342 	 * Returns: the GtkButton widget that was added. [transfer none]
343 	 */
344 	public Widget addButton(string buttonText, int responseId)
345 	{
346 		// GtkWidget * gtk_info_bar_add_button (GtkInfoBar *info_bar,  const gchar *button_text,  gint response_id);
347 		auto p = gtk_info_bar_add_button(gtkInfoBar, Str.toStringz(buttonText), responseId);
348 		
349 		if(p is null)
350 		{
351 			return null;
352 		}
353 		
354 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
355 	}
356 	
357 	/**
358 	 * Calls gtk_widget_set_sensitive (widget, setting) for each
359 	 * widget in the info bars's action area with the given response_id.
360 	 * A convenient way to sensitize/desensitize dialog buttons.
361 	 * Since 2.18
362 	 * Params:
363 	 * responseId = a response ID
364 	 * setting = TRUE for sensitive
365 	 */
366 	public void setResponseSensitive(int responseId, int setting)
367 	{
368 		// void gtk_info_bar_set_response_sensitive (GtkInfoBar *info_bar,  gint response_id,  gboolean setting);
369 		gtk_info_bar_set_response_sensitive(gtkInfoBar, responseId, setting);
370 	}
371 	
372 	/**
373 	 * Sets the last widget in the info bar's action area with
374 	 * the given response_id as the default widget for the dialog.
375 	 * Pressing "Enter" normally activates the default widget.
376 	 * Note that this function currently requires info_bar to
377 	 * be added to a widget hierarchy.
378 	 * Since 2.18
379 	 * Params:
380 	 * responseId = a response ID
381 	 */
382 	public void setDefaultResponse(int responseId)
383 	{
384 		// void gtk_info_bar_set_default_response (GtkInfoBar *info_bar,  gint response_id);
385 		gtk_info_bar_set_default_response(gtkInfoBar, responseId);
386 	}
387 	
388 	/**
389 	 * Emits the 'response' signal with the given response_id.
390 	 * Since 2.18
391 	 * Params:
392 	 * responseId = a response ID
393 	 */
394 	public void response(int responseId)
395 	{
396 		// void gtk_info_bar_response (GtkInfoBar *info_bar,  gint response_id);
397 		gtk_info_bar_response(gtkInfoBar, responseId);
398 	}
399 	
400 	/**
401 	 * Sets the message type of the message area.
402 	 * GTK+ uses this type to determine what color to use
403 	 * when drawing the message area.
404 	 * Since 2.18
405 	 * Params:
406 	 * messageType = a GtkMessageType
407 	 */
408 	public void setMessageType(GtkMessageType messageType)
409 	{
410 		// void gtk_info_bar_set_message_type (GtkInfoBar *info_bar,  GtkMessageType message_type);
411 		gtk_info_bar_set_message_type(gtkInfoBar, messageType);
412 	}
413 	
414 	/**
415 	 * Returns the message type of the message area.
416 	 * Since 2.18
417 	 * Returns: the message type of the message area.
418 	 */
419 	public GtkMessageType getMessageType()
420 	{
421 		// GtkMessageType gtk_info_bar_get_message_type (GtkInfoBar *info_bar);
422 		return gtk_info_bar_get_message_type(gtkInfoBar);
423 	}
424 	
425 	/**
426 	 * Returns whether the widget will display a standard close button.
427 	 * Returns: TRUE if the widget displays standard close button Since 3.10
428 	 */
429 	public int getShowCloseButton()
430 	{
431 		// gboolean gtk_info_bar_get_show_close_button (GtkInfoBar *info_bar);
432 		return gtk_info_bar_get_show_close_button(gtkInfoBar);
433 	}
434 	
435 	/**
436 	 * If true, a standard close button is shown. When clicked it emits
437 	 * the response GTK_RESPONSE_CLOSE.
438 	 * Params:
439 	 * setting = TRUE to include a close button
440 	 * Since 3.10
441 	 */
442 	public void setShowCloseButton(int setting)
443 	{
444 		// void gtk_info_bar_set_show_close_button (GtkInfoBar *info_bar,  gboolean setting);
445 		gtk_info_bar_set_show_close_button(gtkInfoBar, setting);
446 	}
447 }