Revision: 2620
http://geany.svn.sourceforge.net/geany/?rev=2620&view=rev
Author: ntrel
Date: 2008-05-27 10:03:43 -0700 (Tue, 27 May 2008)
Log Message:
-----------
Use plugin_init() in comments.
Modified Paths:
--------------
trunk/plugins/demoplugin.c
trunk/plugins/vcdiff.c
Modified: trunk/plugins/demoplugin.c
===================================================================
--- trunk/plugins/demoplugin.c 2008-05-27 15:10:08 UTC (rev 2619)
+++ trunk/plugins/demoplugin.c 2008-05-27 17:03:43 UTC (rev 2620)
@@ -43,7 +43,7 @@
#include "pluginmacros.h" /* some useful macros to avoid typing geany_data so often */
-/* These items are set by Geany before init() is called. */
+/* These items are set by Geany before plugin_init() is called. */
PluginInfo *plugin_info;
PluginFields *plugin_fields;
GeanyData *geany_data;
@@ -102,7 +102,7 @@
/* Called by Geany to show the plugin's configure dialog. This function is always called after
- * init() was called.
+ * plugin_init() was called.
* You can omit this function if the plugin doesn't need to be configured.
* Note: parent is the parent window which can be used as the transient window for the created
* dialog. */
@@ -148,10 +148,10 @@
/* Called by Geany before unloading the plugin.
* Here any UI changes should be removed, memory freed and any other finalization done.
- * Be sure to leave Geany as it was before init(). */
+ * Be sure to leave Geany as it was before plugin_init(). */
void plugin_cleanup(void)
{
- /* remove the menu item added in init() */
+ /* remove the menu item added in plugin_init() */
gtk_widget_destroy(plugin_fields->menu_item);
/* release other allocated strings and objects */
g_free(welcome_text);
Modified: trunk/plugins/vcdiff.c
===================================================================
--- trunk/plugins/vcdiff.c 2008-05-27 15:10:08 UTC (rev 2619)
+++ trunk/plugins/vcdiff.c 2008-05-27 17:03:43 UTC (rev 2620)
@@ -556,6 +556,6 @@
/* Called by Geany before unloading the plugin. */
void plugin_cleanup(void)
{
- /* remove the menu item added in init() */
+ /* remove the menu item added in plugin_init() */
gtk_widget_destroy(plugin_fields->menu_item);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2619
http://geany.svn.sourceforge.net/geany/?rev=2619&view=rev
Author: ntrel
Date: 2008-05-27 08:10:08 -0700 (Tue, 27 May 2008)
Log Message:
-----------
Make plugin_free() act like a destructor only, let
pm_dialog_response() call a separate function to only free non-active
plugins.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/plugins.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-05-27 14:47:38 UTC (rev 2618)
+++ trunk/ChangeLog 2008-05-27 15:10:08 UTC (rev 2619)
@@ -2,6 +2,10 @@
* src/plugins.c:
Fail to load a plugin if it has no plugin_init() function.
+ * src/plugins.c:
+ Make plugin_free() act like a destructor only, let
+ pm_dialog_response() call a separate function to only free non-active
+ plugins.
2008-05-26 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2008-05-27 14:47:38 UTC (rev 2618)
+++ trunk/src/plugins.c 2008-05-27 15:10:08 UTC (rev 2619)
@@ -93,13 +93,6 @@
static void pm_show_dialog(GtkMenuItem *menuitem, gpointer user_data);
-enum
-{
- PLUGIN_FREE_NON_ACTIVE,
- PLUGIN_FREE_ALL
-};
-
-
static DocumentFuncs doc_funcs = {
&document_new_file,
&document_get_cur_idx,
@@ -651,15 +644,11 @@
static void
-plugin_free(Plugin *plugin, gpointer data)
+plugin_free(Plugin *plugin)
{
g_return_if_fail(plugin);
g_return_if_fail(plugin->module);
- /* don't do anything when closing the plugin manager and it is an active plugin */
- if (GPOINTER_TO_INT(data) == PLUGIN_FREE_NON_ACTIVE && is_active_plugin(plugin))
- return;
-
plugin_unload(plugin);
if (plugin->module != NULL && ! g_module_close(plugin->module))
@@ -844,7 +833,7 @@
}
if (active_plugin_list != NULL)
{
- g_list_foreach(active_plugin_list, (GFunc) plugin_free, GINT_TO_POINTER(PLUGIN_FREE_ALL));
+ g_list_foreach(active_plugin_list, (GFunc) plugin_free, NULL);
g_list_free(active_plugin_list);
}
g_strfreev(active_plugins_pref);
@@ -965,7 +954,7 @@
/* unload plugin module */
if (!state)
keybindings_write_to_file(); /* save shortcuts (only need this group, but it doesn't take long) */
- plugin_free(p, GINT_TO_POINTER(PLUGIN_FREE_ALL));
+ plugin_free(p);
/* reload plugin module and initialize it if item is checked */
p = plugin_new(file_name, state, TRUE);
@@ -1067,12 +1056,25 @@
}
+static void
+free_non_active_plugin(gpointer data, gpointer user_data)
+{
+ Plugin *plugin = data;
+
+ /* don't do anything when closing the plugin manager and it is an active plugin */
+ if (is_active_plugin(plugin))
+ return;
+
+ plugin_free(plugin);
+}
+
+
static void pm_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
{
if (plugin_list != NULL)
{
/* remove all non-active plugins from the list */
- g_list_foreach(plugin_list, (GFunc) plugin_free, GINT_TO_POINTER(PLUGIN_FREE_NON_ACTIVE));
+ g_list_foreach(plugin_list, free_non_active_plugin, NULL);
g_list_free(plugin_list);
plugin_list = NULL;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2618
http://geany.svn.sourceforge.net/geany/?rev=2618&view=rev
Author: ntrel
Date: 2008-05-27 07:47:38 -0700 (Tue, 27 May 2008)
Log Message:
-----------
Fail to load a plugin if it has no plugin_init() function.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/plugins.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-05-26 17:24:11 UTC (rev 2617)
+++ trunk/ChangeLog 2008-05-27 14:47:38 UTC (rev 2618)
@@ -1,3 +1,9 @@
+2008-05-27 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/plugins.c:
+ Fail to load a plugin if it has no plugin_init() function.
+
+
2008-05-26 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/plugins.c:
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2008-05-26 17:24:11 UTC (rev 2617)
+++ trunk/src/plugins.c 2008-05-27 14:47:38 UTC (rev 2618)
@@ -470,11 +470,8 @@
*plugin_fields = &plugin->fields;
/* start the plugin */
- g_module_symbol(plugin->module, "plugin_init", (void *) &plugin->init);
- if (plugin->init != NULL)
- plugin->init(&geany_data);
- else
- geany_debug("Plugin '%s' has no plugin_init() function!", plugin->info.name);
+ g_return_if_fail(plugin->init);
+ plugin->init(&geany_data);
/* store some function pointers for later use */
g_module_symbol(plugin->module, "configure", (void *) &plugin->configure);
@@ -511,7 +508,7 @@
}
-/* Load and init a plugin.
+/* Load and optionally init a plugin.
* init_plugin decides whether the plugin's plugin_init() function should be called or not. If it is
* called, the plugin will be started, if not the plugin will be read only (for the list of
* available plugins in the plugin manager).
@@ -590,6 +587,18 @@
g_free(plugin);
return NULL;
}
+
+ g_module_symbol(module, "plugin_init", (void *) &plugin->init);
+ if (plugin->init == NULL)
+ {
+ geany_debug("Plugin '%s' has no plugin_init() function - ignoring plugin!",
+ plugin->info.name);
+
+ if (! g_module_close(module))
+ g_warning("%s: %s", fname, g_module_error());
+ g_free(plugin);
+ return NULL;
+ }
geany_debug("Initializing plugin '%s'", plugin->info.name);
plugin->filename = g_strdup(fname);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2616
http://geany.svn.sourceforge.net/geany/?rev=2616&view=rev
Author: ntrel
Date: 2008-05-26 10:09:43 -0700 (Mon, 26 May 2008)
Log Message:
-----------
Add plugin_ prefix for plugin symbols version_check, init and
cleanup. Deprecate init and cleanup; update PLUGIN_VERSION_CHECK
macro.
Add a debug message and fail to load a plugin if it has no
plugin_version_check() function.
Check that plugin keybinding names have been set in plugin_init(),
otherwise print a debug message and ignore all of them.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/plugin-symbols.c
trunk/doc/plugins.dox
trunk/src/plugindata.h
trunk/src/plugins.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-05-26 14:22:02 UTC (rev 2615)
+++ trunk/ChangeLog 2008-05-26 17:09:43 UTC (rev 2616)
@@ -3,6 +3,15 @@
* src/plugins.c:
Move all symbol lookups except plugin_set_info() into plugin_init().
Add debug message for missing init() function in a plugin.
+ * src/plugindata.h, src/plugins.c, doc/plugin-symbols.c,
+ doc/plugins.dox:
+ Add plugin_ prefix for plugin symbols version_check, init and
+ cleanup. Deprecate init and cleanup; update PLUGIN_VERSION_CHECK
+ macro.
+ Add a debug message and fail to load a plugin if it has no
+ plugin_version_check() function.
+ Check that plugin keybinding names have been set in plugin_init(),
+ otherwise print a debug message and ignore all of them.
2008-05-23 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/doc/plugin-symbols.c
===================================================================
--- trunk/doc/plugin-symbols.c 2008-05-26 14:22:02 UTC (rev 2615)
+++ trunk/doc/plugin-symbols.c 2008-05-26 17:09:43 UTC (rev 2616)
@@ -35,7 +35,7 @@
*/
/** Use the PLUGIN_VERSION_CHECK() macro instead. Required by Geany. */
-gint version_check(gint);
+gint plugin_version_check(gint);
/** Use the PLUGIN_SET_INFO() macro to define it. Required by Geany.
* This function is called before the plugin is initialized, so Geany
@@ -65,11 +65,11 @@
PluginCallback plugin_callbacks[];
/** Most plugins should use the PLUGIN_KEY_GROUP() macro to define it. However,
- * its fields are not read until after init() is called for the plugin, so it
+ * its fields are not read until after plugin_init() is called for the plugin, so it
* is possible to setup a variable number of keybindings, e.g. based on the
* plugin's configuration file settings.
* - The @c name field must not be empty or match Geany's default group name.
- * - The @c label field is set by Geany after init() is called to the name of the
+ * - The @c label field is set by Geany after plugin_init() is called to the name of the
* plugin.
* @note This is a single element array for implementation reasons,
* but you can treat it like a pointer. */
@@ -83,9 +83,9 @@
/** Called after loading the plugin.
* @param data The same as #geany_data. */
-void init(GeanyData *data);
+void plugin_init(GeanyData *data);
/** Called before unloading the plugin. Required for normal plugins - it should undo
- * everything done in init() - e.g. destroy menu items, free memory. */
-void cleanup();
+ * everything done in plugin_init() - e.g. destroy menu items, free memory. */
+void plugin_cleanup();
Modified: trunk/doc/plugins.dox
===================================================================
--- trunk/doc/plugins.dox 2008-05-26 14:22:02 UTC (rev 2615)
+++ trunk/doc/plugins.dox 2008-05-26 17:09:43 UTC (rev 2616)
@@ -189,8 +189,8 @@
* the plugin uses with the used Geany sources. Furthermore, it also checks
* the binary compatiblity of the plugin with Geany.
*
- * A few functions are necessary to let Geany work with the plugin, at least init() must
- * exist in the plugin. cleanup() should also be used to free allocated memory or destroy
+ * A few functions are necessary to let Geany work with the plugin, at least plugin_init() must
+ * exist in the plugin. plugin_cleanup() should also be used to free allocated memory or destroy
* created widgets.
*
* @subsection buildenv Build environment
Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h 2008-05-26 14:22:02 UTC (rev 2615)
+++ trunk/src/plugindata.h 2008-05-26 17:09:43 UTC (rev 2616)
@@ -36,19 +36,19 @@
/* The API version should be incremented whenever any plugin data types below are
* modified or appended to. */
-static const gint api_version = 63;
+static const gint api_version = 64;
/* The ABI version should be incremented whenever existing fields in the plugin
* data types below have to be changed or reordered. It should stay the same if fields
* are only appended, as this doesn't affect existing fields. */
-static const gint abi_version = 33;
+static const gint abi_version = 34;
/** Check the plugin can be loaded by Geany.
* This performs runtime checks that try to ensure:
* - Geany ABI data types are compatible with this plugin.
* - Geany sources provide the required API for this plugin. */
#define PLUGIN_VERSION_CHECK(api_required) \
- gint version_check(gint abi_ver) \
+ gint plugin_version_check(gint abi_ver) \
{ \
if (abi_ver != abi_version) \
return -1; \
@@ -93,8 +93,8 @@
/** Declare and initialise a keybinding group.
* @code KeyBindingGroup plugin_key_group[1]; @endcode
- * You must then set the @c plugin_key_group::keys[] entries for the group in init().
- * The @c plugin_key_group::label field is set by Geany after @c init()
+ * You must then set the @c plugin_key_group::keys[] entries for the group in plugin_init().
+ * The @c plugin_key_group::label field is set by Geany after @c plugin_init()
* is called, to the name of the plugin.
* @param group_name A unique group name (without quotes) to be used in the
* configuration file, such as @c html_chars.
@@ -452,6 +452,9 @@
#define PLUGIN_INFO PLUGIN_SET_INFO
+#define init plugin_init
+#define cleanup plugin_cleanup
+
#endif /* GEANY_DISABLE_DEPRECATED */
#endif
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2008-05-26 14:22:02 UTC (rev 2615)
+++ trunk/src/plugins.c 2008-05-26 17:09:43 UTC (rev 2616)
@@ -352,13 +352,19 @@
plugin_check_version(GModule *module)
{
gint (*version_check)(gint) = NULL;
- gint result;
- g_module_symbol(module, "version_check", (void *) &version_check);
+ g_module_symbol(module, "plugin_version_check", (void *) &version_check);
- if (version_check)
+ if (! version_check)
{
- result = version_check(abi_version);
+ geany_debug("Plugin \"%s\" has no plugin_version_check() function - ignoring plugin!",
+ g_module_name(module));
+ return FALSE;
+ }
+ else
+ {
+ gint result = version_check(abi_version);
+
if (result < 0)
{
ui_set_statusbar(TRUE, _("The plugin \"%s\" is not binary compatible with this "
@@ -410,12 +416,27 @@
static void
add_kb_group(Plugin *plugin)
{
+ guint i;
+
g_return_if_fail(NZV(plugin->key_group->name));
g_return_if_fail(! g_str_equal(plugin->key_group->name, keybindings_keyfile_group_name));
+ for (i = 0; i < plugin->key_group->count; i++)
+ {
+ KeyBinding *kb = &plugin->key_group->keys[i];
+
+ if (!NZV(kb->name))
+ {
+ geany_debug("Plugin \"%s\" has not set a name for keybinding %d"
+ " - ignoring all keybindings!",
+ plugin->info.name, i);
+ plugin->key_group->count = 0;
+ break;
+ }
+ }
if (plugin->key_group->count == 0)
{
- plugin->key_group = NULL; /* Ignore the group */
+ plugin->key_group = NULL; /* Ignore the group (maybe the plugin has optional KB) */
return;
}
@@ -434,7 +455,7 @@
GeanyData **p_geany_data;
GeanyFunctions **p_geany_functions;
- /* set these symbols before init() is called */
+ /* set these symbols before plugin_init() is called */
g_module_symbol(plugin->module, "plugin_info", (void *) &p_info);
if (p_info)
*p_info = &plugin->info;
@@ -449,23 +470,23 @@
*plugin_fields = &plugin->fields;
/* start the plugin */
- g_module_symbol(plugin->module, "init", (void *) &plugin->init);
+ g_module_symbol(plugin->module, "plugin_init", (void *) &plugin->init);
if (plugin->init != NULL)
plugin->init(&geany_data);
else
- geany_debug("Plugin '%s' has no init() function!", plugin->info.name);
+ geany_debug("Plugin '%s' has no plugin_init() function!", plugin->info.name);
/* store some function pointers for later use */
g_module_symbol(plugin->module, "configure", (void *) &plugin->configure);
- g_module_symbol(plugin->module, "cleanup", (void *) &plugin->cleanup);
+ g_module_symbol(plugin->module, "plugin_cleanup", (void *) &plugin->cleanup);
if (plugin->init != NULL && plugin->cleanup == NULL)
{
if (app->debug_mode)
- g_warning("Plugin '%s' has no cleanup() function - there may be memory leaks!",
+ g_warning("Plugin '%s' has no plugin_cleanup() function - there may be memory leaks!",
plugin->info.name);
}
- /* now read any plugin-owned data that might have been set in init() */
+ /* now read any plugin-owned data that might have been set in plugin_init() */
if (plugin->fields.flags & PLUGIN_IS_DOCUMENT_SENSITIVE)
{
@@ -491,7 +512,7 @@
/* Load and init a plugin.
- * init_plugin decides whether the plugin's init() function should be called or not. If it is
+ * init_plugin decides whether the plugin's plugin_init() function should be called or not. If it is
* called, the plugin will be started, if not the plugin will be read only (for the list of
* available plugins in the plugin manager).
* When add_to_list is set, the plugin will be added to the plugin manager's plugin_list. */
@@ -548,7 +569,7 @@
g_module_symbol(module, "plugin_set_info", (void *) &plugin_set_info);
if (plugin_set_info == NULL)
{
- geany_debug("No plugin_set_info() defined for \"%s\"!", fname);
+ geany_debug("No plugin_set_info() defined for \"%s\" - ignoring plugin!", fname);
if (! g_module_close(module))
g_warning("%s: %s", fname, g_module_error());
@@ -561,7 +582,8 @@
plugin_set_info(&plugin->info);
if (!NZV(plugin->info.name))
{
- geany_debug("No plugin name set in plugin_set_info() for \"%s\"!", fname);
+ geany_debug("No plugin name set in plugin_set_info() for \"%s\" - ignoring plugin!",
+ fname);
if (! g_module_close(module))
g_warning("%s: %s", fname, g_module_error());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2612
http://geany.svn.sourceforge.net/geany/?rev=2612&view=rev
Author: ntrel
Date: 2008-05-23 10:08:58 -0700 (Fri, 23 May 2008)
Log Message:
-----------
Deprecate PLUGIN_INFO() in favour of PLUGIN_SET_INFO().
Remove plugin symbol info(), which is replaced by plugin_set_info()
and a new symbol plugin_info. This is so the PluginInfo struct is
zero'd first by Geany, so plugins are still ABI compatible if we
want to add any more fields in the future.
Fail to load a plugin if plugin_info->name is not set.
Remove now unused string.h include from plugindata.h.
Modified Paths:
--------------
trunk/ChangeLog
trunk/doc/plugin-symbols.c
trunk/doc/plugins.dox
trunk/plugins/autosave.c
trunk/plugins/classbuilder.c
trunk/plugins/demoplugin.c
trunk/plugins/export.c
trunk/plugins/filebrowser.c
trunk/plugins/htmlchars.c
trunk/plugins/vcdiff.c
trunk/src/plugindata.h
trunk/src/plugins.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/ChangeLog 2008-05-23 17:08:58 UTC (rev 2612)
@@ -7,6 +7,17 @@
by the plugin, not Geany.
* src/plugindata.h:
Increment plugin ABI, API versions for plugin_callbacks change.
+ * src/plugindata.h, src/plugins.c, doc/plugin-symbols.c,
+ doc/plugins.dox, plugins/export.c, plugins/vcdiff.c,
+ plugins/demoplugin.c, plugins/filebrowser.c, plugins/htmlchars.c,
+ plugins/autosave.c, plugins/classbuilder.c:
+ Deprecate PLUGIN_INFO() in favour of PLUGIN_SET_INFO().
+ Remove plugin symbol info(), which is replaced by plugin_set_info()
+ and a new symbol plugin_info. This is so the PluginInfo struct is
+ zero'd first by Geany, so plugins are still ABI compatible if we
+ want to add any more fields in the future.
+ Fail to load a plugin if plugin_info->name is not set.
+ Remove now unused string.h include from plugindata.h.
2008-05-22 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/doc/plugin-symbols.c
===================================================================
--- trunk/doc/plugin-symbols.c 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/doc/plugin-symbols.c 2008-05-23 17:08:58 UTC (rev 2612)
@@ -37,16 +37,25 @@
/** Use the PLUGIN_VERSION_CHECK() macro instead. Required by Geany. */
gint version_check(gint);
-/** Use the PLUGIN_INFO() macro to define it. Required by Geany. */
-PluginInfo* info();
+/** Use the PLUGIN_SET_INFO() macro to define it. Required by Geany.
+ * This function is called before the plugin is initialized, so Geany
+ * can read the plugin's name.
+ * @param info The data struct which should be initialized by this function. */
+void plugin_set_info(PluginInfo *info);
+/** Basic information about a plugin, which is set in plugin_set_info(). */
+const PluginInfo* plugin_info;
+
/** Geany owned data pointers.
* Example: @c assert(geany_data->app->configdir != NULL); */
-GeanyData* geany_data;
+const GeanyData* geany_data;
/** Geany owned function pointers, split into groups.
- * Example: @c geany_functions->p_document->new_file(NULL, NULL, NULL); */
-GeanyFunctions* geany_functions;
+ * Example: @c geany_functions->p_document->new_file(NULL, NULL, NULL);
+ *
+ * Note: Usually plugins would use the pluginmacros.h file and just call:
+ * @c p_document->new_file(NULL, NULL, NULL); */
+const GeanyFunctions* geany_functions;
/** Plugin owned fields, including flags. */
PluginFields* plugin_fields;
@@ -78,5 +87,5 @@
/** Called before unloading the plugin. Required for normal plugins - it should undo
* everything done in init() - e.g. destroy menu items, free memory. */
-void cleanup(); */
+void cleanup();
Modified: trunk/doc/plugins.dox
===================================================================
--- trunk/doc/plugins.dox 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/doc/plugins.dox 2008-05-23 17:08:58 UTC (rev 2612)
@@ -180,9 +180,9 @@
* Every plugin should include "geany.h" and "plugindata.h" which provide necessary
* preprocessor macros and other basic information.
* There are two important preprocessor macros which need to be used at the beginning:
- * PLUGIN_INFO() and PLUGIN_VERSION_CHECK().
+ * PLUGIN_SET_INFO() and PLUGIN_VERSION_CHECK().
*
- * PLUGIN_INFO() tells Geany about basic plugin information like name, description,
+ * PLUGIN_SET_INFO() tells Geany about basic plugin information like name, description,
* version and author of the plugin.
*
* PLUGIN_VERSION_CHECK() checks for compatibility of the API version which
Modified: trunk/plugins/autosave.c
===================================================================
--- trunk/plugins/autosave.c 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/plugins/autosave.c 2008-05-23 17:08:58 UTC (rev 2612)
@@ -39,7 +39,7 @@
PLUGIN_VERSION_CHECK(32)
-PLUGIN_INFO(_("Auto Save"), _("Save automatically all open files in a given time interval."),
+PLUGIN_SET_INFO(_("Auto Save"), _("Save automatically all open files in a given time interval."),
VERSION, _("The Geany developer team"))
Modified: trunk/plugins/classbuilder.c
===================================================================
--- trunk/plugins/classbuilder.c 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/plugins/classbuilder.c 2008-05-23 17:08:58 UTC (rev 2612)
@@ -41,7 +41,7 @@
PLUGIN_VERSION_CHECK(7)
-PLUGIN_INFO(_("Class Builder"), _("Creates source files for new class types."), VERSION,
+PLUGIN_SET_INFO(_("Class Builder"), _("Creates source files for new class types."), VERSION,
"Alexander Rodin")
Modified: trunk/plugins/demoplugin.c
===================================================================
--- trunk/plugins/demoplugin.c 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/plugins/demoplugin.c 2008-05-23 17:08:58 UTC (rev 2612)
@@ -44,6 +44,7 @@
/* These items are set by Geany before init() is called. */
+PluginInfo *plugin_info;
PluginFields *plugin_fields;
GeanyData *geany_data;
GeanyFunctions *geany_functions;
@@ -54,7 +55,7 @@
PLUGIN_VERSION_CHECK(7)
/* All plugins must set name, description, version and author. */
-PLUGIN_INFO(_("Demo"), _("Example plugin."), VERSION, _("The Geany developer team"))
+PLUGIN_SET_INFO(_("Demo"), _("Example plugin."), VERSION, _("The Geany developer team"))
/* text to be shown in the plugin dialog */
@@ -74,7 +75,7 @@
GTK_BUTTONS_OK,
"%s", welcome_text);
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- _("(From the %s plugin)"), info()->name);
+ _("(From the %s plugin)"), plugin_info->name);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
Modified: trunk/plugins/export.c
===================================================================
--- trunk/plugins/export.c 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/plugins/export.c 2008-05-23 17:08:58 UTC (rev 2612)
@@ -43,7 +43,7 @@
GeanyFunctions *geany_functions;
PLUGIN_VERSION_CHECK(20)
-PLUGIN_INFO(_("Export"), _("Exports the current file into different formats."), VERSION,
+PLUGIN_SET_INFO(_("Export"), _("Exports the current file into different formats."), VERSION,
_("The Geany developer team"))
#define ROTATE_RGB(color) \
Modified: trunk/plugins/filebrowser.c
===================================================================
--- trunk/plugins/filebrowser.c 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/plugins/filebrowser.c 2008-05-23 17:08:58 UTC (rev 2612)
@@ -25,6 +25,7 @@
/* Sidebar file browser plugin. */
#include "geany.h"
+#include <string.h>
#include <gdk/gdkkeysyms.h>
@@ -47,7 +48,7 @@
PLUGIN_VERSION_CHECK(26)
-PLUGIN_INFO(_("File Browser"), _("Adds a file browser tab to the sidebar."), VERSION,
+PLUGIN_SET_INFO(_("File Browser"), _("Adds a file browser tab to the sidebar."), VERSION,
_("The Geany developer team"))
Modified: trunk/plugins/htmlchars.c
===================================================================
--- trunk/plugins/htmlchars.c 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/plugins/htmlchars.c 2008-05-23 17:08:58 UTC (rev 2612)
@@ -40,7 +40,7 @@
PLUGIN_VERSION_CHECK(48)
-PLUGIN_INFO(_("HTML Characters"), _("Inserts HTML character entities like '&'."), VERSION,
+PLUGIN_SET_INFO(_("HTML Characters"), _("Inserts HTML character entities like '&'."), VERSION,
_("The Geany developer team"))
Modified: trunk/plugins/vcdiff.c
===================================================================
--- trunk/plugins/vcdiff.c 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/plugins/vcdiff.c 2008-05-23 17:08:58 UTC (rev 2612)
@@ -28,6 +28,8 @@
* e.g. ".svn". */
#include "geany.h"
+#include <string.h>
+
#include "support.h"
#include "plugindata.h"
#include "document.h"
@@ -45,7 +47,7 @@
PLUGIN_VERSION_CHECK(27)
-PLUGIN_INFO(_("Version Diff"), _("Creates a patch of a file against version control."), VERSION,
+PLUGIN_SET_INFO(_("Version Diff"), _("Creates a patch of a file against version control."), VERSION,
_("The Geany developer team"))
@@ -120,7 +122,7 @@
else
base = g_path_get_dirname(filename);
- while(strcmp(base, base_prev) != 0)
+ while (strcmp(base, base_prev) != 0)
{
gitdir = g_build_path("/", base, subdir, NULL);
ret = g_file_test(gitdir, G_FILE_TEST_IS_DIR);
Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/src/plugindata.h 2008-05-23 17:08:58 UTC (rev 2612)
@@ -28,6 +28,7 @@
* For detailed documentation of the plugin system please read the plugin
* API documentation.
**/
+/* Note: Remember to increment api_version (and abi_version if necessary) when making changes. */
#ifndef PLUGINDATA_H
@@ -35,12 +36,12 @@
/* The API version should be incremented whenever any plugin data types below are
* modified or appended to. */
-static const gint api_version = 62;
+static const gint api_version = 63;
/* The ABI version should be incremented whenever existing fields in the plugin
* data types below have to be changed or reordered. It should stay the same if fields
* are only appended, as this doesn't affect existing fields. */
-static const gint abi_version = 32;
+static const gint abi_version = 33;
/** Check the plugin can be loaded by Geany.
* This performs runtime checks that try to ensure:
@@ -58,7 +59,7 @@
/** Plugin info structure to hold basic information about a plugin.
- * Should only be set with PLUGIN_INFO. */
+ * Should usually be set with PLUGIN_SET_INFO(). */
typedef struct PluginInfo
{
/** The name of the plugin. */
@@ -69,25 +70,24 @@
gchar *version;
/** The author of the plugin. */
gchar *author;
- /** Reserved for later use. */
- gpointer reserved2;
}
PluginInfo;
-#include <string.h>
-
-/** Set the plugin name and some other basic information about a plugin. */
-#define PLUGIN_INFO(p_name, p_description, p_version, p_author) \
- PluginInfo *info(void) \
+/** Set the plugin name and some other basic information about a plugin.
+ * This declares a function, so you can use the _() translation macro for arguments.
+ *
+ * Example:
+ * @code PLUGIN_SET_INFO(_("Cool Feature"), _("Adds cool feature support."), "0.1", "Joe Author") @endcode */
+/* plugin_set_info() could be written manually for plugins if we want to add any
+ * extra PluginInfo features (such as an icon), so we don't need to break API
+ * compatibility. Alternatively just add a new macro, PLUGIN_SET_INFO_FULL(). -ntrel */
+#define PLUGIN_SET_INFO(p_name, p_description, p_version, p_author) \
+ void plugin_set_info(PluginInfo* info) \
{ \
- static PluginInfo p_info; \
- \
- memset(&p_info, 0, sizeof(PluginInfo)); \
- p_info.name = (p_name); \
- p_info.description = (p_description); \
- p_info.version = (p_version); \
- p_info.author = (p_author); \
- return &p_info; \
+ info->name = (p_name); \
+ info->description = (p_description); \
+ info->version = (p_version); \
+ info->author = (p_author); \
}
@@ -136,7 +136,6 @@
PluginFlags;
/** Fields set and owned by the plugin. */
-/* Note: Remember to increment api_version (and abi_version if necessary) when making changes. */
typedef struct PluginFields
{
/** Bitmask of PluginFlags. */
@@ -451,6 +450,8 @@
typedef PluginCallback GeanyCallback;
#define geany_callbacks plugin_callbacks
+#define PLUGIN_INFO PLUGIN_SET_INFO
+
#endif /* GEANY_DISABLE_DEPRECATED */
#endif
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2008-05-23 14:14:04 UTC (rev 2611)
+++ trunk/src/plugins.c 2008-05-23 17:08:58 UTC (rev 2612)
@@ -68,12 +68,12 @@
{
GModule *module;
gchar *filename; /* plugin filename (/path/libname.so) */
+ PluginInfo info; /* plugin name, description, etc */
PluginFields fields;
gulong *signal_ids; /* signal IDs to disconnect when unloading */
gsize signal_ids_len;
KeyBindingGroup *key_group;
- PluginInfo* (*info) (void); /* Returns plugin name, description */
void (*init) (GeanyData *data); /* Called when the plugin is enabled */
void (*configure) (GtkWidget *parent); /* plugin configure dialog, optionally */
void (*cleanup) (void); /* Called when the plugin is disabled or when Geany exits */
@@ -419,7 +419,7 @@
return;
}
- plugin->key_group->label = plugin->info()->name;
+ plugin->key_group->label = plugin->info.name;
g_ptr_array_add(keybinding_groups, plugin->key_group);
}
@@ -429,6 +429,7 @@
plugin_init(Plugin *plugin)
{
PluginCallback *callbacks;
+ PluginInfo **p_info;
if (plugin->init)
plugin->init(&geany_data);
@@ -439,6 +440,10 @@
gtk_widget_set_sensitive(plugin->fields.menu_item, enable);
}
+ g_module_symbol(plugin->module, "plugin_info", (void *) &p_info);
+ if (p_info)
+ *p_info = &plugin->info;
+
g_module_symbol(plugin->module, "plugin_callbacks", (void *) &callbacks);
if (callbacks)
add_callbacks(plugin, callbacks);
@@ -451,7 +456,7 @@
active_plugin_list = g_list_append(active_plugin_list, plugin);
geany_debug("Loaded: %s (%s)", plugin->filename,
- NVL(plugin->info()->name, "<Unknown>"));
+ NVL(plugin->info.name, "<Unknown>"));
}
@@ -465,7 +470,7 @@
{
Plugin *plugin;
GModule *module;
- PluginInfo* (*info)(void);
+ void (*plugin_set_info)(PluginInfo*);
PluginFields **plugin_fields;
GeanyData **p_geany_data;
GeanyFunctions **p_geany_functions;
@@ -488,7 +493,8 @@
* causing a segfault. Without that flag the module will safely fail to load.
* G_MODULE_BIND_LOCAL also helps find undefined symbols e.g. app when it would
* otherwise not be detected due to the shadowing of Geany's app variable.
- * Also without G_MODULE_BIND_LOCAL calling info() in a plugin will be shadowed. */
+ * Also without G_MODULE_BIND_LOCAL calling public functions e.g. the old info()
+ * function from a plugin will be shadowed. */
module = g_module_open(fname, G_MODULE_BIND_LOCAL);
if (! module)
{
@@ -512,19 +518,31 @@
return NULL;
}
- g_module_symbol(module, "info", (void *) &info);
- if (info == NULL)
+ g_module_symbol(module, "plugin_set_info", (void *) &plugin_set_info);
+ if (plugin_set_info == NULL)
{
- geany_debug("Unknown plugin info for \"%s\"!", fname);
+ geany_debug("No plugin_set_info() defined for \"%s\"!", fname);
if (! g_module_close(module))
g_warning("%s: %s", fname, g_module_error());
return NULL;
}
- geany_debug("Initializing plugin '%s'", info()->name);
plugin = g_new0(Plugin, 1);
- plugin->info = info;
+
+ /* read plugin name, etc. */
+ plugin_set_info(&plugin->info);
+ if (!NZV(plugin->info.name))
+ {
+ geany_debug("No plugin name set in plugin_set_info() for \"%s\"!", fname);
+
+ if (! g_module_close(module))
+ g_warning("%s: %s", fname, g_module_error());
+ g_free(plugin);
+ return NULL;
+ }
+ geany_debug("Initializing plugin '%s'", plugin->info.name);
+
plugin->filename = g_strdup(fname);
plugin->module = module;
@@ -545,7 +563,7 @@
{
if (app->debug_mode)
g_warning("Plugin '%s' has no cleanup() function - there may be memory leaks!",
- info()->name);
+ plugin->info.name);
}
if (init_plugin)
@@ -871,7 +889,7 @@
gchar *text;
PluginInfo *pi;
- pi = p->info();
+ pi = &p->info;
text = g_strdup_printf(
_("Plugin: %s %s\nDescription: %s\nAuthor(s): %s"),
pi->name, pi->version, pi->description, pi->author);
@@ -976,12 +994,14 @@
{
for (; list != NULL; list = list->next)
{
+ Plugin *p = list->data;
+
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
- PLUGIN_COLUMN_CHECK, is_active_plugin(list->data),
- PLUGIN_COLUMN_NAME, ((Plugin*)list->data)->info()->name,
- PLUGIN_COLUMN_FILE, ((Plugin*)list->data)->filename,
- PLUGIN_COLUMN_PLUGIN, list->data,
+ PLUGIN_COLUMN_CHECK, is_active_plugin(p),
+ PLUGIN_COLUMN_NAME, p->info.name,
+ PLUGIN_COLUMN_FILE, p->filename,
+ PLUGIN_COLUMN_PLUGIN, p,
-1);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 2611
http://geany.svn.sourceforge.net/geany/?rev=2611&view=rev
Author: ntrel
Date: 2008-05-23 07:14:04 -0700 (Fri, 23 May 2008)
Log Message:
-----------
Increment plugin ABI, API versions for plugin_callbacks change.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/plugindata.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-05-23 12:29:32 UTC (rev 2610)
+++ trunk/ChangeLog 2008-05-23 14:14:04 UTC (rev 2611)
@@ -5,6 +5,8 @@
Make GeanyCallback, geany_callbacks deprecated, and replace with
PluginCallback, plugin_callbacks. This is because the array is owned
by the plugin, not Geany.
+ * src/plugindata.h:
+ Increment plugin ABI, API versions for plugin_callbacks change.
2008-05-22 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h 2008-05-23 12:29:32 UTC (rev 2610)
+++ trunk/src/plugindata.h 2008-05-23 14:14:04 UTC (rev 2611)
@@ -35,12 +35,12 @@
/* The API version should be incremented whenever any plugin data types below are
* modified or appended to. */
-static const gint api_version = 61;
+static const gint api_version = 62;
/* The ABI version should be incremented whenever existing fields in the plugin
* data types below have to be changed or reordered. It should stay the same if fields
* are only appended, as this doesn't affect existing fields. */
-static const gint abi_version = 31;
+static const gint abi_version = 32;
/** Check the plugin can be loaded by Geany.
* This performs runtime checks that try to ensure:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.