Fix a Gtk warning when checking path input in the log viewer.
[anjuta-git-plugin.git] / libanjuta / anjuta-ui.h
blob349559754036c1efa521abb50a0d693d0605977b
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>
37 #include <gio/gio.h>
39 G_BEGIN_DECLS
41 #define ANJUTA_TYPE_UI (anjuta_ui_get_type ())
42 #define ANJUTA_UI(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_TYPE_UI, AnjutaUI))
43 #define ANJUTA_UI_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ANJUTA_TYPE_UI, AnjutaUIClass))
44 #define ANJUTA_IS_UI(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ANJUTA_TYPE_UI))
45 #define ANJUTA_IS_UI_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ANJUTA_TYPE_UI))
47 typedef struct _AnjutaUI AnjutaUI;
48 typedef struct _AnjutaUIClass AnjutaUIClass;
49 typedef struct _AnjutaUIPrivate AnjutaUIPrivate;
51 struct _AnjutaUI {
52 GtkUIManager parent;
54 AnjutaUIPrivate *priv;
57 struct _AnjutaUIClass {
58 GtkUIManagerClass parent;
61 GType anjuta_ui_get_type (void);
63 /* Creates a new AnjutaUI object */
64 AnjutaUI* anjuta_ui_new (void);
66 /* Adds a group of Action entries with the give group name.
67 * Caller does not get a reference to the returned ActionGroup. Use it
68 * as reference ID to remove the action-group later (after which the object
69 * will no longer be valid).
71 GtkActionGroup* anjuta_ui_add_action_group_entries (AnjutaUI *ui,
72 const gchar *action_group_name,
73 const gchar *action_group_label,
74 GtkActionEntry *entries,
75 gint num_entries,
76 const gchar *translation_domain,
77 gboolean can_customize,
78 gpointer user_data);
80 GtkActionGroup* anjuta_ui_add_toggle_action_group_entries (AnjutaUI *ui,
81 const gchar *action_group_name,
82 const gchar *action_group_label,
83 GtkToggleActionEntry *entries,
84 gint num_entries,
85 const gchar *translation_domain,
86 gboolean can_customize,
87 gpointer user_data);
89 void anjuta_ui_add_action_group (AnjutaUI *ui,
90 const gchar *action_group_name,
91 const gchar *action_group_label,
92 GtkActionGroup *action_group,
93 gboolean can_customize);
95 /* Removes the group of Actions */
96 void anjuta_ui_remove_action_group (AnjutaUI *ui, GtkActionGroup *action_group);
98 /* Get the action object from the given group with the given name */
99 GtkAction * anjuta_ui_get_action (AnjutaUI *ui,
100 const gchar *action_group_name,
101 const gchar *action_name);
103 /* Activates (calls the action callback) the action given by the action
104 * path. Path is given by "ActionGroupName/ActionName".
106 void anjuta_ui_activate_action_by_path (AnjutaUI *ui,
107 const gchar *action_path);
109 /* Activates the action in the given Action group object with the given
110 * action name.
112 void anjuta_ui_activate_action_by_group (AnjutaUI *ui,
113 GtkActionGroup *action_group,
114 const gchar *action_name);
116 /* Merges the given UI description file (written in xml)
117 Returns an id representing it */
118 gint anjuta_ui_merge (AnjutaUI *ui, const gchar *ui_filename);
120 /* Unmerges the give merge id */
121 void anjuta_ui_unmerge (AnjutaUI *ui, gint id);
123 /* Gets the icon factory */
124 GtkIconFactory* anjuta_ui_get_icon_factory (AnjutaUI* ui);
126 /* Get accel group associated with UI */
127 GtkAccelGroup* anjuta_ui_get_accel_group (AnjutaUI *ui);
129 GtkWidget* anjuta_ui_get_accel_editor (AnjutaUI *ui);
131 /* Dump the whole tree in STDOUT. Useful for debugging */
132 void anjuta_ui_dump_tree (AnjutaUI *ui);
134 /* Loading and saving accels */
135 void anjuta_ui_load_accels (void);
137 void anjuta_ui_save_accels (void);
139 /* Convenience macros to register stock icons */
140 #define BEGIN_REGISTER_ICON(plugin) \
142 AnjutaUI *ui = anjuta_shell_get_ui ((plugin)->shell, NULL); \
143 GtkIconFactory *icon_factory = anjuta_ui_get_icon_factory (ui); \
144 GtkIconSet *icon_set; \
145 GtkIconSource * icon_source = gtk_icon_source_new ();
147 /* Register icon with size 16 and size 24, icon should be the
148 * filename (without path) striped of the size (16,24) and the *.png
149 * (e.g anjuta-icon-24.png => anjuta-icon)
152 #define REGISTER_ICON_FULL(icon, stock_id) \
153 icon_set = gtk_icon_set_new(); \
154 gtk_icon_source_set_filename (icon_source, PACKAGE_PIXMAPS_DIR"/"icon"-16.png"); \
155 gtk_icon_source_set_size (icon_source, 16); \
156 gtk_icon_set_add_source (icon_set, icon_source); \
157 gtk_icon_source_set_filename (icon_source, PACKAGE_PIXMAPS_DIR"/"icon"-24.png"); \
158 gtk_icon_source_set_size (icon_source, 24); \
159 gtk_icon_set_add_source (icon_set, icon_source); \
160 icon_set = gtk_icon_set_new(); \
161 gtk_icon_set_add_source (icon_set, icon_source); \
162 gtk_icon_factory_add (icon_factory, stock_id, icon_set);
164 /* Register icon for all sizes (will be scaled)
165 * icon should be the full filename without path (e.g anjuta-icon.png)
168 #define REGISTER_ICON(icon, stock_id) \
170 GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR"/"icon, NULL); \
171 if (pixbuf) \
173 icon_set = gtk_icon_set_new_from_pixbuf (pixbuf); \
174 gtk_icon_factory_add (icon_factory, stock_id, icon_set); \
175 g_object_unref (pixbuf); \
179 #define END_REGISTER_ICON \
180 gtk_icon_source_free (icon_source); \
183 G_END_DECLS
185 #endif