Fix a Gtk warning when checking path input in the log viewer.
[anjuta-git-plugin.git] / libanjuta / anjuta-plugin.h
blob2d8e2805890d3df513a8ad0e616df362f608d4a6
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * Anjuta
4 * Copyright (C) 2000 Dave Camp, Naba Kumar <naba@gnome.org>
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,
19 * Boston, MA 02110-1301, USA.
22 #ifndef ANJUTA_PLUGIN_H
23 #define ANJUTA_PLUGIN_H
25 #include <glib.h>
26 #include <glib-object.h>
28 #include <string.h>
29 #include <libanjuta/anjuta-shell.h>
30 #include <libanjuta/anjuta-ui.h>
31 #include <libanjuta/anjuta-preferences.h>
32 #include <libanjuta/anjuta-utils.h>
34 G_BEGIN_DECLS
36 /* Add this alias in case some plugin outside Anjuta tree still uses it */
37 typedef GTypeModule AnjutaGluePlugin;
39 typedef struct _AnjutaPlugin AnjutaPlugin;
40 typedef struct _AnjutaPluginClass AnjutaPluginClass;
41 typedef struct _AnjutaPluginPrivate AnjutaPluginPrivate;
43 /**
44 * AnjutaPluginValueAdded:
45 * @plugin: The #AnjutaPlugin based plugin
46 * @name: name of value being added.
47 * @value: value of value being added.
48 * @user_data: User data set during anjuta_plugin_add_watch()
50 * The callback to pass to anjuta_plugin_add_watch(). When a @name value
51 * is added to shell by another plugin, this callback will be called.
53 typedef void (*AnjutaPluginValueAdded) (AnjutaPlugin *plugin,
54 const char *name,
55 const GValue *value,
56 gpointer user_data);
58 /**
59 * AnjutaPluginValueRemoved:
60 * @plugin: The #AnjutaPlugin based plugin
61 * @name: name of value being added.
62 * @user_data: User data set during anjuta_plugin_add_watch()
64 * The callback to pass to anjuta_plugin_add_watch(). When the @name value
65 * is removed from the shell (by the plugin exporting this value), this
66 * callback will be called.
68 typedef void (*AnjutaPluginValueRemoved) (AnjutaPlugin *plugin,
69 const char *name,
70 gpointer user_data);
73 #define ANJUTA_TYPE_PLUGIN (anjuta_plugin_get_type ())
74 #define ANJUTA_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_TYPE_PLUGIN, AnjutaPlugin))
75 #define ANJUTA_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ANJUTA_TYPE_PLUGIN, AnjutaPluginClass))
76 #define ANJUTA_IS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ANJUTA_TYPE_PLUGIN))
77 #define ANJUTA_IS_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ANJUTA_TYPE_PLUGIN))
78 #define ANJUTA_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), ANJUTA_TYPE_PLUGIN, AnjutaPluginClass))
80 struct _AnjutaPlugin {
81 GObject parent;
83 /* The shell in which the plugin has been added */
84 AnjutaShell *shell;
86 /*< private >*/
87 AnjutaPluginPrivate *priv;
90 struct _AnjutaPluginClass {
91 GObjectClass parent_class;
93 /* Signals */
94 void (*activated) (AnjutaPlugin *plugin);
95 void (*deactivated) (AnjutaPlugin *plugin);
97 /* Virtual functions */
98 gboolean (*activate) (AnjutaPlugin *plugin);
99 gboolean (*deactivate) (AnjutaPlugin *plugin);
102 GType anjuta_plugin_get_type (void);
104 gboolean anjuta_plugin_activate (AnjutaPlugin *plugin);
106 gboolean anjuta_plugin_deactivate (AnjutaPlugin *plugin);
108 gboolean anjuta_plugin_is_active (AnjutaPlugin *plugin);
110 guint anjuta_plugin_add_watch (AnjutaPlugin *plugin,
111 const gchar *name,
112 AnjutaPluginValueAdded added,
113 AnjutaPluginValueRemoved removed,
114 gpointer user_data);
116 void anjuta_plugin_remove_watch (AnjutaPlugin *plugin, guint id,
117 gboolean send_remove);
120 * ANJUTA_PLUGIN_BEGIN:
121 * @class_name: Name of the class. e.g. EditorPlugin
122 * @prefix: prefix of member function names. e.g. editor_plugin
124 * This is a convienient macro defined to make it easy to write plugin
125 * classes . This macro begins the class type definition. member function
126 * @prefix _class_init and @prefix _instance_init should be statically defined
127 * before using this macro.
129 * The class type definition is finished with ANJUTA_PLUGIN_END() macro. In
130 * between which any number of interface definitions could be added with
131 * ANJUTA_PLUGIN_ADD_INTERFACE() macro.
133 #define ANJUTA_PLUGIN_BEGIN(class_name, prefix) \
134 extern GType \
135 prefix##_get_type (GTypeModule *module) \
137 static GType type = 0; \
138 if (G_UNLIKELY (!type)) { \
139 static const GTypeInfo type_info = { \
140 sizeof (class_name##Class), \
141 NULL, \
142 NULL, \
143 (GClassInitFunc)prefix##_class_init, \
144 NULL, \
145 NULL, \
146 sizeof (class_name), \
147 0, \
148 (GInstanceInitFunc)prefix##_instance_init \
149 }; \
150 g_return_val_if_fail (module != NULL, 0); \
151 type = g_type_module_register_type (module, \
152 ANJUTA_TYPE_PLUGIN, \
153 #class_name, \
154 &type_info, 0);
156 * ANJUTA_PLUGIN_END:
158 * Ends the plugin class type definition started with ANJUTA_PLUGIN_BEGIN()
160 #define ANJUTA_PLUGIN_END \
162 return type; \
166 * ANJUTA_PLUGIN_ADD_INTERFACE:
167 * @interface_type: Interface type. e.g. IANJUTA_TYPE_EDITOR
168 * @prefix: prefix of member function names.
170 * This is a convienient macro defined to make it easy to add interfaces
171 * to a plugin type. @prefix _iface_init should be statically defined
172 * before using this macro. This macro should be called between
173 * ANJUTA_PLUGIN_BEGIN() and ANJUTA_PLUGIN_END() macros.
175 #define ANJUTA_PLUGIN_ADD_INTERFACE(prefix,interface_type) \
177 GInterfaceInfo iface_info = { \
178 (GInterfaceInitFunc)prefix##_iface_init, \
179 NULL, \
180 NULL \
181 }; \
182 g_type_module_add_interface (module, \
183 type, interface_type, \
184 &iface_info); \
188 * ANJUTA_PLUGIN_BOILERPLATE:
189 * @class_name: Name of the class. e.g EditorPlugin
190 * @prefix: prefix of member function names. e.g. editor_plugin
192 * This macro is similar to using ANJUTA_PLUGIN_BEGIN() and then immediately
193 * using ANJUTA_PLUGIN_END(). It is basically a plugin type definition macro
194 * that does not have any interface implementation.
196 #define ANJUTA_PLUGIN_BOILERPLATE(class_name, prefix) \
197 ANJUTA_PLUGIN_BEGIN(class_name, prefix); \
198 ANJUTA_PLUGIN_END
201 * ANJUTA_SIMPLE_PLUGIN:
202 * @class_name: Name of the class. e.g. EditorPlugin
203 * @prefix: prefix of member function names. e.g. editor_plugin
205 * Sets up necessary codes for the plugin factory to know the class type of
206 * of the plugin. This macro is generally used at the end of plugin class
207 * and member functions definitions.
209 #define ANJUTA_SIMPLE_PLUGIN(class_name, prefix) \
210 G_MODULE_EXPORT void anjuta_glue_register_components (GTypeModule *module); \
211 G_MODULE_EXPORT void \
212 anjuta_glue_register_components (GTypeModule *module) \
214 prefix##_get_type (module); \
217 G_END_DECLS
219 #endif