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  = GtkMenuToolButton.html
27  * outPack = gtk
28  * outFile = MenuToolButton
29  * strct   = GtkMenuToolButton
30  * realStrct=
31  * ctorStrct=GtkToolItem
32  * clss    = MenuToolButton
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_menu_tool_button_
41  * 	- gtk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * 	- gtk_menu_tool_button_new
46  * 	- gtk_menu_tool_button_new_from_stock
47  * 	- gtk_menu_tool_button_get_menu
48  * omit signals:
49  * imports:
50  * 	- glib.Str
51  * 	- gtk.ToolItem
52  * 	- gtk.Widget
53  * 	- gtk.Tooltips
54  * 	- gtk.Menu
55  * structWrap:
56  * 	- GtkToolItem* -> ToolItem
57  * 	- GtkTooltips* -> Tooltips
58  * 	- GtkWidget* -> Widget
59  * module aliases:
60  * local aliases:
61  * overrides:
62  */
63 
64 module gtk.MenuToolButton;
65 
66 public  import gtkc.gtktypes;
67 
68 private import gtkc.gtk;
69 private import glib.ConstructionException;
70 private import gobject.ObjectG;
71 
72 private import gobject.Signals;
73 public  import gtkc.gdktypes;
74 
75 private import glib.Str;
76 private import gtk.ToolItem;
77 private import gtk.Widget;
78 private import gtk.Tooltips;
79 private import gtk.Menu;
80 
81 
82 
83 private import gtk.ToolButton;
84 
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.
93  * GtkMenuToolButton as GtkBuildable
94  * The GtkMenuToolButton implementation of the GtkBuildable interface
95  * supports adding a menu by specifying "menu" as the "type"
96  * attribute of a <child> element.
97  * $(DDOC_COMMENT example)
98  */
99 public class MenuToolButton : ToolButton
100 {
101 	
102 	/** the main Gtk struct */
103 	protected GtkMenuToolButton* gtkMenuToolButton;
104 	
105 	
106 	public GtkMenuToolButton* getMenuToolButtonStruct()
107 	{
108 		return gtkMenuToolButton;
109 	}
110 	
111 	
112 	/** the main Gtk struct as a void* */
113 	protected override void* getStruct()
114 	{
115 		return cast(void*)gtkMenuToolButton;
116 	}
117 	
118 	/**
119 	 * Sets our main struct and passes it to the parent class
120 	 */
121 	public this (GtkMenuToolButton* gtkMenuToolButton)
122 	{
123 		super(cast(GtkToolButton*)gtkMenuToolButton);
124 		this.gtkMenuToolButton = gtkMenuToolButton;
125 	}
126 	
127 	protected override void setStruct(GObject* obj)
128 	{
129 		super.setStruct(obj);
130 		gtkMenuToolButton = cast(GtkMenuToolButton*)obj;
131 	}
132 	
133 	/**
134 	 * Creates a new GtkMenuToolButton using icon_widget as icon and
135 	 * label as label.
136 	 * Since 2.6
137 	 * Params:
138 	 *  iconWidget = a widget that will be used as icon widget, or NULL
139 	 *  label = a string that will be used as label, or NULL
140 	 * Throws: ConstructionException GTK+ fails to create the object.
141 	 */
142 	public this(Widget iconWidget, string label)
143 	{
144 		// GtkToolItem* gtk_menu_tool_button_new (GtkWidget *icon_widget,  const gchar *label);
145 		auto p = gtk_menu_tool_button_new((iconWidget is null) ? null : iconWidget.getWidgetStruct(),
146 		Str.toStringz(label));
147 		
148 		if(p is null)
149 		{
150 			throw new ConstructionException("null returned by gtk_menu_tool_button_new");
151 		}
152 		
153 		this(cast(GtkMenuToolButton*) p);
154 	}
155 	
156 	/**
157 	 * Creates a new GtkMenuToolButton.
158 	 * The new GtkMenuToolButton will contain an icon and label from
159 	 * the stock item indicated by stockID.
160 	 * Since 2.6
161 	 * Params:
162 	 * stockID = the name of a stock item
163 	 * Throws: ConstructionException GTK+ fails to create the object.
164 	 */
165 	public this(StockID stockId)
166 	{
167 		// GtkToolItem* gtk_menu_tool_button_new_from_stock  (const gchar *stock_id);
168 		auto p = gtk_menu_tool_button_new_from_stock(
169 		Str.toStringz(StockDesc[stockId]));
170 		
171 		if(p is null)
172 		{
173 			throw new ConstructionException("null returned by gtk_menu_tool_button_new_from_stock");
174 		}
175 		
176 		this(cast(GtkMenuToolButton*) p);
177 	}
178 	
179 	/**
180 	 * Gets the GtkMenu associated with GtkMenuToolButton.
181 	 * Since 2.6
182 	 * Params:
183 	 *  button = a GtkMenuToolButton
184 	 * Returns:
185 	 *  the GtkMenu associated with GtkMenuToolButton
186 	 */
187 	public Menu getMenu()
188 	{
189 		// GtkWidget* gtk_menu_tool_button_get_menu (GtkMenuToolButton *button);
190 		auto p =  gtk_menu_tool_button_get_menu(gtkMenuToolButton);
191 		if(p is null)
192 		{
193 			return null;
194 		}
195 		return new Menu(cast(GtkMenu*)p);
196 	}
197 	
198 	/**
199 	 * Sets the toolTip for the arrow
200 	 * Deprecated: Since 2.12 use Widget.setArrowTooltipText() or Widget.setArrowTooltipMarkup()
201 	 * Params:
202 	 *    	tipText =
203 	 *    	tipPrivate =
204 	 */
205 	public void setArrowTooltip(string tipText, string tipPrivate)
206 	{
207 		Tooltips tooltips = new Tooltips();
208 		gtk_menu_tool_button_set_arrow_tooltip(
209 		gtkMenuToolButton,
210 		(tooltips is null) ? null : tooltips.getTooltipsStruct(),
211 		Str.toStringz(tipText),
212 		Str.toStringz(tipPrivate)
213 		);
214 	}
215 	
216 	/**
217 	 */
218 	int[string] connectedSignals;
219 	
220 	void delegate(MenuToolButton)[] onShowMenuListeners;
221 	/**
222 	 * The ::show-menu signal is emitted before the menu is shown.
223 	 * It can be used to populate the menu on demand, using
224 	 * gtk_menu_tool_button_get_menu().
225 	 * Note that even if you populate the menu dynamically in this way,
226 	 * you must set an empty menu on the GtkMenuToolButton beforehand,
227 	 * since the arrow is made insensitive if the menu is not set.
228 	 * See Also
229 	 *
230 	 * GtkToolbar, GtkToolButton
231 	 * The toolbar widget
232 	 *  The parent class of GtkMenuToolButton. The properties
233 	 *  "label_widget", "label", "icon_widget", and "stock_id" on
234 	 *  GtkToolButton determine the label and icon used on
235 	 *  GtkMenuToolButtons.
236 	 *
237 	 */
238 	void addOnShowMenu(void delegate(MenuToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
239 	{
240 		if ( !("show-menu" in connectedSignals) )
241 		{
242 			Signals.connectData(
243 			getStruct(),
244 			"show-menu",
245 			cast(GCallback)&callBackShowMenu,
246 			cast(void*)this,
247 			null,
248 			connectFlags);
249 			connectedSignals["show-menu"] = 1;
250 		}
251 		onShowMenuListeners ~= dlg;
252 	}
253 	extern(C) static void callBackShowMenu(GtkMenuToolButton* buttonStruct, MenuToolButton _menuToolButton)
254 	{
255 		foreach ( void delegate(MenuToolButton) dlg ; _menuToolButton.onShowMenuListeners )
256 		{
257 			dlg(_menuToolButton);
258 		}
259 	}
260 	
261 	
262 	/**
263 	 * Sets the GtkMenu that is popped up when the user clicks on the arrow.
264 	 * If menu is NULL, the arrow button becomes insensitive.
265 	 * Since 2.6
266 	 * Params:
267 	 * menu = the GtkMenu associated with GtkMenuToolButton
268 	 */
269 	public void setMenu(Widget menu)
270 	{
271 		// void gtk_menu_tool_button_set_menu (GtkMenuToolButton *button,  GtkWidget *menu);
272 		gtk_menu_tool_button_set_menu(gtkMenuToolButton, (menu is null) ? null : menu.getWidgetStruct());
273 	}
274 	
275 	/**
276 	 * Warning
277 	 * gtk_menu_tool_button_set_arrow_tooltip has been deprecated since version 2.12 and should not be used in newly-written code. Use gtk_menu_tool_button_set_arrow_tooltip_text()
278 	 * instead.
279 	 * Sets the GtkTooltips object to be used for arrow button which
280 	 * pops up the menu. See gtk_tool_item_set_tooltip() for setting
281 	 * a tooltip on the whole GtkMenuToolButton.
282 	 * Since 2.6
283 	 * Params:
284 	 * tooltips = the GtkTooltips object to be used
285 	 * tipText = text to be used as tooltip text for tool_item. [allow-none]
286 	 * tipPrivate = text to be used as private tooltip text. [allow-none]
287 	 */
288 	public void setArrowTooltip(Tooltips tooltips, string tipText, string tipPrivate)
289 	{
290 		// void gtk_menu_tool_button_set_arrow_tooltip  (GtkMenuToolButton *button,  GtkTooltips *tooltips,  const gchar *tip_text,  const gchar *tip_private);
291 		gtk_menu_tool_button_set_arrow_tooltip(gtkMenuToolButton, (tooltips is null) ? null : tooltips.getTooltipsStruct(), Str.toStringz(tipText), Str.toStringz(tipPrivate));
292 	}
293 	
294 	/**
295 	 * Sets the tooltip text to be used as tooltip for the arrow button which
296 	 * pops up the menu. See gtk_tool_item_set_tooltip() for setting a tooltip
297 	 * on the whole GtkMenuToolButton.
298 	 * Since 2.12
299 	 * Params:
300 	 * text = text to be used as tooltip text for button's arrow button
301 	 */
302 	public void setArrowTooltipText(string text)
303 	{
304 		// void gtk_menu_tool_button_set_arrow_tooltip_text  (GtkMenuToolButton *button,  const gchar *text);
305 		gtk_menu_tool_button_set_arrow_tooltip_text(gtkMenuToolButton, Str.toStringz(text));
306 	}
307 	
308 	/**
309 	 * Sets the tooltip markup text to be used as tooltip for the arrow button
310 	 * which pops up the menu. See gtk_tool_item_set_tooltip() for setting a
311 	 * tooltip on the whole GtkMenuToolButton.
312 	 * Since 2.12
313 	 * Params:
314 	 * markup = markup text to be used as tooltip text for button's arrow button
315 	 */
316 	public void setArrowTooltipMarkup(string markup)
317 	{
318 		// void gtk_menu_tool_button_set_arrow_tooltip_markup  (GtkMenuToolButton *button,  const gchar *markup);
319 		gtk_menu_tool_button_set_arrow_tooltip_markup(gtkMenuToolButton, Str.toStringz(markup));
320 	}
321 }