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 = GtkToggleToolButton.html 27 * outPack = gtk 28 * outFile = ToggleToolButton 29 * strct = GtkToggleToolButton 30 * realStrct= 31 * ctorStrct=GtkToolItem 32 * clss = ToggleToolButton 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_toggle_tool_button_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * structWrap: 48 * module aliases: 49 * local aliases: 50 * overrides: 51 */ 52 53 module gtk.ToggleToolButton; 54 55 public import gtkc.gtktypes; 56 57 private import gtkc.gtk; 58 private import glib.ConstructionException; 59 private import gobject.ObjectG; 60 61 private import gobject.Signals; 62 public import gtkc.gdktypes; 63 private import glib.Str; 64 65 66 private import gtk.ToolButton; 67 68 /** 69 * A GtkToggleToolButton is a GtkToolItem that contains a toggle 70 * button. 71 * 72 * Use gtk_toggle_tool_button_new() to create a new 73 * GtkToggleToolButton. 74 */ 75 public class ToggleToolButton : ToolButton 76 { 77 78 /** the main Gtk struct */ 79 protected GtkToggleToolButton* gtkToggleToolButton; 80 81 82 /** Get the main Gtk struct */ 83 public GtkToggleToolButton* getToggleToolButtonStruct() 84 { 85 return gtkToggleToolButton; 86 } 87 88 89 /** the main Gtk struct as a void* */ 90 protected override void* getStruct() 91 { 92 return cast(void*)gtkToggleToolButton; 93 } 94 95 /** 96 * Sets our main struct and passes it to the parent class 97 */ 98 public this (GtkToggleToolButton* gtkToggleToolButton) 99 { 100 super(cast(GtkToolButton*)gtkToggleToolButton); 101 this.gtkToggleToolButton = gtkToggleToolButton; 102 } 103 104 protected override void setStruct(GObject* obj) 105 { 106 super.setStruct(obj); 107 gtkToggleToolButton = cast(GtkToggleToolButton*)obj; 108 } 109 110 /** 111 * Creates a new GtkToggleToolButton containing the image and text 112 * from a stock item. 113 */ 114 public this(StockID stockId) 115 { 116 this(StockDesc[stockId]); 117 } 118 119 /** 120 */ 121 int[string] connectedSignals; 122 123 void delegate(ToggleToolButton)[] onToggledListeners; 124 /** 125 * Emitted whenever the toggle tool button changes state. 126 * See Also 127 * GtkToolbar, GtkToolButton, GtkSeparatorToolItem 128 */ 129 void addOnToggled(void delegate(ToggleToolButton) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 130 { 131 if ( !("toggled" in connectedSignals) ) 132 { 133 Signals.connectData( 134 getStruct(), 135 "toggled", 136 cast(GCallback)&callBackToggled, 137 cast(void*)this, 138 null, 139 connectFlags); 140 connectedSignals["toggled"] = 1; 141 } 142 onToggledListeners ~= dlg; 143 } 144 extern(C) static void callBackToggled(GtkToggleToolButton* toggleToolButtonStruct, ToggleToolButton _toggleToolButton) 145 { 146 foreach ( void delegate(ToggleToolButton) dlg ; _toggleToolButton.onToggledListeners ) 147 { 148 dlg(_toggleToolButton); 149 } 150 } 151 152 153 /** 154 * Returns a new GtkToggleToolButton 155 * Since 2.4 156 * Throws: ConstructionException GTK+ fails to create the object. 157 */ 158 public this () 159 { 160 // GtkToolItem * gtk_toggle_tool_button_new (void); 161 auto p = gtk_toggle_tool_button_new(); 162 if(p is null) 163 { 164 throw new ConstructionException("null returned by gtk_toggle_tool_button_new()"); 165 } 166 this(cast(GtkToggleToolButton*) p); 167 } 168 169 /** 170 * Warning 171 * gtk_toggle_tool_button_new_from_stock has been deprecated since version 3.10 and should not be used in newly-written code. Use gtk_toggle_tool_button_new() instead. 172 * Creates a new GtkToggleToolButton containing the image and text from a 173 * stock item. Some stock ids have preprocessor macros like GTK_STOCK_OK 174 * and GTK_STOCK_APPLY. 175 * It is an error if stock_id is not a name of a stock item. 176 * Since 2.4 177 * Params: 178 * stockId = the name of the stock item 179 * Throws: ConstructionException GTK+ fails to create the object. 180 */ 181 public this (string stockId) 182 { 183 // GtkToolItem * gtk_toggle_tool_button_new_from_stock (const gchar *stock_id); 184 auto p = gtk_toggle_tool_button_new_from_stock(Str.toStringz(stockId)); 185 if(p is null) 186 { 187 throw new ConstructionException("null returned by gtk_toggle_tool_button_new_from_stock(Str.toStringz(stockId))"); 188 } 189 this(cast(GtkToggleToolButton*) p); 190 } 191 192 /** 193 * Sets the status of the toggle tool button. Set to TRUE if you 194 * want the GtkToggleButton to be 'pressed in', and FALSE to raise it. 195 * This action causes the toggled signal to be emitted. 196 * Since 2.4 197 * Params: 198 * isActive = whether button should be active 199 */ 200 public void setActive(int isActive) 201 { 202 // void gtk_toggle_tool_button_set_active (GtkToggleToolButton *button, gboolean is_active); 203 gtk_toggle_tool_button_set_active(gtkToggleToolButton, isActive); 204 } 205 206 /** 207 * Queries a GtkToggleToolButton and returns its current state. 208 * Returns TRUE if the toggle button is pressed in and FALSE if it is raised. 209 * Since 2.4 210 * Returns: TRUE if the toggle tool button is pressed in, FALSE if not 211 */ 212 public int getActive() 213 { 214 // gboolean gtk_toggle_tool_button_get_active (GtkToggleToolButton *button); 215 return gtk_toggle_tool_button_get_active(gtkToggleToolButton); 216 } 217 }