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 Library 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 | * Library General Public License for more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU Library 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-1999. 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 | #ifdef __cplusplus |
---|
40 | extern "C" { |
---|
41 | #endif /* __cplusplus */ |
---|
42 | |
---|
43 | |
---|
44 | /* Pattern matching |
---|
45 | */ |
---|
46 | typedef struct _GtkPatternSpec GtkPatternSpec; |
---|
47 | |
---|
48 | struct _GtkPatternSpec |
---|
49 | { |
---|
50 | GtkMatchType match_type; |
---|
51 | guint pattern_length; |
---|
52 | gchar *pattern; |
---|
53 | gchar *pattern_reversed; |
---|
54 | gpointer user_data; |
---|
55 | guint seq_id; |
---|
56 | }; |
---|
57 | |
---|
58 | void gtk_pattern_spec_init (GtkPatternSpec *pspec, |
---|
59 | const gchar *pattern); |
---|
60 | void gtk_pattern_spec_free_segs (GtkPatternSpec *pspec); |
---|
61 | gboolean gtk_pattern_match (GtkPatternSpec *pspec, |
---|
62 | guint string_length, |
---|
63 | const gchar *string, |
---|
64 | const gchar *string_reversed); |
---|
65 | gboolean gtk_pattern_match_string (GtkPatternSpec *pspec, |
---|
66 | const gchar *string); |
---|
67 | gboolean gtk_pattern_match_simple (const gchar *pattern, |
---|
68 | const gchar *string); |
---|
69 | |
---|
70 | |
---|
71 | /* Binding sets |
---|
72 | */ |
---|
73 | |
---|
74 | typedef struct _GtkBindingSet GtkBindingSet; |
---|
75 | typedef struct _GtkBindingEntry GtkBindingEntry; |
---|
76 | typedef struct _GtkBindingSignal GtkBindingSignal; |
---|
77 | typedef struct _GtkBindingArg GtkBindingArg; |
---|
78 | |
---|
79 | struct _GtkBindingSet |
---|
80 | { |
---|
81 | gchar *set_name; |
---|
82 | gint priority; |
---|
83 | GSList *widget_path_pspecs; |
---|
84 | GSList *widget_class_pspecs; |
---|
85 | GSList *class_branch_pspecs; |
---|
86 | GtkBindingEntry *entries; |
---|
87 | GtkBindingEntry *current; |
---|
88 | }; |
---|
89 | |
---|
90 | struct _GtkBindingEntry |
---|
91 | { |
---|
92 | /* key portion |
---|
93 | */ |
---|
94 | guint keyval; |
---|
95 | guint modifiers; |
---|
96 | |
---|
97 | GtkBindingSet *binding_set; |
---|
98 | guint destroyed : 1; |
---|
99 | guint in_emission : 1; |
---|
100 | GtkBindingEntry *set_next; |
---|
101 | GtkBindingEntry *hash_next; |
---|
102 | GtkBindingSignal *signals; |
---|
103 | }; |
---|
104 | |
---|
105 | struct _GtkBindingSignal |
---|
106 | { |
---|
107 | GtkBindingSignal *next; |
---|
108 | gchar *signal_name; |
---|
109 | guint n_args; |
---|
110 | GtkBindingArg *args; |
---|
111 | }; |
---|
112 | |
---|
113 | struct _GtkBindingArg |
---|
114 | { |
---|
115 | GtkType arg_type; |
---|
116 | union { |
---|
117 | glong long_data; |
---|
118 | gdouble double_data; |
---|
119 | gchar *string_data; |
---|
120 | } d; |
---|
121 | }; |
---|
122 | |
---|
123 | |
---|
124 | /* Application-level methods */ |
---|
125 | |
---|
126 | GtkBindingSet* gtk_binding_set_new (const gchar *set_name); |
---|
127 | GtkBindingSet* gtk_binding_set_by_class(gpointer object_class); |
---|
128 | GtkBindingSet* gtk_binding_set_find (const gchar *set_name); |
---|
129 | gboolean gtk_bindings_activate (GtkObject *object, |
---|
130 | guint keyval, |
---|
131 | guint modifiers); |
---|
132 | gboolean gtk_binding_set_activate (GtkBindingSet *binding_set, |
---|
133 | guint keyval, |
---|
134 | guint modifiers, |
---|
135 | GtkObject *object); |
---|
136 | #define gtk_binding_entry_add gtk_binding_entry_clear |
---|
137 | void gtk_binding_entry_clear (GtkBindingSet *binding_set, |
---|
138 | guint keyval, |
---|
139 | guint modifiers); |
---|
140 | void gtk_binding_entry_add_signal (GtkBindingSet *binding_set, |
---|
141 | guint keyval, |
---|
142 | guint modifiers, |
---|
143 | const gchar *signal_name, |
---|
144 | guint n_args, |
---|
145 | ...); |
---|
146 | void gtk_binding_set_add_path (GtkBindingSet *binding_set, |
---|
147 | GtkPathType path_type, |
---|
148 | const gchar *path_pattern, |
---|
149 | GtkPathPriorityType priority); |
---|
150 | |
---|
151 | |
---|
152 | /* Non-public methods */ |
---|
153 | |
---|
154 | void gtk_binding_entry_remove (GtkBindingSet *binding_set, |
---|
155 | guint keyval, |
---|
156 | guint modifiers); |
---|
157 | void gtk_binding_entry_add_signall (GtkBindingSet *binding_set, |
---|
158 | guint keyval, |
---|
159 | guint modifiers, |
---|
160 | const gchar *signal_name, |
---|
161 | GSList *binding_args); |
---|
162 | guint gtk_binding_parse_binding (GScanner *scanner); |
---|
163 | |
---|
164 | |
---|
165 | |
---|
166 | |
---|
167 | #ifdef __cplusplus |
---|
168 | } |
---|
169 | #endif /* __cplusplus */ |
---|
170 | |
---|
171 | |
---|
172 | #endif /* __GTK_BINDINGS_H__ */ |
---|