[gnome-todo/wip/gbsneto/plugins] activatable: add ::active property



commit f8ed1c8c59d0a266abd7d19f73eb972d71403389
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Jan 14 21:01:18 2016 -0200

    activatable: add ::active property
    
    Used on implementations to track whether the
    plugin is active or not. When the plugin is
    activated, we'll call peas_activatable_activate,
    and the other way round.

 plugins/eds/gtd-plugin-eds.c     |   23 +++++++++++++++++++++--
 src/interfaces/gtd-activatable.c |   12 ++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/plugins/eds/gtd-plugin-eds.c b/plugins/eds/gtd-plugin-eds.c
index a04267a..4d08910 100644
--- a/plugins/eds/gtd-plugin-eds.c
+++ b/plugins/eds/gtd-plugin-eds.c
@@ -50,11 +50,14 @@ struct _GtdPluginEds
 
   /* Providers */
   GList                  *providers;
+
+  gboolean                active;
 };
 
 enum
 {
   PROP_0,
+  PROP_ACTIVE,
   PROP_OBJECT,
   PROP_PROVIDERS,
   PROP_PANELS,
@@ -85,13 +88,21 @@ G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtdPluginEds, gtd_plugin_eds, PEAS_TYPE_EXTENSIO
 static void
 gtd_plugin_eds_activate (PeasActivatable *activatable)
 {
-  g_message ("activate");
+  GtdPluginEds *plugin = GTD_PLUGIN_EDS (activatable);
+
+  plugin->active = TRUE;
+
+  g_object_notify (G_OBJECT (activatable), "active");
 }
 
 static void
 gtd_plugin_eds_deactivate (PeasActivatable *activatable)
 {
-  g_message ("deactivate");
+  GtdPluginEds *plugin = GTD_PLUGIN_EDS (activatable);
+
+  plugin->active = FALSE;
+
+  g_object_notify (G_OBJECT (activatable), "active");
 }
 
 static void
@@ -320,6 +331,10 @@ gtd_plugin_eds_get_property (GObject    *object,
 
   switch (prop_id)
     {
+    case PROP_ACTIVE:
+      g_value_set_boolean (value, self->active);
+      break;
+
     case PROP_OBJECT:
       g_value_set_object (value, NULL);
       break;
@@ -363,6 +378,10 @@ gtd_plugin_eds_class_init (GtdPluginEdsClass *klass)
   object_class->set_property = gtd_plugin_eds_set_property;
 
   g_object_class_override_property (object_class,
+                                    PROP_ACTIVE,
+                                    "active");
+
+  g_object_class_override_property (object_class,
                                     PROP_OBJECT,
                                     "object");
 
diff --git a/src/interfaces/gtd-activatable.c b/src/interfaces/gtd-activatable.c
index 9f6298d..0ed71fa 100644
--- a/src/interfaces/gtd-activatable.c
+++ b/src/interfaces/gtd-activatable.c
@@ -38,6 +38,18 @@ static void
 gtd_activatable_default_init (GtdActivatableInterface *iface)
 {
   /**
+   * GtdActivatable::active:
+   *
+   * Whether the plugin is active or not.
+   */
+  g_object_interface_install_property (iface,
+                                       g_param_spec_boolean ("active",
+                                                             "Whether the plugin is active",
+                                                             "Whether the plugin is active or not",
+                                                             FALSE,
+                                                             G_PARAM_READABLE));
+
+  /**
    * GtdActivatable::panels:
    *
    * A list of #GtdPanel this plugin carries.


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