[vinagre/no-separate-plugins: 4/9] Remove libpeas support



commit bc912a9aee152405fbf437a2c7f9f13f9a95532e
Author: David King <amigadave amigadave com>
Date:   Fri Jun 10 19:18:31 2011 +0200

    Remove libpeas support

 Makefile.am                      |    8 +-
 configure.ac                     |    4 +-
 data/vinagre-ui.xml              |    1 -
 vinagre/vinagre-commands.c       |    2 +-
 vinagre/vinagre-plugins-engine.c |  199 ++++++-------------------------------
 vinagre/vinagre-plugins-engine.h |   10 +-
 vinagre/vinagre-protocol.h       |    1 -
 vinagre/vinagre-ui.h             |    3 -
 vinagre/vinagre-window-private.h |    4 -
 vinagre/vinagre-window.c         |   46 ---------
 10 files changed, 43 insertions(+), 235 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 91a76f1..883af26 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -51,7 +51,6 @@ noinst_vinagreh_headers = \
 	vinagre/view/autoDrawer.h \
 	vinagre/view/drawer.h \
 	vinagre/view/ovBox.h \
-	vinagre/vinagre-plugin-dialog.h \
 	vinagre/vinagre-window-private.h \
 	vinagre/pty_open.h \
 	vinagre/vinagre-options.h
@@ -82,9 +81,7 @@ vinagreh_HEADERS = \
 
 INTROSPECTION_GIR_INCLUDES = \
 	Gtk-3.0 \
-	libxml2-2.0 \
-	Peas-1.0 \
-	PeasGtk-1.0
+	libxml2-2.0
 
 # The main library
 noinst_LTLIBRARIES = libvinagre.la
@@ -105,7 +102,6 @@ handwritten_sources = \
 	vinagre/vinagre-dirs.c \
 	vinagre/vinagre-fav.c \
 	vinagre/vinagre-notebook.c \
-	vinagre/vinagre-plugin-dialog.c \
 	vinagre/vinagre-prefs.c \
 	vinagre/vinagre-static-extension.c \
 	vinagre/vinagre-tab.c \
@@ -152,7 +148,7 @@ INTROSPECTION_GIRS = Vinagre-3.0.gir
 Vinagre-3.0.gir: libvinagre.la
 INTROSPECTION_SCANNER_ARGS = $(common_cppflags) $(VINAGRE_CFLAGS) -I$(top_srcdir) --warn-all
 Vinagre_3_0_gir_LIBS = libvinagre.la
-Vinagre_3_0_gir_FILES = $(vinagreh_HEADERS) $(filter-out pty_open.h vinagre-plugin-dialog.h, $(noinst_vinagreh_headers)) $(handwritten_sources)
+Vinagre_3_0_gir_FILES = $(vinagreh_HEADERS) $(filter-out pty_open.h, $(noinst_vinagreh_headers)) $(handwritten_sources)
 Vinagre_3_0_gir_INCLUDES = $(INTROSPECTION_GIR_INCLUDES)
 
 girdir = $(pkgdatadir)/gir-1.0
diff --git a/configure.ac b/configure.ac
index 8f838ea..e906525 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,6 @@ AC_PROG_SED
 AC_SUBST([VINAGRE_ABI_VERSION], [3.0])
 AC_DEFINE_UNQUOTED([VINAGRE_ABI_VERSION], ["$VINAGRE_ABI_VERSION"], [Vinagre ABI version])
 
-AC_SUBST([PLUGIN_LIBTOOL_FLAGS], ["-module -avoid-version"])
 AC_SUBST([VINAGRE_PLUGINS_DATA_DIR], ["$datadir/vinagre-$VINAGRE_ABI_VERSION/plugins"])
 AC_SUBST([VINAGRE_PLUGINS_LIBS_DIR], ["$libdir/vinagre-$VINAGRE_ABI_VERSION/plugins"])
 
@@ -35,7 +34,6 @@ GTHREAD_DEPS="gthread-2.0 >= 2.0.0"
 GTK_DEPS="gtk+-3.0 >= 3.0.3"
 GTK_VNC_DEPS="gtk-vnc-2.0 >= 0.4.3"
 XML2_DEPS="libxml-2.0 >= 2.6.31"
