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