Revision: 3559 http://geany.svn.sourceforge.net/geany/?rev=3559&view=rev Author: eht16 Date: 2009-02-06 19:05:12 +0000 (Fri, 06 Feb 2009)
Log Message: ----------- Add plugin_module_make_resident() to the plugin API which allows plugins to make the module resident. This seems necessary when using GTypes, e.g. by using the GObject API.
Modified Paths: -------------- trunk/ChangeLog trunk/plugins/geanyfunctions.h trunk/src/plugindata.h trunk/src/plugins.c
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2009-02-06 15:52:04 UTC (rev 3558) +++ trunk/ChangeLog 2009-02-06 19:05:12 UTC (rev 3559) @@ -2,6 +2,10 @@
* src/main.c: Don't check for old configuration directory location on Windows. + * plugins/geanyfunctions.h, src/plugindata.h, src/plugins.c: + Add plugin_module_make_resident() to the plugin API which allows + plugins to make the module resident. This seems necessary when + using GTypes, e.g. by using the GObject API.
2009-02-05 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/plugins/geanyfunctions.h =================================================================== --- trunk/plugins/geanyfunctions.h 2009-02-06 15:52:04 UTC (rev 3558) +++ trunk/plugins/geanyfunctions.h 2009-02-06 19:05:12 UTC (rev 3559) @@ -10,6 +10,8 @@
#define plugin_add_toolbar_item \ geany_functions->p_plugin->add_toolbar_item +#define plugin_module_make_resident \ + geany_functions->p_plugin->module_make_resident #define document_new_file \ geany_functions->p_document->new_file #define document_get_current \
Modified: trunk/src/plugindata.h =================================================================== --- trunk/src/plugindata.h 2009-02-06 15:52:04 UTC (rev 3558) +++ trunk/src/plugindata.h 2009-02-06 19:05:12 UTC (rev 3559) @@ -45,7 +45,7 @@ enum { /** The Application Programming Interface (API) version, incremented * whenever any plugin data types are modified or appended to. */ - GEANY_API_VERSION = 131, + GEANY_API_VERSION = 132,
/** The Application Binary Interface (ABI) version, incremented whenever * existing fields in the plugin data types have to be changed or reordered. */ @@ -283,7 +283,7 @@ void (*end_undo_action) (struct _ScintillaObject* sci); void (*set_text) (struct _ScintillaObject *sci, const gchar *text); void (*insert_text) (struct _ScintillaObject *sci, gint pos, const gchar *text); - void (*get_text) (struct _ScintillaObject *sci, gint len, gchar* text); + void (*get_text) (struct _ScintillaObject *sci, gint len, gchar *text); gint (*get_length) (struct _ScintillaObject *sci); gint (*get_current_position) (struct _ScintillaObject *sci); void (*set_current_position) (struct _ScintillaObject* sci, gint position, @@ -291,8 +291,8 @@ gint (*get_col_from_position) (struct _ScintillaObject* sci, gint position); gint (*get_line_from_position) (struct _ScintillaObject* sci, gint position); gint (*get_position_from_line) (struct _ScintillaObject* sci, gint line); - void (*replace_sel) (struct _ScintillaObject* sci, const gchar* text); - void (*get_selected_text) (struct _ScintillaObject* sci, gchar* text); + void (*replace_sel) (struct _ScintillaObject* sci, const gchar *text); + void (*get_selected_text) (struct _ScintillaObject* sci, gchar *text); gint (*get_selected_text_length) (struct _ScintillaObject* sci); gint (*get_selection_start) (struct _ScintillaObject* sci); gint (*get_selection_end) (struct _ScintillaObject* sci); @@ -300,7 +300,7 @@ void (*set_selection_mode) (struct _ScintillaObject* sci, gint mode); void (*set_selection_start) (struct _ScintillaObject* sci, gint position); void (*set_selection_end) (struct _ScintillaObject* sci, gint position); - void (*get_text_range) (struct _ScintillaObject* sci, gint start, gint end, gchar*text); + void (*get_text_range) (struct _ScintillaObject* sci, gint start, gint end, gchar *text); gchar* (*get_line) (struct _ScintillaObject* sci, gint line_num); gint (*get_line_length) (struct _ScintillaObject* sci, gint line); gint (*get_line_count) (struct _ScintillaObject* sci); @@ -529,6 +529,7 @@ typedef struct PluginFuncs { void (*add_toolbar_item)(GeanyPlugin *plugin, GtkToolItem *item); + void (*module_make_resident) (GeanyPlugin *plugin); } PluginFuncs;
Modified: trunk/src/plugins.c =================================================================== --- trunk/src/plugins.c 2009-02-06 15:52:04 UTC (rev 3558) +++ trunk/src/plugins.c 2009-02-06 19:05:12 UTC (rev 3559) @@ -72,6 +72,7 @@ typedef struct GeanyPluginPrivate { GeanyAutoSeparator toolbar_separator; + gboolean resident; } GeanyPluginPrivate;
@@ -111,10 +112,12 @@ static void pm_show_dialog(GtkMenuItem *menuitem, gpointer user_data);
void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item); +void plugin_module_make_resident(GeanyPlugin *plugin);
static PluginFuncs plugin_funcs = { - &plugin_add_toolbar_item + &plugin_add_toolbar_item, + &plugin_module_make_resident };
static DocumentFuncs doc_funcs = { @@ -537,6 +540,9 @@ g_return_if_fail(plugin->init); plugin->init(&geany_data);
+ if (p_geany_plugin && (*p_geany_plugin)->priv->resident) + g_module_make_resident(plugin->module); + /* store some function pointers for later use */ g_module_symbol(plugin->module, "plugin_configure", (void *) &plugin->configure); g_module_symbol(plugin->module, "plugin_help", (void *) &plugin->help); @@ -1321,4 +1327,17 @@ }
+/** Ensures that a plugin's module (*.so) will never be unloaded. + * This is necessary if you register new GTypes in your plugin, e.g. when using own classes + * using the GObject system. + * + * @param plugin Must be @ref geany_plugin. */ +void plugin_module_make_resident(GeanyPlugin *plugin) +{ + g_return_if_fail(plugin); + + plugin->priv->resident = TRUE; +} + + #endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.