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  = GtkToolButton.html
27  * outPack = gtk
28  * outFile = ToolButton
29  * strct   = GtkToolButton
30  * realStrct=
31  * ctorStrct=GtkToolItem
32  * clss    = ToolButton
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_tool_button_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- gtk.ToolItem
49  * 	- gtk.Widget
50  * structWrap:
51  * 	- GtkWidget* -> Widget
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module gtk.ToolButton;
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 
68 private import glib.Str;
69 private import gtk.ToolItem;
70 private import gtk.Widget;
71 
72 
73 
74 private import gtk.ToolItem;
75 
76 /**
77  * Description
78  * GtkToolButtons are GtkToolItems containing buttons.
79  * Use gtk_tool_button_new() to create a new GtkToolButton. Use
80  * gtk_tool_button_new_with_stock() to create a GtkToolButton
81  * containing a stock item.
82  * The label of a GtkToolButton is determined by the properties
83  * "label-widget", "label", and "stock-id". If "label-widget" is
84  * non-NULL, then that widget is used as the label. Otherwise, if
85  * "label" is non-NULL, that string is used as the label. Otherwise, if
86  * "stock-id" is non-NULL, the label is determined by the stock
87  * item. Otherwise, the button does not have a label.
88  * The icon of a GtkToolButton is determined by the properties
89  * "icon-widget" and "stock-id". If "icon-widget" is non-NULL, then
90  * that widget is used as the icon. Otherwise, if "stock-id" is
91  * non-NULL, the icon is determined by the stock item. Otherwise,
92  * the button does not have a icon.
93  */
94 public class ToolButton : ToolItem
95 {
96 	
97 	/** the main Gtk struct */
98 	protected GtkToolButton* gtkToolButton;
99 	
100 	
101 	public GtkToolButton* getToolButtonStruct()
102 	{
103 		return gtkToolButton;
104 	}
105 	
106 	
107 	/** the main Gtk struct as a void* */
108 	protected override void* getStruct()
109 	{
110 		return cast(void*)gtkToolButton;
111 	}
112 	
113 	/**
114 	 * Sets our main struct and passes it to the parent class
115 	 */
116 	public this (GtkToolButton* gtkToolButton)
117 	{
118 		super(cast(GtkToolItem*)gtkToolButton);
119 		this.gtkToolButton = gtkToolButton;
120 	}
121 	
122 	protected override void setStruct(GObject* obj)
123 	{
124 		super.setStruct(obj);
125 		gtkToolButton = cast(GtkToolButton*)obj;
126 	}
127 	
128 	/** An arbitrary string to be used by the application */
129 	private string action;
130 	
131 	/** */
132 	public void setActionName(string action)
133 	{
134 		this.action = action;
135 	}
136 	
137 	/** */
138 	public string getActionName()
139 	{
140 		return action;
141 	}
142 	
143 	/** */
144 	public this (StockID stockID)
145 	{
146 		this(StockDesc[stockID]);
147 	}
148 	
149 	/**
150 	 */
151 	int[string] connectedSignals;
152 	
153 	void delegate(ToolButton)[] onClickedListeners;
154 	/**
155 	 * This signal is emitted when the tool button is clicked with the mouse
156 	 * or activated with the keyboard.
157 	 * See Also
158 	 * GtkToolbar
159 	 * The toolbar widget
160 	 * GtkMenuToolButton
161 	 * A subclass of GtkToolButton that displays on
162 	 *  the toolbar a button with an additional dropdown
163 	 *  menu
164 	 * GtkToggleToolButton
165 	 * A subclass of GtkToolButton that displays toggle
166 	 *  buttons on the toolbar
167 	 * GtkRadioToolButton
168 	 * A subclass of GtkToolButton that displays radio
169 	 *  buttons on the toolbar
170 	 * GtkSeparatorToolItem
171 	 * A subclass of GtkToolItem that separates groups of
172 	 *  items on a toolbar
173 	 */
174 	void addOnClicked(void delegate(ToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
175 	{
176 		if ( !("clicked" in connectedSignals) )
177 		{
178 			Signals.connectData(
179 			getStruct(),
180 			"clicked",
181 			cast(GCallback)&callBackClicked,
182 			cast(void*)this,
183 			null,
184 			connectFlags);
185 			connectedSignals["clicked"] = 1;
186 		}
187 		onClickedListeners ~= dlg;
188 	}
189 	extern(C) static void callBackClicked(GtkToolButton* toolbuttonStruct, ToolButton _toolButton)
190 	{
191 		foreach ( void delegate(ToolButton) dlg ; _toolButton.onClickedListeners )
192 		{
193 			dlg(_toolButton);
194 		}
195 	}
196 	
197 	
198 	/**
199 	 * Creates a new GtkToolButton using icon_widget as icon and label as
200 	 * label.
201 	 * Since 2.4
202 	 * Params:
203 	 * iconWidget = a GtkMisc widget that will be used as icon widget, or NULL. [allow-none]
204 	 * label = a string that will be used as label, or NULL. [allow-none]
205 	 * Throws: ConstructionException GTK+ fails to create the object.
206 	 */
207 	public this (Widget iconWidget, string label)
208 	{
209 		// GtkToolItem * gtk_tool_button_new (GtkWidget *icon_widget,  const gchar *label);
210 		auto p = gtk_tool_button_new((iconWidget is null) ? null : iconWidget.getWidgetStruct(), Str.toStringz(label));
211 		if(p is null)
212 		{
213 			throw new ConstructionException("null returned by gtk_tool_button_new((iconWidget is null) ? null : iconWidget.getWidgetStruct(), Str.toStringz(label))");
214 		}
215 		this(cast(GtkToolButton*) p);
216 	}
217 	
218 	/**
219 	 * Creates a new GtkToolButton containing the image and text from a
220 	 * stock item. Some stock ids have preprocessor macros like GTK_STOCK_OK
221 	 * and GTK_STOCK_APPLY.
222 	 * It is an error if stock_id is not a name of a stock item.
223 	 * Since 2.4
224 	 * Params:
225 	 * stockId = the name of the stock item
226 	 * Throws: ConstructionException GTK+ fails to create the object.
227 	 */
228 	public this (string stockId)
229 	{
230 		// GtkToolItem * gtk_tool_button_new_from_stock (const gchar *stock_id);
231 		auto p = gtk_tool_button_new_from_stock(Str.toStringz(stockId));
232 		if(p is null)
233 		{
234 			throw new ConstructionException("null returned by gtk_tool_button_new_from_stock(Str.toStringz(stockId))");
235 		}
236 		this(cast(GtkToolButton*) p);
237 	}
238 	
239 	/**
240 	 * Sets label as the label used for the tool button. The "label" property
241 	 * only has an effect if not overridden by a non-NULL "label_widget" property.
242 	 * If both the "label_widget" and "label" properties are NULL, the label
243 	 * is determined by the "stock_id" property. If the "stock_id" property is also
244 	 * NULL, button will not have a label.
245 	 * Since 2.4
246 	 * Params:
247 	 * label = a string that will be used as label, or NULL. [allow-none]
248 	 */
249 	public void setLabel(string label)
250 	{
251 		// void gtk_tool_button_set_label (GtkToolButton *button,  const gchar *label);
252 		gtk_tool_button_set_label(gtkToolButton, Str.toStringz(label));
253 	}
254 	
255 	/**
256 	 * Returns the label used by the tool button, or NULL if the tool button
257 	 * doesn't have a label. or uses a the label from a stock item. The returned
258 	 * string is owned by GTK+, and must not be modified or freed.
259 	 * Since 2.4
260 	 * Returns: The label, or NULL
261 	 */
262 	public string getLabel()
263 	{
264 		// const gchar * gtk_tool_button_get_label (GtkToolButton *button);
265 		return Str.toString(gtk_tool_button_get_label(gtkToolButton));
266 	}
267 	
268 	/**
269 	 * If set, an underline in the label property indicates that the next character
270 	 * should be used for the mnemonic accelerator key in the overflow menu. For
271 	 * example, if the label property is "_Open" and use_underline is TRUE,
272 	 * the label on the tool button will be "Open" and the item on the overflow
273 	 * menu will have an underlined 'O'.
274 	 * Labels shown on tool buttons never have mnemonics on them; this property
275 	 * only affects the menu item on the overflow menu.
276 	 * Since 2.4
277 	 * Params:
278 	 * useUnderline = whether the button label has the form "_Open"
279 	 */
280 	public void setUseUnderline(int useUnderline)
281 	{
282 		// void gtk_tool_button_set_use_underline (GtkToolButton *button,  gboolean use_underline);
283 		gtk_tool_button_set_use_underline(gtkToolButton, useUnderline);
284 	}
285 	
286 	/**
287 	 * Returns whether underscores in the label property are used as mnemonics
288 	 * on menu items on the overflow menu. See gtk_tool_button_set_use_underline().
289 	 * Since 2.4
290 	 * Returns: TRUE if underscores in the label property are used as mnemonics on menu items on the overflow menu.
291 	 */
292 	public int getUseUnderline()
293 	{
294 		// gboolean gtk_tool_button_get_use_underline (GtkToolButton *button);
295 		return gtk_tool_button_get_use_underline(gtkToolButton);
296 	}
297 	
298 	/**
299 	 * Sets the name of the stock item. See gtk_tool_button_new_from_stock().
300 	 * The stock_id property only has an effect if not
301 	 * overridden by non-NULL "label" and "icon_widget" properties.
302 	 * Since 2.4
303 	 * Params:
304 	 * stockId = a name of a stock item, or NULL. [allow-none]
305 	 */
306 	public void setStockId(string stockId)
307 	{
308 		// void gtk_tool_button_set_stock_id (GtkToolButton *button,  const gchar *stock_id);
309 		gtk_tool_button_set_stock_id(gtkToolButton, Str.toStringz(stockId));
310 	}
311 	
312 	/**
313 	 * Returns the name of the stock item. See gtk_tool_button_set_stock_id().
314 	 * The returned string is owned by GTK+ and must not be freed or modifed.
315 	 * Since 2.4
316 	 * Returns: the name of the stock item for button.
317 	 */
318 	public string getStockId()
319 	{
320 		// const gchar * gtk_tool_button_get_stock_id (GtkToolButton *button);
321 		return Str.toString(gtk_tool_button_get_stock_id(gtkToolButton));
322 	}
323 	
324 	/**
325 	 * Sets the icon for the tool button from a named themed icon.
326 	 * See the docs for GtkIconTheme for more details.
327 	 * The "icon_name" property only has an effect if not
328 	 * overridden by non-NULL "label", "icon_widget" and "stock_id"
329 	 * properties.
330 	 * Since 2.8
331 	 * Params:
332 	 * iconName = the name of the themed icon. [allow-none]
333 	 */
334 	public void setIconName(string iconName)
335 	{
336 		// void gtk_tool_button_set_icon_name (GtkToolButton *button,  const gchar *icon_name);
337 		gtk_tool_button_set_icon_name(gtkToolButton, Str.toStringz(iconName));
338 	}
339 	
340 	/**
341 	 * Returns the name of the themed icon for the tool button,
342 	 * see gtk_tool_button_set_icon_name().
343 	 * Since 2.8
344 	 * Returns: the icon name or NULL if the tool button has no themed icon
345 	 */
346 	public string getIconName()
347 	{
348 		// const gchar * gtk_tool_button_get_icon_name (GtkToolButton *button);
349 		return Str.toString(gtk_tool_button_get_icon_name(gtkToolButton));
350 	}
351 	
352 	/**
353 	 * Sets icon as the widget used as icon on button. If icon_widget is
354 	 * NULL the icon is determined by the "stock_id" property. If the
355 	 * "stock_id" property is also NULL, button will not have an icon.
356 	 * Since 2.4
357 	 * Params:
358 	 * iconWidget = the widget used as icon, or NULL. [allow-none]
359 	 */
360 	public void setIconWidget(Widget iconWidget)
361 	{
362 		// void gtk_tool_button_set_icon_widget (GtkToolButton *button,  GtkWidget *icon_widget);
363 		gtk_tool_button_set_icon_widget(gtkToolButton, (iconWidget is null) ? null : iconWidget.getWidgetStruct());
364 	}
365 	
366 	/**
367 	 * Return the widget used as icon widget on button.
368 	 * See gtk_tool_button_set_icon_widget().
369 	 * Since 2.4
370 	 * Returns: The widget used as icon on button, or NULL. [transfer none]
371 	 */
372 	public Widget getIconWidget()
373 	{
374 		// GtkWidget * gtk_tool_button_get_icon_widget (GtkToolButton *button);
375 		auto p = gtk_tool_button_get_icon_widget(gtkToolButton);
376 		
377 		if(p is null)
378 		{
379 			return null;
380 		}
381 		
382 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
383 	}
384 	
385 	/**
386 	 * Sets label_widget as the widget that will be used as the label
387 	 * for button. If label_widget is NULL the "label" property is used
388 	 * as label. If "label" is also NULL, the label in the stock item
389 	 * determined by the "stock_id" property is used as label. If
390 	 * "stock_id" is also NULL, button does not have a label.
391 	 * Since 2.4
392 	 * Params:
393 	 * labelWidget = the widget used as label, or NULL. [allow-none]
394 	 */
395 	public void setLabelWidget(Widget labelWidget)
396 	{
397 		// void gtk_tool_button_set_label_widget (GtkToolButton *button,  GtkWidget *label_widget);
398 		gtk_tool_button_set_label_widget(gtkToolButton, (labelWidget is null) ? null : labelWidget.getWidgetStruct());
399 	}
400 	
401 	/**
402 	 * Returns the widget used as label on button.
403 	 * See gtk_tool_button_set_label_widget().
404 	 * Since 2.4
405 	 * Returns: The widget used as label on button, or NULL. [transfer none]
406 	 */
407 	public Widget getLabelWidget()
408 	{
409 		// GtkWidget * gtk_tool_button_get_label_widget (GtkToolButton *button);
410 		auto p = gtk_tool_button_get_label_widget(gtkToolButton);
411 		
412 		if(p is null)
413 		{
414 			return null;
415 		}
416 		
417 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
418 	}
419 }