gntbindable.h
Go to the documentation of this file.
1
5 /*
6 * GNT - The GLib Ncurses Toolkit
7 *
8 * GNT is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
11 *
12 * This library is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25 */
26
27 #ifndef GNT_BINDABLE_H
28 #define GNT_BINDABLE_H
29
30 #include <stdio.h>
31 #include <glib.h>
32 #include <glib-object.h>
33 #include <ncurses.h>
34
35 #define GNT_TYPE_BINDABLE (gnt_bindable_get_gtype())
36 #define GNT_BINDABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_BINDABLE, GntBindable))
37 #define GNT_BINDABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_BINDABLE, GntBindableClass))
38 #define GNT_IS_BINDABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_BINDABLE))
39 #define GNT_IS_BINDABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_BINDABLE))
40 #define GNT_BINDABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_BINDABLE, GntBindableClass))
41
42 #define GNTDEBUG
43
44 typedef struct _GntBindable GntBindable;
45 typedef struct _GntBindableClass GntBindableClass;
46
47 struct _GntBindable
48 {
49 GObject inherit;
50 };
51
52 struct _GntBindableClass
53 {
54 GObjectClass parent;
55
56 GHashTable *remaps; /* Key remaps */
57 GHashTable *actions; /* name -> Action */
58 GHashTable *bindings; /* key -> ActionParam */
59
60 GntBindable * help_window;
61
62 void (*gnt_reserved2)(void);
63 void (*gnt_reserved3)(void);
64 void (*gnt_reserved4)(void);
65 };
66
67 G_BEGIN_DECLS
68
74 GType gnt_bindable_get_gtype(void);
75
76 /******************/
77 /* Key Remaps */
78 /******************/
79 const char * gnt_bindable_remap_keys(GntBindable *bindable, const char *text);
80
81 /******************/
82 /* Bindable Actions */
83 /******************/
84 typedef gboolean (*GntBindableActionCallback) (GntBindable *bindable, GList *params);
85 typedef gboolean (*GntBindableActionCallbackNoParam)(GntBindable *bindable);
86
87 typedef struct _GntBindableAction GntBindableAction;
88 typedef struct _GntBindableActionParam GntBindableActionParam;
89
90 struct _GntBindableAction
91 {
92 char *name; /* The name of the action */
93 union {
94 gboolean (*action)(GntBindable *bindable, GList *params);
95 gboolean (*action_noparam)(GntBindable *bindable);
96 } u;
97 };
98
99 struct _GntBindableActionParam
100 {
101 GntBindableAction *action;
102 GList *list;
103 };
104
105 /*GntBindableAction *gnt_bindable_action_parse(const char *name);*/
106
112 void gnt_bindable_action_free(GntBindableAction *action);
113
119 void gnt_bindable_action_param_free(GntBindableActionParam *param);
120
130 void gnt_bindable_class_register_action(GntBindableClass *klass, const char *name, GntBindableActionCallback callback, const char *trigger, ...);
131
139 void gnt_bindable_register_binding(GntBindableClass *klass, const char *name, const char *trigger, ...);
140
149 gboolean gnt_bindable_perform_action_key(GntBindable *bindable, const char *keys);
150
159 gboolean gnt_bindable_check_key(GntBindable *bindable, const char *keys);
160
169 gboolean gnt_bindable_perform_action_named(GntBindable *bindable, const char *name, ...) G_GNUC_NULL_TERMINATED;
170
178 GntBindable * gnt_bindable_bindings_view(GntBindable *bind);
179
189 gboolean gnt_bindable_build_help_window(GntBindable *bindable);
190
191 G_END_DECLS
192
193 #endif /* GNT_BINDABLE_H */
194
_GntBindableAction
Definition: gntbindable.h:90
gnt_bindable_class_register_action
void gnt_bindable_class_register_action(GntBindableClass *klass, const char *name, GntBindableActionCallback callback, const char *trigger,...)
Register a bindable action for a class.
gnt_bindable_perform_action_named
gboolean gnt_bindable_perform_action_named(GntBindable *bindable, const char *name,...) G_GNUC_NULL_TERMINATED
Perform an action on a bindable object.
gnt_bindable_build_help_window
gboolean gnt_bindable_build_help_window(GntBindable *bindable)
Builds a window that list the key bindings for a GntBindable object.
gnt_bindable_get_gtype
G_BEGIN_DECLS GType gnt_bindable_get_gtype(void)
_GntBindable
Definition: gntbindable.h:47
_GntBindableActionParam
Definition: gntbindable.h:99
gnt_bindable_action_free
void gnt_bindable_action_free(GntBindableAction *action)
Free a bindable action.
_GntBindableClass
Definition: gntbindable.h:52
gnt_bindable_action_param_free
void gnt_bindable_action_param_free(GntBindableActionParam *param)
Free a GntBindableActionParam.
gnt_bindable_register_binding
void gnt_bindable_register_binding(GntBindableClass *klass, const char *name, const char *trigger,...)
Register a key-binding to an existing action.
gnt_bindable_bindings_view
GntBindable * gnt_bindable_bindings_view(GntBindable *bind)
Returns a GntTree populated with "key" -> "binding" for the widget.
gnt_bindable_perform_action_key
gboolean gnt_bindable_perform_action_key(GntBindable *bindable, const char *keys)
Perform an action from a keybinding.
gnt_bindable_check_key
gboolean gnt_bindable_check_key(GntBindable *bindable, const char *keys)
Discover if a key is bound.