]> Pileus Git - ~andy/gtk/blob - gtk/gtkbindings.h
f37a673a3179f363a59929425e17d173a0db56a4
[~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 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
31 #error "Only <gtk/gtk.h> can be included directly."
32 #endif
33
34 #ifndef __GTK_BINDINGS_H__
35 #define __GTK_BINDINGS_H__
36
37
38 #include <gdk/gdk.h>
39 #include <gtk/gtkobject.h>
40 #include <gtk/gtkenums.h>
41
42
43 G_BEGIN_DECLS
44
45
46 /* Binding sets
47  */
48
49 typedef struct _GtkBindingSet           GtkBindingSet;
50 typedef struct _GtkBindingEntry         GtkBindingEntry;
51 typedef struct _GtkBindingSignal        GtkBindingSignal;
52 typedef struct _GtkBindingArg           GtkBindingArg;
53
54 struct _GtkBindingSet
55 {
56   gchar                 *set_name;
57   gint                   priority;
58   GSList                *widget_path_pspecs;
59   GSList                *widget_class_pspecs;
60   GSList                *class_branch_pspecs;
61   GtkBindingEntry       *entries;
62   GtkBindingEntry       *current;
63   guint                  parsed : 1; /* From RC content */
64 };
65
66 struct _GtkBindingEntry
67 {
68   /* key portion
69    */
70   guint                  keyval;
71   GdkModifierType        modifiers;
72   
73   GtkBindingSet         *binding_set;
74   guint                 destroyed : 1;
75   guint                 in_emission : 1;
76   guint                 marks_unbound : 1;
77   GtkBindingEntry       *set_next;
78   GtkBindingEntry       *hash_next;
79   GtkBindingSignal      *signals;
80 };
81
82 struct _GtkBindingArg
83 {
84   GType          arg_type;
85   union {
86     glong        long_data;
87     gdouble      double_data;
88     gchar       *string_data;
89   } d;
90 };
91
92 struct _GtkBindingSignal
93 {
94   GtkBindingSignal      *next;
95   gchar                 *signal_name;
96   guint                  n_args;
97   GtkBindingArg         *args;
98 };
99
100 /* Application-level methods */
101
102 GtkBindingSet*  gtk_binding_set_new     (const gchar    *set_name);
103 GtkBindingSet*  gtk_binding_set_by_class(gpointer        object_class);
104 GtkBindingSet*  gtk_binding_set_find    (const gchar    *set_name);
105 gboolean gtk_bindings_activate          (GtkObject      *object,
106                                          guint           keyval,
107                                          GdkModifierType modifiers);
108 gboolean gtk_bindings_activate_event    (GtkObject      *object,
109                                          GdkEventKey    *event);
110 gboolean gtk_binding_set_activate       (GtkBindingSet  *binding_set,
111                                          guint           keyval,
112                                          GdkModifierType modifiers,
113                                          GtkObject      *object);
114
115 #ifndef GTK_DISABLE_DEPRECATED
116 #define  gtk_binding_entry_add          gtk_binding_entry_clear
117 void     gtk_binding_entry_clear        (GtkBindingSet  *binding_set,
118                                          guint           keyval,
119                                          GdkModifierType modifiers);
120 void     gtk_binding_entry_add_signall  (GtkBindingSet  *binding_set,
121                                          guint           keyval,
122                                          GdkModifierType modifiers,
123                                          const gchar    *signal_name,
124                                          GSList         *binding_args);
125 guint    gtk_binding_parse_binding      (GScanner       *scanner);
126 #endif /* GTK_DISABLE_DEPRECATED */
127
128 void     gtk_binding_entry_skip         (GtkBindingSet  *binding_set,
129                                          guint           keyval,
130                                          GdkModifierType modifiers);
131 void     gtk_binding_entry_add_signal   (GtkBindingSet  *binding_set,
132                                          guint           keyval,
133                                          GdkModifierType modifiers,
134                                          const gchar    *signal_name,
135                                          guint           n_args,
136                                          ...);
137 void     gtk_binding_entry_remove       (GtkBindingSet  *binding_set,
138                                          guint           keyval,
139                                          GdkModifierType modifiers);
140
141 void     gtk_binding_set_add_path       (GtkBindingSet  *binding_set,
142                                          GtkPathType     path_type,
143                                          const gchar    *path_pattern,
144                                          GtkPathPriorityType priority);
145
146
147 /* Non-public methods */
148
149 guint    _gtk_binding_parse_binding     (GScanner       *scanner);
150 void     _gtk_binding_reset_parsed      (void);
151 void     _gtk_binding_entry_add_signall (GtkBindingSet  *binding_set,
152                                          guint           keyval,
153                                          GdkModifierType modifiers,
154                                          const gchar    *signal_name,
155                                          GSList         *binding_args);
156
157 G_END_DECLS
158
159 #endif /* __GTK_BINDINGS_H__ */