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