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