Updated Spanish translation
[anjuta-git-plugin.git] / libanjuta / anjuta-ui.h
blob5ae69fce4294daffbd63207925f74eaf69e18183
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/gtkaccelgroup.h>
36 #include <gtk/gtkuimanager.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 /* Convenience macros to register stock icons */
134 #define BEGIN_REGISTER_ICON(plugin) \
136 AnjutaUI *ui = anjuta_shell_get_ui ((plugin)->shell, NULL); \
137 GtkIconFactory *icon_factory = anjuta_ui_get_icon_factory (ui); \
138 GtkIconSet *icon_set; \
139 GtkIconSource * icon_source = gtk_icon_source_new ();
141 /* Register icon with size 16 and size 24, icon should be the
142 * filename (without path) striped of the size (16,24) and the *.png
143 * (e.g anjuta-icon-24.png => anjuta-icon)
146 #define REGISTER_ICON_FULL(icon, stock_id) \
147 icon_set = gtk_icon_set_new(); \
148 gtk_icon_source_set_filename (icon_source, PACKAGE_PIXMAPS_DIR"/"icon"-16.png"); \
149 gtk_icon_source_set_size (icon_source, 16); \
150 gtk_icon_set_add_source (icon_set, icon_source); \
151 gtk_icon_source_set_filename (icon_source, PACKAGE_PIXMAPS_DIR"/"icon"-24.png"); \
152 gtk_icon_source_set_size (icon_source, 24); \
153 gtk_icon_set_add_source (icon_set, icon_source); \
154 icon_set = gtk_icon_set_new(); \
155 gtk_icon_set_add_source (icon_set, icon_source); \
156 gtk_icon_factory_add (icon_factory, stock_id, icon_set);
158 /* Register icon for all sizes (will be scaled)
159 * icon should be the full filename without path (e.g anjuta-icon.png)
162 #define REGISTER_ICON(icon, stock_id) \
164 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"icon, NULL); \
165 if (pixbuf) \
167 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf); \
168 gtk_icon_factory_add (icon_factory, stock_id, icon_set); \
169 g_object_unref (pixbuf); \
173 #define END_REGISTER_ICON \
174 gtk_icon_source_free (icon_source); \
177 G_END_DECLS
179 #endif