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 = GtkRadioAction.html 27 * outPack = gtk 28 * outFile = RadioAction 29 * strct = GtkRadioAction 30 * realStrct= 31 * ctorStrct= 32 * clss = RadioAction 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_radio_action_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - glib.ListSG 48 * structWrap: 49 * - GSList* -> ListSG 50 * module aliases: 51 * local aliases: 52 * overrides: 53 */ 54 55 module gtk.RadioAction; 56 57 public import gtkc.gtktypes; 58 59 private import gtkc.gtk; 60 private import glib.ConstructionException; 61 private import gobject.ObjectG; 62 63 private import gobject.Signals; 64 public import gtkc.gdktypes; 65 private import glib.Str; 66 private import glib.ListSG; 67 68 69 private import gtk.ToggleAction; 70 71 /** 72 * A GtkRadioAction is similar to GtkRadioMenuItem. A number of radio 73 * actions can be linked together so that only one may be active at any 74 * one time. 75 */ 76 public class RadioAction : ToggleAction 77 { 78 79 /** the main Gtk struct */ 80 protected GtkRadioAction* gtkRadioAction; 81 82 83 /** Get the main Gtk struct */ 84 public GtkRadioAction* getRadioActionStruct() 85 { 86 return gtkRadioAction; 87 } 88 89 90 /** the main Gtk struct as a void* */ 91 protected override void* getStruct() 92 { 93 return cast(void*)gtkRadioAction; 94 } 95 96 /** 97 * Sets our main struct and passes it to the parent class 98 */ 99 public this (GtkRadioAction* gtkRadioAction) 100 { 101 super(cast(GtkToggleAction*)gtkRadioAction); 102 this.gtkRadioAction = gtkRadioAction; 103 } 104 105 protected override void setStruct(GObject* obj) 106 { 107 super.setStruct(obj); 108 gtkRadioAction = cast(GtkRadioAction*)obj; 109 } 110 111 /** 112 * Creates a new GtkRadioAction object. To add the action to 113 * a GtkActionGroup and set the accelerator for the action, 114 * call gtk_action_group_add_action_with_accel(). 115 * Since 2.4 116 * Params: 117 * name = A unique name for the action 118 * label = The label displayed in menu items and on buttons, or NULL 119 * tooltip = A tooltip for this action, or NULL 120 * stockId = The stock icon to display in widgets representing this 121 * action, or NULL 122 * value = The value which gtk_radio_action_get_current_value() should 123 * return if this action is selected. 124 * Throws: ConstructionException GTK+ fails to create the object. 125 */ 126 public this (string name, string label, string tooltip, StockID stockId, int value) 127 { 128 this(name, label, tooltip, StockDesc[stockId], value); 129 } 130 131 /** 132 */ 133 int[string] connectedSignals; 134 135 void delegate(GtkRadioAction*, RadioAction)[] onChangedListeners; 136 /** 137 * Warning 138 * GtkRadioAction::changed is deprecated and should not be used in newly-written code. 3.10 139 * The ::changed signal is emitted on every member of a radio group when the 140 * active member is changed. The signal gets emitted after the ::activate signals 141 * for the previous and current active members. 142 * Since 2.4 143 */ 144 void addOnChanged(void delegate(GtkRadioAction*, RadioAction) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 145 { 146 if ( !("changed" in connectedSignals) ) 147 { 148 Signals.connectData( 149 getStruct(), 150 "changed", 151 cast(GCallback)&callBackChanged, 152 cast(void*)this, 153 null, 154 connectFlags); 155 connectedSignals["changed"] = 1; 156 } 157 onChangedListeners ~= dlg; 158 } 159 extern(C) static void callBackChanged(GtkRadioAction* actionStruct, GtkRadioAction* current, RadioAction _radioAction) 160 { 161 foreach ( void delegate(GtkRadioAction*, RadioAction) dlg ; _radioAction.onChangedListeners ) 162 { 163 dlg(current, _radioAction); 164 } 165 } 166 167 168 /** 169 * Warning 170 * gtk_radio_action_new is deprecated and should not be used in newly-written code. 3.10 171 * Creates a new GtkRadioAction object. To add the action to 172 * a GtkActionGroup and set the accelerator for the action, 173 * call gtk_action_group_add_action_with_accel(). 174 * Since 2.4 175 * Params: 176 * name = A unique name for the action 177 * label = The label displayed in menu items and on buttons, 178 * or NULL. [allow-none] 179 * tooltip = A tooltip for this action, or NULL. [allow-none] 180 * stockId = The stock icon to display in widgets representing 181 * this action, or NULL. [allow-none] 182 * value = The value which gtk_radio_action_get_current_value() should 183 * return if this action is selected. 184 * Throws: ConstructionException GTK+ fails to create the object. 185 */ 186 public this (string name, string label, string tooltip, string stockId, int value) 187 { 188 // GtkRadioAction * gtk_radio_action_new (const gchar *name, const gchar *label, const gchar *tooltip, const gchar *stock_id, gint value); 189 auto p = gtk_radio_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId), value); 190 if(p is null) 191 { 192 throw new ConstructionException("null returned by gtk_radio_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId), value)"); 193 } 194 this(cast(GtkRadioAction*) p); 195 } 196 197 /** 198 * Warning 199 * gtk_radio_action_get_group is deprecated and should not be used in newly-written code. 3.10 200 * Returns the list representing the radio group for this object. 201 * Note that the returned list is only valid until the next change 202 * to the group. 203 * Since 2.4 204 * Returns: the list representing the radio group for this object. [element-type GtkRadioAction][transfer none] 205 */ 206 public ListSG getGroup() 207 { 208 // GSList * gtk_radio_action_get_group (GtkRadioAction *action); 209 auto p = gtk_radio_action_get_group(gtkRadioAction); 210 211 if(p is null) 212 { 213 return null; 214 } 215 216 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 217 } 218 219 /** 220 * Warning 221 * gtk_radio_action_set_group is deprecated and should not be used in newly-written code. 3.10 222 * Sets the radio group for the radio action object. 223 * Since 2.4 224 * Params: 225 * group = a list representing a radio group. [element-type GtkRadioAction] 226 */ 227 public void setGroup(ListSG group) 228 { 229 // void gtk_radio_action_set_group (GtkRadioAction *action, GSList *group); 230 gtk_radio_action_set_group(gtkRadioAction, (group is null) ? null : group.getListSGStruct()); 231 } 232 233 /** 234 * Warning 235 * gtk_radio_action_join_group is deprecated and should not be used in newly-written code. 3.10 236 * Joins a radio action object to the group of another radio action object. 237 * Use this in language bindings instead of the gtk_radio_action_get_group() 238 * and gtk_radio_action_set_group() methods 239 * Params: 240 * groupSource = a radio action object whos group we are 241 * joining, or NULL to remove the radio action from its group. [allow-none] 242 * Since 3.0 243 */ 244 public void joinGroup(GtkRadioAction* groupSource) 245 { 246 // void gtk_radio_action_join_group (GtkRadioAction *action, GtkRadioAction *group_source); 247 gtk_radio_action_join_group(gtkRadioAction, groupSource); 248 } 249 250 /** 251 * Warning 252 * gtk_radio_action_get_current_value is deprecated and should not be used in newly-written code. 3.10 253 * Obtains the value property of the currently active member of 254 * the group to which action belongs. 255 * Since 2.4 256 * Returns: The value of the currently active group member 257 */ 258 public int getCurrentValue() 259 { 260 // gint gtk_radio_action_get_current_value (GtkRadioAction *action); 261 return gtk_radio_action_get_current_value(gtkRadioAction); 262 } 263 264 /** 265 * Warning 266 * gtk_radio_action_set_current_value is deprecated and should not be used in newly-written code. 3.10 267 * Sets the currently active group member to the member with value 268 * property current_value. 269 * Since 2.10 270 * Params: 271 * currentValue = the new value 272 */ 273 public void setCurrentValue(int currentValue) 274 { 275 // void gtk_radio_action_set_current_value (GtkRadioAction *action, gint current_value); 276 gtk_radio_action_set_current_value(gtkRadioAction, currentValue); 277 } 278 }