[libpeas] Various cleanups
- From: Garrett Regier <gregier src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Various cleanups
- Date: Wed, 13 Nov 2013 08:36:10 +0000 (UTC)
commit ada8c28f719b28396535fdac6b163ea49580fe77
Author: Garrett Regier <garrettregier gmail com>
Date: Tue Nov 12 22:49:51 2013 -0800
Various cleanups
libpeas/peas-engine.c | 48 +++++++++++----------------
loaders/python/peas-plugin-loader-python.c | 19 +++++++----
2 files changed, 32 insertions(+), 35 deletions(-)
---
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index 684cea3..1a5de04 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -81,12 +81,10 @@ enum {
static guint signals[LAST_SIGNAL];
static GParamSpec *properties[N_PROPERTIES] = { NULL };
-typedef struct _LoaderInfo LoaderInfo;
-
-struct _LoaderInfo {
+typedef struct _LoaderInfo {
PeasPluginLoader *loader;
PeasObjectModule *module;
-};
+} LoaderInfo;
typedef struct _SearchPath {
gchar *module_dir;
@@ -264,7 +262,7 @@ peas_engine_insert_search_path (PeasEngine *engine,
* @module_dir.
*/
void
-peas_engine_add_search_path (PeasEngine *engine,
+peas_engine_add_search_path (PeasEngine *engine,
const gchar *module_dir,
const gchar *data_dir)
{
@@ -285,7 +283,7 @@ peas_engine_add_search_path (PeasEngine *engine,
* Since: 1.6
*/
void
-peas_engine_prepend_search_path (PeasEngine *engine,
+peas_engine_prepend_search_path (PeasEngine *engine,
const gchar *module_dir,
const gchar *data_dir)
{
@@ -793,9 +791,9 @@ peas_engine_get_plugin_info (PeasEngine *engine,
return l == NULL ? NULL : (PeasPluginInfo *) l->data;
}
-static gboolean
-load_plugin (PeasEngine *engine,
- PeasPluginInfo *info)
+static void
+peas_engine_load_plugin_real (PeasEngine *engine,
+ PeasPluginInfo *info)
{
const gchar **dependencies;
PeasPluginInfo *dep_info;
@@ -803,10 +801,10 @@ load_plugin (PeasEngine *engine,
PeasPluginLoader *loader;
if (peas_plugin_info_is_loaded (info))
- return TRUE;
+ return;
if (!peas_plugin_info_is_available (info, NULL))
- return FALSE;
+ return;
/* We set the plugin info as loaded before trying to load the dependencies,
* to make sure we won't have an infinite loop. */
@@ -866,23 +864,15 @@ load_plugin (PeasEngine *engine,
g_debug ("Loaded plugin '%s'", peas_plugin_info_get_module_name (info));
- return TRUE;
+ g_object_notify_by_pspec (G_OBJECT (engine),
+ properties[PROP_LOADED_PLUGINS]);
+
+ return;
error:
info->loaded = FALSE;
info->available = FALSE;
-
- return FALSE;
-}
-
-static void
-peas_engine_load_plugin_real (PeasEngine *engine,
- PeasPluginInfo *info)
-{
- if (load_plugin (engine, info))
- g_object_notify_by_pspec (G_OBJECT (engine),
- properties[PROP_LOADED_PLUGINS]);
}
/**
@@ -903,12 +893,12 @@ peas_engine_load_plugin (PeasEngine *engine,
g_return_val_if_fail (PEAS_IS_ENGINE (engine), FALSE);
g_return_val_if_fail (info != NULL, FALSE);
- if (!peas_plugin_info_is_available (info, NULL))
- return FALSE;
-
if (peas_plugin_info_is_loaded (info))
return TRUE;
+ if (!peas_plugin_info_is_available (info, NULL))
+ return FALSE;
+
g_signal_emit (engine, signals[LOAD_PLUGIN], 0, info);
return peas_plugin_info_is_loaded (info);
@@ -922,8 +912,7 @@ peas_engine_unload_plugin_real (PeasEngine *engine,
const gchar *module_name;
PeasPluginLoader *loader;
- if (!peas_plugin_info_is_loaded (info) ||
- !peas_plugin_info_is_available (info, NULL))
+ if (!peas_plugin_info_is_loaded (info))
return;
/* We set the plugin info as unloaded before trying to unload the
@@ -951,6 +940,9 @@ peas_engine_unload_plugin_real (PeasEngine *engine,
g_debug ("Unloaded plugin '%s'", peas_plugin_info_get_module_name (info));
+ /* Don't notify while in dispose so the
+ * loaded plugins can easily be kept in GSettings
+ */
if (!engine->priv->in_dispose)
g_object_notify_by_pspec (G_OBJECT (engine),
properties[PROP_LOADED_PLUGINS]);
diff --git a/loaders/python/peas-plugin-loader-python.c b/loaders/python/peas-plugin-loader-python.c
index 3ab681a..117e035 100644
--- a/loaders/python/peas-plugin-loader-python.c
+++ b/loaders/python/peas-plugin-loader-python.c
@@ -28,7 +28,8 @@
#include "peas-plugin-loader-python.h"
/* _POSIX_C_SOURCE is defined in Python.h and in limits.h included by
- * glib-object.h, so we unset it here to avoid a warning. Yep, that's bad. */
+ * glib-object.h, so we unset it here to avoid a warning. Yep, that's bad.
+ */
#undef _POSIX_C_SOURCE
#include <pygobject.h>
#include <Python.h>
@@ -283,8 +284,7 @@ peas_plugin_loader_python_garbage_collect (PeasPluginLoader *loader)
{
PeasPluginLoaderPython *pyloader = PEAS_PLUGIN_LOADER_PYTHON (loader);
- /*
- * We both run the GC right now and we schedule
+ /* We both run the GC right now and we schedule
* a further collection in the main loop.
*/
run_gc_protected ();
@@ -435,11 +435,16 @@ peas_plugin_loader_python_initialize (PeasPluginLoader *loader)
g_free (argv[0]);
#endif
- /* Note that we don't call this with the GIL held, since we haven't initialised pygobject yet */
+ /* Note that we don't call this with the GIL held,
+ * since we haven't initialised pygobject yet
+ */
peas_plugin_loader_python_add_module_path (pyloader, PEAS_PYEXECDIR);
/* Initialize PyGObject */
- pygobject_init (PYGOBJECT_MAJOR_VERSION, PYGOBJECT_MINOR_VERSION, PYGOBJECT_MICRO_VERSION);
+ pygobject_init (PYGOBJECT_MAJOR_VERSION,
+ PYGOBJECT_MINOR_VERSION,
+ PYGOBJECT_MICRO_VERSION);
+
if (PyErr_Occurred ())
{
g_warning ("Error initializing Python Plugin Loader: "
@@ -480,8 +485,8 @@ peas_plugin_loader_python_initialize (PeasPluginLoader *loader)
python_init_error:
- g_warning ("Please check the installation of all the Python related packages "
- "required by libpeas and try again");
+ g_warning ("Please check the installation of all the Python "
+ "related packages required by libpeas and try again");
if (PyErr_Occurred ())
PyErr_Clear ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]