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  = GtkToggleAction.html
27  * outPack = gtk
28  * outFile = ToggleAction
29  * strct   = GtkToggleAction
30  * realStrct=
31  * ctorStrct=
32  * clss    = ToggleAction
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_toggle_action_
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.ToggleAction;
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.Action;
67 
68 /**
69  * A GtkToggleAction corresponds roughly to a GtkCheckMenuItem. It has an
70  * "active" state specifying whether the action has been checked or not.
71  */
72 public class ToggleAction : Action
73 {
74 	
75 	/** the main Gtk struct */
76 	protected GtkToggleAction* gtkToggleAction;
77 	
78 	
79 	/** Get the main Gtk struct */
80 	public GtkToggleAction* getToggleActionStruct()
81 	{
82 		return gtkToggleAction;
83 	}
84 	
85 	
86 	/** the main Gtk struct as a void* */
87 	protected override void* getStruct()
88 	{
89 		return cast(void*)gtkToggleAction;
90 	}
91 	
92 	/**
93 	 * Sets our main struct and passes it to the parent class
94 	 */
95 	public this (GtkToggleAction* gtkToggleAction)
96 	{
97 		super(cast(GtkAction*)gtkToggleAction);
98 		this.gtkToggleAction = gtkToggleAction;
99 	}
100 	
101 	protected override void setStruct(GObject* obj)
102 	{
103 		super.setStruct(obj);
104 		gtkToggleAction = cast(GtkToggleAction*)obj;
105 	}
106 	
107 	/**
108 	 * Creates a new GtkToggleAction object. To add the action to
109 	 * a GtkActionGroup and set the accelerator for the action,
110 	 * call gtk_action_group_add_action_with_accel().
111 	 * Since 2.4
112 	 * Params:
113 	 * name =  A unique name for the action
114 	 * label =  The label displayed in menu items and on buttons, or NULL
115 	 * tooltip =  A tooltip for the action, or NULL
116 	 * stockId =  The stock icon to display in widgets representing the
117 	 *  action, or NULL
118 	 * Throws: ConstructionException GTK+ fails to create the object.
119 	 */
120 	public this (string name, string label, string tooltip, StockID stockId)
121 	{
122 		this(name, label, tooltip, StockDesc[stockId]);
123 	}
124 	
125 	/**
126 	 */
127 	int[string] connectedSignals;
128 	
129 	void delegate(ToggleAction)[] onToggledListeners;
130 	/**
131 	 * Warning
132 	 * GtkToggleAction::toggled is deprecated and should not be used in newly-written code. 3.10
133 	 * Should be connected if you wish to perform an action
134 	 * whenever the GtkToggleAction state is changed.
135 	 */
136 	void addOnToggled(void delegate(ToggleAction) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
137 	{
138 		if ( !("toggled" in connectedSignals) )
139 		{
140 			Signals.connectData(
141 			getStruct(),
142 			"toggled",
143 			cast(GCallback)&callBackToggled,
144 			cast(void*)this,
145 			null,
146 			connectFlags);
147 			connectedSignals["toggled"] = 1;
148 		}
149 		onToggledListeners ~= dlg;
150 	}
151 	extern(C) static void callBackToggled(GtkToggleAction* toggleactionStruct, ToggleAction _toggleAction)
152 	{
153 		foreach ( void delegate(ToggleAction) dlg ; _toggleAction.onToggledListeners )
154 		{
155 			dlg(_toggleAction);
156 		}
157 	}
158 	
159 	
160 	/**
161 	 * Warning
162 	 * gtk_toggle_action_new is deprecated and should not be used in newly-written code. 3.10
163 	 * Creates a new GtkToggleAction object. To add the action to
164 	 * a GtkActionGroup and set the accelerator for the action,
165 	 * call gtk_action_group_add_action_with_accel().
166 	 * Since 2.4
167 	 * Params:
168 	 * name = A unique name for the action
169 	 * label = The label displayed in menu items and on buttons,
170 	 * or NULL. [allow-none]
171 	 * tooltip = A tooltip for the action, or NULL. [allow-none]
172 	 * stockId = The stock icon to display in widgets representing
173 	 * the action, or NULL. [allow-none]
174 	 * Throws: ConstructionException GTK+ fails to create the object.
175 	 */
176 	public this (string name, string label, string tooltip, string stockId)
177 	{
178 		// GtkToggleAction * gtk_toggle_action_new (const gchar *name,  const gchar *label,  const gchar *tooltip,  const gchar *stock_id);
179 		auto p = gtk_toggle_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId));
180 		if(p is null)
181 		{
182 			throw new ConstructionException("null returned by gtk_toggle_action_new(Str.toStringz(name), Str.toStringz(label), Str.toStringz(tooltip), Str.toStringz(stockId))");
183 		}
184 		this(cast(GtkToggleAction*) p);
185 	}
186 	
187 	/**
188 	 * Warning
189 	 * gtk_toggle_action_toggled is deprecated and should not be used in newly-written code. 3.10
190 	 * Emits the "toggled" signal on the toggle action.
191 	 * Since 2.4
192 	 */
193 	public void toggled()
194 	{
195 		// void gtk_toggle_action_toggled (GtkToggleAction *action);
196 		gtk_toggle_action_toggled(gtkToggleAction);
197 	}
198 	
199 	/**
200 	 * Warning
201 	 * gtk_toggle_action_set_active is deprecated and should not be used in newly-written code. 3.10
202 	 * Sets the checked state on the toggle action.
203 	 * Since 2.4
204 	 * Params:
205 	 * isActive = whether the action should be checked or not
206 	 */
207 	public void setActive(int isActive)
208 	{
209 		// void gtk_toggle_action_set_active (GtkToggleAction *action,  gboolean is_active);
210 		gtk_toggle_action_set_active(gtkToggleAction, isActive);
211 	}
212 	
213 	/**
214 	 * Warning
215 	 * gtk_toggle_action_get_active is deprecated and should not be used in newly-written code. 3.10
216 	 * Returns the checked state of the toggle action.
217 	 * Since 2.4
218 	 * Returns: the checked state of the toggle action
219 	 */
220 	public int getActive()
221 	{
222 		// gboolean gtk_toggle_action_get_active (GtkToggleAction *action);
223 		return gtk_toggle_action_get_active(gtkToggleAction);
224 	}
225 	
226 	/**
227 	 * Warning
228 	 * gtk_toggle_action_set_draw_as_radio is deprecated and should not be used in newly-written code. 3.10
229 	 * Sets whether the action should have proxies like a radio action.
230 	 * Since 2.4
231 	 * Params:
232 	 * drawAsRadio = whether the action should have proxies like a radio
233 	 * action
234 	 */
235 	public void setDrawAsRadio(int drawAsRadio)
236 	{
237 		// void gtk_toggle_action_set_draw_as_radio (GtkToggleAction *action,  gboolean draw_as_radio);
238 		gtk_toggle_action_set_draw_as_radio(gtkToggleAction, drawAsRadio);
239 	}
240 	
241 	/**
242 	 * Warning
243 	 * gtk_toggle_action_get_draw_as_radio is deprecated and should not be used in newly-written code. 3.10
244 	 * Returns whether the action should have proxies like a radio action.
245 	 * Since 2.4
246 	 * Returns: whether the action should have proxies like a radio action.
247 	 */
248 	public int getDrawAsRadio()
249 	{
250 		// gboolean gtk_toggle_action_get_draw_as_radio (GtkToggleAction *action);
251 		return gtk_toggle_action_get_draw_as_radio(gtkToggleAction);
252 	}
253 }