[libpeas] Add peas_engine_prepend_search_path()
- From: Danielle Madeley <daniellem src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libpeas] Add peas_engine_prepend_search_path()
- Date: Mon, 16 Apr 2012 12:25:59 +0000 (UTC)
commit fe328c40130806b125fad53c1bff9d7cd30d13be
Author: Danielle Madeley <danielle madeley collabora co uk>
Date: Fri Apr 13 15:16:58 2012 +1000
Add peas_engine_prepend_search_path()
Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=674029
docs/reference/libpeas-sections.txt | 1 +
libpeas/peas-engine.c | 58 ++++++++++++++++++++++++++---------
libpeas/peas-engine.h | 3 ++
3 files changed, 47 insertions(+), 15 deletions(-)
---
diff --git a/docs/reference/libpeas-sections.txt b/docs/reference/libpeas-sections.txt
index fbfadd9..e245a37 100644
--- a/docs/reference/libpeas-sections.txt
+++ b/docs/reference/libpeas-sections.txt
@@ -62,6 +62,7 @@ PeasEngineClass
peas_engine_new
peas_engine_get_default
peas_engine_add_search_path
+peas_engine_prepend_search_path
peas_engine_enable_loader
peas_engine_rescan_plugins
peas_engine_get_plugin_list
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index 017f1a8..58c60c4 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -216,6 +216,30 @@ peas_engine_rescan_plugins (PeasEngine *engine)
g_object_thaw_notify (G_OBJECT (engine));
}
+static void
+peas_engine_insert_search_path (PeasEngine *engine,
+ guint position,
+ const gchar *module_dir,
+ const gchar *data_dir)
+{
+ SearchPath *sp;
+
+ g_return_if_fail (PEAS_IS_ENGINE (engine));
+ g_return_if_fail (module_dir != NULL);
+
+ sp = g_slice_new (SearchPath);
+ sp->module_dir = g_strdup (module_dir);
+ sp->data_dir = g_strdup (data_dir ? data_dir : module_dir);
+
+ engine->priv->search_paths = g_list_insert (engine->priv->search_paths,
+ sp,
+ position);
+
+ g_object_freeze_notify (G_OBJECT (engine));
+ load_dir_real (engine, sp->module_dir, sp->data_dir, 1);
+ g_object_thaw_notify (G_OBJECT (engine));
+}
+
/**
* peas_engine_add_search_path:
* @engine: A #PeasEngine.
@@ -244,22 +268,26 @@ peas_engine_add_search_path (PeasEngine *engine,
const gchar *module_dir,
const gchar *data_dir)
{
- SearchPath *sp;
-
- g_return_if_fail (PEAS_IS_ENGINE (engine));
- g_return_if_fail (module_dir != NULL);
-
- sp = g_slice_new (SearchPath);
- sp->module_dir = g_strdup (module_dir);
- sp->data_dir = g_strdup (data_dir ? data_dir : module_dir);
-
- /* Appending to a list is bad, but is easier to handle wrt refreshing
- * the plugin list. */
- engine->priv->search_paths = g_list_append (engine->priv->search_paths, sp);
+ peas_engine_insert_search_path (engine, -1, module_dir, data_dir);
+}
- g_object_freeze_notify (G_OBJECT (engine));
- load_dir_real (engine, sp->module_dir, sp->data_dir, 1);
- g_object_thaw_notify (G_OBJECT (engine));
+/**
+ * peas_engine_prepend_search_path:
+ * @engine: A #PeasEngine.
+ * @module_dir: the plugin module directory.
+ * @data_dir: (allow-none): the plugin data directory.
+ *
+ * This function prepends a search path to the list of paths where to
+ * look for plugins.
+ *
+ * See Also: peas_engine_add_search_path()
+ */
+void
+peas_engine_prepend_search_path (PeasEngine *engine,
+ const gchar *module_dir,
+ const gchar *data_dir)
+{
+ peas_engine_insert_search_path (engine, 0, module_dir, data_dir);
}
static guint
diff --git a/libpeas/peas-engine.h b/libpeas/peas-engine.h
index eb77142..a72e930 100644
--- a/libpeas/peas-engine.h
+++ b/libpeas/peas-engine.h
@@ -80,6 +80,9 @@ PeasEngine *peas_engine_get_default (void);
void peas_engine_add_search_path (PeasEngine *engine,
const gchar *module_dir,
const gchar *data_dir);
+void peas_engine_prepend_search_path (PeasEngine *engine,
+ const gchar *module_dir,
+ const gchar *data_dir);
/* plugin management */
void peas_engine_enable_loader (PeasEngine *engine,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]