Kaydet (Commit) 51b3a335 authored tarafından Enrico Tröger's avatar Enrico Tröger

Add plugin_module_make_resident() to the plugin API which allows plugins to make…

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.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3559 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 98306aad
......@@ -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>
......
......@@ -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 \
......
......@@ -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 @@ typedef struct SciFuncs
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 @@ typedef struct SciFuncs
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 @@ typedef struct SciFuncs
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 @@ EditorFuncs;
typedef struct PluginFuncs
{
void (*add_toolbar_item)(GeanyPlugin *plugin, GtkToolItem *item);
void (*module_make_resident) (GeanyPlugin *plugin);
}
PluginFuncs;
......
......@@ -72,6 +72,7 @@
typedef struct GeanyPluginPrivate
{
GeanyAutoSeparator toolbar_separator;
gboolean resident;
}
GeanyPluginPrivate;
......@@ -111,10 +112,12 @@ static GtkWidget *menu_separator = NULL;
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 @@ plugin_init(Plugin *plugin)
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 @@ void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item)
}
/** 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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment