alternative to assert
[gtkD.git] / gtkD / src / gtk / MenuToolButton.d
blob918a2d43cb2aad1755044e13cb22e9529a749bd5
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 = GtkMenuToolButton.html
26 * outPack = gtk
27 * outFile = MenuToolButton
28 * strct = GtkMenuToolButton
29 * realStrct=
30 * ctorStrct=GtkToolItem
31 * clss = MenuToolButton
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gtk_menu_tool_button_
40 * - gtk_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gtk_menu_tool_button_new
45 * - gtk_menu_tool_button_new_from_stock
46 * - gtk_menu_tool_button_get_menu
47 * imports:
48 * - glib.Str
49 * - gtk.ToolItem
50 * - gtk.Widget
51 * - gtk.Tooltips
52 * - gtk.Menu
53 * structWrap:
54 * - GtkToolItem* -> ToolItem
55 * - GtkTooltips* -> Tooltips
56 * - GtkWidget* -> Widget
57 * module aliases:
58 * local aliases:
61 module gtk.MenuToolButton;
63 version(noAssert)
65 version(Tango)
67 import tango.io.Stdout; // use the tango loging?
71 private import gtkc.gtktypes;
73 private import gtkc.gtk;
76 private import glib.Str;
77 private import gtk.ToolItem;
78 private import gtk.Widget;
79 private import gtk.Tooltips;
80 private import gtk.Menu;
85 /**
86 * Description
87 * A GtkMenuToolButton is a GtkToolItem that contains a button and
88 * a small additional button with an arrow. When clicked, the arrow
89 * button pops up a dropdown menu.
90 * Use gtk_menu_tool_button_new() to create a new
91 * GtkMenuToolButton. Use gtk_menu_tool_button_new_from_stock() to
92 * create a new GtkMenuToolButton containing a stock item.
94 private import gtk.ToolButton;
95 public class MenuToolButton : ToolButton
98 /** the main Gtk struct */
99 protected GtkMenuToolButton* gtkMenuToolButton;
102 public GtkMenuToolButton* getMenuToolButtonStruct()
104 return gtkMenuToolButton;
108 /** the main Gtk struct as a void* */
109 protected void* getStruct()
111 return cast(void*)gtkMenuToolButton;
115 * Sets our main struct and passes it to the parent class
117 public this (GtkMenuToolButton* gtkMenuToolButton)
119 version(noAssert)
121 if ( gtkMenuToolButton is null )
123 int zero = 0;
124 version(Tango)
126 Stdout("struct gtkMenuToolButton is null on constructor").newline;
128 else
130 printf("struct gtkMenuToolButton is null on constructor");
132 zero = zero / zero;
135 else
137 assert(gtkMenuToolButton !is null, "struct gtkMenuToolButton is null on constructor");
139 super(cast(GtkToolButton*)gtkMenuToolButton);
140 this.gtkMenuToolButton = gtkMenuToolButton;
144 * Creates a new GtkMenuToolButton using icon_widget as icon and
145 * label as label.
146 * icon_widget:
147 * a widget that will be used as icon widget, or NULL
148 * label:
149 * a string that will be used as label, or NULL
150 * Returns:
151 * the new GtkMenuToolButton
152 * Since 2.6
154 public this(Widget iconWidget, char[] label)
156 // GtkToolItem* gtk_menu_tool_button_new (GtkWidget *icon_widget, const gchar *label);
157 this( cast(GtkMenuToolButton*)gtk_menu_tool_button_new(
158 (iconWidget is null) ? null : iconWidget.getWidgetStruct(),
159 Str.toStringz(label))
164 * Creates a new GtkMenuToolButton.
165 * The new GtkMenuToolButton will contain an icon and label from
166 * the stock item indicated by stock_id.
167 * stock_id:
168 * the name of a stock item
169 * Returns:
170 * the new GtkMenuToolButton
171 * Since 2.6
173 public this(StockID stockId)
175 // GtkToolItem* gtk_menu_tool_button_new_from_stock (const gchar *stock_id);
176 this(
177 cast(GtkMenuToolButton*)gtk_menu_tool_button_new_from_stock(
178 Str.toStringz(StockDesc[stockId]))
183 * Gets the GtkMenu associated with GtkMenuToolButton.
184 * button:
185 * a GtkMenuToolButton
186 * Returns:
187 * the GtkMenu associated with GtkMenuToolButton
188 * Since 2.6
190 public Menu getMenu()
192 // GtkWidget* gtk_menu_tool_button_get_menu (GtkMenuToolButton *button);
193 return new Menu( cast(GtkMenu*)gtk_menu_tool_button_get_menu(gtkMenuToolButton) );
197 * Sets the toolTip for the arrow
198 * Params:
199 * tipText =
200 * tipPrivate =
202 public void setArrowTooltip(char[] tipText, char[] tipPrivate)
204 Tooltips tooltips = new Tooltips();
205 gtk_menu_tool_button_set_arrow_tooltip(
206 gtkMenuToolButton,
207 (tooltips is null) ? null : tooltips.getTooltipsStruct(),
208 Str.toStringz(tipText),
209 Str.toStringz(tipPrivate)
216 // imports for the signal processing
217 private import gobject.Signals;
218 private import gtkc.gdktypes;
219 int[char[]] connectedSignals;
221 void delegate(MenuToolButton)[] onShowMenuListeners;
222 void addOnShowMenu(void delegate(MenuToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
224 if ( !("show-menu" in connectedSignals) )
226 Signals.connectData(
227 getStruct(),
228 "show-menu",
229 cast(GCallback)&callBackShowMenu,
230 cast(void*)this,
231 null,
232 connectFlags);
233 connectedSignals["show-menu"] = 1;
235 onShowMenuListeners ~= dlg;
237 extern(C) static void callBackShowMenu(GtkMenuToolButton* menutoolbuttonStruct, MenuToolButton menuToolButton)
239 bool consumed = false;
241 foreach ( void delegate(MenuToolButton) dlg ; menuToolButton.onShowMenuListeners )
243 dlg(menuToolButton);
246 return consumed;
254 * Sets the GtkMenu that is popped up when the user clicks on the arrow.
255 * If menu is NULL, the arrow button becomes insensitive.
256 * button:
257 * a GtkMenuToolButton
258 * menu:
259 * the GtkMenu associated with GtkMenuToolButton
260 * Since 2.6
262 public void setMenu(Widget menu)
264 // void gtk_menu_tool_button_set_menu (GtkMenuToolButton *button, GtkWidget *menu);
265 gtk_menu_tool_button_set_menu(gtkMenuToolButton, (menu is null) ? null : menu.getWidgetStruct());
270 * Sets the GtkTooltips object to be used for arrow button which
271 * pops up the menu. See gtk_tool_item_set_tooltip() for setting
272 * a tooltip on the whole GtkMenuToolButton.
273 * button:
274 * a GtkMenuToolButton
275 * tooltips:
276 * the GtkTooltips object to be used
277 * tip_text:
278 * text to be used as tooltip text for tool_item
279 * tip_private:
280 * text to be used as private tooltip text
281 * Since 2.6
282 * Property Details
283 * The "menu" property
284 * "menu" GtkMenu : Read / Write
285 * The dropdown menu.
286 * Signal Details
287 * The "show-menu" signal
288 * void user_function (GtkMenuToolButton *menutoolbutton,
289 * gpointer user_data) : Run First
290 * menutoolbutton:
291 * the object which received the signal.
292 * user_data:
293 * user data set when the signal handler was connected.
294 * See Also
295 * GtkToolbar, GtkToolButton
296 * The toolbar widget
297 * The parent class of GtkMenuToolButton. The properties
298 * "label_widget", "label", "icon_widget", and "stock_id" on
299 * GtkToolButton determine the label and icon used on
300 * GtkMenuToolButtons.
302 public void setArrowTooltip(Tooltips tooltips, char[] tipText, char[] tipPrivate)
304 // void gtk_menu_tool_button_set_arrow_tooltip (GtkMenuToolButton *button, GtkTooltips *tooltips, const gchar *tip_text, const gchar *tip_private);
305 gtk_menu_tool_button_set_arrow_tooltip(gtkMenuToolButton, (tooltips is null) ? null : tooltips.getTooltipsStruct(), Str.toStringz(tipText), Str.toStringz(tipPrivate));