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