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  = GtkCellRendererToggle.html
27  * outPack = gtk
28  * outFile = CellRendererToggle
29  * strct   = GtkCellRendererToggle
30  * realStrct=
31  * ctorStrct=GtkCellRenderer
32  * clss    = CellRendererToggle
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gtk_cell_renderer_toggle_
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.CellRendererToggle;
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.CellRenderer;
69 
70 /**
71  * GtkCellRendererToggle renders a toggle button in a cell. The
72  * button is drawn as a radio or a checkbutton, depending on the
73  * "radio" property.
74  * When activated, it emits the "toggled" signal.
75  */
76 public class CellRendererToggle : CellRenderer
77 {
78 	
79 	/** the main Gtk struct */
80 	protected GtkCellRendererToggle* gtkCellRendererToggle;
81 	
82 	
83 	public GtkCellRendererToggle* getCellRendererToggleStruct()
84 	{
85 		return gtkCellRendererToggle;
86 	}
87 	
88 	
89 	/** the main Gtk struct as a void* */
90 	protected override void* getStruct()
91 	{
92 		return cast(void*)gtkCellRendererToggle;
93 	}
94 	
95 	/**
96 	 * Sets our main struct and passes it to the parent class
97 	 */
98 	public this (GtkCellRendererToggle* gtkCellRendererToggle)
99 	{
100 		super(cast(GtkCellRenderer*)gtkCellRendererToggle);
101 		this.gtkCellRendererToggle = gtkCellRendererToggle;
102 	}
103 	
104 	protected override void setStruct(GObject* obj)
105 	{
106 		super.setStruct(obj);
107 		gtkCellRendererToggle = cast(GtkCellRendererToggle*)obj;
108 	}
109 	
110 	/**
111 	 */
112 	int[string] connectedSignals;
113 	
114 	void delegate(string, CellRendererToggle)[] onToggledListeners;
115 	/**
116 	 * The ::toggled signal is emitted when the cell is toggled.
117 	 */
118 	void addOnToggled(void delegate(string, CellRendererToggle) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
119 	{
120 		if ( !("toggled" in connectedSignals) )
121 		{
122 			Signals.connectData(
123 			getStruct(),
124 			"toggled",
125 			cast(GCallback)&callBackToggled,
126 			cast(void*)this,
127 			null,
128 			connectFlags);
129 			connectedSignals["toggled"] = 1;
130 		}
131 		onToggledListeners ~= dlg;
132 	}
133 	extern(C) static void callBackToggled(GtkCellRendererToggle* cellRendererStruct, gchar* path, CellRendererToggle _cellRendererToggle)
134 	{
135 		foreach ( void delegate(string, CellRendererToggle) dlg ; _cellRendererToggle.onToggledListeners )
136 		{
137 			dlg(Str.toString(path), _cellRendererToggle);
138 		}
139 	}
140 	
141 	
142 	/**
143 	 * Creates a new GtkCellRendererToggle. Adjust rendering
144 	 * parameters using object properties. Object properties can be set
145 	 * globally (with g_object_set()). Also, with GtkTreeViewColumn, you
146 	 * can bind a property to a value in a GtkTreeModel. For example, you
147 	 * can bind the "active" property on the cell renderer to a boolean value
148 	 * in the model, thus causing the check button to reflect the state of
149 	 * the model.
150 	 * Throws: ConstructionException GTK+ fails to create the object.
151 	 */
152 	public this ()
153 	{
154 		// GtkCellRenderer * gtk_cell_renderer_toggle_new (void);
155 		auto p = gtk_cell_renderer_toggle_new();
156 		if(p is null)
157 		{
158 			throw new ConstructionException("null returned by gtk_cell_renderer_toggle_new()");
159 		}
160 		this(cast(GtkCellRendererToggle*) p);
161 	}
162 	
163 	/**
164 	 * Returns whether we're rendering radio toggles rather than checkboxes.
165 	 * Returns: TRUE if we're rendering radio toggles rather than checkboxes
166 	 */
167 	public int getRadio()
168 	{
169 		// gboolean gtk_cell_renderer_toggle_get_radio (GtkCellRendererToggle *toggle);
170 		return gtk_cell_renderer_toggle_get_radio(gtkCellRendererToggle);
171 	}
172 	
173 	/**
174 	 * If radio is TRUE, the cell renderer renders a radio toggle
175 	 * (i.e. a toggle in a group of mutually-exclusive toggles).
176 	 * If FALSE, it renders a check toggle (a standalone boolean option).
177 	 * This can be set globally for the cell renderer, or changed just
178 	 * before rendering each cell in the model (for GtkTreeView, you set
179 	 * up a per-row setting using GtkTreeViewColumn to associate model
180 	 * columns with cell renderer properties).
181 	 * Params:
182 	 * radio = TRUE to make the toggle look like a radio button
183 	 */
184 	public void setRadio(int radio)
185 	{
186 		// void gtk_cell_renderer_toggle_set_radio (GtkCellRendererToggle *toggle,  gboolean radio);
187 		gtk_cell_renderer_toggle_set_radio(gtkCellRendererToggle, radio);
188 	}
189 	
190 	/**
191 	 * Returns whether the cell renderer is active. See
192 	 * gtk_cell_renderer_toggle_set_active().
193 	 * Returns: TRUE if the cell renderer is active.
194 	 */
195 	public int getActive()
196 	{
197 		// gboolean gtk_cell_renderer_toggle_get_active (GtkCellRendererToggle *toggle);
198 		return gtk_cell_renderer_toggle_get_active(gtkCellRendererToggle);
199 	}
200 	
201 	/**
202 	 * Activates or deactivates a cell renderer.
203 	 * Params:
204 	 * setting = the value to set.
205 	 */
206 	public void setActive(int setting)
207 	{
208 		// void gtk_cell_renderer_toggle_set_active (GtkCellRendererToggle *toggle,  gboolean setting);
209 		gtk_cell_renderer_toggle_set_active(gtkCellRendererToggle, setting);
210 	}
211 	
212 	/**
213 	 * Returns whether the cell renderer is activatable. See
214 	 * gtk_cell_renderer_toggle_set_activatable().
215 	 * Since 2.18
216 	 * Returns: TRUE if the cell renderer is activatable.
217 	 */
218 	public int getActivatable()
219 	{
220 		// gboolean gtk_cell_renderer_toggle_get_activatable  (GtkCellRendererToggle *toggle);
221 		return gtk_cell_renderer_toggle_get_activatable(gtkCellRendererToggle);
222 	}
223 	
224 	/**
225 	 * Makes the cell renderer activatable.
226 	 * Since 2.18
227 	 * Params:
228 	 * setting = the value to set.
229 	 */
230 	public void setActivatable(int setting)
231 	{
232 		// void gtk_cell_renderer_toggle_set_activatable  (GtkCellRendererToggle *toggle,  gboolean setting);
233 		gtk_cell_renderer_toggle_set_activatable(gtkCellRendererToggle, setting);
234 	}
235 }