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.ToggleAction; 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.Action; 32 private import gtk.c.functions; 33 public import gtk.c.types; 34 public import gtkc.gtktypes; 35 private import std.algorithm; 36 37 38 /** 39 * A #GtkToggleAction corresponds roughly to a #GtkCheckMenuItem. It has an 40 * “active” state specifying whether the action has been checked or not. 41 */ 42 public class ToggleAction : Action 43 { 44 /** the main Gtk struct */ 45 protected GtkToggleAction* gtkToggleAction; 46 47 /** Get the main Gtk struct */ 48 public GtkToggleAction* getToggleActionStruct(bool transferOwnership = false) 49 { 50 if (transferOwnership) 51 ownedRef = false; 52 return gtkToggleAction; 53 } 54 55 /** the main Gtk struct as a void* */ 56 protected override void* getStruct() 57 { 58 return cast(void*)gtkToggleAction; 59 } 60 61 /** 62 * Sets our main struct and passes it to the parent class. 63 */ 64 public this (GtkToggleAction* gtkToggleAction, bool ownedRef = false) 65 { 66 this.gtkToggleAction = gtkToggleAction; 67 super(cast(GtkAction*)gtkToggleAction, ownedRef); 68 } 69 70 /** 71 * Creates a new ToggleAction object. To add the action to 72 * a ActionGroup and set the accelerator for the action, 73 * call gtk.ActionGroup.ActionGroup.addActionWithAccel(). 74 * 75 * Since: 2.4 76 * 77 * Params: 78 * name = A unique name for the action 79 * label = The label displayed in menu items and on buttons, or null 80 * tooltip = A tooltip for the action, or null 81 * stockId = The stock icon to display in widgets representing the 82 * action, or null 83 * Throws: ConstructionException GTK+ fails to create the object. 84 */ 85 public this (string name, string label, string tooltip, StockID stockId) 86 { 87 this(name, label, tooltip, cast(string)stockId); 88 } 89 90 /** 91 */ 92 93 /** */ 94 public static GType getType() 95 { 96 return gtk_toggle_action_get_type(); 97 } 98 99 /** 100 * Creates a new #GtkToggleAction object. To add the action to 101 * a #GtkActionGroup and set the accelerator for the action, 102 * call gtk_action_group_add_action_with_accel(). 103 * 104 * Params: 105 * name = A unique name for the action 106 * label = The label displayed in menu items and on buttons, 107 * or %NULL 108 * tooltip = A tooltip for the action, or %NULL 109 * stockId = The stock icon to display in widgets representing 110 * the action, or %NULL 111 * 112 * Returns: a new #GtkToggleAction 113 * 114 * Since: 2.4 115 * 116 * Throws: ConstructionException GTK+ fails to create the object. 117 */ 118 public this(string name, string label, string tooltip, string stockId) 119 { 120 auto p = gtk_toggle_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId)); 121 122 if(p is null) 123 { 124 throw new ConstructionException("null returned by new"); 125 } 126 127 this(cast(GtkToggleAction*) p, true); 128 } 129 130 /** 131 * Returns the checked state of the toggle action. 132 * 133 * Returns: the checked state of the toggle action 134 * 135 * Since: 2.4 136 */ 137 public bool getActive() 138 { 139 return gtk_toggle_action_get_active(gtkToggleAction) != 0; 140 } 141 142 /** 143 * Returns whether the action should have proxies like a radio action. 144 * 145 * Returns: whether the action should have proxies like a radio action. 146 * 147 * Since: 2.4 148 */ 149 public bool getDrawAsRadio() 150 { 151 return gtk_toggle_action_get_draw_as_radio(gtkToggleAction) != 0; 152 } 153 154 /** 155 * Sets the checked state on the toggle action. 156 * 157 * Params: 158 * isActive = whether the action should be checked or not 159 * 160 * Since: 2.4 161 */ 162 public void setActive(bool isActive) 163 { 164 gtk_toggle_action_set_active(gtkToggleAction, isActive); 165 } 166 167 /** 168 * Sets whether the action should have proxies like a radio action. 169 * 170 * Params: 171 * drawAsRadio = whether the action should have proxies like a radio 172 * action 173 * 174 * Since: 2.4 175 */ 176 public void setDrawAsRadio(bool drawAsRadio) 177 { 178 gtk_toggle_action_set_draw_as_radio(gtkToggleAction, drawAsRadio); 179 } 180 181 /** 182 * Emits the “toggled” signal on the toggle action. 183 * 184 * Since: 2.4 185 */ 186 public void toggled() 187 { 188 gtk_toggle_action_toggled(gtkToggleAction); 189 } 190 191 /** 192 * Should be connected if you wish to perform an action 193 * whenever the #GtkToggleAction state is changed. 194 */ 195 gulong addOnToggled(void delegate(ToggleAction) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 196 { 197 return Signals.connect(this, "toggled", dlg, connectFlags ^ ConnectFlags.SWAPPED); 198 } 199 }