[libpeas] Added "loaded-plugins" property to PeasEngine



commit cb31175ce8f0fdce6d9478097f1493a49b7e118d
Author: Garrett Regier <alias301 gmail com>
Date:   Thu Jul 22 08:47:05 2010 -0700

    Added "loaded-plugins" property to PeasEngine
    
    This will allow saving the loaded plugins in one statement using
    g_settings_bind().

 libpeas/peas-engine.c |   45 ++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 42 insertions(+), 3 deletions(-)
---
diff --git a/libpeas/peas-engine.c b/libpeas/peas-engine.c
index 522b120..ea8119c 100644
--- a/libpeas/peas-engine.c
+++ b/libpeas/peas-engine.c
@@ -62,7 +62,8 @@ enum {
   PROP_APP_NAME,
   PROP_BASE_MODULE_DIR,
   PROP_SEARCH_PATHS,
-  PROP_PLUGIN_LIST
+  PROP_PLUGIN_LIST,
+  PROP_LOADED_PLUGINS
 };
 
 typedef struct _LoaderInfo LoaderInfo;
@@ -308,6 +309,10 @@ peas_engine_set_property (GObject      *object,
     case PROP_SEARCH_PATHS:
       engine->priv->search_paths = g_value_dup_boxed (value);
       break;
+    case PROP_LOADED_PLUGINS:
+      peas_engine_set_loaded_plugins (engine,
+                                      (const gchar **) g_value_get_boxed (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -333,10 +338,14 @@ peas_engine_get_property (GObject    *object,
     case PROP_SEARCH_PATHS:
       g_value_set_boxed (value, engine->priv->search_paths);
       break;
-      case PROP_PLUGIN_LIST:
+    case PROP_PLUGIN_LIST:
       g_value_set_pointer (value,
                            (gpointer) peas_engine_get_plugin_list (engine));
       break;
+    case PROP_LOADED_PLUGINS:
+      g_value_take_boxed (value,
+                          (gconstpointer) peas_engine_get_loaded_plugins (engine));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -487,6 +496,33 @@ peas_engine_class_init (PeasEngineClass *klass)
                                                          G_PARAM_STATIC_STRINGS));
 
   /**
+   * PeasEngine:loaded-plugins:
+   *
+   * The list of loaded plugins.
+   *
+   * This will be modified when peas_engine_load_plugin() or
+   * peas_engine_unload_plugin() is called.
+   *
+   * This can be used with GSettings to save the loaded plugins by binding
+   * to this property after instantiating the engine by doing:
+   * |[
+   *   g_settings_bind (gsettings_object,
+   *                    LOADED_PLUGINS_KEY,
+   *                    engine,
+   *                    "loaded-plugins",
+   *                    G_SETTINGS_BIND_DEFAULT);
+   * ]|
+   */
+  g_object_class_install_property (object_class,
+                                   PROP_LOADED_PLUGINS,
+                                   g_param_spec_boxed ("loaded-plugins",
+                                                       "Loaded plugins",
+                                                       "The list of loaded plugins",
+                                                       G_TYPE_STRV,
+                                                       G_PARAM_READWRITE |
+                                                       G_PARAM_STATIC_STRINGS));
+
+  /**
    * PeasEngine::load-plugin:
    * @engine: A #PeasEngine.
    * @info: A #PeasPluginInfo.
@@ -751,7 +787,8 @@ static void
 peas_engine_load_plugin_real (PeasEngine     *engine,
                               PeasPluginInfo *info)
 {
-  load_plugin (engine, info);
+  if (load_plugin (engine, info))
+    g_object_notify (G_OBJECT (engine), "loaded-plugins");
 }
 
 /**
@@ -797,6 +834,8 @@ peas_engine_unload_plugin_real (PeasEngine     *engine,
   peas_plugin_loader_unload (loader, info);
 
   info->loaded = FALSE;
+
+  g_object_notify (G_OBJECT (engine), "loaded-plugins");
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]