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