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