symbol-db: project's progress bar fixed.
[anjuta.git] / libanjuta / anjuta-ui.h
blobbee3e97572d6d89614983f01c76121cdf032493a
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta-ui.h
4 * Copyright (C) Naba Kumar <naba@gnome.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef _ANJUTA_UI_H_
21 #define _ANJUTA_UI_H_
23 /* Usage Notes:
24 * 1) Any object which added any action or action group is responsible
25 * for removing them when done (for example, a plugin object).
27 * 2) Any object which merged a UI is responsible for unmerging it
28 * when done with it (for example, a plugin object).
30 * 3) Avoid using EggMenuMerge object gotten by anjuta_ui_get_menu_merge(),
31 * because AnjutaUI keeps track of all actions/action-groups added to or
32 * removed from it and accordingly updates the required UI interfaces.
33 * Use the EggMenuMerge object only to do things not doable by AnjutaUI.
35 #include <gtk/gtk.h>
36 #include <gio/gio.h>
38 G_BEGIN_DECLS
40 #define ANJUTA_TYPE_UI (anjuta_ui_get_type ())
41 #define ANJUTA_UI(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_TYPE_UI, AnjutaUI))
42 #define ANJUTA_UI_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ANJUTA_TYPE_UI, AnjutaUIClass))
43 #define ANJUTA_IS_UI(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ANJUTA_TYPE_UI))
44 #define ANJUTA_IS_UI_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ANJUTA_TYPE_UI))
46 typedef struct _AnjutaUI AnjutaUI;
47 typedef struct _AnjutaUIClass AnjutaUIClass;
48 typedef struct _AnjutaUIPrivate AnjutaUIPrivate;
50 struct _AnjutaUI {
51 GtkUIManager parent;
53 AnjutaUIPrivate *priv;
56 struct _AnjutaUIClass {
57 GtkUIManagerClass parent;
60 GType anjuta_ui_get_type (void);
62 /* Creates a new AnjutaUI object */
63 AnjutaUI* anjuta_ui_new (void);
65 /* Adds a group of Action entries with the give group name.
66 * Caller does not get a reference to the returned ActionGroup. Use it
67 * as reference ID to remove the action-group later (after which the object
68 * will no longer be valid).
70 GtkActionGroup* anjuta_ui_add_action_group_entries (AnjutaUI *ui,
71 const gchar *action_group_name,
72 const gchar *action_group_label,
73 GtkActionEntry *entries,
74 gint num_entries,
75 const gchar *translation_domain,
76 gboolean can_customize,
77 gpointer user_data);
79 GtkActionGroup* anjuta_ui_add_toggle_action_group_entries (AnjutaUI *ui,
80 const gchar *action_group_name,
81 const gchar *action_group_label,
82 GtkToggleActionEntry *entries,
83 gint num_entries,
84 const gchar *translation_domain,
85 gboolean can_customize,
86 gpointer user_data);
88 void anjuta_ui_add_action_group (AnjutaUI *ui,
89 const gchar *action_group_name,
90 const gchar *action_group_label,
91 GtkActionGroup *action_group,
92 gboolean can_customize);
94 /* Removes the group of Actions */
95 void anjuta_ui_remove_action_group (AnjutaUI *ui, GtkActionGroup *action_group);
97 /* Get the action object from the given group with the given name */
98 GtkAction * anjuta_ui_get_action (AnjutaUI *ui,
99 const gchar *action_group_name,
100 const gchar *action_name);
102 /* Activates (calls the action callback) the action given by the action
103 * path. Path is given by "ActionGroupName/ActionName".
105 void anjuta_ui_activate_action_by_path (AnjutaUI *ui,
106 const gchar *action_path);
108 /* Activates the action in the given Action group object with the given
109 * action name.
111 void anjuta_ui_activate_action_by_group (AnjutaUI *ui,
112 GtkActionGroup *action_group,
113 const gchar *action_name);
115 /* Merges the given UI description file (written in xml)
116 Returns an id representing it */
117 gint anjuta_ui_merge (AnjutaUI *ui, const gchar *ui_filename);
119 /* Unmerges the give merge id */
120 void anjuta_ui_unmerge (AnjutaUI *ui, gint id);
122 /* Gets the icon factory */
123 GtkIconFactory* anjuta_ui_get_icon_factory (AnjutaUI* ui);
125 /* Get accel group associated with UI */
126 GtkAccelGroup* anjuta_ui_get_accel_group (AnjutaUI *ui);
128 GtkWidget* anjuta_ui_get_accel_editor (AnjutaUI *ui);
130 /* Dump the whole tree in STDOUT. Useful for debugging */
131 void anjuta_ui_dump_tree (AnjutaUI *ui);
133 /* Loading and saving accels */
134 void anjuta_ui_load_accels (const gchar *filename);
136 void anjuta_ui_save_accels (const gchar *filename);
138 void anjuta_ui_unload_accels (AnjutaUI *ui);
141 * BEGIN_REGISTER_ICON:
142 * @plugin: The anjuta plugin to register the icons for
144 * Convenience macros to register stock icons
146 #define BEGIN_REGISTER_ICON(plugin) \
148 AnjutaUI *ui = anjuta_shell_get_ui ((plugin)->shell, NULL); \
149 GtkIconFactory *icon_factory = anjuta_ui_get_icon_factory (ui); \
150 GtkIconSet *icon_set; \
151 GtkIconSource * icon_source = gtk_icon_source_new ();
154 * REGISTER_ICON_FULL:
155 * @icon: name of the icon (without size and extension)
156 * @stock_id: stock-id that should be assigned to the icon
158 * Register icon with size 16 and size 24, icon should be the
159 * filename (without path) striped of the size (16,24) and the *.png
160 * (e.g anjuta-icon-24.png => anjuta-icon)
163 #define REGISTER_ICON_FULL(icon, stock_id) \
164 icon_set = gtk_icon_set_new(); \
165 gtk_icon_source_set_filename (icon_source, PACKAGE_PIXMAPS_DIR"/"icon"-16.png"); \
166 gtk_icon_source_set_size (icon_source, 16); \
167 gtk_icon_set_add_source (icon_set, icon_source); \
168 gtk_icon_source_set_filename (icon_source, PACKAGE_PIXMAPS_DIR"/"icon"-24.png"); \
169 gtk_icon_source_set_size (icon_source, 24); \
170 gtk_icon_set_add_source (icon_set, icon_source); \
171 icon_set = gtk_icon_set_new(); \
172 gtk_icon_set_add_source (icon_set, icon_source); \
173 gtk_icon_factory_add (icon_factory, stock_id, icon_set);
176 * REGISTER_ICON:
177 * @icon: name of the icon (without size and extension)
178 * @stock_id: stock-id that should be assigned to the icon
180 * Register icon for all sizes (will be scaled)
181 * icon should be the full filename without path (e.g anjuta-icon.png)
184 #define REGISTER_ICON(icon, stock_id) \
186 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"icon, NULL); \
187 if (pixbuf) \
189 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf); \
190 gtk_icon_factory_add (icon_factory, stock_id, icon_set); \
191 g_object_unref (pixbuf); \
196 /**
197 * END_REGISTER_ICON:
199 * Ends a BEGIN_REGISTER_ICON sequence
201 #define END_REGISTER_ICON \
202 gtk_icon_source_free (icon_source); \
205 G_END_DECLS
207 #endif