[emerillon/gtk3] Simplify plugin managament code
- From: Johannes Schmid <jhs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [emerillon/gtk3] Simplify plugin managament code
- Date: Sun, 26 Jun 2011 18:36:20 +0000 (UTC)
commit 3794d5fb79c77326dd8a32e1515405ab41832bfd
Author: Johannes Schmid <jhs gnome org>
Date: Sun Jun 26 13:10:45 2011 +0200
Simplify plugin managament code
emerillon/Makefile.am | 2 -
emerillon/main.c | 16 +++-
emerillon/manager.c | 240 -----------------------------------------------
emerillon/manager.h | 64 -------------
emerillon/preferences.c | 4 +-
emerillon/window.c | 38 +++++++-
6 files changed, 50 insertions(+), 314 deletions(-)
---
diff --git a/emerillon/Makefile.am b/emerillon/Makefile.am
index da87f6b..cae2361 100644
--- a/emerillon/Makefile.am
+++ b/emerillon/Makefile.am
@@ -21,8 +21,6 @@ noinst_LTLIBRARIES = libemerillon.la
BUILT_SOURCES =
libemerillon_la_SOURCES = \
- manager.h \
- manager.c \
preferences.h \
preferences.c \
window.c \
diff --git a/emerillon/main.c b/emerillon/main.c
index 0fed8b5..f099333 100644
--- a/emerillon/main.c
+++ b/emerillon/main.c
@@ -35,8 +35,8 @@
#include <stdlib.h>
-#include "manager.h"
#include "window.h"
+#include "config-keys.h"
static void
display_version ()
@@ -127,6 +127,7 @@ main (int argc,
NULL,
NULL};
gchar **dir = NULL;
+ GSettings *settings;
user_data = g_build_path (G_DIR_SEPARATOR_S,
g_get_user_data_dir (),
@@ -176,14 +177,21 @@ main (int argc,
g_object_unref (plugin_dir);
/* Setup the plugin infrastructure */
- engine = emerillon_manager_dup_default ();
+ engine = peas_engine_get_default();
peas_engine_enable_loader (engine, "python");
+ g_irepository_require (g_irepository_get_default (),
+ "Peas", "1.0", 0, NULL);
+
for (dir = plugin_dirs; *dir != NULL; dir++)
{
peas_engine_add_search_path (engine, *dir, NULL);
}
- emerillon_manager_initialize(EMERILLON_MANAGER(engine));
-
+ settings = g_settings_new (EMERILLON_SCHEMA_PLUGINS);
+ g_settings_bind (settings,
+ EMERILLON_CONF_PLUGINS_ACTIVE_PLUGINS,
+ engine,
+ "loaded-plugins",
+ G_SETTINGS_BIND_DEFAULT);
gtk_main ();
g_free (user_data);
diff --git a/emerillon/preferences.c b/emerillon/preferences.c
index ca4e14e..65016b6 100644
--- a/emerillon/preferences.c
+++ b/emerillon/preferences.c
@@ -118,14 +118,12 @@ build_plugin_tab (GtkNotebook *notebook)
PeasEngine *manager;
label = gtk_label_new (_("Plugins"));
- manager = emerillon_manager_dup_default ();
+ manager = peas_engine_get_default();
tab = peas_gtk_plugin_manager_new (manager);
gtk_widget_show (tab);
gtk_container_set_border_width (GTK_CONTAINER (tab), 10);
gtk_notebook_append_page (notebook, tab, label);
-
- g_object_unref (manager);
}
static void
diff --git a/emerillon/window.c b/emerillon/window.c
index a39a128..51c3bac 100644
--- a/emerillon/window.c
+++ b/emerillon/window.c
@@ -31,6 +31,7 @@
#include <geoclue/geoclue-position.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include <libpeas/peas.h>
#include "config-keys.h"
#include "sidebar.h"
@@ -48,6 +49,8 @@ struct _EmerillonWindowPrivate
{
GtkUIManager *ui_manager;
+ PeasExtensionSet* ext_set;
+
GtkWidget *toolbar;
GtkWidget *statusbar;
GtkWidget *sidebar;
@@ -193,6 +196,24 @@ position_changed_cb (GeocluePosition *position,
}
static void
+on_extension_added (PeasExtensionSet *set,
+ PeasPluginInfo *info,
+ PeasExtension *exten,
+ EmerillonWindow *self)
+{
+ peas_activatable_activate (PEAS_ACTIVATABLE (exten));
+}
+
+static void
+on_extension_removed (PeasExtensionSet *set,
+ PeasPluginInfo *info,
+ PeasExtension *exten,
+ EmerillonWindow *self)
+{
+ peas_activatable_deactivate (PEAS_ACTIVATABLE (exten));
+}
+
+static void
emerillon_window_init (EmerillonWindow *self)
{
GdkGeometry geometry;
@@ -209,6 +230,16 @@ emerillon_window_init (EmerillonWindow *self)
/* GSettings. */
self->priv->settings_ui = g_settings_new (EMERILLON_SCHEMA_UI);
+ /* Extension setup */
+ self->priv->ext_set = peas_extension_set_new (peas_engine_get_default (),
+ PEAS_TYPE_ACTIVATABLE,
+ NULL);
+
+ peas_extension_set_call (self->priv->ext_set, "activate");
+
+ g_signal_connect (self->priv->ext_set, "extension-added", G_CALLBACK (on_extension_added), self);
+ g_signal_connect (self->priv->ext_set, "extension-removed", G_CALLBACK (on_extension_removed), self);
+
/* Window setup. */
geometry.min_width = 400;
geometry.min_height = 350;
@@ -291,7 +322,12 @@ emerillon_window_dispose (GObject *object)
g_object_unref (self->priv->geoclue_position);
self->priv->geoclue_client = NULL;
}
-
+ if (self->priv->ext_set)
+ {
+ g_object_unref (self->priv->ext_set);
+ self->priv->ext_set = NULL;
+ }
+
G_OBJECT_CLASS (emerillon_window_parent_class)->dispose (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]