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 module gtk.CellRendererToggle;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gobject.Signals;
31 private import gtk.CellRenderer;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 private import std.algorithm;
35 
36 
37 /**
38  * Renders a toggle button in a cell
39  * 
40  * #GtkCellRendererToggle renders a toggle button in a cell. The
41  * button is drawn as a radio or a checkbutton, depending on the
42  * #GtkCellRendererToggle:radio property.
43  * When activated, it emits the #GtkCellRendererToggle::toggled signal.
44  */
45 public class CellRendererToggle : CellRenderer
46 {
47 	/** the main Gtk struct */
48 	protected GtkCellRendererToggle* gtkCellRendererToggle;
49 
50 	/** Get the main Gtk struct */
51 	public GtkCellRendererToggle* getCellRendererToggleStruct(bool transferOwnership = false)
52 	{
53 		if (transferOwnership)
54 			ownedRef = false;
55 		return gtkCellRendererToggle;
56 	}
57 
58 	/** the main Gtk struct as a void* */
59 	protected override void* getStruct()
60 	{
61 		return cast(void*)gtkCellRendererToggle;
62 	}
63 
64 	/**
65 	 * Sets our main struct and passes it to the parent class.
66 	 */
67 	public this (GtkCellRendererToggle* gtkCellRendererToggle, bool ownedRef = false)
68 	{
69 		this.gtkCellRendererToggle = gtkCellRendererToggle;
70 		super(cast(GtkCellRenderer*)gtkCellRendererToggle, ownedRef);
71 	}
72 
73 
74 	/** */
75 	public static GType getType()
76 	{
77 		return gtk_cell_renderer_toggle_get_type();
78 	}
79 
80 	/**
81 	 * Creates a new #GtkCellRendererToggle. Adjust rendering
82 	 * parameters using object properties. Object properties can be set
83 	 * globally (with g_object_set()). Also, with #GtkTreeViewColumn, you
84 	 * can bind a property to a value in a #GtkTreeModel. For example, you
85 	 * can bind the “active” property on the cell renderer to a boolean value
86 	 * in the model, thus causing the check button to reflect the state of
87 	 * the model.
88 	 *
89 	 * Returns: the new cell renderer
90 	 *
91 	 * Throws: ConstructionException GTK+ fails to create the object.
92 	 */
93 	public this()
94 	{
95 		auto __p = gtk_cell_renderer_toggle_new();
96 
97 		if(__p is null)
98 		{
99 			throw new ConstructionException("null returned by new");
100 		}
101 
102 		this(cast(GtkCellRendererToggle*) __p);
103 	}
104 
105 	/**
106 	 * Returns whether the cell renderer is activatable. See
107 	 * gtk_cell_renderer_toggle_set_activatable().
108 	 *
109 	 * Returns: %TRUE if the cell renderer is activatable.
110 	 */
111 	public bool getActivatable()
112 	{
113 		return gtk_cell_renderer_toggle_get_activatable(gtkCellRendererToggle) != 0;
114 	}
115 
116 	/**
117 	 * Returns whether the cell renderer is active. See
118 	 * gtk_cell_renderer_toggle_set_active().
119 	 *
120 	 * Returns: %TRUE if the cell renderer is active.
121 	 */
122 	public bool getActive()
123 	{
124 		return gtk_cell_renderer_toggle_get_active(gtkCellRendererToggle) != 0;
125 	}
126 
127 	/**
128 	 * Returns whether we’re rendering radio toggles rather than checkboxes.
129 	 *
130 	 * Returns: %TRUE if we’re rendering radio toggles rather than checkboxes
131 	 */
132 	public bool getRadio()
133 	{
134 		return gtk_cell_renderer_toggle_get_radio(gtkCellRendererToggle) != 0;
135 	}
136 
137 	/**
138 	 * Makes the cell renderer activatable.
139 	 *
140 	 * Params:
141 	 *     setting = the value to set.
142 	 */
143 	public void setActivatable(bool setting)
144 	{
145 		gtk_cell_renderer_toggle_set_activatable(gtkCellRendererToggle, setting);
146 	}
147 
148 	/**
149 	 * Activates or deactivates a cell renderer.
150 	 *
151 	 * Params:
152 	 *     setting = the value to set.
153 	 */
154 	public void setActive(bool setting)
155 	{
156 		gtk_cell_renderer_toggle_set_active(gtkCellRendererToggle, setting);
157 	}
158 
159 	/**
160 	 * If @radio is %TRUE, the cell renderer renders a radio toggle
161 	 * (i.e. a toggle in a group of mutually-exclusive toggles).
162 	 * If %FALSE, it renders a check toggle (a standalone boolean option).
163 	 * This can be set globally for the cell renderer, or changed just
164 	 * before rendering each cell in the model (for #GtkTreeView, you set
165 	 * up a per-row setting using #GtkTreeViewColumn to associate model
166 	 * columns with cell renderer properties).
167 	 *
168 	 * Params:
169 	 *     radio = %TRUE to make the toggle look like a radio button
170 	 */
171 	public void setRadio(bool radio)
172 	{
173 		gtk_cell_renderer_toggle_set_radio(gtkCellRendererToggle, radio);
174 	}
175 
176 	/**
177 	 * The ::toggled signal is emitted when the cell is toggled.
178 	 *
179 	 * It is the responsibility of the application to update the model
180 	 * with the correct value to store at @path.  Often this is simply the
181 	 * opposite of the value currently stored at @path.
182 	 *
183 	 * Params:
184 	 *     path = string representation of #GtkTreePath describing the
185 	 *         event location
186 	 */
187 	gulong addOnToggled(void delegate(string, CellRendererToggle) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
188 	{
189 		return Signals.connect(this, "toggled", dlg, connectFlags ^ ConnectFlags.SWAPPED);
190 	}
191 }