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 = gtk3-Bindings.html 27 * outPack = gtk 28 * outFile = BindingSet 29 * strct = GtkBindingSet 30 * realStrct= 31 * ctorStrct= 32 * clss = BindingSet 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_binding_set_ 41 * - gtk_binding_ 42 * - gtk_bindings_ 43 * omit structs: 44 * omit prefixes: 45 * omit code: 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - glib.ListSG 50 * - gobject.ObjectG 51 * structWrap: 52 * - GObject* -> ObjectG 53 * - GSList* -> ListSG 54 * - GtkBindingSet* -> BindingSet 55 * module aliases: 56 * local aliases: 57 * overrides: 58 */ 59 60 module gtk.BindingSet; 61 62 public import gtkc.gtktypes; 63 64 private import gtkc.gtk; 65 private import glib.ConstructionException; 66 private import gobject.ObjectG; 67 68 private import glib.Str; 69 private import glib.ListSG; 70 private import gobject.ObjectG; 71 72 73 74 /** 75 * GtkBindingSet provides a mechanism for configuring GTK+ key bindings 76 * through CSS files. This eases key binding adjustments for application 77 * developers as well as users and provides GTK+ users or administrators 78 * with high key binding configurability which requires no application 79 * or toolkit side changes. 80 * 81 * Installing a key binding 82 * 83 * A CSS file binding consists of a 'binding-set' definition and a match 84 * statement to apply the binding set to specific widget types. Details 85 * on the matching mechanism are described under 86 * Selectors 87 * in the GtkCssProvider documentation. Inside the binding set definition, 88 * key combinations are bound to one or more specific signal emissions on 89 * the target widget. Key combinations are strings consisting of an optional 90 * GdkModifierType name and key names 91 * such as those defined in <gdk/gdkkeysyms.h> 92 * or returned from gdk_keyval_name(), they have to be parsable by 93 * gtk_accelerator_parse(). Specifications of signal emissions consist 94 * of a string identifying the signal name, and a list of signal specific 95 * arguments in parenthesis. 96 * 97 * For example for binding Control and the left or right cursor keys 98 * of a GtkEntry widget to the "move-cursor" signal (so movement 99 * occurs in 3-character steps), the following binding can be used: 100 * 101 * $(DDOC_COMMENT example) 102 * 103 * <hr> 104 * 105 * Unbinding existing key bindings 106 * 107 * GTK+ already defines a number of useful bindings for the widgets 108 * it provides. Because custom bindings set up in CSS files take 109 * precedence over the default bindings shipped with GTK+, overriding 110 * existing bindings as demonstrated in 111 * Installing a key binding 112 * works as expected. The same mechanism can not be used to "unbind" 113 * existing bindings, however. 114 * 115 * $(DDOC_COMMENT example) 116 * 117 * The above example will not have the desired effect of causing 118 * "<Control>Right" and "<Control>Left" key presses to 119 * be ignored by GTK+. Instead, it just causes any existing bindings 120 * from the bindings set "MoveCursor3" to be deleted, so when 121 * "<Control>Right" or "<Control>Left" are pressed, no 122 * binding for these keys is found in binding set "MoveCursor3". 123 * GTK+ will thus continue to search for matching key bindings, and will 124 * eventually lookup and find the default GTK+ bindings for entries which 125 * implement word movement. To keep GTK+ from activating its default 126 * bindings, the "unbind" keyword can be used like this: 127 * 128 * $(DDOC_COMMENT example) 129 * 130 * Now, GTK+ will find a match when looking up "<Control>Right" 131 * and "<Control>Left" key presses before it resorts to its default 132 * bindings, and the match instructs it to abort ("unbind") the search, 133 * so the key presses are not consumed by this widget. As usual, further 134 * processing of the key presses, e.g. by an entry's parent widget, is 135 * now possible. 136 */ 137 public class BindingSet 138 { 139 140 /** the main Gtk struct */ 141 protected GtkBindingSet* gtkBindingSet; 142 143 144 /** Get the main Gtk struct */ 145 public GtkBindingSet* getBindingSetStruct() 146 { 147 return gtkBindingSet; 148 } 149 150 151 /** the main Gtk struct as a void* */ 152 protected void* getStruct() 153 { 154 return cast(void*)gtkBindingSet; 155 } 156 157 /** 158 * Sets our main struct and passes it to the parent class 159 */ 160 public this (GtkBindingSet* gtkBindingSet) 161 { 162 this.gtkBindingSet = gtkBindingSet; 163 } 164 165 /** 166 */ 167 168 /** 169 * Override or install a new key binding for keyval with modifiers on 170 * binding_set. 171 * Params: 172 * keyval = key value 173 * modifiers = key modifier 174 * signalName = signal name to be bound 175 * bindingArgs = list of GtkBindingArg signal arguments. [transfer none][element-type GtkBindingArg] 176 */ 177 public void entryAddSignall(uint keyval, GdkModifierType modifiers, string signalName, ListSG bindingArgs) 178 { 179 // void gtk_binding_entry_add_signall (GtkBindingSet *binding_set, guint keyval, GdkModifierType modifiers, const gchar *signal_name, GSList *binding_args); 180 gtk_binding_entry_add_signall(gtkBindingSet, keyval, modifiers, Str.toStringz(signalName), (bindingArgs is null) ? null : bindingArgs.getListSGStruct()); 181 } 182 183 /** 184 * GTK+ maintains a global list of binding sets. Each binding set has 185 * a unique name which needs to be specified upon creation. 186 * Params: 187 * setName = unique name of this binding set 188 * Throws: ConstructionException GTK+ fails to create the object. 189 */ 190 public this (string setName) 191 { 192 // GtkBindingSet * gtk_binding_set_new (const gchar *set_name); 193 auto p = gtk_binding_set_new(Str.toStringz(setName)); 194 if(p is null) 195 { 196 throw new ConstructionException("null returned by gtk_binding_set_new(Str.toStringz(setName))"); 197 } 198 this(cast(GtkBindingSet*) p); 199 } 200 201 /** 202 * This function returns the binding set named after the type name of 203 * the passed in class structure. New binding sets are created on 204 * demand by this function. 205 * Params: 206 * objectClass = a valid GObject class 207 * Returns: the binding set corresponding to object_class. [transfer full] 208 */ 209 public static BindingSet byClass(void* objectClass) 210 { 211 // GtkBindingSet * gtk_binding_set_by_class (gpointer object_class); 212 auto p = gtk_binding_set_by_class(objectClass); 213 214 if(p is null) 215 { 216 return null; 217 } 218 219 return ObjectG.getDObject!(BindingSet)(cast(GtkBindingSet*) p); 220 } 221 222 /** 223 * Find a binding set by its globally unique name. 224 * The set_name can either be a name used for gtk_binding_set_new() 225 * or the type name of a class used in gtk_binding_set_by_class(). 226 * Params: 227 * setName = unique binding set name 228 * Returns: NULL or the specified binding set. [transfer none] 229 */ 230 public static BindingSet find(string setName) 231 { 232 // GtkBindingSet * gtk_binding_set_find (const gchar *set_name); 233 auto p = gtk_binding_set_find(Str.toStringz(setName)); 234 235 if(p is null) 236 { 237 return null; 238 } 239 240 return ObjectG.getDObject!(BindingSet)(cast(GtkBindingSet*) p); 241 } 242 243 /** 244 * Find a key binding matching keyval and modifiers and activate the 245 * binding on object. 246 * Params: 247 * object = object to activate when binding found 248 * keyval = key value of the binding 249 * modifiers = key modifier of the binding 250 * Returns: TRUE if a binding was found and activated 251 */ 252 public static int activate(ObjectG object, uint keyval, GdkModifierType modifiers) 253 { 254 // gboolean gtk_bindings_activate (GObject *object, guint keyval, GdkModifierType modifiers); 255 return gtk_bindings_activate((object is null) ? null : object.getObjectGStruct(), keyval, modifiers); 256 } 257 258 /** 259 * Looks up key bindings for object to find one matching 260 * event, and if one was found, activate it. 261 * Since 2.4 262 * Params: 263 * object = a GObject (generally must be a widget) 264 * event = a GdkEventKey 265 * Returns: TRUE if a matching key binding was found 266 */ 267 public static int activateEvent(ObjectG object, GdkEventKey* event) 268 { 269 // gboolean gtk_bindings_activate_event (GObject *object, GdkEventKey *event); 270 return gtk_bindings_activate_event((object is null) ? null : object.getObjectGStruct(), event); 271 } 272 273 /** 274 * Find a key binding matching keyval and modifiers within 275 * binding_set and activate the binding on object. 276 * Params: 277 * keyval = key value of the binding 278 * modifiers = key modifier of the binding 279 * object = object to activate when binding found 280 * Returns: TRUE if a binding was found and activated 281 */ 282 public int activate(uint keyval, GdkModifierType modifiers, ObjectG object) 283 { 284 // gboolean gtk_binding_set_activate (GtkBindingSet *binding_set, guint keyval, GdkModifierType modifiers, GObject *object); 285 return gtk_binding_set_activate(gtkBindingSet, keyval, modifiers, (object is null) ? null : object.getObjectGStruct()); 286 } 287 288 /** 289 * Parses a signal description from signal_desc and incorporates 290 * it into binding_set. 291 * Signal descriptions may either bind a key combination to 292 * Params: 293 * signalDesc = a signal description 294 * Returns: G_TOKEN_NONE if the signal was successfully parsed and added, the expected token otherwise Since 3.0 295 */ 296 public GTokenType entryAddSignalFromString(string signalDesc) 297 { 298 // GTokenType gtk_binding_entry_add_signal_from_string (GtkBindingSet *binding_set, const gchar *signal_desc); 299 return gtk_binding_entry_add_signal_from_string(gtkBindingSet, Str.toStringz(signalDesc)); 300 } 301 302 /** 303 * Install a binding on binding_set which causes key lookups 304 * to be aborted, to prevent bindings from lower priority sets 305 * to be activated. 306 * Since 2.12 307 * Params: 308 * keyval = key value of binding to skip 309 * modifiers = key modifier of binding to skip 310 */ 311 public void entrySkip(uint keyval, GdkModifierType modifiers) 312 { 313 // void gtk_binding_entry_skip (GtkBindingSet *binding_set, guint keyval, GdkModifierType modifiers); 314 gtk_binding_entry_skip(gtkBindingSet, keyval, modifiers); 315 } 316 317 /** 318 * Remove a binding previously installed via 319 * gtk_binding_entry_add_signal() on binding_set. 320 * Params: 321 * keyval = key value of binding to remove 322 * modifiers = key modifier of binding to remove 323 */ 324 public void entryRemove(uint keyval, GdkModifierType modifiers) 325 { 326 // void gtk_binding_entry_remove (GtkBindingSet *binding_set, guint keyval, GdkModifierType modifiers); 327 gtk_binding_entry_remove(gtkBindingSet, keyval, modifiers); 328 } 329 330 /** 331 * Warning 332 * gtk_binding_set_add_path is deprecated and should not be used in newly-written code. 3.0 333 * This function was used internally by the GtkRC parsing mechanism 334 * to assign match patterns to GtkBindingSet structures. 335 * In GTK+ 3, these match patterns are unused. 336 * Params: 337 * pathType = path type the pattern applies to 338 * pathPattern = the actual match pattern 339 * priority = binding priority 340 */ 341 public void addPath(GtkPathType pathType, string pathPattern, GtkPathPriorityType priority) 342 { 343 // void gtk_binding_set_add_path (GtkBindingSet *binding_set, GtkPathType path_type, const gchar *path_pattern, GtkPathPriorityType priority); 344 gtk_binding_set_add_path(gtkBindingSet, pathType, Str.toStringz(pathPattern), priority); 345 } 346 }