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 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * - gtk_menu_tool_button_get_menu 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gtk.Menu 49 * - gtk.Widget 50 * structWrap: 51 * - GtkWidget* -> Widget 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gtk.MenuToolButton; 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 private import glib.Str; 68 private import gtk.Menu; 69 private import gtk.Widget; 70 71 72 private import gtk.ToolButton; 73 74 /** 75 * A GtkMenuToolButton is a GtkToolItem that contains a button and 76 * a small additional button with an arrow. When clicked, the arrow 77 * button pops up a dropdown menu. 78 * 79 * Use gtk_menu_tool_button_new() to create a new 80 * GtkMenuToolButton. 81 * 82 * GtkMenuToolButton as GtkBuildable 83 * 84 * The GtkMenuToolButton implementation of the GtkBuildable interface 85 * supports adding a menu by specifying "menu" as the "type" 86 * attribute of a <child> element. 87 * 88 * $(DDOC_COMMENT example) 89 */ 90 public class MenuToolButton : ToolButton 91 { 92 93 /** the main Gtk struct */ 94 protected GtkMenuToolButton* gtkMenuToolButton; 95 96 97 /** Get the main Gtk struct */ 98 public GtkMenuToolButton* getMenuToolButtonStruct() 99 { 100 return gtkMenuToolButton; 101 } 102 103 104 /** the main Gtk struct as a void* */ 105 protected override void* getStruct() 106 { 107 return cast(void*)gtkMenuToolButton; 108 } 109 110 /** 111 * Sets our main struct and passes it to the parent class 112 */ 113 public this (GtkMenuToolButton* gtkMenuToolButton) 114 { 115 super(cast(GtkToolButton*)gtkMenuToolButton); 116 this.gtkMenuToolButton = gtkMenuToolButton; 117 } 118 119 protected override void setStruct(GObject* obj) 120 { 121 super.setStruct(obj); 122 gtkMenuToolButton = cast(GtkMenuToolButton*)obj; 123 } 124 125 /** 126 * Creates a new GtkMenuToolButton. 127 * The new GtkMenuToolButton will contain an icon and label from 128 * the stock item indicated by stockID. 129 * Since 2.6 130 * Params: 131 * stockID = the name of a stock item 132 * Throws: ConstructionException GTK+ fails to create the object. 133 */ 134 public this(StockID stockId) 135 { 136 this(StockDesc[stockId]); 137 } 138 139 /** 140 * Gets the GtkMenu associated with GtkMenuToolButton. 141 * Since 2.6 142 * Params: 143 * button = a GtkMenuToolButton 144 * Returns: 145 * the GtkMenu associated with GtkMenuToolButton 146 */ 147 public Menu getMenu() 148 { 149 // GtkWidget* gtk_menu_tool_button_get_menu (GtkMenuToolButton *button); 150 auto p = gtk_menu_tool_button_get_menu(gtkMenuToolButton); 151 if(p is null) 152 { 153 return null; 154 } 155 return new Menu(cast(GtkMenu*)p); 156 } 157 158 /** 159 */ 160 int[string] connectedSignals; 161 162 void delegate(MenuToolButton)[] onShowMenuListeners; 163 /** 164 * The ::show-menu signal is emitted before the menu is shown. 165 * It can be used to populate the menu on demand, using 166 * gtk_menu_tool_button_set_menu(). 167 * Note that even if you populate the menu dynamically in this way, 168 * you must set an empty menu on the GtkMenuToolButton beforehand, 169 * since the arrow is made insensitive if the menu is not set. 170 * See Also 171 * GtkToolbar, GtkToolButton 172 */ 173 void addOnShowMenu(void delegate(MenuToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 174 { 175 if ( !("show-menu" in connectedSignals) ) 176 { 177 Signals.connectData( 178 getStruct(), 179 "show-menu", 180 cast(GCallback)&callBackShowMenu, 181 cast(void*)this, 182 null, 183 connectFlags); 184 connectedSignals["show-menu"] = 1; 185 } 186 onShowMenuListeners ~= dlg; 187 } 188 extern(C) static void callBackShowMenu(GtkMenuToolButton* buttonStruct, MenuToolButton _menuToolButton) 189 { 190 foreach ( void delegate(MenuToolButton) dlg ; _menuToolButton.onShowMenuListeners ) 191 { 192 dlg(_menuToolButton); 193 } 194 } 195 196 197 /** 198 * Creates a new GtkMenuToolButton using icon_widget as icon and 199 * label as label. 200 * Since 2.6 201 * Params: 202 * iconWidget = a widget that will be used as icon widget, or NULL. [allow-none] 203 * label = a string that will be used as label, or NULL. [allow-none] 204 * Throws: ConstructionException GTK+ fails to create the object. 205 */ 206 public this (Widget iconWidget, string label) 207 { 208 // GtkToolItem * gtk_menu_tool_button_new (GtkWidget *icon_widget, const gchar *label); 209 auto p = gtk_menu_tool_button_new((iconWidget is null) ? null : iconWidget.getWidgetStruct(), Str.toStringz(label)); 210 if(p is null) 211 { 212 throw new ConstructionException("null returned by gtk_menu_tool_button_new((iconWidget is null) ? null : iconWidget.getWidgetStruct(), Str.toStringz(label))"); 213 } 214 this(cast(GtkMenuToolButton*) p); 215 } 216 217 /** 218 * Warning 219 * gtk_menu_tool_button_new_from_stock has been deprecated since version 3.10 and should not be used in newly-written code. Use gtk_menu_tool_button_new() instead. 220 * Creates a new GtkMenuToolButton. 221 * The new GtkMenuToolButton will contain an icon and label from 222 * the stock item indicated by stock_id. 223 * Since 2.6 224 * Params: 225 * stockId = the name of a stock item 226 * Throws: ConstructionException GTK+ fails to create the object. 227 */ 228 public this (string stockId) 229 { 230 // GtkToolItem * gtk_menu_tool_button_new_from_stock (const gchar *stock_id); 231 auto p = gtk_menu_tool_button_new_from_stock(Str.toStringz(stockId)); 232 if(p is null) 233 { 234 throw new ConstructionException("null returned by gtk_menu_tool_button_new_from_stock(Str.toStringz(stockId))"); 235 } 236 this(cast(GtkMenuToolButton*) p); 237 } 238 239 /** 240 * Sets the GtkMenu that is popped up when the user clicks on the arrow. 241 * If menu is NULL, the arrow button becomes insensitive. 242 * Since 2.6 243 * Params: 244 * menu = the GtkMenu associated with GtkMenuToolButton 245 */ 246 public void setMenu(Widget menu) 247 { 248 // void gtk_menu_tool_button_set_menu (GtkMenuToolButton *button, GtkWidget *menu); 249 gtk_menu_tool_button_set_menu(gtkMenuToolButton, (menu is null) ? null : menu.getWidgetStruct()); 250 } 251 252 /** 253 * Sets the tooltip text to be used as tooltip for the arrow button which 254 * pops up the menu. See gtk_tool_item_set_tooltip_text() for setting a tooltip 255 * on the whole GtkMenuToolButton. 256 * Since 2.12 257 * Params: 258 * text = text to be used as tooltip text for button's arrow button 259 */ 260 public void setArrowTooltipText(string text) 261 { 262 // void gtk_menu_tool_button_set_arrow_tooltip_text (GtkMenuToolButton *button, const gchar *text); 263 gtk_menu_tool_button_set_arrow_tooltip_text(gtkMenuToolButton, Str.toStringz(text)); 264 } 265 266 /** 267 * Sets the tooltip markup text to be used as tooltip for the arrow button 268 * which pops up the menu. See gtk_tool_item_set_tooltip_text() for setting 269 * a tooltip on the whole GtkMenuToolButton. 270 * Since 2.12 271 * Params: 272 * markup = markup text to be used as tooltip text for button's arrow button 273 */ 274 public void setArrowTooltipMarkup(string markup) 275 { 276 // void gtk_menu_tool_button_set_arrow_tooltip_markup (GtkMenuToolButton *button, const gchar *markup); 277 gtk_menu_tool_button_set_arrow_tooltip_markup(gtkMenuToolButton, Str.toStringz(markup)); 278 } 279 }