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