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 module gtk.MenuToolButton; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.Menu; 32 private import gtk.ToolButton; 33 private import gtk.ToolItem; 34 private import gtk.Widget; 35 private import gtk.c.functions; 36 public import gtk.c.types; 37 public import gtkc.gtktypes; 38 private import std.algorithm; 39 40 41 /** 42 * A #GtkMenuToolButton is a #GtkToolItem that contains a button and 43 * a small additional button with an arrow. When clicked, the arrow 44 * button pops up a dropdown menu. 45 * 46 * Use gtk_menu_tool_button_new() to create a new 47 * #GtkMenuToolButton. 48 * 49 * # GtkMenuToolButton as GtkBuildable 50 * 51 * The GtkMenuToolButton implementation of the GtkBuildable interface 52 * supports adding a menu by specifying “menu” as the “type” attribute 53 * of a <child> element. 54 * 55 * An example for a UI definition fragment with menus: 56 * |[ 57 * <object class="GtkMenuToolButton"> 58 * <child type="menu"> 59 * <object class="GtkMenu"/> 60 * </child> 61 * </object> 62 * ]| 63 */ 64 public class MenuToolButton : ToolButton 65 { 66 /** the main Gtk struct */ 67 protected GtkMenuToolButton* gtkMenuToolButton; 68 69 /** Get the main Gtk struct */ 70 public GtkMenuToolButton* getMenuToolButtonStruct(bool transferOwnership = false) 71 { 72 if (transferOwnership) 73 ownedRef = false; 74 return gtkMenuToolButton; 75 } 76 77 /** the main Gtk struct as a void* */ 78 protected override void* getStruct() 79 { 80 return cast(void*)gtkMenuToolButton; 81 } 82 83 /** 84 * Sets our main struct and passes it to the parent class. 85 */ 86 public this (GtkMenuToolButton* gtkMenuToolButton, bool ownedRef = false) 87 { 88 this.gtkMenuToolButton = gtkMenuToolButton; 89 super(cast(GtkToolButton*)gtkMenuToolButton, ownedRef); 90 } 91 92 /** 93 * Creates a new GtkMenuToolButton. 94 * The new GtkMenuToolButton will contain an icon and label from 95 * the stock item indicated by stockID. 96 * Since: 2.6 97 * Params: 98 * stockID = the name of a stock item 99 * Throws: ConstructionException GTK+ fails to create the object. 100 */ 101 public this(StockID stockId) 102 { 103 this(cast(string)stockId); 104 } 105 106 /** 107 * Gets the GtkMenu associated with GtkMenuToolButton. 108 * Since: 2.6 109 * Params: 110 * button = a GtkMenuToolButton 111 * Returns: 112 * the GtkMenu associated with GtkMenuToolButton 113 */ 114 public Menu getMenu() 115 { 116 auto p = gtk_menu_tool_button_get_menu(gtkMenuToolButton); 117 if(p is null) 118 { 119 return null; 120 } 121 return new Menu(cast(GtkMenu*)p); 122 } 123 124 /** 125 */ 126 127 /** */ 128 public static GType getType() 129 { 130 return gtk_menu_tool_button_get_type(); 131 } 132 133 /** 134 * Creates a new #GtkMenuToolButton using @icon_widget as icon and 135 * @label as label. 136 * 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 * 141 * Returns: the new #GtkMenuToolButton 142 * 143 * Since: 2.6 144 * 145 * Throws: ConstructionException GTK+ fails to create the object. 146 */ 147 public this(Widget iconWidget, string label) 148 { 149 auto p = gtk_menu_tool_button_new((iconWidget is null) ? null : iconWidget.getWidgetStruct(), Str.toStringz(label)); 150 151 if(p is null) 152 { 153 throw new ConstructionException("null returned by new"); 154 } 155 156 this(cast(GtkMenuToolButton*) p); 157 } 158 159 /** 160 * Creates a new #GtkMenuToolButton. 161 * The new #GtkMenuToolButton will contain an icon and label from 162 * the stock item indicated by @stock_id. 163 * 164 * Deprecated: Use gtk_menu_tool_button_new() instead. 165 * 166 * Params: 167 * stockId = the name of a stock item 168 * 169 * Returns: the new #GtkMenuToolButton 170 * 171 * Since: 2.6 172 * 173 * Throws: ConstructionException GTK+ fails to create the object. 174 */ 175 public this(string stockId) 176 { 177 auto p = gtk_menu_tool_button_new_from_stock(Str.toStringz(stockId)); 178 179 if(p is null) 180 { 181 throw new ConstructionException("null returned by new_from_stock"); 182 } 183 184 this(cast(GtkMenuToolButton*) p); 185 } 186 187 /** 188 * Sets the tooltip markup text to be used as tooltip for the arrow button 189 * which pops up the menu. See gtk_tool_item_set_tooltip_text() for setting 190 * a tooltip on the whole #GtkMenuToolButton. 191 * 192 * Params: 193 * markup = markup text to be used as tooltip text for button’s arrow button 194 * 195 * Since: 2.12 196 */ 197 public void setArrowTooltipMarkup(string markup) 198 { 199 gtk_menu_tool_button_set_arrow_tooltip_markup(gtkMenuToolButton, Str.toStringz(markup)); 200 } 201 202 /** 203 * Sets the tooltip text to be used as tooltip for the arrow button which 204 * pops up the menu. See gtk_tool_item_set_tooltip_text() for setting a tooltip 205 * on the whole #GtkMenuToolButton. 206 * 207 * Params: 208 * text = text to be used as tooltip text for button’s arrow button 209 * 210 * Since: 2.12 211 */ 212 public void setArrowTooltipText(string text) 213 { 214 gtk_menu_tool_button_set_arrow_tooltip_text(gtkMenuToolButton, Str.toStringz(text)); 215 } 216 217 /** 218 * Sets the #GtkMenu that is popped up when the user clicks on the arrow. 219 * If @menu is NULL, the arrow button becomes insensitive. 220 * 221 * Params: 222 * menu = the #GtkMenu associated with #GtkMenuToolButton 223 * 224 * Since: 2.6 225 */ 226 public void setMenu(Widget menu) 227 { 228 gtk_menu_tool_button_set_menu(gtkMenuToolButton, (menu is null) ? null : menu.getWidgetStruct()); 229 } 230 231 /** 232 * The ::show-menu signal is emitted before the menu is shown. 233 * 234 * It can be used to populate the menu on demand, using 235 * gtk_menu_tool_button_set_menu(). 236 * 237 * Note that even if you populate the menu dynamically in this way, 238 * you must set an empty menu on the #GtkMenuToolButton beforehand, 239 * since the arrow is made insensitive if the menu is not set. 240 */ 241 gulong addOnShowMenu(void delegate(MenuToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 242 { 243 return Signals.connect(this, "show-menu", dlg, connectFlags ^ ConnectFlags.SWAPPED); 244 } 245 }