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  = GtkSwitch.html
27  * outPack = gtk
28  * outFile = Switch
29  * strct   = GtkSwitch
30  * realStrct=
31  * ctorStrct=
32  * clss    = Switch
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * 	- ActionableIF
40  * 	- ActivatableIF
41  * prefixes:
42  * 	- gtk_switch_
43  * omit structs:
44  * omit prefixes:
45  * omit code:
46  * omit signals:
47  * imports:
48  * 	- gtk.ActionableIF
49  * 	- gtk.ActionableT
50  * 	- gtk.ActivatableT
51  * 	- gtk.ActivatableIF
52  * structWrap:
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module gtk.Switch;
59 
60 public  import gtkc.gtktypes;
61 
62 private import gtkc.gtk;
63 private import glib.ConstructionException;
64 private import gobject.ObjectG;
65 
66 private import gobject.Signals;
67 public  import gtkc.gdktypes;
68 private import gtk.ActionableIF;
69 private import gtk.ActionableT;
70 private import gtk.ActivatableT;
71 private import gtk.ActivatableIF;
72 
73 
74 private import gtk.Widget;
75 
76 /**
77  * GtkSwitch is a widget that has two states: on or off. The user can control
78  * which state should be active by clicking the empty area, or by dragging the
79  * handle.
80  */
81 public class Switch : Widget, ActionableIF, ActivatableIF
82 {
83 	
84 	/** the main Gtk struct */
85 	protected GtkSwitch* gtkSwitch;
86 	
87 	
88 	/** Get the main Gtk struct */
89 	public GtkSwitch* getSwitchStruct()
90 	{
91 		return gtkSwitch;
92 	}
93 	
94 	
95 	/** the main Gtk struct as a void* */
96 	protected override void* getStruct()
97 	{
98 		return cast(void*)gtkSwitch;
99 	}
100 	
101 	/**
102 	 * Sets our main struct and passes it to the parent class
103 	 */
104 	public this (GtkSwitch* gtkSwitch)
105 	{
106 		super(cast(GtkWidget*)gtkSwitch);
107 		this.gtkSwitch = gtkSwitch;
108 	}
109 	
110 	protected override void setStruct(GObject* obj)
111 	{
112 		super.setStruct(obj);
113 		gtkSwitch = cast(GtkSwitch*)obj;
114 	}
115 	
116 	// add the Actionable capabilities
117 	mixin ActionableT!(GtkSwitch);
118 	
119 	// add the Activatable capabilities
120 	mixin ActivatableT!(GtkSwitch);
121 	
122 	/**
123 	 */
124 	int[string] connectedSignals;
125 	
126 	void delegate(Switch)[] onActivateListeners;
127 	/**
128 	 * The ::activate signal on GtkSwitch is an action signal and
129 	 * emitting it causes the switch to animate.
130 	 * Applications should never connect to this signal, but use the
131 	 * notify::active signal.
132 	 * See Also
133 	 * GtkToggleButton
134 	 */
135 	void addOnActivate(void delegate(Switch) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
136 	{
137 		if ( !("activate" in connectedSignals) )
138 		{
139 			Signals.connectData(
140 			getStruct(),
141 			"activate",
142 			cast(GCallback)&callBackActivate,
143 			cast(void*)this,
144 			null,
145 			connectFlags);
146 			connectedSignals["activate"] = 1;
147 		}
148 		onActivateListeners ~= dlg;
149 	}
150 	extern(C) static void callBackActivate(GtkSwitch* widgetStruct, Switch _switc)
151 	{
152 		foreach ( void delegate(Switch) dlg ; _switc.onActivateListeners )
153 		{
154 			dlg(_switc);
155 		}
156 	}
157 	
158 	
159 	/**
160 	 * Creates a new GtkSwitch widget.
161 	 * Throws: ConstructionException GTK+ fails to create the object.
162 	 */
163 	public this ()
164 	{
165 		// GtkWidget * gtk_switch_new (void);
166 		auto p = gtk_switch_new();
167 		if(p is null)
168 		{
169 			throw new ConstructionException("null returned by gtk_switch_new()");
170 		}
171 		this(cast(GtkSwitch*) p);
172 	}
173 	
174 	/**
175 	 * Changes the state of sw to the desired one.
176 	 * Params:
177 	 * isActive = TRUE if sw should be active, and FALSE otherwise
178 	 * Since 3.0
179 	 */
180 	public void setActive(int isActive)
181 	{
182 		// void gtk_switch_set_active (GtkSwitch *sw,  gboolean is_active);
183 		gtk_switch_set_active(gtkSwitch, isActive);
184 	}
185 	
186 	/**
187 	 * Gets whether the GtkSwitch is in its "on" or "off" state.
188 	 * Returns: TRUE if the GtkSwitch is active, and FALSE otherwise Since 3.0
189 	 */
190 	public int getActive()
191 	{
192 		// gboolean gtk_switch_get_active (GtkSwitch *sw);
193 		return gtk_switch_get_active(gtkSwitch);
194 	}
195 }