[gnome-todo/wip/gbsneto/plugins] activatable: update interface



commit bfdedb4c2bc003e55c4a9e9b20c5734d17bde13e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Jan 17 16:55:41 2016 -0200

    activatable: update interface

 plugins/eds/eds.plugin.in        |    2 +-
 plugins/eds/gtd-plugin-eds.c     |   73 ++++---------------------------------
 src/Makefile.am                  |   21 ++++++-----
 src/interfaces/gtd-activatable.c |   57 +++++++++++++++++------------
 src/interfaces/gtd-activatable.h |   13 ++++++-
 src/plugin/gtd-plugin-dialog.c   |   10 +++---
 src/plugin/gtd-plugin-manager.c  |    2 +-
 7 files changed, 72 insertions(+), 106 deletions(-)
---
diff --git a/plugins/eds/eds.plugin.in b/plugins/eds/eds.plugin.in
index 3861a59..4b0d1ce 100644
--- a/plugins/eds/eds.plugin.in
+++ b/plugins/eds/eds.plugin.in
@@ -6,7 +6,7 @@ Version = @VERSION@
 Authors = Georges Basile Stavracas Neto <gbsneto gnome org>
 Copyright = Copyleft © The To Do maintainers
 Website = https://wiki.gnome.org/Apps/Todo
-Builin = true
+Builtin = true
 Hidden = true
 License = GPL
 Loader = C
