]> Pileus Git - ~andy/gtk/blob - gtk/gtkbindings.h
a3109b2988b710f46c540ca74361fc6a8b819bfd
[~andy/gtk] / gtk / gtkbindings.h
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * GtkBindingSet: Keybinding manager for GtkObjects.
5  * Copyright (C) 1998 Tim Janik
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 /*
24  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
25  * file for a list of people on the GTK+ Team.  See the ChangeLog
26  * files for a list of changes.  These files are distributed with
27  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
28  */
29
30 #ifndef __GTK_BINDINGS_H__
31 #define __GTK_BINDINGS_H__
32
33
34 #include <gdk/gdk.h>
35 #include <gtk/gtkobject.h>
36 #include <gtk/gtkenums.h>
37
38
39 G_BEGIN_DECLS
40
41
42 /* Binding sets
43  */
44
45 typedef struct _GtkBindingSet           GtkBindingSet;
46 typedef struct _GtkBindingEntry         GtkBindingEntry;
47 typedef struct _GtkBindingSignal        GtkBindingSignal;
48 typedef struct _GtkBindingArg           GtkBindingArg;
49
50 struct _GtkBindingSet
51 {
52   gchar                 *set_name;
53   gint                   priority;
54   GSList                *widget_path_pspecs;
55   GSList                *widget_class_pspecs;
56   GSList                *class_branch_pspecs;
57   GtkBindingEntry       *entries;
58   GtkBindingEntry       *current;
59   guint                  parsed : 1; /* From RC content */
60 };
61
62 struct _GtkBindingEntry
63 {
64   /* key portion
65    */
66   guint                  keyval;
67   GdkModifierType        modifiers;
68   
69   GtkBindingSet         *binding_set;
70   guint                 destroyed : 1;
71   guint                 in_emission : 1;
72   guint                 marks_unbound : 1;
73   GtkBindingEntry       *set_next;
74   GtkBindingEntry       *hash_next;
75   GtkBindingSignal      *signals;
76 };
77
78 struct _GtkBindingArg
79 {
80   GType          arg_type;
81   union {
82     glong        long_data;
83     gdouble      double_data;
84     gchar       *string_data;
85   } d;
86 };
87
88 struct _GtkBindingSignal
89 {
90   GtkBindingSignal      *next;
91   gchar                 *signal_name;
92   guint                  n_args;
93   GtkBindingArg         *args;
94 };
95
96 /* Application-level methods */
97
98 GtkBindingSet*  gtk_binding_set_new     (const gchar    *set_name);
99 GtkBindingSet*  gtk_binding_set_by_class(gpointer        object_class);
100 GtkBindingSet*  gtk_binding_set_find    (const gchar    *set_name);
101 gboolean gtk_bindings_activate          (GtkObject      *object,
102                                          guint           keyval,
103                                          GdkModifierType modifiers);
104 gboolean gtk_bindings_activate_event    (GtkObject      *object,
105                                          GdkEventKey    *event);
106 gboolean gtk_binding_set_activate       (GtkBindingSet  *binding_set,
107                                          guint           keyval,
108                                          GdkModifierType modifiers,
109                                          GtkObject      *object);
110
111 #ifndef GTK_DISABLE_DEPRECATED
112 #define  gtk_binding_entry_add          gtk_binding_entry_clear
113 void     gtk_binding_entry_clear        (GtkBindingSet  *binding_set,
114                                          guint           keyval,
115                                          GdkModifierType modifiers);
116 void     gtk_binding_entry_add_signall  (GtkBindingSet  *binding_set,
117                                          guint           keyval,
118                                          GdkModifierType modifiers,
119                                          const gchar    *signal_name,
120                                          GSList         *binding_args);
121 guint    gtk_binding_parse_binding      (GScanner       *scanner);
122 #endif /* GTK_DISABLE_DEPRECATED */
123
124 void     gtk_binding_entry_skip         (GtkBindingSet  *binding_set,
125                                          guint           keyval,
126                                          GdkModifierType modifiers);
127 void     gtk_binding_entry_add_signal   (GtkBindingSet  *binding_set,
128                                          guint           keyval,
129                                          GdkModifierType modifiers,
130                                          const gchar    *signal_name,
131                                          guint           n_args,
132                                          ...);
133 void     gtk_binding_entry_remove       (GtkBindingSet  *binding_set,
134                                          guint           keyval,
135                                          GdkModifierType modifiers);
136
137 void     gtk_binding_set_add_path       (GtkBindingSet  *binding_set,
138                                          GtkPathType     path_type,
139                                          const gchar    *path_pattern,
140                                          GtkPathPriorityType priority);
141
142
143 /* Non-public methods */
144
145 guint    _gtk_binding_parse_binding     (GScanner       *scanner);
146 void     _gtk_binding_reset_parsed      (void);
147 void     _gtk_binding_entry_add_signall (GtkBindingSet  *binding_set,
148                                          guint           keyval,
149                                          GdkModifierType modifiers,
150                                          const gchar    *signal_name,
151                                          GSList         *binding_args);
152
153 /* Creates a signal with a fixed callback instead of a class offset;
154  * useful for key binding signals
155  */
156 guint _gtk_binding_signal_new (const gchar       *signal_name,
157                                GType              itype,
158                                GSignalFlags       signal_flags,
159                                GCallback          handler,
160                                GSignalAccumulator accumulator,
161                                gpointer           accu_data,
162                                GSignalCMarshaller c_marshaller,
163                                GType              return_type,
164                                guint              n_params,
165                                ...);
166
167 G_END_DECLS
168
169
170 #endif /* __GTK_BINDINGS_H__ */