[vinagre] Initial test of vnc plugin



commit 7120eaffb2c9e6d323c5eeed6a4fcd8d0b665369
Author: Jonh Wendell <jwendell gnome org>
Date:   Wed Jul 8 15:00:35 2009 +0100

    Initial test of vnc plugin

 plugins/vnc/vinagre-vnc-plugin.c |   10 +++++++
 vinagre/vinagre-dirs.c           |    4 +-
 vinagre/vinagre-main.c           |   16 ++++++++++-
 vinagre/vinagre-plugin-manager.c |    2 +-
 vinagre/vinagre-plugin.c         |   47 +++++++++++++++++++++++---------
 vinagre/vinagre-plugin.h         |   56 +++++++++++++++++++-------------------
 vinagre/vinagre-plugins-engine.c |   37 +++++++++++++-----------
 vinagre/vinagre-plugins-engine.h |    2 +-
 8 files changed, 111 insertions(+), 63 deletions(-)
---
diff --git a/plugins/vnc/vinagre-vnc-plugin.c b/plugins/vnc/vinagre-vnc-plugin.c
index 910e5f4..debc532 100644
--- a/plugins/vnc/vinagre-vnc-plugin.c
+++ b/plugins/vnc/vinagre-vnc-plugin.c
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <glib/gi18n-lib.h>
 #include <gmodule.h>
+#include <vncdisplay.h>
 
 #include <vinagre/vinagre-debug.h>
 #include <vinagre/vinagre-utils.h>
@@ -56,6 +57,14 @@ impl_update_ui (VinagrePlugin *plugin,
   vinagre_debug_message (DEBUG_PLUGINS, "VinagreVncPlugin Update UI");
 }
 
+static GOptionGroup *
+impl_get_context_group (VinagrePlugin *plugin)
+{
+  vinagre_debug_message (DEBUG_PLUGINS, "VinagreVncPlugin Get Context Group");
+
+  return vnc_display_get_option_group ();
+}
+
 static void
 vinagre_vnc_plugin_init (VinagreVncPlugin *plugin)
 {
@@ -81,5 +90,6 @@ vinagre_vnc_plugin_class_init (VinagreVncPluginClass *klass)
   plugin_class->activate   = impl_activate;
   plugin_class->deactivate = impl_deactivate;
   plugin_class->update_ui  = impl_update_ui;
+  plugin_class->get_context_group = impl_get_context_group;
 }
 /* vim: set ts=8: */
diff --git a/vinagre/vinagre-dirs.c b/vinagre/vinagre-dirs.c
index 6a93747..6414909 100644
--- a/vinagre/vinagre-dirs.c
+++ b/vinagre/vinagre-dirs.c
@@ -169,7 +169,7 @@ vinagre_dirs_get_vinagre_lib_dir (void)
 
 #ifndef G_OS_WIN32
 	lib_dir = g_build_filename (LIBDIR,
-				    "vinagre",
+				    "vinagre-1",
 				    NULL);
 #else
 	gchar *win32_dir;
@@ -178,7 +178,7 @@ vinagre_dirs_get_vinagre_lib_dir (void)
 
 	lib_dir = g_build_filename (win32_dir,
 				    "lib",
-				    "vinagre",
+				    "vinagre-1",
 				    NULL);
 	
 	g_free (win32_dir);
diff --git a/vinagre/vinagre-main.c b/vinagre/vinagre-main.c
index baf43cb..78867cc 100644
--- a/vinagre/vinagre-main.c
+++ b/vinagre/vinagre-main.c
@@ -36,6 +36,8 @@
 #include "vinagre-prefs.h"
 #include "vinagre-bacon.h"
 #include "vinagre-plugins-engine.h"
+#include "vinagre-plugin-info.h"
+#include "vinagre-plugin-info-priv.h"
 
 #ifdef HAVE_TELEPATHY
 #include "vinagre-tubes-manager.h"