diff --git a/plugins/eds/gtd-plugin-eds.c b/plugins/eds/gtd-plugin-eds.c
index 1ab6619..461c764 100644
--- a/plugins/eds/gtd-plugin-eds.c
+++ b/plugins/eds/gtd-plugin-eds.c
@@ -41,7 +41,7 @@
 
 struct _GtdPluginEds
 {
-  PeasExtensionBaseClass  parent;
+  GObject                 parent;
 
   GtkCssProvider         *provider;
   ESourceRegistry        *registry;
@@ -59,10 +59,7 @@ enum
 {
   PROP_0,
   PROP_ACTIVE,
-  PROP_OBJECT,
   PROP_PREFERENCES_PANEL,
-  PROP_PROVIDERS,
-  PROP_PANELS,
   LAST_PROP
 };
 
@@ -75,20 +72,16 @@ const gchar *supported_accounts[] = {
 
 static void          gtd_activatable_iface_init                  (GtdActivatableInterface  *iface);
 
-static void          peas_activatable_iface_init                 (PeasActivatableInterface *iface);
-
-G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtdPluginEds, gtd_plugin_eds, PEAS_TYPE_EXTENSION_BASE,
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (GtdPluginEds, gtd_plugin_eds, G_TYPE_OBJECT,
                                 0,
-                                G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
-                                                               peas_activatable_iface_init)
                                 G_IMPLEMENT_INTERFACE_DYNAMIC (GTD_TYPE_ACTIVATABLE,
                                                                gtd_activatable_iface_init))
 
 /*
- * PeasActivatable interface implementation
+ * GtdActivatable interface implementation
  */
 static void
-gtd_plugin_eds_activate (PeasActivatable *activatable)
+gtd_plugin_eds_activate (GtdActivatable *activatable)
 {
   GtdPluginEds *plugin = GTD_PLUGIN_EDS (activatable);
 
@@ -98,7 +91,7 @@ gtd_plugin_eds_activate (PeasActivatable *activatable)
 }
 
 static void
-gtd_plugin_eds_deactivate (PeasActivatable *activatable)
+gtd_plugin_eds_deactivate (GtdActivatable *activatable)
 {
   GtdPluginEds *plugin = GTD_PLUGIN_EDS (activatable);
 
@@ -107,16 +100,6 @@ gtd_plugin_eds_deactivate (PeasActivatable *activatable)
   g_object_notify (G_OBJECT (activatable), "active");
 }
 
-static void
-peas_activatable_iface_init (PeasActivatableInterface *iface)
-{
-  iface->activate = gtd_plugin_eds_activate;
-  iface->deactivate = gtd_plugin_eds_deactivate;
-}
-
-/*
- * GtdActivatable interface implementation
- */
 static GList*
 gtd_plugin_eds_get_header_widgets (GtdActivatable *activatable)
 {
@@ -148,6 +131,8 @@ gtd_plugin_eds_get_providers (GtdActivatable *activatable)
 static void
 gtd_activatable_iface_init (GtdActivatableInterface *iface)
 {
+  iface->activate = gtd_plugin_eds_activate;
+  iface->deactivate = gtd_plugin_eds_deactivate;
   iface->get_header_widgets = gtd_plugin_eds_get_header_widgets;
   iface->get_preferences_panel = gtd_plugin_eds_get_preferences_panel;
   iface->get_panels = gtd_plugin_eds_get_panels;
@@ -311,11 +296,10 @@ gtd_plugin_eds_source_registry_finish_cb (GObject      *source_object,
 
   /* Load the local provider */
   provider = gtd_provider_local_new (registry);
-  g_signal_emit_by_name (self, "provider-added", provider);
 
   self->providers = g_list_append (self->providers, provider);
 
-  g_object_notify (G_OBJECT (self), "providers");
+  g_signal_emit_by_name (self, "provider-added", provider);
 
   /* We only start loading Goa accounts after
    * ESourceRegistry is get, since it'd be way
@@ -351,38 +335,10 @@ gtd_plugin_eds_get_property (GObject    *object,
       g_value_set_boolean (value, self->active);
       break;
 
-    case PROP_OBJECT:
-      g_value_set_object (value, NULL);
-      break;
-
     case PROP_PREFERENCES_PANEL:
       g_value_set_object (value, NULL);
       break;
 
-    case PROP_PANELS:
-      g_value_set_pointer (value, self->panels);
-      break;
-
-    case PROP_PROVIDERS:
-      g_value_set_pointer (value, self->providers);
-      break;
-
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-    }
-}
-
-static void
-gtd_plugin_eds_set_property (GObject      *object,
-                             guint         prop_id,
-                             const GValue *value,
-                             GParamSpec   *pspec)
-{
-  switch (prop_id)
-    {
-    case PROP_OBJECT:
-      break;
-
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -395,27 +351,14 @@ gtd_plugin_eds_class_init (GtdPluginEdsClass *klass)
 
   object_class->finalize = gtd_plugin_eds_finalize;
   object_class->get_property = gtd_plugin_eds_get_property;
-  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");
-
-  g_object_class_override_property (object_class,
-                                    PROP_PANELS,
-                                    "panels");
-
-  g_object_class_override_property (object_class,
                                     PROP_PREFERENCES_PANEL,
                                     "preferences-panel");
-
-  g_object_class_override_property (object_class,
-                                    PROP_PROVIDERS,
-                                    "providers");
 }
 
 static void
diff --git a/src/Makefile.am b/src/Makefile.am
index 8cd4ff8..c7d7ffb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,7 +4,10 @@ AM_CPPFLAGS = \
        -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
        -DUI_DATA_DIR=\""$(pkgdatadir)/style"\" \
        -I$(srcdir)/provider \
-       -I$(srcdir)/notification
+       -I$(srcdir)/notification \
+       -I$(srcdir)/interfaces \
+       -I$(srcdir)/plugin \
+       -I$(srcdir)/views
 
 bin_PROGRAMS = gnome-todo
 
@@ -178,16 +181,16 @@ introspection_sources = \
        gtd-types.h \
        $(NULL)
 
-Todo-1.0.gir: gnome-todo
-Todo_1_0_gir_INCLUDES = Gio-2.0 GObject-2.0 Gtk-3.0
-Todo_1_0_gir_CFLAGS = $(gnome_todo_CFLAGS)
-Todo_1_0_gir_PROGRAM = $(builddir)/gnome-todo
-Todo_1_0_gir_SCANNERFLAGS = \
-       -n Todo \
+Gtd-1.0.gir: gnome-todo
+Gtd_1_0_gir_INCLUDES = Gio-2.0 GObject-2.0 Gtk-3.0
+Gtd_1_0_gir_CFLAGS = $(gnome_todo_CFLAGS)
+Gtd_1_0_gir_PROGRAM = $(builddir)/gnome-todo
+Gtd_1_0_gir_SCANNERFLAGS = \
+       -n Gtd \
        --identifier-prefix Gtd  \
        --symbol-prefix gtd
-Todo_1_0_gir_FILES = $(introspection_sources)
-INTROSPECTION_GIRS += Todo-1.0.gir
+Gtd_1_0_gir_FILES = $(introspection_sources)
+INTROSPECTION_GIRS += Gtd-1.0.gir
 
 girdir = $(datadir)/gir-1.0
 gir_DATA = $(INTROSPECTION_GIRS)
diff --git a/src/interfaces/gtd-activatable.c b/src/interfaces/gtd-activatable.c
index 044036b..c60e66d 100644
--- a/src/interfaces/gtd-activatable.c
+++ b/src/interfaces/gtd-activatable.c
@@ -20,7 +20,7 @@
 #include "gtd-panel.h"
 #include "gtd-provider.h"
 
-G_DEFINE_INTERFACE (GtdActivatable, gtd_activatable, PEAS_TYPE_ACTIVATABLE)
+G_DEFINE_INTERFACE (GtdActivatable, gtd_activatable, G_TYPE_OBJECT)
 
 enum
 {
@@ -62,28 +62,6 @@ gtd_activatable_default_init (GtdActivatableInterface *iface)
                                                             G_PARAM_READABLE));
 
   /**
-   * GtdActivatable::panels:
-   *
-   * A list of #GtdPanel this plugin carries.
-   */
-  g_object_interface_install_property (iface,
-                                       g_param_spec_pointer ("panels",
-                                                             "Panels this widget has",
-                                                             "A list of panel this widget has",
-                                                             G_PARAM_READABLE));
-
-  /**
-   * GtdActivatable::providers:
-   *
-   * A list of #GtdProvider this plugin carries.
-   */
-  g_object_interface_install_property (iface,
-                                       g_param_spec_pointer ("providers",
-                                                             "Providers this widget has",
-                                                             "A list of providers this widget has",
-                                                             G_PARAM_READABLE));
-
-  /**
    * GtdActivatable::panel-added:
    * @activatable: a #GtdActivatable
    * @panel: a #GtdPanel
@@ -180,6 +158,39 @@ gtd_activatable_default_init (GtdActivatableInterface *iface)
 }
 
 /**
+ * gtd_activatable_activate:
+ * @activatable: a #GtdActivatable
+ *
+ * Activates the extension. This is the starting point where
+ * the implementation does everything it needs to do. Avoid
+ * doing it earlier than this call.
+ */
+void
+gtd_activatable_activate (GtdActivatable *activatable)
+{
+  g_return_if_fail (GTD_IS_ACTIVATABLE (activatable));
+  g_return_if_fail (GTD_ACTIVATABLE_GET_IFACE (activatable)->activate);
+
+  GTD_ACTIVATABLE_GET_IFACE (activatable)->activate (activatable);
+}
+
+/**
+ * gtd_activatable_deactivate:
+ * @activatable: a #GtdActivatable
+ *
+ * Deactivates the extension. Here, the extension should remove
+ * all providers and panels it set.
+ */
+void
+gtd_activatable_deactivate (GtdActivatable *activatable)
+{
+  g_return_if_fail (GTD_IS_ACTIVATABLE (activatable));
+  g_return_if_fail (GTD_ACTIVATABLE_GET_IFACE (activatable)->activate);
+
+  GTD_ACTIVATABLE_GET_IFACE (activatable)->deactivate (activatable);
+}
+
+/**
  * gtd_activatable_get_header_widgets:
  * @activatable: a #GtdActivatable
  *
diff --git a/src/interfaces/gtd-activatable.h b/src/interfaces/gtd-activatable.h
index a017dd3..1f7b012 100644
--- a/src/interfaces/gtd-activatable.h
+++ b/src/interfaces/gtd-activatable.h
@@ -20,6 +20,7 @@
 #define GTD_ACTIVATABLE_H
 
 #include <glib.h>
+#include <glib-object.h>
 #include <gtk/gtk.h>
 #include <libpeas/peas.h>
 
@@ -27,11 +28,15 @@ G_BEGIN_DECLS
 
 #define GTD_TYPE_ACTIVATABLE (gtd_activatable_get_type ())
 
-G_DECLARE_INTERFACE (GtdActivatable, gtd_activatable, GTD, ACTIVATABLE, PeasActivatable)
+G_DECLARE_INTERFACE (GtdActivatable, gtd_activatable, GTD, ACTIVATABLE, GObject)
 
 struct _GtdActivatableInterface
 {
-  PeasActivatableInterface parent;
+  GTypeInterface    parent;
+
+  void             (*activate)                             (GtdActivatable     *activatable);
+
+  void             (*deactivate)                           (GtdActivatable     *activatable);
 
   GList*           (*get_header_widgets)                   (GtdActivatable     *activatable);
 
@@ -42,6 +47,10 @@ struct _GtdActivatableInterface
   GList*           (*get_providers)                        (GtdActivatable     *activatable);
 };
 
+void                 gtd_activatable_activate                    (GtdActivatable     *activatable);
+
+void                 gtd_activatable_deactivate                  (GtdActivatable     *activatable);
+
 GList*               gtd_activatable_get_header_widgets          (GtdActivatable     *activatable);
 
 GtkWidget*           gtd_activatable_get_preferences_panel       (GtdActivatable     *activatable);
diff --git a/src/plugin/gtd-plugin-dialog.c b/src/plugin/gtd-plugin-dialog.c
index e8d91da..d14ff84 100644
--- a/src/plugin/gtd-plugin-dialog.c
+++ b/src/plugin/gtd-plugin-dialog.c
@@ -98,9 +98,9 @@ transform_to (GBinding     *binding,
 }
 
 static void
-enabled_switch_changed (GtkSwitch       *sw,
-                        GParamSpec      *pspec,
-                        PeasActivatable *activatable)
+enabled_switch_changed (GtkSwitch      *sw,
+                        GParamSpec     *pspec,
+                        GtdActivatable *activatable)
 {
   gboolean active;
 
@@ -113,9 +113,9 @@ enabled_switch_changed (GtkSwitch       *sw,
     return;
 
   if (gtk_switch_get_active (sw))
-    peas_activatable_activate (activatable);
+    gtd_activatable_activate (activatable);
   else
-    peas_activatable_deactivate (activatable);
+    gtd_activatable_deactivate (activatable);
 }
 
 static GtkWidget*
diff --git a/src/plugin/gtd-plugin-manager.c b/src/plugin/gtd-plugin-manager.c
index 3d0435b..967c42e 100644
--- a/src/plugin/gtd-plugin-manager.c
+++ b/src/plugin/gtd-plugin-manager.c
@@ -314,7 +314,7 @@ on_plugin_loaded (PeasEngine       *engine,
       if (g_strv_contains ((const gchar* const*) active_extensions,
                            peas_plugin_info_get_module_name (info)))
         {
-          peas_activatable_activate (PEAS_ACTIVATABLE (activatable));
+          gtd_activatable_activate (activatable);
         }
 
       g_hash_table_insert (self->info_to_extension,


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