1 /** C API for libkeybinder */
2 module keybinder_c;
3 
4 alias GDestroyNotify = void*;
5 
6 alias KeybinderHandler = extern(C) void function(const char* keystring, void* data);
7 
8 extern(C):
9 
10 /**
11  * Initialize the keybinder library.
12  *
13  * This function must be called after initializing GTK, before calling any
14  * other function in the library. Can only be called once.
15  */
16 void keybinder_init();
17 
18 /**
19  * "Cooked" accelerators use symbols produced by using modifiers such
20  * as shift or altgr, for example if "!" is produced by "Shift+1".
21  *
22  * If cooked accelerators are enabled, use "<Ctrl>exclam" to bind
23  * "Ctrl+!" If disabled, use "<Ctrl><Shift>1" to bind
24  * "Ctrl+Shift+1". These two examples are not equal on all keymaps.
25  *
26  * The cooked accelerator keyvalue and modifiers are provided by the
27  * function gdk_keymap_translate_keyboard_state()
28  *
29  * Cooked accelerators are useful if you receive keystrokes from GTK to bind,
30  * but raw accelerators can be useful if you or the user inputs accelerators as
31  * text.
32  *
33  * Default: Enabled. Should be set before binding anything.
34  *
35  * Args:
36  *   use_cooked = if %FALSE disable cooked accelerators
37  */
38 void keybinder_set_use_cooked_accelerators(bool use_cooked);
39 
40 /**
41  * Grab a key combination globally and register a callback to be called each
42  * time the key combination is pressed.
43  *
44  * This function is excluded from introspected bindings and is replaced by
45  * keybinder_bind_full.
46  *
47  * Returns: %TRUE if the accelerator could be grabbed
48  *
49  * Args:
50  *   keystring = an accelerator description (gtk_accelerator_parse() format)
51  *   handler   = callback function
52  *   user_data = data to pass to @handler
53  */
54 bool keybinder_bind(const char* keystring, KeybinderHandler handler, void* user_data);
55 
56 /**
57  * Grab a key combination globally and register a callback to be called each
58  * time the key combination is pressed.
59  *
60  * Args:
61  *   keystring = an accelerator description (gtk_accelerator_parse() format)
62  *   handler   = (scope notified):        callback function
63  *   user_data = (closure) (allow-none):  data to pass to @handler
64  *   notify    = (allow-none):  called when @handler is unregistered
65  * Returns: %TRUE if the accelerator could be grabbed
66  */
67 bool keybinder_bind_full(
68         const char* keystring,
69         KeybinderHandler handler,
70         void* user_data,
71         GDestroyNotify notify);
72 
73 /**
74  * Unregister all previously bound callbacks for this keystring.
75  *
76  * Args:
77  *   keystring = an accelerator description (gtk_accelerator_parse() format)
78  */
79 void keybinder_unbind_all(const char* keystring);
80 
81 /**
82  * Returns: the current event timestamp in an unspecified format
83  */
84 uint keybinder_get_current_event_time();
85 
86