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 
69 private import gtk.ActionableIF;
70 private import gtk.ActionableT;
71 private import gtk.ActivatableT;
72 private import gtk.ActivatableIF;
73 
74 
75 
76 private import gtk.Widget;
77 
78 /**
79  * GtkSwitch is a widget that has two states: on or off. The user can control
80  * which state should be active by clicking the empty area, or by dragging the
81  * handle.
82  */
83 public class Switch : Widget, ActionableIF, ActivatableIF
84 {
85 	
86 	/** the main Gtk struct */
87 	protected GtkSwitch* gtkSwitch;
88 	
89 	
90 	public GtkSwitch* getSwitchStruct()
91 	{
92 		return gtkSwitch;
93 	}
94 	
95 	
96 	/** the main Gtk struct as a void* */
97 	protected override void* getStruct()
98 	{
99 		return cast(void*)gtkSwitch;
100 	}
101 	
102 	/**
103 	 * Sets our main struct and passes it to the parent class
104 	 */
105 	public this (GtkSwitch* gtkSwitch)
106 	{
107 		super(cast(GtkWidget*)gtkSwitch);
108 		this.gtkSwitch = gtkSwitch;
109 	}
110 	
111 	protected override void setStruct(GObject* obj)
112 	{
113 		super.setStruct(obj);
114 		gtkSwitch = cast(GtkSwitch*)obj;
115 	}
116 	
117 	// add the Actionable capabilities
118 	mixin ActionableT!(GtkSwitch);
119 	
120 	// add the Activatable capabilities
121 	mixin ActivatableT!(GtkSwitch);
122 	
123 	/**
124 	 */
125 	int[string] connectedSignals;
126 	
127 	void delegate(Switch)[] onActivateListeners;
128 	/**
129 	 * The ::activate signal on GtkSwitch is an action signal and
130 	 * emitting it causes the switch to animate.
131 	 * Applications should never connect to this signal, but use the
132 	 * notify::active signal.
133 	 * See Also
134 	 * GtkToggleButton
135 	 */
136 	void addOnActivate(void delegate(Switch) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
137 	{
138 		if ( !("activate" in connectedSignals) )
139 		{
140 			Signals.connectData(
141 			getStruct(),
142 			"activate",
143 			cast(GCallback)&callBackActivate,
144 			cast(void*)this,
145 			null,
146 			connectFlags);
147 			connectedSignals["activate"] = 1;
148 		}
149 		onActivateListeners ~= dlg;
150 	}
151 	extern(C) static void callBackActivate(GtkSwitch* widgetStruct, Switch _switc)
152 	{
153 		foreach ( void delegate(Switch) dlg ; _switc.onActivateListeners )
154 		{
155 			dlg(_switc);
156 		}
157 	}
158 	
159 	
160 	/**
161 	 * Creates a new GtkSwitch widget.
162 	 * Throws: ConstructionException GTK+ fails to create the object.
163 	 */
164 	public this ()
165 	{
166 		// GtkWidget * gtk_switch_new (void);
167 		auto p = gtk_switch_new();
168 		if(p is null)
169 		{
170 			throw new ConstructionException("null returned by gtk_switch_new()");
171 		}
172 		this(cast(GtkSwitch*) p);
173 	}
174 	
175 	/**
176 	 * Changes the state of sw to the desired one.
177 	 * Params:
178 	 * isActive = TRUE if sw should be active, and FALSE otherwise
179 	 * Since 3.0
180 	 */
181 	public void setActive(int isActive)
182 	{
183 		// void gtk_switch_set_active (GtkSwitch *sw,  gboolean is_active);
184 		gtk_switch_set_active(gtkSwitch, isActive);
185 	}
186 	
187 	/**
188 	 * Gets whether the GtkSwitch is in its "on" or "off" state.
189 	 * Returns: TRUE if the GtkSwitch is active, and FALSE otherwise Since 3.0
190 	 */
191 	public int getActive()
192 	{
193 		// gboolean gtk_switch_get_active (GtkSwitch *sw);
194 		return gtk_switch_get_active(gtkSwitch);
195 	}
196 }