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 
48 {
49  GObject inherit;
50 };
51 
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 
89 
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 
100 {
101  GntBindableAction *action;
102  GList *list;
103 };
104 
105 /*GntBindableAction *gnt_bindable_action_parse(const char *name);*/
106 
113 
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 
179 
189 gboolean gnt_bindable_build_help_window(GntBindable *bindable);
190 
191 G_END_DECLS
192 
193 #endif /* GNT_BINDABLE_H */
194 
void gnt_bindable_class_register_action(GntBindableClass *klass, const char *name, GntBindableActionCallback callback, const char *trigger,...)
Register a bindable action for a class.
gboolean gnt_bindable_perform_action_named(GntBindable *bindable, const char *name,...) G_GNUC_NULL_TERMINATED
Perform an action on a bindable object.
gboolean gnt_bindable_build_help_window(GntBindable *bindable)
Builds a window that list the key bindings for a GntBindable object.
G_BEGIN_DECLS GType gnt_bindable_get_gtype(void)
void gnt_bindable_action_free(GntBindableAction *action)
Free a bindable action.
void gnt_bindable_action_param_free(GntBindableActionParam *param)
Free a GntBindableActionParam.
void gnt_bindable_register_binding(GntBindableClass *klass, const char *name, const char *trigger,...)
Register a key-binding to an existing action.
GntBindable * gnt_bindable_bindings_view(GntBindable *bind)
Returns a GntTree populated with "key" -> "binding" for the widget.
gboolean gnt_bindable_perform_action_key(GntBindable *bindable, const char *keys)
Perform an action from a keybinding.
gboolean gnt_bindable_check_key(GntBindable *bindable, const char *keys)
Discover if a key is bound.