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 = GtkToolButton.html 27 * outPack = gtk 28 * outFile = ToolButton 29 * strct = GtkToolButton 30 * realStrct= 31 * ctorStrct=GtkToolItem 32 * clss = ToolButton 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * - ActionableIF 40 * prefixes: 41 * - gtk_tool_button_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gtk.Widget 49 * - gtk.ActionableIF 50 * - gtk.ActionableT 51 * structWrap: 52 * - GtkWidget* -> Widget 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module gtk.ToolButton; 59 60 public import gtkc.gtktypes; 61 62 private import gtkc.gtk; 63 private import glib.ConstructionException; 64 private import gobject.ObjectG; 65 66 private import gobject.Signals; 67 public import gtkc.gdktypes; 68 private import glib.Str; 69 private import gtk.Widget; 70 private import gtk.ActionableIF; 71 private import gtk.ActionableT; 72 73 74 private import gtk.ToolItem; 75 76 /** 77 * GtkToolButtons are GtkToolItems containing buttons. 78 * 79 * Use gtk_tool_button_new() to create a new GtkToolButton. 80 * 81 * The label of a GtkToolButton is determined by the properties 82 * "label-widget", "label", and 83 * "stock-id". If "label-widget" is 84 * non-NULL, then that widget is used as the label. Otherwise, if 85 * "label" is non-NULL, that string is used as the label. 86 * Otherwise, if "stock-id" is non-NULL, the label is 87 * determined by the stock item. Otherwise, the button does not have a label. 88 * 89 * The icon of a GtkToolButton is determined by the properties 90 * "icon-widget" and "stock-id". If 91 * "icon-widget" is non-NULL, then 92 * that widget is used as the icon. Otherwise, if "stock-id" is 93 * non-NULL, the icon is determined by the stock item. Otherwise, 94 * the button does not have a icon. 95 */ 96 public class ToolButton : ToolItem, ActionableIF 97 { 98 99 /** the main Gtk struct */ 100 protected GtkToolButton* gtkToolButton; 101 102 103 /** Get the main Gtk struct */ 104 public GtkToolButton* getToolButtonStruct() 105 { 106 return gtkToolButton; 107 } 108 109 110 /** the main Gtk struct as a void* */ 111 protected override void* getStruct() 112 { 113 return cast(void*)gtkToolButton; 114 } 115 116 /** 117 * Sets our main struct and passes it to the parent class 118 */ 119 public this (GtkToolButton* gtkToolButton) 120 { 121 super(cast(GtkToolItem*)gtkToolButton); 122 this.gtkToolButton = gtkToolButton; 123 } 124 125 protected override void setStruct(GObject* obj) 126 { 127 super.setStruct(obj); 128 gtkToolButton = cast(GtkToolButton*)obj; 129 } 130 131 // add the Actionable capabilities 132 mixin ActionableT!(GtkToolButton); 133 134 /** */ 135 public this (StockID stockID) 136 { 137 this(StockDesc[stockID]); 138 } 139 140 /** 141 */ 142 int[string] connectedSignals; 143 144 void delegate(ToolButton)[] onClickedListeners; 145 /** 146 * This signal is emitted when the tool button is clicked with the mouse 147 * or activated with the keyboard. 148 * See Also 149 * GtkToolbar, GtkMenuToolButton, GtkToggleToolButton, 150 * GtkRadioToolButton, GtkSeparatorToolItem 151 */ 152 void addOnClicked(void delegate(ToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 153 { 154 if ( !("clicked" in connectedSignals) ) 155 { 156 Signals.connectData( 157 getStruct(), 158 "clicked", 159 cast(GCallback)&callBackClicked, 160 cast(void*)this, 161 null, 162 connectFlags); 163 connectedSignals["clicked"] = 1; 164 } 165 onClickedListeners ~= dlg; 166 } 167 extern(C) static void callBackClicked(GtkToolButton* toolbuttonStruct, ToolButton _toolButton) 168 { 169 foreach ( void delegate(ToolButton) dlg ; _toolButton.onClickedListeners ) 170 { 171 dlg(_toolButton); 172 } 173 } 174 175 176 /** 177 * Creates a new GtkToolButton using icon_widget as contents and label as 178 * label. 179 * Since 2.4 180 * Params: 181 * label = a string that will be used as label, or NULL. [allow-none] 182 * iconWidget = a widget that will be used as the button contents, or NULL. [allow-none] 183 * Throws: ConstructionException GTK+ fails to create the object. 184 */ 185 public this (Widget iconWidget, string label) 186 { 187 // GtkToolItem * gtk_tool_button_new (GtkWidget *icon_widget, const gchar *label); 188 auto p = gtk_tool_button_new((iconWidget is null) ? null : iconWidget.getWidgetStruct(), Str.toStringz(label)); 189 if(p is null) 190 { 191 throw new ConstructionException("null returned by gtk_tool_button_new((iconWidget is null) ? null : iconWidget.getWidgetStruct(), Str.toStringz(label))"); 192 } 193 this(cast(GtkToolButton*) p); 194 } 195 196 /** 197 * Warning 198 * gtk_tool_button_new_from_stock has been deprecated since version 3.10 and should not be used in newly-written code. Use gtk_tool_button_new() instead. 199 * Creates a new GtkToolButton containing the image and text from a 200 * stock item. Some stock ids have preprocessor macros like GTK_STOCK_OK 201 * and GTK_STOCK_APPLY. 202 * It is an error if stock_id is not a name of a stock item. 203 * Since 2.4 204 * Params: 205 * stockId = the name of the stock item 206 * Throws: ConstructionException GTK+ fails to create the object. 207 */ 208 public this (string stockId) 209 { 210 // GtkToolItem * gtk_tool_button_new_from_stock (const gchar *stock_id); 211 auto p = gtk_tool_button_new_from_stock(Str.toStringz(stockId)); 212 if(p is null) 213 { 214 throw new ConstructionException("null returned by gtk_tool_button_new_from_stock(Str.toStringz(stockId))"); 215 } 216 this(cast(GtkToolButton*) p); 217 } 218 219 /** 220 * Sets label as the label used for the tool button. The "label" property 221 * only has an effect if not overridden by a non-NULL "label_widget" property. 222 * If both the "label_widget" and "label" properties are NULL, the label 223 * is determined by the "stock_id" property. If the "stock_id" property is also 224 * NULL, button will not have a label. 225 * Since 2.4 226 * Params: 227 * label = a string that will be used as label, or NULL. [allow-none] 228 */ 229 public void setLabel(string label) 230 { 231 // void gtk_tool_button_set_label (GtkToolButton *button, const gchar *label); 232 gtk_tool_button_set_label(gtkToolButton, Str.toStringz(label)); 233 } 234 235 /** 236 * Returns the label used by the tool button, or NULL if the tool button 237 * doesn't have a label. or uses a the label from a stock item. The returned 238 * string is owned by GTK+, and must not be modified or freed. 239 * Since 2.4 240 * Returns: The label, or NULL 241 */ 242 public string getLabel() 243 { 244 // const gchar * gtk_tool_button_get_label (GtkToolButton *button); 245 return Str.toString(gtk_tool_button_get_label(gtkToolButton)); 246 } 247 248 /** 249 * If set, an underline in the label property indicates that the next character 250 * should be used for the mnemonic accelerator key in the overflow menu. For 251 * example, if the label property is "_Open" and use_underline is TRUE, 252 * the label on the tool button will be "Open" and the item on the overflow 253 * menu will have an underlined 'O'. 254 * Labels shown on tool buttons never have mnemonics on them; this property 255 * only affects the menu item on the overflow menu. 256 * Since 2.4 257 * Params: 258 * useUnderline = whether the button label has the form "_Open" 259 */ 260 public void setUseUnderline(int useUnderline) 261 { 262 // void gtk_tool_button_set_use_underline (GtkToolButton *button, gboolean use_underline); 263 gtk_tool_button_set_use_underline(gtkToolButton, useUnderline); 264 } 265 266 /** 267 * Returns whether underscores in the label property are used as mnemonics 268 * on menu items on the overflow menu. See gtk_tool_button_set_use_underline(). 269 * Since 2.4 270 * Returns: TRUE if underscores in the label property are used as mnemonics on menu items on the overflow menu. 271 */ 272 public int getUseUnderline() 273 { 274 // gboolean gtk_tool_button_get_use_underline (GtkToolButton *button); 275 return gtk_tool_button_get_use_underline(gtkToolButton); 276 } 277 278 /** 279 * Warning 280 * gtk_tool_button_set_stock_id has been deprecated since version 3.10 and should not be used in newly-written code. Use gtk_tool_button_set_icon_name() instead. 281 * Sets the name of the stock item. See gtk_tool_button_new_from_stock(). 282 * The stock_id property only has an effect if not 283 * overridden by non-NULL "label" and "icon_widget" properties. 284 * Since 2.4 285 * Params: 286 * stockId = a name of a stock item, or NULL. [allow-none] 287 */ 288 public void setStockId(string stockId) 289 { 290 // void gtk_tool_button_set_stock_id (GtkToolButton *button, const gchar *stock_id); 291 gtk_tool_button_set_stock_id(gtkToolButton, Str.toStringz(stockId)); 292 } 293 294 /** 295 * Warning 296 * gtk_tool_button_get_stock_id has been deprecated since version 3.10 and should not be used in newly-written code. Use gtk_tool_button_get_icon_name() instead. 297 * Returns the name of the stock item. See gtk_tool_button_set_stock_id(). 298 * The returned string is owned by GTK+ and must not be freed or modifed. 299 * Since 2.4 300 * Returns: the name of the stock item for button. 301 */ 302 public string getStockId() 303 { 304 // const gchar * gtk_tool_button_get_stock_id (GtkToolButton *button); 305 return Str.toString(gtk_tool_button_get_stock_id(gtkToolButton)); 306 } 307 308 /** 309 * Sets the icon for the tool button from a named themed icon. 310 * See the docs for GtkIconTheme for more details. 311 * The "icon_name" property only has an effect if not 312 * overridden by non-NULL "label", "icon_widget" and "stock_id" 313 * properties. 314 * Since 2.8 315 * Params: 316 * iconName = the name of the themed icon. [allow-none] 317 */ 318 public void setIconName(string iconName) 319 { 320 // void gtk_tool_button_set_icon_name (GtkToolButton *button, const gchar *icon_name); 321 gtk_tool_button_set_icon_name(gtkToolButton, Str.toStringz(iconName)); 322 } 323 324 /** 325 * Returns the name of the themed icon for the tool button, 326 * see gtk_tool_button_set_icon_name(). 327 * Since 2.8 328 * Returns: the icon name or NULL if the tool button has no themed icon 329 */ 330 public string getIconName() 331 { 332 // const gchar * gtk_tool_button_get_icon_name (GtkToolButton *button); 333 return Str.toString(gtk_tool_button_get_icon_name(gtkToolButton)); 334 } 335 336 /** 337 * Sets icon as the widget used as icon on button. If icon_widget is 338 * NULL the icon is determined by the "stock_id" property. If the 339 * "stock_id" property is also NULL, button will not have an icon. 340 * Since 2.4 341 * Params: 342 * iconWidget = the widget used as icon, or NULL. [allow-none] 343 */ 344 public void setIconWidget(Widget iconWidget) 345 { 346 // void gtk_tool_button_set_icon_widget (GtkToolButton *button, GtkWidget *icon_widget); 347 gtk_tool_button_set_icon_widget(gtkToolButton, (iconWidget is null) ? null : iconWidget.getWidgetStruct()); 348 } 349 350 /** 351 * Return the widget used as icon widget on button. 352 * See gtk_tool_button_set_icon_widget(). 353 * Since 2.4 354 * Returns: The widget used as icon on button, or NULL. [transfer none] 355 */ 356 public Widget getIconWidget() 357 { 358 // GtkWidget * gtk_tool_button_get_icon_widget (GtkToolButton *button); 359 auto p = gtk_tool_button_get_icon_widget(gtkToolButton); 360 361 if(p is null) 362 { 363 return null; 364 } 365 366 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 367 } 368 369 /** 370 * Sets label_widget as the widget that will be used as the label 371 * for button. If label_widget is NULL the "label" property is used 372 * as label. If "label" is also NULL, the label in the stock item 373 * determined by the "stock_id" property is used as label. If 374 * "stock_id" is also NULL, button does not have a label. 375 * Since 2.4 376 * Params: 377 * labelWidget = the widget used as label, or NULL. [allow-none] 378 */ 379 public void setLabelWidget(Widget labelWidget) 380 { 381 // void gtk_tool_button_set_label_widget (GtkToolButton *button, GtkWidget *label_widget); 382 gtk_tool_button_set_label_widget(gtkToolButton, (labelWidget is null) ? null : labelWidget.getWidgetStruct()); 383 } 384 385 /** 386 * Returns the widget used as label on button. 387 * See gtk_tool_button_set_label_widget(). 388 * Since 2.4 389 * Returns: The widget used as label on button, or NULL. [transfer none] 390 */ 391 public Widget getLabelWidget() 392 { 393 // GtkWidget * gtk_tool_button_get_label_widget (GtkToolButton *button); 394 auto p = gtk_tool_button_get_label_widget(gtkToolButton); 395 396 if(p is null) 397 { 398 return null; 399 } 400 401 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 402 } 403 }