[14481] | 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 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_ITEM_FACTORY_H__ |
---|
| 31 | #define __GTK_ITEM_FACTORY_H__ |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | #include <gtk/gtkwidget.h> |
---|
| 35 | #include <gtk/gtkmenufactory.h> /* for GtkMenuEntry */ |
---|
| 36 | #include <gtk/gtkbindings.h> /* for GtkPatternSpec */ |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | #ifdef __cplusplus |
---|
| 40 | extern "C" { |
---|
| 41 | #endif /* __cplusplus */ |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | typedef void (*GtkPrintFunc) (gpointer func_data, |
---|
| 45 | gchar *str); |
---|
| 46 | typedef gchar * (*GtkTranslateFunc) (const gchar *path, |
---|
| 47 | gpointer func_data); |
---|
| 48 | typedef void (*GtkItemFactoryCallback) (); |
---|
| 49 | typedef void (*GtkItemFactoryCallback1) (gpointer callback_data, |
---|
| 50 | guint callback_action, |
---|
| 51 | GtkWidget *widget); |
---|
| 52 | |
---|
| 53 | #define GTK_TYPE_ITEM_FACTORY (gtk_item_factory_get_type ()) |
---|
| 54 | #define GTK_ITEM_FACTORY(object) (GTK_CHECK_CAST (object, GTK_TYPE_ITEM_FACTORY, GtkItemFactory)) |
---|
| 55 | #define GTK_ITEM_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_CAST (klass, GTK_TYPE_ITEM_FACTORY, GtkItemFactoryClass)) |
---|
| 56 | #define GTK_IS_ITEM_FACTORY(object) (GTK_CHECK_TYPE (object, GTK_TYPE_ITEM_FACTORY)) |
---|
| 57 | #define GTK_IS_ITEM_FACTORY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ITEM_FACTORY)) |
---|
| 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 | GtkDestroyNotify translate_notify; |
---|
| 77 | }; |
---|
| 78 | |
---|
| 79 | struct _GtkItemFactoryClass |
---|
| 80 | { |
---|
| 81 | GtkObjectClass object_class; |
---|
| 82 | |
---|
| 83 | gchar *cpair_comment_single; |
---|
| 84 | |
---|
| 85 | GHashTable *item_ht; |
---|
| 86 | |
---|
| 87 | gpointer dummy; |
---|
| 88 | }; |
---|
| 89 | |
---|
| 90 | struct _GtkItemFactoryEntry |
---|
| 91 | { |
---|
| 92 | gchar *path; |
---|
| 93 | gchar *accelerator; |
---|
| 94 | |
---|
| 95 | GtkItemFactoryCallback callback; |
---|
| 96 | guint callback_action; |
---|
| 97 | |
---|
| 98 | /* possible values: |
---|
| 99 | * NULL -> "<Item>" |
---|
| 100 | * "" -> "<Item>" |
---|
| 101 | * "<Title>" -> create a title item |
---|
| 102 | * "<Item>" -> create a simple item |
---|
| 103 | * "<CheckItem>" -> create a check item |
---|
| 104 | * "<ToggleItem>" -> create a toggle item |
---|
| 105 | * "<RadioItem>" -> create a radio item |
---|
| 106 | * <path> -> path of a radio item to link against |
---|
| 107 | * "<Separator>" -> create a separator |
---|
| 108 | * "<Branch>" -> create an item to hold sub items |
---|
| 109 | * "<LastBranch>" -> create a right justified item to hold sub items |
---|
| 110 | */ |
---|
| 111 | gchar *item_type; |
---|
| 112 | }; |
---|
| 113 | |
---|
| 114 | struct _GtkItemFactoryItem |
---|
| 115 | { |
---|
| 116 | gchar *path; |
---|
| 117 | guint accelerator_key; |
---|
| 118 | guint accelerator_mods; |
---|
| 119 | guint modified : 1; |
---|
| 120 | guint in_propagation : 1; |
---|
| 121 | gchar *dummy; |
---|
| 122 | |
---|
| 123 | GSList *widgets; |
---|
| 124 | }; |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | GtkType gtk_item_factory_get_type (void); |
---|
| 128 | |
---|
| 129 | /* `container_type' must be of GTK_TYPE_MENU_BAR, GTK_TYPE_MENU, |
---|
| 130 | * or GTK_TYPE_OPTION_MENU. |
---|
| 131 | */ |
---|
| 132 | GtkItemFactory* gtk_item_factory_new (GtkType container_type, |
---|
| 133 | const gchar *path, |
---|
| 134 | GtkAccelGroup *accel_group); |
---|
| 135 | void gtk_item_factory_construct (GtkItemFactory *ifactory, |
---|
| 136 | GtkType container_type, |
---|
| 137 | const gchar *path, |
---|
| 138 | GtkAccelGroup *accel_group); |
---|
| 139 | |
---|
| 140 | /* These functions operate on GtkItemFactoryClass basis. |
---|
| 141 | */ |
---|
| 142 | void gtk_item_factory_parse_rc (const gchar *file_name); |
---|
| 143 | void gtk_item_factory_parse_rc_string (const gchar *rc_string); |
---|
| 144 | void gtk_item_factory_parse_rc_scanner (GScanner *scanner); |
---|
| 145 | void gtk_item_factory_add_foreign (GtkWidget *accel_widget, |
---|
| 146 | const gchar *full_path, |
---|
| 147 | GtkAccelGroup *accel_group, |
---|
| 148 | guint keyval, |
---|
| 149 | GdkModifierType modifiers); |
---|
| 150 | |
---|
| 151 | GtkItemFactory* gtk_item_factory_from_widget (GtkWidget *widget); |
---|
| 152 | gchar* gtk_item_factory_path_from_widget (GtkWidget *widget); |
---|
| 153 | |
---|
| 154 | GtkWidget* gtk_item_factory_get_item (GtkItemFactory *ifactory, |
---|
| 155 | const gchar *path); |
---|
| 156 | GtkWidget* gtk_item_factory_get_widget (GtkItemFactory *ifactory, |
---|
| 157 | const gchar *path); |
---|
| 158 | GtkWidget* gtk_item_factory_get_widget_by_action (GtkItemFactory *ifactory, |
---|
| 159 | guint action); |
---|
| 160 | GtkWidget* gtk_item_factory_get_item_by_action (GtkItemFactory *ifactory, |
---|
| 161 | guint action); |
---|
| 162 | |
---|
| 163 | /* If `path_pspec' is passed as `NULL', this function will iterate over |
---|
| 164 | * all hash entries. otherwise only those entries will be dumped for which |
---|
| 165 | * the pattern matches, e.g. "<Image>*...". |
---|
| 166 | */ |
---|
| 167 | void gtk_item_factory_dump_items (GtkPatternSpec *path_pspec, |
---|
| 168 | gboolean modified_only, |
---|
| 169 | GtkPrintFunc print_func, |
---|
| 170 | gpointer func_data); |
---|
| 171 | void gtk_item_factory_dump_rc (const gchar *file_name, |
---|
| 172 | GtkPatternSpec *path_pspec, |
---|
| 173 | gboolean modified_only); |
---|
| 174 | void gtk_item_factory_print_func (gpointer FILE_pointer, |
---|
| 175 | gchar *string); |
---|
| 176 | void gtk_item_factory_create_item (GtkItemFactory *ifactory, |
---|
| 177 | GtkItemFactoryEntry *entry, |
---|
| 178 | gpointer callback_data, |
---|
| 179 | guint callback_type); |
---|
| 180 | void gtk_item_factory_create_items (GtkItemFactory *ifactory, |
---|
| 181 | guint n_entries, |
---|
| 182 | GtkItemFactoryEntry *entries, |
---|
| 183 | gpointer callback_data); |
---|
| 184 | void gtk_item_factory_delete_item (GtkItemFactory *ifactory, |
---|
| 185 | const gchar *path); |
---|
| 186 | void gtk_item_factory_delete_entry (GtkItemFactory *ifactory, |
---|
| 187 | GtkItemFactoryEntry *entry); |
---|
| 188 | void gtk_item_factory_delete_entries (GtkItemFactory *ifactory, |
---|
| 189 | guint n_entries, |
---|
| 190 | GtkItemFactoryEntry *entries); |
---|
| 191 | void gtk_item_factory_popup (GtkItemFactory *ifactory, |
---|
| 192 | guint x, |
---|
| 193 | guint y, |
---|
| 194 | guint mouse_button, |
---|
| 195 | guint32 time); |
---|
| 196 | void gtk_item_factory_popup_with_data(GtkItemFactory *ifactory, |
---|
| 197 | gpointer popup_data, |
---|
| 198 | GtkDestroyNotify destroy, |
---|
| 199 | guint x, |
---|
| 200 | guint y, |
---|
| 201 | guint mouse_button, |
---|
| 202 | guint32 time); |
---|
| 203 | gpointer gtk_item_factory_popup_data (GtkItemFactory *ifactory); |
---|
| 204 | gpointer gtk_item_factory_popup_data_from_widget (GtkWidget *widget); |
---|
| 205 | void gtk_item_factory_set_translate_func (GtkItemFactory *ifactory, |
---|
| 206 | GtkTranslateFunc func, |
---|
| 207 | gpointer data, |
---|
| 208 | GtkDestroyNotify notify); |
---|
| 209 | |
---|
| 210 | /* Compatibility functions for deprecated GtkMenuFactory code |
---|
| 211 | */ |
---|
| 212 | GtkItemFactory* gtk_item_factory_from_path (const gchar *path); |
---|
| 213 | void gtk_item_factory_create_menu_entries (guint n_entries, |
---|
| 214 | GtkMenuEntry *entries); |
---|
| 215 | void gtk_item_factories_path_delete (const gchar *ifactory_path, |
---|
| 216 | const gchar *path); |
---|
| 217 | typedef void (*GtkItemFactoryCallback2) (GtkWidget *widget, |
---|
| 218 | gpointer callback_data, |
---|
| 219 | guint callback_action); |
---|
| 220 | void gtk_item_factory_create_items_ac (GtkItemFactory *ifactory, |
---|
| 221 | guint n_entries, |
---|
| 222 | GtkItemFactoryEntry *entries, |
---|
| 223 | gpointer callback_data, |
---|
| 224 | guint callback_type); |
---|
| 225 | |
---|
| 226 | |
---|
| 227 | |
---|
| 228 | #ifdef __cplusplus |
---|
| 229 | } |
---|
| 230 | #endif /* __cplusplus */ |
---|
| 231 | |
---|
| 232 | |
---|
| 233 | #endif /* __GTK_ITEM_FACTORY_H__ */ |
---|