1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * GtkItemFactory: Flexible item factory with automatic rc handling
5 * Copyright (C) 1998 Tim Janik
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.
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.
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.
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/.
30 #ifndef __GTK_ITEM_FACTORY_H__
31 #define __GTK_ITEM_FACTORY_H__
34 #include <gtk/gtkwidget.h>
38 typedef gchar * (*GtkTranslateFunc) (const gchar *path,
41 #if !defined (GTK_DISABLE_DEPRECATED)
43 typedef void (*GtkPrintFunc) (gpointer func_data,
45 /* We use () here to mean unspecified arguments. This is deprecated
46 * as of C99, but we can't change it without breaking compatibility.
47 * (Note that if we are included from a C++ program () will mean
48 * (void) so an explicit cast will be needed.)
50 typedef void (*GtkItemFactoryCallback) ();
51 typedef void (*GtkItemFactoryCallback1) (gpointer callback_data,
52 guint callback_action,
55 #define GTK_TYPE_ITEM_FACTORY (gtk_item_factory_get_type ())
56 #define GTK_ITEM_FACTORY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GTK_TYPE_ITEM_FACTORY, GtkItemFactory))
57 #define GTK_ITEM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_ITEM_FACTORY, GtkItemFactoryClass))
58 #define GTK_IS_ITEM_FACTORY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GTK_TYPE_ITEM_FACTORY))
59 #define GTK_IS_ITEM_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ITEM_FACTORY))
60 #define GTK_ITEM_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_ITEM_FACTORY, GtkItemFactoryClass))
63 typedef struct _GtkItemFactory GtkItemFactory;
64 typedef struct _GtkItemFactoryClass GtkItemFactoryClass;
65 typedef struct _GtkItemFactoryEntry GtkItemFactoryEntry;
66 typedef struct _GtkItemFactoryItem GtkItemFactoryItem;
68 struct _GtkItemFactory
73 GtkAccelGroup *accel_group;
77 GtkTranslateFunc translate_func;
78 gpointer translate_data;
79 GtkDestroyNotify translate_notify;
82 struct _GtkItemFactoryClass
84 GtkObjectClass object_class;
88 /* Padding for future expansion */
89 void (*_gtk_reserved1) (void);
90 void (*_gtk_reserved2) (void);
91 void (*_gtk_reserved3) (void);
92 void (*_gtk_reserved4) (void);
95 struct _GtkItemFactoryEntry
100 GtkItemFactoryCallback callback;
101 guint callback_action;
106 * "<Title>" -> create a title item
107 * "<Item>" -> create a simple item
108 * "<ImageItem>" -> create an item holding an image
109 * "<StockItem>" -> create an item holding a stock image
110 * "<CheckItem>" -> create a check item
111 * "<ToggleItem>" -> create a toggle item
112 * "<RadioItem>" -> create a radio item
113 * <path> -> path of a radio item to link against
114 * "<Separator>" -> create a separator
115 * "<Tearoff>" -> create a tearoff separator
116 * "<Branch>" -> create an item to hold sub items
117 * "<LastBranch>" -> create a right justified item to hold sub items
121 /* Extra data for some item types:
122 * ImageItem -> pointer to inlined pixbuf stream
123 * StockItem -> name of stock item
125 gconstpointer extra_data;
128 struct _GtkItemFactoryItem
135 GType gtk_item_factory_get_type (void) G_GNUC_CONST;
137 /* `container_type' must be of GTK_TYPE_MENU_BAR, GTK_TYPE_MENU,
138 * or GTK_TYPE_OPTION_MENU.
140 GtkItemFactory* gtk_item_factory_new (GType container_type,
142 GtkAccelGroup *accel_group);
143 void gtk_item_factory_construct (GtkItemFactory *ifactory,
144 GType container_type,
146 GtkAccelGroup *accel_group);
148 /* These functions operate on GtkItemFactoryClass basis.
150 void gtk_item_factory_add_foreign (GtkWidget *accel_widget,
151 const gchar *full_path,
152 GtkAccelGroup *accel_group,
154 GdkModifierType modifiers);
156 GtkItemFactory* gtk_item_factory_from_widget (GtkWidget *widget);
157 G_CONST_RETURN gchar* gtk_item_factory_path_from_widget (GtkWidget *widget);
159 GtkWidget* gtk_item_factory_get_item (GtkItemFactory *ifactory,
161 GtkWidget* gtk_item_factory_get_widget (GtkItemFactory *ifactory,
163 GtkWidget* gtk_item_factory_get_widget_by_action (GtkItemFactory *ifactory,
165 GtkWidget* gtk_item_factory_get_item_by_action (GtkItemFactory *ifactory,
168 void gtk_item_factory_create_item (GtkItemFactory *ifactory,
169 GtkItemFactoryEntry *entry,
170 gpointer callback_data,
171 guint callback_type);
172 void gtk_item_factory_create_items (GtkItemFactory *ifactory,
174 GtkItemFactoryEntry *entries,
175 gpointer callback_data);
176 void gtk_item_factory_delete_item (GtkItemFactory *ifactory,
178 void gtk_item_factory_delete_entry (GtkItemFactory *ifactory,
179 GtkItemFactoryEntry *entry);
180 void gtk_item_factory_delete_entries (GtkItemFactory *ifactory,
182 GtkItemFactoryEntry *entries);
183 void gtk_item_factory_popup (GtkItemFactory *ifactory,
188 void gtk_item_factory_popup_with_data(GtkItemFactory *ifactory,
190 GtkDestroyNotify destroy,
195 gpointer gtk_item_factory_popup_data (GtkItemFactory *ifactory);
196 gpointer gtk_item_factory_popup_data_from_widget (GtkWidget *widget);
197 void gtk_item_factory_set_translate_func (GtkItemFactory *ifactory,
198 GtkTranslateFunc func,
200 GtkDestroyNotify notify);
202 /* Compatibility functions for deprecated GtkMenuFactory code
205 /* Used by gtk_item_factory_create_menu_entries () */
206 typedef void (*GtkMenuCallback) (GtkWidget *widget,
211 GtkMenuCallback callback;
212 gpointer callback_data;
216 /* Used by gtk_item_factory_callback_marshal () */
217 typedef void (*GtkItemFactoryCallback2) (GtkWidget *widget,
218 gpointer callback_data,
219 guint callback_action);
221 /* Used by gtk_item_factory_create_items () */
222 void gtk_item_factory_create_items_ac (GtkItemFactory *ifactory,
224 GtkItemFactoryEntry *entries,
225 gpointer callback_data,
226 guint callback_type);
228 GtkItemFactory* gtk_item_factory_from_path (const gchar *path);
229 void gtk_item_factory_create_menu_entries (guint n_entries,
230 GtkMenuEntry *entries);
231 void gtk_item_factories_path_delete (const gchar *ifactory_path,
234 #endif /* !GTK_DISABLE_DEPRECATED */
239 #endif /* __GTK_ITEM_FACTORY_H__ */