gntbindable.h

Go to the documentation of this file.
00001 
00005 /*
00006  * GNT - The GLib Ncurses Toolkit
00007  *
00008  * GNT is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This library is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  */
00026 
00027 #ifndef GNT_BINDABLE_H
00028 #define GNT_BINDABLE_H
00029 
00030 #include <stdio.h>
00031 #include <glib.h>
00032 #include <glib-object.h>
00033 #include <ncurses.h>
00034 
00035 #define GNT_TYPE_BINDABLE               (gnt_bindable_get_gtype())
00036 #define GNT_BINDABLE(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_BINDABLE, GntBindable))
00037 #define GNT_BINDABLE_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_BINDABLE, GntBindableClass))
00038 #define GNT_IS_BINDABLE(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_BINDABLE))
00039 #define GNT_IS_BINDABLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_BINDABLE))
00040 #define GNT_BINDABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_BINDABLE, GntBindableClass))
00041 
00042 #define GNTDEBUG
00043 
00044 typedef struct _GntBindable         GntBindable;
00045 typedef struct _GntBindableClass        GntBindableClass;
00046 
00047 struct _GntBindable
00048 {
00049     GObject inherit;
00050 };
00051 
00052 struct _GntBindableClass
00053 {
00054     GObjectClass parent;
00055 
00056     GHashTable *remaps;   /* Key remaps */
00057     GHashTable *actions;  /* name -> Action */
00058     GHashTable *bindings; /* key -> ActionParam */
00059 
00060     GntBindable * help_window;
00061 
00062     void (*gnt_reserved2)(void);
00063     void (*gnt_reserved3)(void);
00064     void (*gnt_reserved4)(void);
00065 };
00066 
00067 G_BEGIN_DECLS
00068 
00074 GType gnt_bindable_get_gtype(void);
00075 
00076 /******************/
00077 /*   Key Remaps   */
00078 /******************/
00079 const char * gnt_bindable_remap_keys(GntBindable *bindable, const char *text);
00080 
00081 /******************/
00082 /* Bindable Actions */
00083 /******************/
00084 typedef gboolean (*GntBindableActionCallback) (GntBindable *bindable, GList *params);
00085 typedef gboolean (*GntBindableActionCallbackNoParam)(GntBindable *bindable);
00086 
00087 typedef struct _GntBindableAction GntBindableAction;
00088 typedef struct _GntBindableActionParam GntBindableActionParam;
00089 
00090 struct _GntBindableAction
00091 {
00092     char *name;        /* The name of the action */
00093     union {
00094         gboolean (*action)(GntBindable *bindable, GList *params);
00095         gboolean (*action_noparam)(GntBindable *bindable);
00096     } u;
00097 };
00098 
00099 struct _GntBindableActionParam
00100 {
00101     GntBindableAction *action;
00102     GList *list;
00103 };
00104 
00105 /*GntBindableAction *gnt_bindable_action_parse(const char *name);*/
00106 
00112 void gnt_bindable_action_free(GntBindableAction *action);
00113 
00119 void gnt_bindable_action_param_free(GntBindableActionParam *param);
00120 
00130 void gnt_bindable_class_register_action(GntBindableClass *klass, const char *name, GntBindableActionCallback callback, const char *trigger, ...);
00131 
00139 void gnt_bindable_register_binding(GntBindableClass *klass, const char *name, const char *trigger, ...);
00140 
00149 gboolean gnt_bindable_perform_action_key(GntBindable *bindable, const char *keys);
00150 
00159 gboolean gnt_bindable_check_key(GntBindable *bindable, const char *keys);
00160 
00169 gboolean gnt_bindable_perform_action_named(GntBindable *bindable, const char *name, ...);
00170 
00178 GntBindable * gnt_bindable_bindings_view(GntBindable *bind);
00179 
00189 gboolean gnt_bindable_build_help_window(GntBindable *bindable);
00190 
00191 G_END_DECLS
00192 
00193 #endif /* GNT_BINDABLE_H */
00194