1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis 3 * 4 * gimpuimanager.h 5 * Copyright (C) 2004 Michael Natterer <mitch@gimp.org> 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program 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 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <https://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef __GIMP_UI_MANAGER_H__ 22 #define __GIMP_UI_MANAGER_H__ 23 24 25 typedef struct _GimpUIManagerUIEntry GimpUIManagerUIEntry; 26 27 struct _GimpUIManagerUIEntry 28 { 29 gchar *ui_path; 30 gchar *basename; 31 GimpUIManagerSetupFunc setup_func; 32 guint merge_id; 33 GtkWidget *widget; 34 }; 35 36 37 #define GIMP_TYPE_UI_MANAGER (gimp_ui_manager_get_type ()) 38 #define GIMP_UI_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_UI_MANAGER, GimpUIManager)) 39 #define GIMP_UI_MANAGER_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), GIMP_TYPE_UI_MANAGER, GimpUIManagerClass)) 40 #define GIMP_IS_UI_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_UI_MANAGER)) 41 #define GIMP_IS_UI_MANAGER_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), GIMP_TYPE_UI_MANAGER)) 42 #define GIMP_UI_MANAGER_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), GIMP_TYPE_UI_MANAGER, GimpUIManagerClass)) 43 44 45 typedef struct _GimpUIManagerClass GimpUIManagerClass; 46 47 /** 48 * Among other things, is responsible for updating menu bars. A more 49 * appropriate name would perhaps be GimpMenubarManager. 50 */ 51 struct _GimpUIManager 52 { 53 GtkUIManager parent_instance; 54 55 gchar *name; 56 Gimp *gimp; 57 GList *registered_uis; 58 }; 59 60 struct _GimpUIManagerClass 61 { 62 GtkUIManagerClass parent_class; 63 64 GHashTable *managers; 65 66 void (* update) (GimpUIManager *manager, 67 gpointer update_data); 68 void (* show_tooltip) (GimpUIManager *manager, 69 const gchar *tooltip); 70 void (* hide_tooltip) (GimpUIManager *manager); 71 }; 72 73 74 GType gimp_ui_manager_get_type (void) G_GNUC_CONST; 75 76 GimpUIManager * gimp_ui_manager_new (Gimp *gimp, 77 const gchar *name); 78 79 GList * gimp_ui_managers_from_name (const gchar *name); 80 81 void gimp_ui_manager_update (GimpUIManager *manager, 82 gpointer update_data); 83 84 void gimp_ui_manager_insert_action_group (GimpUIManager *manager, 85 GimpActionGroup *group, 86 gint pos); 87 GimpActionGroup * gimp_ui_manager_get_action_group (GimpUIManager *manager, 88 const gchar *name); 89 GList * gimp_ui_manager_get_action_groups (GimpUIManager *manager); 90 91 GtkAccelGroup * gimp_ui_manager_get_accel_group (GimpUIManager *manager); 92 93 GtkWidget * gimp_ui_manager_get_widget (GimpUIManager *manager, 94 const gchar *path); 95 96 gchar * gimp_ui_manager_get_ui (GimpUIManager *manager); 97 98 guint gimp_ui_manager_new_merge_id (GimpUIManager *manager); 99 void gimp_ui_manager_add_ui (GimpUIManager *manager, 100 guint merge_id, 101 const gchar *path, 102 const gchar *name, 103 const gchar *action, 104 GtkUIManagerItemType type, 105 gboolean top); 106 void gimp_ui_manager_remove_ui (GimpUIManager *manager, 107 guint merge_id); 108 109 void gimp_ui_manager_ensure_update (GimpUIManager *manager); 110 111 GimpAction * gimp_ui_manager_get_action (GimpUIManager *manager, 112 const gchar *path); 113 GimpAction * gimp_ui_manager_find_action (GimpUIManager *manager, 114 const gchar *group_name, 115 const gchar *action_name); 116 gboolean gimp_ui_manager_activate_action (GimpUIManager *manager, 117 const gchar *group_name, 118 const gchar *action_name); 119 gboolean gimp_ui_manager_toggle_action (GimpUIManager *manager, 120 const gchar *group_name, 121 const gchar *action_name, 122 gboolean active); 123 124 void gimp_ui_manager_ui_register (GimpUIManager *manager, 125 const gchar *ui_path, 126 const gchar *basename, 127 GimpUIManagerSetupFunc setup_func); 128 129 void gimp_ui_manager_ui_popup (GimpUIManager *manager, 130 const gchar *ui_path, 131 GtkWidget *parent, 132 GimpMenuPositionFunc position_func, 133 gpointer position_data, 134 GDestroyNotify popdown_func, 135 gpointer popdown_data); 136 137 138 #endif /* __GIMP_UI_MANAGER_H__ */ 139