@@ -125,7 +127,7 @@ vinagre_main_process_command_line (VinagreWindow *window)
 int main (int argc, char **argv) {
   GOptionContext       *context;
   GError               *error = NULL;
-  GSList               *l, *next;
+  GSList               *l, *next, *plugins;
   VinagreWindow        *window;
   VinagreApp           *app;
   VinagrePluginsEngine *engine;
@@ -149,11 +151,23 @@ int main (int argc, char **argv) {
   /* Init plugins engine */
   vinagre_debug_message (DEBUG_APP, "Init plugins");
   engine = vinagre_plugins_engine_get_default ();
+  plugins = (const GSList *) vinagre_plugins_engine_get_plugin_list (engine);
 
   /* Setup command line options */
   context = g_option_context_new (_("- Remote Desktop Viewer"));
   g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
   g_option_context_add_group (context, gtk_get_option_group (TRUE));
+
+  for (l = plugins; l; l = l->next)
+    {
+      GOptionGroup      *group;
+      VinagrePluginInfo *info = VINAGRE_PLUGIN_INFO (l->data);
+
+      group = vinagre_plugin_get_context_group (info->plugin);
+      if (group)
+	g_option_context_add_group (context, group);
+    }
+
   g_option_context_parse (context, &argc, &argv, &error);
   if (error)
     {
diff --git a/vinagre/vinagre-plugin-manager.c b/vinagre/vinagre-plugin-manager.c
index 7531a50..7cab8a5 100644
--- a/vinagre/vinagre-plugin-manager.c
+++ b/vinagre/vinagre-plugin-manager.c
@@ -263,7 +263,7 @@ row_activated_cb (GtkTreeView       *tree_view,
 static void
 plugin_manager_populate_lists (VinagrePluginManager *pm)
 {
-	const GList *plugins;
+	const GSList *plugins;
 	GtkListStore *model;
 	GtkTreeIter iter;
 
diff --git a/vinagre/vinagre-plugin.c b/vinagre/vinagre-plugin.c
index 426afd5..29128e4 100644
--- a/vinagre/vinagre-plugin.c
+++ b/vinagre/vinagre-plugin.c
@@ -3,6 +3,7 @@
  * This file is part of vinagre
  *
  * Copyright (C) 2009 Jorge Pereira <jorge jorgepereira com br>
+ * Copyright (C) 2009 Jonh Wendell <wendell bani com br>
  * 
  * vinagre-plugin.c is free software: you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -48,13 +49,19 @@ G_DEFINE_TYPE(VinagrePlugin, vinagre_plugin, G_TYPE_OBJECT)
 static void
 dummy (VinagrePlugin *plugin, VinagreWindow *window)
 {
-	/* Empty */
+  /* Empty */
 }
 
 static GtkWidget *
 create_configure_dialog	(VinagrePlugin *plugin)
 {
-	return NULL;
+  return NULL;
+}
+
+static GOptionGroup *
+default_context_group (VinagrePlugin *plugin)
+{
+  return NULL;
 }
 
 static gboolean
@@ -123,6 +130,7 @@ vinagre_plugin_class_init (VinagrePluginClass *klass)
 	klass->activate = dummy;
 	klass->deactivate = dummy;
 	klass->update_ui = dummy;
+	klass->get_context_group = default_context_group;
 	
 	klass->create_configure_dialog = create_configure_dialog;
 	klass->is_configurable = is_configurable;
@@ -248,12 +256,11 @@ vinagre_plugin_get_data_dir (VinagrePlugin *plugin)
  */
 void
 vinagre_plugin_activate (VinagrePlugin *plugin,
-		       VinagreWindow *window)
+			 VinagreWindow *window)
 {
-	g_return_if_fail (VINAGRE_IS_PLUGIN (plugin));
-	g_return_if_fail (VINAGRE_IS_WINDOW (window));
+  g_return_if_fail (VINAGRE_IS_PLUGIN (plugin));
 	
-	VINAGRE_PLUGIN_GET_CLASS (plugin)->activate (plugin, window);
+  VINAGRE_PLUGIN_GET_CLASS (plugin)->activate (plugin, window);
 }
 
 /**
@@ -264,13 +271,12 @@ vinagre_plugin_activate (VinagrePlugin *plugin,
  * Deactivates the plugin.
  */
 void
-vinagre_plugin_deactivate	(VinagrePlugin *plugin,
-			 VinagreWindow *window)
+vinagre_plugin_deactivate (VinagrePlugin *plugin,
+			   VinagreWindow *window)
 {
-	g_return_if_fail (VINAGRE_IS_PLUGIN (plugin));
-	g_return_if_fail (VINAGRE_IS_WINDOW (window));
+  g_return_if_fail (VINAGRE_IS_PLUGIN (plugin));
 
-	VINAGRE_PLUGIN_GET_CLASS (plugin)->deactivate (plugin, window);
+  VINAGRE_PLUGIN_GET_CLASS (plugin)->deactivate (plugin, window);
 }
 
 /**
@@ -318,7 +324,22 @@ vinagre_plugin_is_configurable (VinagrePlugin *plugin)
 GtkWidget *
 vinagre_plugin_create_configure_dialog (VinagrePlugin *plugin)
 {
-	g_return_val_if_fail (VINAGRE_IS_PLUGIN (plugin), NULL);
+  g_return_val_if_fail (VINAGRE_IS_PLUGIN (plugin), NULL);
+	
+  return VINAGRE_PLUGIN_GET_CLASS (plugin)->create_configure_dialog (plugin);
+}
+
+/**
+ * vinagre_plugin_get_context_group
+ * @plugin: a #VinagrePlugin
+ *
+ *
+ * Returns: a context group to be used on command line, if available
+ */
+GOptionGroup *
+vinagre_plugin_get_context_group (VinagrePlugin *plugin)
+{
+  g_return_val_if_fail (VINAGRE_IS_PLUGIN (plugin), NULL);
 	
-	return VINAGRE_PLUGIN_GET_CLASS (plugin)->create_configure_dialog (plugin);
+  return VINAGRE_PLUGIN_GET_CLASS (plugin)->get_context_group (plugin);
 }
diff --git a/vinagre/vinagre-plugin.h b/vinagre/vinagre-plugin.h
index 96a658e..549cbb1 100644
--- a/vinagre/vinagre-plugin.h
+++ b/vinagre/vinagre-plugin.h
@@ -48,7 +48,7 @@ typedef struct _VinagrePlugin VinagrePlugin;
 
 struct _VinagrePlugin 
 {
-	GObject parent;
+  GObject parent;
 };
 
 /*
@@ -58,52 +58,52 @@ typedef struct _VinagrePluginClass VinagrePluginClass;
 
 struct _VinagrePluginClass 
 {
-	GObjectClass parent_class;
+  GObjectClass parent_class;
 
-	/* Virtual public methods */
-	
-	void 		(*activate)		(VinagrePlugin *plugin,
+  /* Virtual public methods */
+  void 		(*activate)			(VinagrePlugin *plugin,
 						 VinagreWindow *window);
-	void 		(*deactivate)		(VinagrePlugin *plugin,
+  void 		(*deactivate)			(VinagrePlugin *plugin,
 						 VinagreWindow *window);
 
-	void 		(*update_ui)		(VinagrePlugin *plugin,
+  void 		(*update_ui)			(VinagrePlugin *plugin,
 						 VinagreWindow *window);
 
-	GtkWidget 	*(*create_configure_dialog)
-						(VinagrePlugin *plugin);
+  GtkWidget 	*(*create_configure_dialog)	(VinagrePlugin *plugin);
 
-	/* Plugins should not override this, it's handled automatically by
-	   the VinagrePluginClass */
-	gboolean 	(*is_configurable)
-						(VinagrePlugin *plugin);
+  GOptionGroup *(*get_context_group)		(VinagrePlugin *plugin);
 
-	/* Padding for future expansion */
-	void		(*_vinagre_reserved1)	(void);
-	void		(*_vinagre_reserved2)	(void);
-	void		(*_vinagre_reserved3)	(void);
-	void		(*_vinagre_reserved4)	(void);
+  /* Plugins should not override this, it's handled automatically by
+     the VinagrePluginClass */
+  gboolean 	(*is_configurable)		(VinagrePlugin *plugin);
+
+  /* Padding for future expansion */
+  void		(*_vinagre_reserved1)		(void);
+  void		(*_vinagre_reserved2)		(void);
+  void		(*_vinagre_reserved3)		(void);
+  void		(*_vinagre_reserved4)		(void);
 };
 
 /*
  * Public methods
  */
-GType 		 vinagre_plugin_get_type 		(void) G_GNUC_CONST;
+GType 		 vinagre_plugin_get_type		(void) G_GNUC_CONST;
 
-gchar 		*vinagre_plugin_get_install_dir	(VinagrePlugin *plugin);
-gchar 		*vinagre_plugin_get_data_dir	(VinagrePlugin *plugin);
+gchar 		*vinagre_plugin_get_install_dir		(VinagrePlugin *plugin);
+gchar 		*vinagre_plugin_get_data_dir		(VinagrePlugin *plugin);
 
 void 		 vinagre_plugin_activate		(VinagrePlugin *plugin,
-						 VinagreWindow *window);
-void 		 vinagre_plugin_deactivate	(VinagrePlugin *plugin,
-						 VinagreWindow *window);
+							 VinagreWindow *window);
+void 		 vinagre_plugin_deactivate		(VinagrePlugin *plugin,
+							 VinagreWindow *window);
 				 
 void 		 vinagre_plugin_update_ui		(VinagrePlugin *plugin,
-						 VinagreWindow *window);
+							 VinagreWindow *window);
+
+gboolean	 vinagre_plugin_is_configurable		(VinagrePlugin *plugin);
+GtkWidget	*vinagre_plugin_create_configure_dialog	(VinagrePlugin *plugin);
 
-gboolean	 vinagre_plugin_is_configurable	(VinagrePlugin *plugin);
-GtkWidget	*vinagre_plugin_create_configure_dialog		
-						(VinagrePlugin *plugin);
+GOptionGroup *	 vinagre_plugin_get_context_group	(VinagrePlugin *plugin);
 
 /**
  * VINAGRE_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, CODE):
diff --git a/vinagre/vinagre-plugins-engine.c b/vinagre/vinagre-plugins-engine.c
index ec282a9..6582a10 100644
--- a/vinagre/vinagre-plugins-engine.c
+++ b/vinagre/vinagre-plugins-engine.c
@@ -61,7 +61,7 @@ G_DEFINE_TYPE(VinagrePluginsEngine, vinagre_plugins_engine, G_TYPE_OBJECT)
 
 struct _VinagrePluginsEnginePrivate
 {
-  GList *plugin_list;
+  GSList *plugin_list;
   GHashTable *loaders;
 
   gboolean activate_from_prefs;
@@ -146,7 +146,7 @@ load_plugin_info (VinagrePluginsEngine *engine,
 		return TRUE;
 	}
 
-	engine->priv->plugin_list = g_list_prepend (engine->priv->plugin_list, info);
+	engine->priv->plugin_list = g_slist_prepend (engine->priv->plugin_list, info);
 
 	vinagre_debug_message (DEBUG_PLUGINS, "Plugin %s loaded", info->name);
 	return TRUE;
@@ -259,7 +259,7 @@ add_loader (VinagrePluginsEngine *engine,
 static void
 activate_engine_plugins (VinagrePluginsEngine *engine)
 {
-  GList *item;
+  GSList *item;
 
   vinagre_debug_message (DEBUG_PLUGINS, "Activating engine plugins");
   for (item = engine->priv->plugin_list; item; item = item->next)
@@ -321,7 +321,7 @@ static void
 vinagre_plugins_engine_finalize (GObject *object)
 {
 	VinagrePluginsEngine *engine = VINAGRE_PLUGINS_ENGINE (object);
-	GList *item;
+	GSList *item;
 	
 	vinagre_debug (DEBUG_PLUGINS);
 
@@ -345,7 +345,7 @@ vinagre_plugins_engine_finalize (GObject *object)
 		_vinagre_plugin_info_unref (info);
 	}
 
-	g_list_free (engine->priv->plugin_list);
+	g_slist_free (engine->priv->plugin_list);
 
 	G_OBJECT_CLASS (vinagre_plugins_engine_parent_class)->finalize (object);
 }
@@ -508,7 +508,7 @@ vinagre_plugins_engine_get_default (void)
   return default_engine;
 }
 
-const GList *
+const GSList *
 vinagre_plugins_engine_get_plugin_list (VinagrePluginsEngine *engine)
 {
   vinagre_debug (DEBUG_PLUGINS);
@@ -526,9 +526,9 @@ VinagrePluginInfo *
 vinagre_plugins_engine_get_plugin_info (VinagrePluginsEngine *engine,
 					const gchar          *name)
 {
-  GList *l = g_list_find_custom (engine->priv->plugin_list,
-				 name,
-				 (GCompareFunc) compare_plugin_info_and_name);
+  GSList *l = g_slist_find_custom (engine->priv->plugin_list,
+				   name,
+				   (GCompareFunc) compare_plugin_info_and_name);
 
   return l == NULL ? NULL : (VinagrePluginInfo *) l->data;
 }
@@ -536,8 +536,7 @@ vinagre_plugins_engine_get_plugin_info (VinagrePluginsEngine *engine,
 static void
 save_active_plugin_list (VinagrePluginsEngine *engine)
 {
-  GSList *active_plugins = NULL;
-  GList *l;
+  GSList *l, *active_plugins = NULL;
 
   for (l = engine->priv->plugin_list; l != NULL; l = l->next)
     {
@@ -603,6 +602,12 @@ vinagre_plugins_engine_activate_plugin_real (VinagrePluginsEngine *engine,
   if (!load_plugin (engine, info))
     return;
 
+  if (vinagre_plugin_info_is_engine (info))
+    {
+      vinagre_plugin_activate (info->plugin, NULL);
+      return;
+    }
+
   /* activate plugin for all windows */
   wins = vinagre_app_get_windows (vinagre_app_get_default ());
   for (; wins != NULL; wins = wins->next)
@@ -693,8 +698,7 @@ void
 vinagre_plugins_engine_activate_plugins (VinagrePluginsEngine *engine,
 					 VinagreWindow        *window)
 {
-  GSList *active_plugins = NULL;
-  GList *pl;
+  GSList *pl, *active_plugins = NULL;
 
   vinagre_debug (DEBUG_PLUGINS);
 
@@ -745,7 +749,7 @@ void
 vinagre_plugins_engine_deactivate_plugins (VinagrePluginsEngine *engine,
                               					   VinagreWindow        *window)
 {
-	GList *pl;
+	GSList *pl;
 	
 	vinagre_debug (DEBUG_PLUGINS);
 
@@ -771,7 +775,7 @@ void
 vinagre_plugins_engine_update_plugins_ui (VinagrePluginsEngine *engine,
                                           VinagreWindow        *window)
 {
-	GList *pl;
+	GSList *pl;
 
 	vinagre_debug (DEBUG_PLUGINS);
 
@@ -827,8 +831,7 @@ void
 vinagre_plugins_engine_active_plugins_changed (VinagrePluginsEngine *engine)
 {
 	gboolean to_activate;
-	GSList *active_plugins;
-	GList *pl;
+	GSList *pl, *active_plugins;
 
 	vinagre_debug (DEBUG_PLUGINS);
 
diff --git a/vinagre/vinagre-plugins-engine.h b/vinagre/vinagre-plugins-engine.h
index 08eac1b..fd89946 100644
--- a/vinagre/vinagre-plugins-engine.h
+++ b/vinagre/vinagre-plugins-engine.h
@@ -63,7 +63,7 @@ VinagrePluginsEngine	*vinagre_plugins_engine_get_default		(void);
 
 void			 vinagre_plugins_engine_garbage_collect		(VinagrePluginsEngine *engine);
 
-const GList		*vinagre_plugins_engine_get_plugin_list 	(VinagrePluginsEngine *engine);
+const GSList		*vinagre_plugins_engine_get_plugin_list 	(VinagrePluginsEngine *engine);
 
 VinagrePluginInfo	*vinagre_plugins_engine_get_plugin_info		(VinagrePluginsEngine *engine,
 									 const gchar        *name);



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