From 49ef32b76c55cbefba53568f02028dddf23a9bc9 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 7 Feb 2010 12:36:53 -0500 Subject: Coding style and whitespace cleanup. --- modules/plugin-lib/e-plugin-lib.c | 55 ++++++++++++++++++--------------------- modules/plugin-lib/e-plugin-lib.h | 2 +- 2 files changed, 26 insertions(+), 31 deletions(-) (limited to 'modules/plugin-lib') diff --git a/modules/plugin-lib/e-plugin-lib.c b/modules/plugin-lib/e-plugin-lib.c index f5b5b9dbd1..33ba699258 100644 --- a/modules/plugin-lib/e-plugin-lib.c +++ b/modules/plugin-lib/e-plugin-lib.c @@ -79,40 +79,41 @@ plugin_lib_loadmodule (EPlugin *plugin) } static gpointer -plugin_lib_invoke (EPlugin *plugin, const gchar *name, gpointer data) +plugin_lib_get_symbol (EPlugin *plugin, const gchar *name) { EPluginLib *plugin_lib = E_PLUGIN_LIB (plugin); - EPluginLibFunc cb; - - if (!plugin->enabled) { - g_warning ("trying to invoke '%s' on disabled plugin '%s'", name, plugin->id); - return NULL; - } + gpointer symbol; if (plugin_lib_loadmodule (plugin) != 0) return NULL; - if (!g_module_symbol (plugin_lib->module, name, (gpointer)&cb)) { - g_warning ("Cannot resolve symbol '%s' in plugin '%s' (not exported?)", name, plugin_lib->location); + if (!g_module_symbol (plugin_lib->module, name, &symbol)) return NULL; - } - return cb (plugin, data); + return symbol; } static gpointer -plugin_lib_get_symbol (EPlugin *plugin, const gchar *name) +plugin_lib_invoke (EPlugin *plugin, const gchar *name, gpointer data) { EPluginLib *plugin_lib = E_PLUGIN_LIB (plugin); - gpointer symbol; + EPluginLibFunc func; - if (plugin_lib_loadmodule (plugin) != 0) + if (!plugin->enabled) { + g_warning ("trying to invoke '%s' on disabled plugin '%s'", name, plugin->id); return NULL; + } - if (!g_module_symbol (plugin_lib->module, name, &symbol)) + func = plugin_lib_get_symbol (plugin, name); + + if (func == NULL) { + g_warning ( + "Cannot resolve symbol '%s' in plugin '%s' " + "(not exported?)", name, plugin_lib->location); return NULL; + } - return symbol; + return func (plugin, data); } static gint @@ -164,16 +165,14 @@ plugin_lib_construct (EPlugin *plugin, xmlNodePtr root) static GtkWidget * plugin_lib_get_configure_widget (EPlugin *plugin) { - EPluginLib *plugin_lib = E_PLUGIN_LIB (plugin); EPluginLibGetConfigureWidgetFunc get_configure_widget; - if (plugin_lib_loadmodule (plugin) != 0) { - return NULL; - } + get_configure_widget = plugin_lib_get_symbol ( + plugin, "e_plugin_lib_get_configure_widget"); + + if (get_configure_widget != NULL) + return get_configure_widget (plugin); - if (g_module_symbol (plugin_lib->module, "e_plugin_lib_get_configure_widget", (gpointer)&get_configure_widget)) { - return (GtkWidget*) get_configure_widget (plugin); - } return NULL; } @@ -189,14 +188,10 @@ plugin_lib_enable (EPlugin *plugin, gint state) if (!state && plugin_lib->module == NULL) return; - /* this will noop if we're disabling since we tested it above */ - if (plugin_lib_loadmodule (plugin) != 0) - return; + enable = plugin_lib_get_symbol (plugin, "e_plugin_lib_enable"); - if (g_module_symbol (plugin_lib->module, "e_plugin_lib_enable", (gpointer) &enable)) { - if (enable (plugin, state) != 0) - return; - } + if (enable != NULL) + enable (plugin, state); } static void diff --git a/modules/plugin-lib/e-plugin-lib.h b/modules/plugin-lib/e-plugin-lib.h index 6ca7d697a9..91f440bf49 100644 --- a/modules/plugin-lib/e-plugin-lib.h +++ b/modules/plugin-lib/e-plugin-lib.h @@ -57,7 +57,7 @@ typedef gpointer (*EPluginLibFunc) (EPlugin *ep, gpointer data); * is disabled. */ typedef gint (*EPluginLibEnableFunc) (EPlugin *ep, gint enable); -typedef gpointer (*EPluginLibGetConfigureWidgetFunc) (EPlugin *ep); +typedef GtkWidget * (*EPluginLibGetConfigureWidgetFunc) (EPlugin *ep); /** * struct _EPluginLib - -- cgit v1.2.3