Wrote the README_GIT file to be a proper tutorial on git, repo.or.cz and gtkD.
[gtkD.git] / gtkD / src / gtk / ToolButton.d
blob6df476fa5c0a580072ae892ed2dc49bab395767e
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkToolButton.html
26 * outPack = gtk
27 * outFile = ToolButton
28 * strct = GtkToolButton
29 * realStrct=
30 * ctorStrct=GtkToolItem
31 * clss = ToolButton
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_tool_button_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * - gtk.ToolItem
47 * - gtk.Widget
48 * structWrap:
49 * - GtkWidget* -> Widget
50 * module aliases:
51 * local aliases:
54 module gtk.ToolButton;
56 version(noAssert)
58 version(Tango)
60 import tango.io.Stdout; // use the tango loging?
64 private import gtkc.gtktypes;
66 private import gtkc.gtk;
69 private import glib.Str;
70 private import gtk.ToolItem;
71 private import gtk.Widget;
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 label.
94 private import gtk.ToolItem;
95 public class ToolButton : ToolItem
98 /** the main Gtk struct */
99 protected GtkToolButton* gtkToolButton;
102 public GtkToolButton* getToolButtonStruct()
104 return gtkToolButton;
108 /** the main Gtk struct as a void* */
109 protected void* getStruct()
111 return cast(void*)gtkToolButton;
115 * Sets our main struct and passes it to the parent class
117 public this (GtkToolButton* gtkToolButton)
119 version(noAssert)
121 if ( gtkToolButton is null )
123 int zero = 0;
124 version(Tango)
126 Stdout("struct gtkToolButton is null on constructor").newline;
128 else
130 printf("struct gtkToolButton is null on constructor");
132 zero = zero / zero;
135 else
137 assert(gtkToolButton !is null, "struct gtkToolButton is null on constructor");
139 super(cast(GtkToolItem*)gtkToolButton);
140 this.gtkToolButton = gtkToolButton;
143 /** An arbitrary string to be used by the application */
144 private char[] action;
146 public void setActionName(char[] action)
148 this.action = action.dup;
151 public char[] getActionName()
153 return action;
156 public this (StockID stockID)
158 this(StockDesc[stockID]);
165 // imports for the signal processing
166 private import gobject.Signals;
167 private import gtkc.gdktypes;
168 int[char[]] connectedSignals;
170 void delegate(ToolButton)[] onClickedListeners;
171 void addOnClicked(void delegate(ToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
173 if ( !("clicked" in connectedSignals) )
175 Signals.connectData(
176 getStruct(),
177 "clicked",
178 cast(GCallback)&callBackClicked,
179 cast(void*)this,
180 null,
181 connectFlags);
182 connectedSignals["clicked"] = 1;
184 onClickedListeners ~= dlg;
186 extern(C) static void callBackClicked(GtkToolButton* toolbuttonStruct, ToolButton toolButton)
188 bool consumed = false;
190 foreach ( void delegate(ToolButton) dlg ; toolButton.onClickedListeners )
192 dlg(toolButton);
195 return consumed;
201 * Creates a new GtkToolButton using icon_widget as icon and label as
202 * label.
203 * icon_widget:
204 * a widget that will be used as icon widget, or NULL
205 * label:
206 * a string that will be used as label, or NULL
207 * Returns:
208 * A new GtkToolButton
209 * Since 2.4
211 public this (Widget iconWidget, char[] label)
213 // GtkToolItem* gtk_tool_button_new (GtkWidget *icon_widget, const gchar *label);
214 this(cast(GtkToolButton*)gtk_tool_button_new((iconWidget is null) ? null : iconWidget.getWidgetStruct(), Str.toStringz(label)) );
218 * Creates a new GtkToolButton containing the image and text from a
219 * stock item. Some stock ids have preprocessor macros like GTK_STOCK_OK
220 * and GTK_STOCK_APPLY.
221 * It is an error if stock_id is not a name of a stock item.
222 * stock_id:
223 * the name of the stock item
224 * Returns:
225 * A new GtkToolButton
226 * Since 2.4
228 public this (char[] stockId)
230 // GtkToolItem* gtk_tool_button_new_from_stock (const gchar *stock_id);
231 this(cast(GtkToolButton*)gtk_tool_button_new_from_stock(Str.toStringz(stockId)) );
235 * Sets label as the label used for the tool button. The "label" property
236 * only has an effect if not overridden by a non-NULL "label_widget" property.
237 * If both the "label_widget" and "label" properties are NULL, the label
238 * is determined by the "stock_id" property. If the "stock_id" property is also
239 * NULL, button will not have a label.
240 * button:
241 * a GtkToolButton
242 * label:
243 * a string that will be used as label, or NULL.
244 * Since 2.4
246 public void setLabel(char[] label)
248 // void gtk_tool_button_set_label (GtkToolButton *button, const gchar *label);
249 gtk_tool_button_set_label(gtkToolButton, Str.toStringz(label));
253 * Returns the label used by the tool button, or NULL if the tool button
254 * doesn't have a label. or uses a the label from a stock item. The returned
255 * string is owned by GTK+, and must not be modified or freed.
256 * button:
257 * a GtkToolButton
258 * Returns:
259 * The label, or NULL
260 * Since 2.4
262 public char[] getLabel()
264 // const gchar* gtk_tool_button_get_label (GtkToolButton *button);
265 return Str.toString(gtk_tool_button_get_label(gtkToolButton) );
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 * button:
277 * a GtkToolButton
278 * use_underline:
279 * whether the button label has the form "_Open"
280 * Since 2.4
282 public void setUseUnderline(int useUnderline)
284 // void gtk_tool_button_set_use_underline (GtkToolButton *button, gboolean use_underline);
285 gtk_tool_button_set_use_underline(gtkToolButton, useUnderline);
289 * Returns whether underscores in the label property are used as mnemonics
290 * on menu items on the overflow menu. See gtk_tool_button_set_use_underline().
291 * button:
292 * a GtkToolButton
293 * Returns:
294 * TRUE if underscores in the label property are used as
295 * mnemonics on menu items on the overflow menu.
296 * Since 2.4
298 public int getUseUnderline()
300 // gboolean gtk_tool_button_get_use_underline (GtkToolButton *button);
301 return gtk_tool_button_get_use_underline(gtkToolButton);
305 * Sets the name of the stock item. See gtk_tool_button_new_from_stock().
306 * The stock_id property only has an effect if not
307 * overridden by non-NULL "label" and "icon_widget" properties.
308 * button:
309 * a GtkToolButton
310 * stock_id:
311 * a name of a stock item, or NULL
312 * Since 2.4
314 public void setStockId(char[] stockId)
316 // void gtk_tool_button_set_stock_id (GtkToolButton *button, const gchar *stock_id);
317 gtk_tool_button_set_stock_id(gtkToolButton, Str.toStringz(stockId));
321 * Returns the name of the stock item. See gtk_tool_button_set_stock_id().
322 * The returned string is owned by GTK+ and must not be freed or modifed.
323 * button:
324 * a GtkToolButton
325 * Returns:
326 * the name of the stock item for button.
327 * Since 2.4
329 public char[] getStockId()
331 // const gchar* gtk_tool_button_get_stock_id (GtkToolButton *button);
332 return Str.toString(gtk_tool_button_get_stock_id(gtkToolButton) );
336 * Sets the icon for the tool button from a named themed icon.
337 * See the docs for GtkIconTheme for more details.
338 * The "icon_name" property only has an effect if not
339 * overridden by non-NULL "label", "icon_widget" and "stock_id"
340 * properties.
341 * button:
342 * a GtkToolButton
343 * icon_name:
344 * the name of the themed icon
345 * Since 2.8
347 public void setIconName(char[] iconName)
349 // void gtk_tool_button_set_icon_name (GtkToolButton *button, const gchar *icon_name);
350 gtk_tool_button_set_icon_name(gtkToolButton, Str.toStringz(iconName));
354 * Returns the name of the themed icon for the tool button,
355 * see gtk_tool_button_set_icon_name().
356 * button:
357 * a GtkToolButton
358 * Returns:
359 * the icon name or NULL if the tool button has
360 * no themed icon
361 * Since 2.8
363 public char[] getIconName()
365 // const gchar* gtk_tool_button_get_icon_name (GtkToolButton *button);
366 return Str.toString(gtk_tool_button_get_icon_name(gtkToolButton) );
370 * Sets icon as the widget used as icon on button. If icon_widget is
371 * NULL the icon is determined by the "stock_id" property. If the
372 * "stock_id" property is also NULL, button will not have an icon.
373 * button:
374 * a GtkToolButton
375 * icon_widget:
376 * the widget used as icon, or NULL
377 * Since 2.4
379 public void setIconWidget(Widget iconWidget)
381 // void gtk_tool_button_set_icon_widget (GtkToolButton *button, GtkWidget *icon_widget);
382 gtk_tool_button_set_icon_widget(gtkToolButton, (iconWidget is null) ? null : iconWidget.getWidgetStruct());
386 * Return the widget used as icon widget on button. See
387 * gtk_tool_button_set_icon_widget().
388 * button:
389 * a GtkToolButton
390 * Returns:
391 * The widget used as icon on button, or NULL.
392 * Since 2.4
394 public Widget getIconWidget()
396 // GtkWidget* gtk_tool_button_get_icon_widget (GtkToolButton *button);
397 return new Widget( gtk_tool_button_get_icon_widget(gtkToolButton) );
401 * Sets label_widget as the widget that will be used as the label
402 * for button. If label_widget is NULL the "label" property is used
403 * as label. If "label" is also NULL, the label in the stock item
404 * determined by the "stock_id" property is used as label. If
405 * "stock_id" is also NULL, button does not have a label.
406 * button:
407 * a GtkToolButton
408 * label_widget:
409 * the widget used as label, or NULL
410 * Since 2.4
412 public void setLabelWidget(Widget labelWidget)
414 // void gtk_tool_button_set_label_widget (GtkToolButton *button, GtkWidget *label_widget);
415 gtk_tool_button_set_label_widget(gtkToolButton, (labelWidget is null) ? null : labelWidget.getWidgetStruct());
419 * Returns the widget used as label on button. See
420 * gtk_tool_button_set_label_widget().
421 * button:
422 * a GtkToolButton
423 * Returns:
424 * The widget used as label on button, or NULL.
425 * Since 2.4
426 * Property Details
427 * The "icon-name" property
428 * "icon-name" gchararray : Read / Write
429 * The name of the themed icon displayed on the item.
430 * This property only has an effect if not overridden by "label",
431 * "icon_widget" or "stock_id" properties.
432 * Default value: NULL
433 * Since 2.8
435 public Widget getLabelWidget()
437 // GtkWidget* gtk_tool_button_get_label_widget (GtkToolButton *button);
438 return new Widget( gtk_tool_button_get_label_widget(gtkToolButton) );