1 | /* GTK - The GIMP Toolkit |
2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
3 | * |
4 | * GtkItemFactory: Flexible item factory with automatic rc handling |
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_DISABLE_DEPRECATED |
31 | |
32 | #ifndef __GTK_ITEM_FACTORY_H__ |
33 | #define __GTK_ITEM_FACTORY_H__ |
34 | |
35 | #include <gtk/gtk.h> |
36 | |
37 | |
38 | G_BEGIN_DECLS |
39 | |
40 | typedef void (*GtkPrintFunc) (gpointer func_data, |
41 | const gchar *str); |
42 | /* We use () here to mean unspecified arguments. This is deprecated |
43 | * as of C99, but we can't change it without breaking compatibility. |
44 | * (Note that if we are included from a C++ program () will mean |
45 | * (void) so an explicit cast will be needed.) |
46 | */ |
47 | typedef void (*GtkItemFactoryCallback) (); |
48 | typedef void (*GtkItemFactoryCallback1) (gpointer callback_data, |
49 | guint callback_action, |
50 | GtkWidget *widget); |
51 | |
52 | #define GTK_TYPE_ITEM_FACTORY (gtk_item_factory_get_type ()) |
53 | #define GTK_ITEM_FACTORY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ITEM_FACTORY, GtkItemFactory)) |
54 | #define GTK_ITEM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ITEM_FACTORY, GtkItemFactoryClass)) |
55 | #define GTK_IS_ITEM_FACTORY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ITEM_FACTORY)) |
56 | #define GTK_IS_ITEM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ITEM_FACTORY)) |
57 | #define GTK_ITEM_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ITEM_FACTORY, GtkItemFactoryClass)) |
58 | |
59 | |
60 | typedef struct _GtkItemFactory GtkItemFactory; |
61 | typedef struct _GtkItemFactoryClass GtkItemFactoryClass; |
62 | typedef struct _GtkItemFactoryEntry GtkItemFactoryEntry; |
63 | typedef struct _GtkItemFactoryItem GtkItemFactoryItem; |
64 | |
65 | struct _GtkItemFactory |
66 | { |
67 | GtkObject object; |
68 | |
69 | gchar *path; |
70 | GtkAccelGroup *accel_group; |
71 | GtkWidget *widget; |
72 | GSList *items; |
73 | |
74 | GtkTranslateFunc translate_func; |
75 | gpointer translate_data; |
76 | GDestroyNotify translate_notify; |
77 | }; |
78 | |
79 | struct _GtkItemFactoryClass |
80 | { |
81 | GtkObjectClass object_class; |
82 | |
83 | GHashTable *item_ht; |
84 | |
85 | /* Padding for future expansion */ |
86 | void (*_gtk_reserved1) (void); |
87 | void (*_gtk_reserved2) (void); |
88 | void (*_gtk_reserved3) (void); |
89 | void (*_gtk_reserved4) (void); |
90 | }; |
91 | |
92 | struct _GtkItemFactoryEntry |
93 | { |
94 | gchar *path; |
95 | gchar *accelerator; |
96 | |
97 | GtkItemFactoryCallback callback; |
98 | guint callback_action; |
99 | |
100 | /* possible values: |
101 | * NULL -> "<Item>" |
102 | * "" -> "<Item>" |
103 | * "<Title>" -> create a title item |
104 | * "<Item>" -> create a simple item |
105 | * "<ImageItem>" -> create an item holding an image |
106 | * "<StockItem>" -> create an item holding a stock image |
107 | * "<CheckItem>" -> create a check item |
108 | * "<ToggleItem>" -> create a toggle item |
109 | * "<RadioItem>" -> create a radio item |
110 | * <path> -> path of a radio item to link against |
111 | * "<Separator>" -> create a separator |
112 | * "<Tearoff>" -> create a tearoff separator |
113 | * "<Branch>" -> create an item to hold sub items |
114 | * "<LastBranch>" -> create a right justified item to hold sub items |
115 | */ |
116 | gchar *item_type; |
117 | |
118 | /* Extra data for some item types: |
119 | * ImageItem -> pointer to inlined pixbuf stream |
120 | * StockItem -> name of stock item |
121 | */ |
122 | gconstpointer ; |
123 | }; |
124 | |
125 | struct _GtkItemFactoryItem |
126 | { |
127 | gchar *path; |
128 | GSList *widgets; |
129 | }; |
130 | |
131 | |
132 | GType gtk_item_factory_get_type (void) G_GNUC_CONST; |
133 | |
134 | /* `container_type' must be of GTK_TYPE_MENU_BAR, GTK_TYPE_MENU, |
135 | * or GTK_TYPE_OPTION_MENU. |
136 | */ |
137 | GtkItemFactory* gtk_item_factory_new (GType container_type, |
138 | const gchar *path, |
139 | GtkAccelGroup *accel_group); |
140 | void gtk_item_factory_construct (GtkItemFactory *ifactory, |
141 | GType container_type, |
142 | const gchar *path, |
143 | GtkAccelGroup *accel_group); |
144 | |
145 | /* These functions operate on GtkItemFactoryClass basis. |
146 | */ |
147 | void gtk_item_factory_add_foreign (GtkWidget *accel_widget, |
148 | const gchar *full_path, |
149 | GtkAccelGroup *accel_group, |
150 | guint keyval, |
151 | GdkModifierType modifiers); |
152 | |
153 | GtkItemFactory* gtk_item_factory_from_widget (GtkWidget *widget); |
154 | const gchar * gtk_item_factory_path_from_widget (GtkWidget *widget); |
155 | |
156 | GtkWidget* gtk_item_factory_get_item (GtkItemFactory *ifactory, |
157 | const gchar *path); |
158 | GtkWidget* gtk_item_factory_get_widget (GtkItemFactory *ifactory, |
159 | const gchar *path); |
160 | GtkWidget* gtk_item_factory_get_widget_by_action (GtkItemFactory *ifactory, |
161 | guint action); |
162 | GtkWidget* gtk_item_factory_get_item_by_action (GtkItemFactory *ifactory, |
163 | guint action); |
164 | |
165 | void gtk_item_factory_create_item (GtkItemFactory *ifactory, |
166 | GtkItemFactoryEntry *entry, |
167 | gpointer callback_data, |
168 | guint callback_type); |
169 | void gtk_item_factory_create_items (GtkItemFactory *ifactory, |
170 | guint n_entries, |
171 | GtkItemFactoryEntry *entries, |
172 | gpointer callback_data); |
173 | void gtk_item_factory_delete_item (GtkItemFactory *ifactory, |
174 | const gchar *path); |
175 | void gtk_item_factory_delete_entry (GtkItemFactory *ifactory, |
176 | GtkItemFactoryEntry *entry); |
177 | void gtk_item_factory_delete_entries (GtkItemFactory *ifactory, |
178 | guint n_entries, |
179 | GtkItemFactoryEntry *entries); |
180 | void (GtkItemFactory *ifactory, |
181 | guint x, |
182 | guint y, |
183 | guint mouse_button, |
184 | guint32 time_); |
185 | void (GtkItemFactory *ifactory, |
186 | gpointer , |
187 | GDestroyNotify destroy, |
188 | guint x, |
189 | guint y, |
190 | guint mouse_button, |
191 | guint32 time_); |
192 | gpointer (GtkItemFactory *ifactory); |
193 | gpointer (GtkWidget *widget); |
194 | void gtk_item_factory_set_translate_func (GtkItemFactory *ifactory, |
195 | GtkTranslateFunc func, |
196 | gpointer data, |
197 | GDestroyNotify notify); |
198 | |
199 | /* Compatibility functions for deprecated GtkMenuFactory code |
200 | */ |
201 | |
202 | /* Used by gtk_item_factory_create_menu_entries () */ |
203 | typedef void (*) (GtkWidget *widget, |
204 | gpointer user_data); |
205 | typedef struct { |
206 | gchar *path; |
207 | gchar *accelerator; |
208 | GtkMenuCallback callback; |
209 | gpointer callback_data; |
210 | GtkWidget *widget; |
211 | } ; |
212 | |
213 | /* Used by gtk_item_factory_callback_marshal () */ |
214 | typedef void (*GtkItemFactoryCallback2) (GtkWidget *widget, |
215 | gpointer callback_data, |
216 | guint callback_action); |
217 | |
218 | /* Used by gtk_item_factory_create_items () */ |
219 | void gtk_item_factory_create_items_ac (GtkItemFactory *ifactory, |
220 | guint n_entries, |
221 | GtkItemFactoryEntry *entries, |
222 | gpointer callback_data, |
223 | guint callback_type); |
224 | |
225 | GtkItemFactory* gtk_item_factory_from_path (const gchar *path); |
226 | void (guint n_entries, |
227 | GtkMenuEntry *entries); |
228 | void gtk_item_factories_path_delete (const gchar *ifactory_path, |
229 | const gchar *path); |
230 | |
231 | G_END_DECLS |
232 | |
233 | #endif /* !GTK_DISABLE_DEPRECATED */ |
234 | |
235 | #endif /* __GTK_ITEM_FACTORY_H__ */ |
236 | |
237 | |