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