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