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.CellRendererAccel; 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.CellRendererText; 33 private import gtkc.gtk; 34 public import gtkc.gtktypes; 35 private import std.algorithm; 36 37 38 /** 39 * #GtkCellRendererAccel displays a keyboard accelerator (i.e. a key 40 * combination like `Control + a`). If the cell renderer is editable, 41 * the accelerator can be changed by simply typing the new combination. 42 * 43 * The #GtkCellRendererAccel cell renderer was added in GTK+ 2.10. 44 */ 45 public class CellRendererAccel : CellRendererText 46 { 47 /** the main Gtk struct */ 48 protected GtkCellRendererAccel* gtkCellRendererAccel; 49 50 /** Get the main Gtk struct */ 51 public GtkCellRendererAccel* getCellRendererAccelStruct() 52 { 53 return gtkCellRendererAccel; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected override void* getStruct() 58 { 59 return cast(void*)gtkCellRendererAccel; 60 } 61 62 protected override void setStruct(GObject* obj) 63 { 64 gtkCellRendererAccel = cast(GtkCellRendererAccel*)obj; 65 super.setStruct(obj); 66 } 67 68 /** 69 * Sets our main struct and passes it to the parent class. 70 */ 71 public this (GtkCellRendererAccel* gtkCellRendererAccel, bool ownedRef = false) 72 { 73 this.gtkCellRendererAccel = gtkCellRendererAccel; 74 super(cast(GtkCellRendererText*)gtkCellRendererAccel, ownedRef); 75 } 76 77 78 /** */ 79 public static GType getType() 80 { 81 return gtk_cell_renderer_accel_get_type(); 82 } 83 84 /** 85 * Creates a new #GtkCellRendererAccel. 86 * 87 * Returns: the new cell renderer 88 * 89 * Since: 2.10 90 * 91 * Throws: ConstructionException GTK+ fails to create the object. 92 */ 93 public this() 94 { 95 auto p = gtk_cell_renderer_accel_new(); 96 97 if(p is null) 98 { 99 throw new ConstructionException("null returned by new"); 100 } 101 102 this(cast(GtkCellRendererAccel*) p); 103 } 104 105 protected class OnAccelClearedDelegateWrapper 106 { 107 static OnAccelClearedDelegateWrapper[] listeners; 108 void delegate(string, CellRendererAccel) dlg; 109 gulong handlerId; 110 111 this(void delegate(string, CellRendererAccel) dlg) 112 { 113 this.dlg = dlg; 114 this.listeners ~= this; 115 } 116 117 void remove(OnAccelClearedDelegateWrapper source) 118 { 119 foreach(index, wrapper; listeners) 120 { 121 if (wrapper.handlerId == source.handlerId) 122 { 123 listeners[index] = null; 124 listeners = std.algorithm.remove(listeners, index); 125 break; 126 } 127 } 128 } 129 } 130 131 /** 132 * Gets emitted when the user has removed the accelerator. 133 * 134 * Params: 135 * pathString = the path identifying the row of the edited cell 136 * 137 * Since: 2.10 138 */ 139 gulong addOnAccelCleared(void delegate(string, CellRendererAccel) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 140 { 141 auto wrapper = new OnAccelClearedDelegateWrapper(dlg); 142 wrapper.handlerId = Signals.connectData( 143 this, 144 "accel-cleared", 145 cast(GCallback)&callBackAccelCleared, 146 cast(void*)wrapper, 147 cast(GClosureNotify)&callBackAccelClearedDestroy, 148 connectFlags); 149 return wrapper.handlerId; 150 } 151 152 extern(C) static void callBackAccelCleared(GtkCellRendererAccel* cellrendereraccelStruct, char* pathString, OnAccelClearedDelegateWrapper wrapper) 153 { 154 wrapper.dlg(Str.toString(pathString), wrapper.outer); 155 } 156 157 extern(C) static void callBackAccelClearedDestroy(OnAccelClearedDelegateWrapper wrapper, GClosure* closure) 158 { 159 wrapper.remove(wrapper); 160 } 161 162 protected class OnAccelEditedDelegateWrapper 163 { 164 static OnAccelEditedDelegateWrapper[] listeners; 165 void delegate(string, uint, GdkModifierType, uint, CellRendererAccel) dlg; 166 gulong handlerId; 167 168 this(void delegate(string, uint, GdkModifierType, uint, CellRendererAccel) dlg) 169 { 170 this.dlg = dlg; 171 this.listeners ~= this; 172 } 173 174 void remove(OnAccelEditedDelegateWrapper source) 175 { 176 foreach(index, wrapper; listeners) 177 { 178 if (wrapper.handlerId == source.handlerId) 179 { 180 listeners[index] = null; 181 listeners = std.algorithm.remove(listeners, index); 182 break; 183 } 184 } 185 } 186 } 187 188 /** 189 * Gets emitted when the user has selected a new accelerator. 190 * 191 * Params: 192 * pathString = the path identifying the row of the edited cell 193 * accelKey = the new accelerator keyval 194 * accelMods = the new acclerator modifier mask 195 * hardwareKeycode = the keycode of the new accelerator 196 * 197 * Since: 2.10 198 */ 199 gulong addOnAccelEdited(void delegate(string, uint, GdkModifierType, uint, CellRendererAccel) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 200 { 201 auto wrapper = new OnAccelEditedDelegateWrapper(dlg); 202 wrapper.handlerId = Signals.connectData( 203 this, 204 "accel-edited", 205 cast(GCallback)&callBackAccelEdited, 206 cast(void*)wrapper, 207 cast(GClosureNotify)&callBackAccelEditedDestroy, 208 connectFlags); 209 return wrapper.handlerId; 210 } 211 212 extern(C) static void callBackAccelEdited(GtkCellRendererAccel* cellrendereraccelStruct, char* pathString, uint accelKey, GdkModifierType accelMods, uint hardwareKeycode, OnAccelEditedDelegateWrapper wrapper) 213 { 214 wrapper.dlg(Str.toString(pathString), accelKey, accelMods, hardwareKeycode, wrapper.outer); 215 } 216 217 extern(C) static void callBackAccelEditedDestroy(OnAccelEditedDelegateWrapper wrapper, GClosure* closure) 218 { 219 wrapper.remove(wrapper); 220 } 221 }