comparison console/libgnt/gntbindable.h @ 14900:065e7ac30338

[gaim-migrate @ 17672] Rearranging a bunch of stuff. Users shouldn't notice any change, apart from the added ability to bind keys for the window-manager. I will update the manual in a while. I need to know how to revert a commit in case things go terribly wrong. ... I am going to remind everyone that Dido is AWESOME! committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 05 Nov 2006 17:28:33 +0000
parents
children 233c4a2f7b77
comparison
equal deleted inserted replaced
14899:a8f92a837590 14900:065e7ac30338
1 #ifndef GNT_BINDABLE_H
2 #define GNT_BINDABLE_H
3
4 #include <stdio.h>
5 #include <glib.h>
6 #include <glib-object.h>
7 #include <ncurses.h>
8
9 #define GNT_TYPE_BINDABLE (gnt_bindable_get_gtype())
10 #define GNT_BINDABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_BINDABLE, GntBindable))
11 #define GNT_BINDABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_BINDABLE, GntBindableClass))
12 #define GNT_IS_BINDABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_BINDABLE))
13 #define GNT_IS_BINDABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_BINDABLE))
14 #define GNT_BINDABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_BINDABLE, GntBindableClass))
15
16 #define GNTDEBUG fprintf(stderr, "%s\n", __FUNCTION__)
17
18 typedef struct _GnBindable GntBindable;
19 typedef struct _GnBindableClass GntBindableClass;
20
21 struct _GnBindable
22 {
23 GObject inherit;
24 };
25
26 struct _GnBindableClass
27 {
28 GObjectClass parent;
29
30 GHashTable *remaps; /* Key remaps */
31 GHashTable *actions; /* name -> Action */
32 GHashTable *bindings; /* key -> ActionParam */
33
34 void (*gnt_reserved1)(void);
35 void (*gnt_reserved2)(void);
36 void (*gnt_reserved3)(void);
37 void (*gnt_reserved4)(void);
38 };
39
40 G_BEGIN_DECLS
41
42 GType gnt_bindable_get_gtype(void);
43
44 /******************/
45 /* Key Remaps */
46 /******************/
47 const char * gnt_bindable_remap_keys(GntBindable *bindable, const char *text);
48
49 /******************/
50 /* Bindable Actions */
51 /******************/
52 typedef gboolean (*GntBindableActionCallback) (GntBindable *bindable, GList *params);
53 typedef gboolean (*GntBindableActionCallbackNoParam)(GntBindable *bindable);
54
55 typedef struct _GnBindableAction GntBindableAction;
56 typedef struct _GnBindableActionParam GntBindableActionParam;
57
58 struct _GnBindableAction
59 {
60 char *name; /* The name of the action */
61 union {
62 gboolean (*action)(GntBindable *bindable, GList *params);
63 gboolean (*action_noparam)(GntBindable *bindable);
64 } u;
65 };
66
67 struct _GnBindableActionParam
68 {
69 GntBindableAction *action;
70 GList *list;
71 };
72
73
74 /*GntBindableAction *gnt_bindable_action_parse(const char *name);*/
75
76 void gnt_bindable_action_free(GntBindableAction *action);
77 void gnt_bindable_action_param_free(GntBindableActionParam *param);
78
79 void gnt_bindable_class_register_action(GntBindableClass *klass, const char *name,
80 GntBindableActionCallback callback, const char *trigger, ...);
81 void gnt_bindable_register_binding(GntBindableClass *klass, const char *name,
82 const char *trigger, ...);
83
84 gboolean gnt_bindable_perform_action_key(GntBindable *bindable, const char *keys);
85 gboolean gnt_bindable_perform_action_named(GntBindable *bindable, const char *name, ...);
86
87 G_END_DECLS
88
89 #endif /* GNT_BINDABLE_H */
90