-PEAS_DEPS="libpeas-1.0 >= 0.7.2 libpeas-gtk-1.0 >= 0.7.2"
 
 # Whether to enable support for SSH.
 SSH_DEPS="vte-2.90 >= 0.20 $XML2_DEPS"
@@ -165,7 +163,7 @@ AS_IF([test "x$have_telepathy" = "xyes"],
 AM_CONDITIONAL([VINAGRE_HAVE_TELEPATHY_GLIB], [test "x$have_telepathy" = "xyes"])
 
 # Check required libraries
-PKG_CHECK_MODULES([VINAGRE], [$GLIB_DEPS $GTHREAD_DEPS $GTK_DEPS gnome-keyring-1 $XML2_DEPS $PEAS_DEPS $AVAHI_DEPS $TELEPATHY_GLIB_DEPS $SSH_DEPS])
+PKG_CHECK_MODULES([VINAGRE], [$GLIB_DEPS $GTHREAD_DEPS $GTK_DEPS gnome-keyring-1 $XML2_DEPS $AVAHI_DEPS $TELEPATHY_GLIB_DEPS $SSH_DEPS])
 
 PKG_CHECK_MODULES([VNC], [$GTK_VNC_DEPS $GTK_DEPS $XML2_DEPS])
 
diff --git a/data/vinagre-ui.xml b/data/vinagre-ui.xml
index ed137dd..d41c5b1 100644
--- a/data/vinagre-ui.xml
+++ b/data/vinagre-ui.xml
@@ -38,7 +38,6 @@
 
     <menu name="EditMenu" action="Edit">
       <menuitem name="EditPreferencesMenu" action="EditPreferences"/>
-      <menuitem name="EditPluginsMenu" action="EditPlugins"/>
     </menu>
 
     <menu name="ViewMenu" action="View">
diff --git a/vinagre/vinagre-commands.c b/vinagre/vinagre-commands.c
index f89e90d..da366c2 100644
--- a/vinagre/vinagre-commands.c
+++ b/vinagre/vinagre-commands.c
@@ -240,7 +240,7 @@ vinagre_cmd_edit_plugins (GtkAction     *action,
 {
   g_return_if_fail (VINAGRE_IS_WINDOW (window));
 
-  vinagre_plugin_dialog_show (GTK_WINDOW (window));
+  g_warn_if_reached ();
 }
 
 /* View Menu */
diff --git a/vinagre/vinagre-plugins-engine.c b/vinagre/vinagre-plugins-engine.c
index 0f87112..fefa35e 100644
--- a/vinagre/vinagre-plugins-engine.c
+++ b/vinagre/vinagre-plugins-engine.c
@@ -18,21 +18,19 @@
  * with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <girepository.h>
-
 #include "vinagre-plugins-engine.h"
 #include "vinagre-dirs.h"
 #include "vinagre-debug.h"
 #include "vinagre-protocol.h"
 #include "vinagre-prefs.h"
+#include "vinagre-static-extension.h"
 
-G_DEFINE_TYPE (VinagrePluginsEngine, vinagre_plugins_engine, PEAS_TYPE_ENGINE)
+G_DEFINE_TYPE (VinagrePluginsEngine, vinagre_plugins_engine, G_TYPE_OBJECT)
 
 struct _VinagrePluginsEnginePrivate
 {
   gboolean loading_plugin_list : 1;
   GHashTable *protocols;
-  PeasExtensionSet *extensions;
 };
 
 enum
@@ -46,103 +44,36 @@ static guint signals[LAST_SIGNAL] = { 0 };
 VinagrePluginsEngine *default_engine = NULL;
 
 static void
-vinagre_plugins_engine_load_extensions (VinagrePluginsEngine *engine)
-{
- GStrv plugins;
-
-  g_object_get (vinagre_prefs_get_default (),
-		"active-plugins", &plugins,
-		NULL);
-
-  engine->priv->loading_plugin_list = TRUE;
-  peas_engine_set_loaded_plugins (PEAS_ENGINE (engine), (const gchar **)plugins);
-  engine->priv->loading_plugin_list = FALSE;
-  g_strfreev (plugins);
-}
-
-static void
-vinagre_plugins_engine_extension_added (PeasExtensionSet     *extensions,
-					PeasPluginInfo	     *info,
-					PeasExtension	     *exten,
-					VinagrePluginsEngine *engine)
-{
-  PeasExtension *previous_ext;
-  const gchar *protocol = NULL;
-
-  peas_extension_call (exten, "get_protocol", &protocol);
-
-  if (!protocol)
-    {
-      g_warning ("Unable to determine a protocol for the plugin %s",
-                 peas_plugin_info_get_name (info));
-      return;
-    }
-
-  previous_ext = g_hash_table_lookup (engine->priv->protocols, protocol);
-
-  if (previous_ext)
-    {
-      g_warning ("The protocol %s was already registered by the plugin %s",
-		 protocol,
-		 peas_plugin_info_get_name (info));
-      return;
-    }
-
-  g_hash_table_insert (engine->priv->protocols, (gpointer)protocol, exten);
-  g_signal_emit (engine, signals[PROTOCOL_ADDED], 0, exten);
-}
-
-static void
-vinagre_plugins_engine_extension_removed (PeasExtensionSet     *extensions,
-					  PeasPluginInfo       *info,
-					  PeasExtension	       *exten,
-					  VinagrePluginsEngine *engine)
+vinagre_plugins_engine_add_protocol (VinagrePluginsEngine *engine,
+    const gchar *name, GObject *protocol)
 {
-  const gchar *protocol = NULL;
-
-  peas_extension_call (exten, "get_protocol", &protocol);
+    GObject *previous_ext = g_hash_table_lookup (engine->priv->protocols, name);
 
-  if (!protocol)
+    if (previous_ext)
     {
-      g_warning ("Unable to determine a protocol for the plugin %s",
-                 peas_plugin_info_get_name (info));
-      return;
+        g_warning ("The protocol %s was already registered", name);
+        return;
     }
 
-  g_hash_table_remove (engine->priv->protocols, (gpointer)protocol);
-  g_signal_emit (engine, signals[PROTOCOL_REMOVED], 0, exten);
+    g_hash_table_insert (engine->priv->protocols, (gpointer)name, protocol);
+    g_signal_emit (engine, signals[PROTOCOL_ADDED], 0, protocol);
 }
 
-static void
-vinagre_plugins_engine_constructed (GObject *object)
+gboolean
+vinagre_plugins_engine_load_extension (VinagrePluginsEngine *engine,
+    const gchar *name)
 {
-  VinagrePluginsEngine *engine;
-
-  if (G_OBJECT_CLASS (vinagre_plugins_engine_parent_class)->constructed)
-    G_OBJECT_CLASS (vinagre_plugins_engine_parent_class)->constructed (object);
-
-  engine = VINAGRE_PLUGINS_ENGINE (object);
-  engine->priv->extensions = peas_extension_set_new (PEAS_ENGINE (engine),
-						     VINAGRE_TYPE_PROTOCOL,
-						     NULL);
-  g_signal_connect (engine->priv->extensions,
-		    "extension-added",
-		    G_CALLBACK (vinagre_plugins_engine_extension_added),
-		    engine);
-  g_signal_connect (engine->priv->extensions,
-		    "extension-removed",
-		    G_CALLBACK (vinagre_plugins_engine_extension_removed),
-		    engine);
-
-  vinagre_plugins_engine_load_extensions (engine);
+    g_warn_if_reached ();
+    return FALSE;
 }
 
 static void
 vinagre_plugins_engine_init (VinagrePluginsEngine *engine)
 {
-  gchar *tmp, *typelib_dir;
-  GError *error = NULL;
-  PeasEngine *p_engine = PEAS_ENGINE (engine);
+  guint n_children;
+  GType child, *children;
+  GObject *object;
+  const gchar *protocol;
 
   engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine,
 					      VINAGRE_TYPE_PLUGINS_ENGINE,
@@ -151,34 +82,17 @@ vinagre_plugins_engine_init (VinagrePluginsEngine *engine)
   engine->priv->loading_plugin_list = FALSE;
   engine->priv->protocols = g_hash_table_new (g_str_hash, g_str_equal);
 
-  /* This should be moved to libpeas */
-  g_irepository_require (g_irepository_get_default (),
-			 "Peas", "1.0", 0, NULL);
-  g_irepository_require (g_irepository_get_default (),
-			 "PeasUI", "1.0", 0, NULL);
-
-  /* Require vinagre's typelib. */
-  tmp = vinagre_dirs_get_vinagre_lib_dir ();
-  typelib_dir = g_build_filename (tmp,
-				  "girepository-1.0",
-				  NULL);
-  g_irepository_require_private (g_irepository_get_default (),
-				 typelib_dir, "Vinagre", "3.0", 0, &error);
-  g_free (typelib_dir);
-  g_free (tmp);
-  if (error)
-    {
-      g_print ("error registering vinagre typelib: %s\n", error->message);
-      g_error_free (error);
-    }
-
-  tmp = vinagre_dirs_get_user_plugins_dir ();
-  peas_engine_add_search_path (p_engine, tmp, tmp);
-  g_free (tmp);
-
-  tmp = vinagre_dirs_get_vinagre_plugins_dir ();
-  peas_engine_add_search_path (p_engine, tmp, tmp);
-  g_free (tmp);
+  children = g_type_children (VINAGRE_TYPE_STATIC_EXTENSION, &n_children);
+  while (n_children > 0 )
+  {
+    n_children--;
+    child = children[n_children];
+    object = g_object_new (child, NULL);
+    protocol = vinagre_protocol_get_protocol (VINAGRE_PROTOCOL (object));
+    vinagre_plugins_engine_add_protocol (engine, protocol, object);
+  }
+
+  g_free (children);
 }
 
 static void
@@ -192,58 +106,11 @@ vinagre_plugins_engine_finalize (GObject *object)
 }
 
 static void
-save_plugin_list (VinagrePluginsEngine *engine)
-{
-  gchar **loaded_plugins;
-
-  loaded_plugins = peas_engine_get_loaded_plugins (PEAS_ENGINE (engine));
-
-  g_object_set (vinagre_prefs_get_default (),
-		"active-plugins", loaded_plugins,
-		NULL);
-
-  g_strfreev (loaded_plugins);
-}
-
-static void
-vinagre_plugins_engine_load_plugin (PeasEngine	   *engine,
-				    PeasPluginInfo *info)
-{
-  VinagrePluginsEngine *vengine = VINAGRE_PLUGINS_ENGINE (engine);
-
-  PEAS_ENGINE_CLASS (vinagre_plugins_engine_parent_class)->load_plugin (engine, info);
-
-  /* We won't save the plugin list if we are currently loading the
-   * plugins from the saved list */
-  if (!vengine->priv->loading_plugin_list && peas_plugin_info_is_loaded (info))
-    save_plugin_list (vengine);
-}
-
-static void
-vinagre_plugins_engine_unload_plugin (PeasEngine     *engine,
-				      PeasPluginInfo *info)
-{
-  VinagrePluginsEngine *vengine = VINAGRE_PLUGINS_ENGINE (engine);
-
-  PEAS_ENGINE_CLASS (vinagre_plugins_engine_parent_class)->unload_plugin (engine, info);
-
-  /* We won't save the plugin list if we are currently unloading the
-   * plugins from the saved list */
-  if (!vengine->priv->loading_plugin_list && !peas_plugin_info_is_loaded (info))
-    save_plugin_list (vengine);
-}
-
-static void
 vinagre_plugins_engine_class_init (VinagrePluginsEngineClass *klass)
 {
-  PeasEngineClass *engine_class = PEAS_ENGINE_CLASS (klass);
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   object_class->finalize = vinagre_plugins_engine_finalize;
-  object_class->constructed = vinagre_plugins_engine_constructed;
-
-  engine_class->load_plugin = vinagre_plugins_engine_load_plugin;
-  engine_class->unload_plugin = vinagre_plugins_engine_unload_plugin;
 
   signals[PROTOCOL_ADDED] =
 		g_signal_new ("protocol-added",
@@ -254,7 +121,7 @@ vinagre_plugins_engine_class_init (VinagrePluginsEngineClass *klass)
 			      g_cclosure_marshal_VOID__OBJECT,
 			      G_TYPE_NONE,
 			      1,
-			      PEAS_TYPE_EXTENSION);
+			      VINAGRE_TYPE_PROTOCOL);
 
   signals[PROTOCOL_REMOVED] =
 		g_signal_new ("protocol-removed",
@@ -265,7 +132,7 @@ vinagre_plugins_engine_class_init (VinagrePluginsEngineClass *klass)
 			      g_cclosure_marshal_VOID__OBJECT,
 			      G_TYPE_NONE,
 			      1,
-			      PEAS_TYPE_EXTENSION);
+			      VINAGRE_TYPE_PROTOCOL);
 
   g_type_class_add_private (klass, sizeof (VinagrePluginsEnginePrivate));
 }
