SF.net SVN: geany:[4963] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun May 30 18:05:18 UTC 2010
Revision: 4963
http://geany.svn.sourceforge.net/geany/?rev=4963&view=rev
Author: eht16
Date: 2010-05-30 18:05:18 +0000 (Sun, 30 May 2010)
Log Message:
-----------
Add PLUGIN_SET_TRANSLATABLE_INFO macro to the plugin API so plugins' meta information can be translated already in the plugin manager dialog (patch by Colomban Wendling, thanks).
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/plugindata.h
trunk/src/plugins.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-05-30 17:48:08 UTC (rev 4962)
+++ trunk/ChangeLog 2010-05-30 18:05:18 UTC (rev 4963)
@@ -5,6 +5,10 @@
* tagmanager/c.c:
Fix parsing of C++ classes contain attributes with bitfields
(patch by Lex Trotman, thanks).
+ * src/plugindata.h, src/plugins.c:
+ Add PLUGIN_SET_TRANSLATABLE_INFO macro to the plugin API so
+ plugins' meta information can be translated already in the
+ plugin manager dialog (patch by Colomban Wendling, thanks).
2010-05-29 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h 2010-05-30 17:48:08 UTC (rev 4962)
+++ trunk/src/plugindata.h 2010-05-30 18:05:18 UTC (rev 4963)
@@ -50,7 +50,7 @@
enum {
/** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */
- GEANY_API_VERSION = 187,
+ GEANY_API_VERSION = 188,
/** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */
@@ -102,10 +102,11 @@
/** Sets the plugin name and some other basic information about a plugin.
- * This declares a function, so you can use the _() translation macro for arguments.
*
+ * @note If you want some of the arguments to be translated, see @ref PLUGIN_SET_TRANSLATABLE_INFO()
+ *
* Example:
- * @code PLUGIN_SET_INFO(_("Cool Feature"), _("Adds cool feature support."), "0.1", "Joe Author") @endcode */
+ * @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 */
@@ -118,6 +119,24 @@
info->author = (p_author); \
}
+/** Sets the plugin name and some other basic information about a plugin.
+ * This macro is like @ref PLUGIN_SET_INFO() but allows the passed information to be translated
+ * by setting up the translation mechanism with @ref main_locale_init().
+ * You therefore don't need to call it manually in plugin_init().
+ *
+ * Example:
+ * @code PLUGIN_SET_TRANSLATABLE_INFO(LOCALEDIR, GETTEXT_PACKAGE, _("Cool Feature"), _("Adds a cool feature."), "0.1", "John Doe") @endcode
+ *
+ * @since 0.19 */
+#define PLUGIN_SET_TRANSLATABLE_INFO(localedir, package, p_name, p_description, p_version, p_author) \
+ void plugin_set_info(PluginInfo* info) \
+ { \
+ main_locale_init(localedir, package); \
+ info->name = (p_name); \
+ info->description = (p_description); \
+ info->version = (p_version); \
+ info->author = (p_author); \
+ }
/** @deprecated - use plugin_set_key_group() instead.
* @see PLUGIN_KEY_GROUP() macro. */
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2010-05-30 17:48:08 UTC (rev 4962)
+++ trunk/src/plugins.c 2010-05-30 18:05:18 UTC (rev 4963)
@@ -547,22 +547,15 @@
PluginCallback *callbacks;
PluginInfo **p_info;
PluginFields **plugin_fields;
- GeanyData **p_geany_data;
- GeanyFunctions **p_geany_functions;
- /* set these symbols before plugin_init() is called */
+ /* set these symbols before plugin_init() is called
+ * we don't set geany_functions and geany_data since they are set directly by plugin_new() */
g_module_symbol(plugin->module, "geany_plugin", (void *) &p_geany_plugin);
if (p_geany_plugin)
*p_geany_plugin = &plugin->public;
g_module_symbol(plugin->module, "plugin_info", (void *) &p_info);
if (p_info)
*p_info = &plugin->info;
- g_module_symbol(plugin->module, "geany_data", (void *) &p_geany_data);
- if (p_geany_data)
- *p_geany_data = &geany_data;
- g_module_symbol(plugin->module, "geany_functions", (void *) &p_geany_functions);
- if (p_geany_functions)
- *p_geany_functions = &geany_functions;
g_module_symbol(plugin->module, "plugin_fields", (void *) &plugin_fields);
if (plugin_fields)
*plugin_fields = &plugin->fields;
@@ -618,6 +611,8 @@
{
Plugin *plugin;
GModule *module;
+ GeanyData **p_geany_data;
+ GeanyFunctions **p_geany_functions;
void (*plugin_set_info)(PluginInfo*);
g_return_val_if_fail(fname, NULL);
@@ -675,6 +670,14 @@
plugin = g_new0(Plugin, 1);
+ /* set basic fields here to allow plugins to call Geany functions in set_info() */
+ g_module_symbol(module, "geany_data", (void *) &p_geany_data);
+ if (p_geany_data)
+ *p_geany_data = &geany_data;
+ g_module_symbol(module, "geany_functions", (void *) &p_geany_functions);
+ if (p_geany_functions)
+ *p_geany_functions = &geany_functions;
+
/* read plugin name, etc. */
plugin_set_info(&plugin->info);
if (!NZV(plugin->info.name))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list