@@ -305,7 +172,7 @@ vinagre_plugins_engine_get_plugin_by_protocol (VinagrePluginsEngine *engine,
 /**
  * vinagre_plugins_engine_get_plugins_by_protocol:
  *
- * Return value: (element-type utf8 PeasExtension) (transfer none):
+ * Return value: (element-type utf8 GObject) (transfer none):
  */
 GHashTable *
 vinagre_plugins_engine_get_plugins_by_protocol (VinagrePluginsEngine *engine)
diff --git a/vinagre/vinagre-plugins-engine.h b/vinagre/vinagre-plugins-engine.h
index 812f5f9..b962a04 100644
--- a/vinagre/vinagre-plugins-engine.h
+++ b/vinagre/vinagre-plugins-engine.h
@@ -21,8 +21,8 @@
 #ifndef __VINAGRE_PLUGINS_ENGINE_H__
 #define __VINAGRE_PLUGINS_ENGINE_H__
 
-#include <glib.h>
-#include <libpeas/peas.h>
+#include <glib-object.h>
+
 #include "vinagre-protocol.h"
 
 G_BEGIN_DECLS
@@ -40,13 +40,13 @@ typedef struct _VinagrePluginsEngineClass	VinagrePluginsEngineClass;
 
 struct _VinagrePluginsEngine
 {
-  PeasEngine parent;
+  GObject parent;
   VinagrePluginsEnginePrivate *priv;
 };
 
 struct _VinagrePluginsEngineClass
 {
-  PeasEngineClass parent_class;
+  GObjectClass parent_class;
 };
 
 GType			 vinagre_plugins_engine_get_type	(void) G_GNUC_CONST;
@@ -55,6 +55,8 @@ VinagrePluginsEngine	*vinagre_plugins_engine_get_default	(void);
 VinagreProtocol		*vinagre_plugins_engine_get_plugin_by_protocol	(VinagrePluginsEngine *engine,
 									 const gchar          *protocol);
 GHashTable		*vinagre_plugins_engine_get_plugins_by_protocol	(VinagrePluginsEngine *engine);
+gboolean                 vinagre_plugins_engine_load_extension  (VinagrePluginsEngine *engine,
+                                                                 const gchar *name);
 G_END_DECLS
 
 #endif  /* __VINAGRE_PLUGINS_ENGINE_H__ */
diff --git a/vinagre/vinagre-protocol.h b/vinagre/vinagre-protocol.h
index 1c62aed..cdf2eb4 100644
--- a/vinagre/vinagre-protocol.h
+++ b/vinagre/vinagre-protocol.h
@@ -22,7 +22,6 @@
 #define __VINAGRE_PROTOCOL_H__
 
 #include <glib-object.h>
-#include <libpeas/peas.h>
 
 #include "vinagre-window.h"
 
diff --git a/vinagre/vinagre-ui.h b/vinagre/vinagre-ui.h
index 7496fa0..5308100 100644
--- a/vinagre/vinagre-ui.h
+++ b/vinagre/vinagre-ui.h
@@ -47,9 +47,6 @@ static const GtkActionEntry vinagre_always_sensitive_entries[] =
   /* Edit menu */
   { "EditPreferences", GTK_STOCK_PREFERENCES, NULL, NULL,
     N_("Edit the application preferences"), G_CALLBACK (vinagre_cmd_edit_preferences) },
-  /* TODO: Use a more appropriate icon. Libpeas uses "libpeas-plugin".  */
-  { "EditPlugins", GTK_STOCK_EXECUTE, N_("_Plugins"), NULL,
-    N_("Select active plugins"), G_CALLBACK (vinagre_cmd_edit_plugins) },
 
   /* Help menu */
   {"HelpContents", GTK_STOCK_HELP, N_("_Contents"), "F1",
diff --git a/vinagre/vinagre-window-private.h b/vinagre/vinagre-window-private.h
index 98c6201..fe610f8 100644
--- a/vinagre/vinagre-window-private.h
+++ b/vinagre/vinagre-window-private.h
@@ -21,8 +21,6 @@
 #ifndef __VINAGRE_WINDOW_PRIVATE_H__
 #define __VINAGRE_WINDOW_PRIVATE_H__
 
-#include <libpeas/peas-extension-set.h>
-
 #include "vinagre-window.h"
 #include "vinagre-notebook.h"
 
@@ -57,8 +55,6 @@ struct _VinagreWindowPrivate
   GtkWidget       *toolbar;
   GtkWidget       *menubar;
 
-  PeasExtensionSet *extensions;
-
   gint            width;
   gint            height;
   GdkWindowState  window_state;
diff --git a/vinagre/vinagre-window.c b/vinagre/vinagre-window.c
index 0e9ba89..1dd8b64 100644
--- a/vinagre/vinagre-window.c
+++ b/vinagre/vinagre-window.c
@@ -69,19 +69,6 @@ vinagre_window_dispose (GObject *object)
 {
   VinagreWindow *window = VINAGRE_WINDOW (object);
 
-  peas_engine_garbage_collect (PEAS_ENGINE (vinagre_plugins_engine_get_default ()));
-
-  if (!window->priv->dispose_has_run)
-    {
-      peas_extension_set_call (window->priv->extensions,
-			       "deactivate",
-			       window);
-
-      g_object_unref (window->priv->extensions);
-      peas_engine_garbage_collect (PEAS_ENGINE (vinagre_plugins_engine_get_default ()));
-      window->priv->dispose_has_run = TRUE;
-    }
-
   if (window->priv->manager)
     {
       g_object_unref (window->priv->manager);
@@ -97,8 +84,6 @@ vinagre_window_dispose (GObject *object)
       window->priv->update_recents_menu_ui_id = 0;
     }
 
-  peas_engine_garbage_collect (PEAS_ENGINE (vinagre_plugins_engine_get_default ()));
-
   G_OBJECT_CLASS (vinagre_window_parent_class)->dispose (object);
 }
 
@@ -801,24 +786,6 @@ vinagre_window_check_first_run (VinagreWindow *window)
 }
 
 static void
-extension_added (PeasExtensionSet *extensions,
-		 PeasPluginInfo   *info,
-		 PeasExtension    *exten,
-		 gpointer          user_data)
-{
-  peas_extension_call (exten, "activate");
-}
-
-static void
-extension_removed (PeasExtensionSet *extensions,
-		   PeasPluginInfo   *info,
-		   PeasExtension    *exten,
-		   gpointer          user_data)
-{
-  peas_extension_call (exten, "deactivate");
-}
-
-static void
 protocol_added_removed_cb (VinagrePluginsEngine *engine,
 			   VinagreProtocol      *protocol,
 			   VinagreWindow        *window)
@@ -880,19 +847,6 @@ vinagre_window_init (VinagreWindow *window)
 #endif
 
   engine = vinagre_plugins_engine_get_default ();
-  window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (engine),
-						     PEAS_TYPE_ACTIVATABLE,
-						     "object", window,
-						     NULL);
-  g_signal_connect (window->priv->extensions,
-		    "extension-added",
-		    G_CALLBACK (extension_added),
-		    window);
-  g_signal_connect (window->priv->extensions,
-		    "extension-removed",
-		    G_CALLBACK (extension_removed),
-		    window);
-  peas_extension_set_call (window->priv->extensions, "activate");
 
   g_signal_connect_after (engine,
 			  "protocol-added",



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