[vinagre: 19/22] Port VNC plugin to Peas



commit 205ce2a834c76bf2eceb30d821fb535a8485bc01
Author: Jonh Wendell <jwendell gnome org>
Date:   Fri Jul 30 17:16:02 2010 +0200

    Port VNC plugin to Peas

 plugins/vnc/Makefile.am                   |    9 ++-
 plugins/vnc/vinagre-vnc-listener-dialog.c |    5 +-
 plugins/vnc/vinagre-vnc-listener-dialog.h |    3 +-
 plugins/vnc/vinagre-vnc-plugin.c          |  105 +++++++++++++++--------------
 plugins/vnc/vinagre-vnc-plugin.h          |   30 +++------
 plugins/vnc/vnc.vinagre-plugin.desktop.in |    2 -
 6 files changed, 72 insertions(+), 82 deletions(-)
---
diff --git a/plugins/vnc/Makefile.am b/plugins/vnc/Makefile.am
index e83fd5c..738c29f 100644
--- a/plugins/vnc/Makefile.am
+++ b/plugins/vnc/Makefile.am
@@ -2,10 +2,11 @@
 plugindir = $(VINAGRE_PLUGINS_LIBS_DIR)
 
 INCLUDES = \
-	-I$(top_srcdir) 				\
-	$(VNC_CFLAGS) 					\
-	$(WARN_CFLAGS)					\
-	$(DISABLE_DEPRECATED_CFLAGS)	
+	-I$(top_srcdir) 	\
+	$(VINAGRE_CFLAGS)	\
+	$(VNC_CFLAGS) 		\
+	$(WARN_CFLAGS)		\
+	$(DISABLE_DEPRECATED_CFLAGS)
 
 plugin_LTLIBRARIES = libvnc.la
 
diff --git a/plugins/vnc/vinagre-vnc-listener-dialog.c b/plugins/vnc/vinagre-vnc-listener-dialog.c
index 46fff70..98e95eb 100644
--- a/plugins/vnc/vinagre-vnc-listener-dialog.c
+++ b/plugins/vnc/vinagre-vnc-listener-dialog.c
@@ -204,13 +204,14 @@ always_enabled_toggled_cb (GtkToggleButton *button, VncListenDialog *dialog)
 }
 
 void
-vinagre_vnc_listener_dialog_show (VinagreWindow *parent, VinagrePlugin *plugin)
+vinagre_vnc_listener_dialog_show (VinagreWindow *parent/*, VinagrePlugin *plugin*/)
 {
   VncListenDialog *dialog;
   GtkBuilder *xml;
   gboolean always;
 
-  xml = vinagre_utils_get_builder (plugin, "vnc.ui");
+  //xml = vinagre_utils_get_builder (plugin, "vnc.ui");
+  xml = NULL;
   if (!xml)
     return;
 
diff --git a/plugins/vnc/vinagre-vnc-listener-dialog.h b/plugins/vnc/vinagre-vnc-listener-dialog.h
index 8c6a8d2..932d680 100644
--- a/plugins/vnc/vinagre-vnc-listener-dialog.h
+++ b/plugins/vnc/vinagre-vnc-listener-dialog.h
@@ -22,11 +22,10 @@
 #define __VINAGRE_VNC_LISTENER_DIALOG_H__
 
 #include <vinagre/vinagre-window.h>
-#include <vinagre/vinagre-plugin.h>
 
 G_BEGIN_DECLS
 
-void vinagre_vnc_listener_dialog_show (VinagreWindow *parent, VinagrePlugin *plugin);
+void vinagre_vnc_listener_dialog_show (VinagreWindow *parent/*, VinagrePlugin *plugin*/);
 
 G_END_DECLS
 
diff --git a/plugins/vnc/vinagre-vnc-plugin.c b/plugins/vnc/vinagre-vnc-plugin.c
index 11e62e0..5375647 100644
--- a/plugins/vnc/vinagre-vnc-plugin.c
+++ b/plugins/vnc/vinagre-vnc-plugin.c
@@ -27,9 +27,9 @@
 #include <gmodule.h>
 #include <vncdisplay.h>
 
-#include <vinagre/vinagre-debug.h>
 #include <vinagre/vinagre-prefs.h>
 #include <vinagre/vinagre-cache-prefs.h>
+#include <vinagre/vinagre-protocol.h>
 
 #include "vinagre-vnc-plugin.h"
 #include "vinagre-vnc-connection.h"
@@ -37,10 +37,15 @@
 #include "vinagre-vnc-listener-dialog.h"
 #include "vinagre-vnc-listener.h"
 
-#define VINAGRE_VNC_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), VINAGRE_TYPE_VNC_PLUGIN, VinagreVncPluginPrivate))
 #define WINDOW_DATA_KEY "VinagreVNCPluginWindowData"
 
-VINAGRE_PLUGIN_REGISTER_TYPE(VinagreVncPlugin, vinagre_vnc_plugin)
+static void vinagre_protocol_iface_init (VinagreProtocolInterface *iface);
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (VinagreVncPlugin,
+				vinagre_vnc_plugin,
+				PEAS_TYPE_EXTENSION_BASE,
+				0,
+				G_IMPLEMENT_INTERFACE_DYNAMIC (VINAGRE_TYPE_PROTOCOL,
+							       vinagre_protocol_iface_init))
 
 typedef struct
 {
@@ -50,10 +55,11 @@ typedef struct
 
 typedef struct
 {
-  VinagrePlugin *plugin;
+  VinagreProtocol *plugin;
   VinagreWindow *window;
 } ActionData;
 
+/*
 static void
 free_window_data (WindowData *data)
 {
@@ -70,11 +76,12 @@ free_action_data (ActionData *data)
 
   g_slice_free (ActionData, data);
 }
+*/
 
 static void
 listening_cb (GtkAction *action, ActionData *action_data)
 {
-  vinagre_vnc_listener_dialog_show (action_data->window, action_data->plugin);
+  vinagre_vnc_listener_dialog_show (action_data->window/*, action_data->plugin*/);
 }
 
 static GtkActionEntry action_entries[] =
@@ -89,8 +96,9 @@ static GtkActionEntry action_entries[] =
   }
 };
 
+/*
 static void
-impl_activate (VinagrePlugin *plugin,
+impl_activate (VinagreProtocol *plugin,
                VinagreWindow *window)
 {
   GtkActionGroup *action_group;
@@ -142,7 +150,7 @@ impl_activate (VinagrePlugin *plugin,
 }
 
 static void
-impl_deactivate  (VinagrePlugin *plugin,
+impl_deactivate  (VinagreProtocol *plugin,
                   VinagreWindow *window)
 {
   GtkUIManager *manager;
@@ -159,13 +167,7 @@ impl_deactivate  (VinagrePlugin *plugin,
 
   g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
 }
-
-static void
-impl_update_ui (VinagrePlugin *plugin,
-                VinagreWindow *window)
-{
-  vinagre_debug_message (DEBUG_PLUGINS, "VinagreVncPlugin Update UI");
-}
+*/
 
 static const GOptionEntry vinagre_vnc_args[] =
 {
@@ -176,13 +178,11 @@ static const GOptionEntry vinagre_vnc_args[] =
 };
 
 static GSList *
-impl_get_context_groups (VinagrePlugin *plugin)
+impl_get_context_groups (VinagreProtocol *plugin)
 {
   GOptionGroup *group;
   GSList       *groups = NULL;
 
-  vinagre_debug_message (DEBUG_PLUGINS, "VinagreVncPlugin Get Context Group");
-
   scaling_command_line = FALSE;
   group = g_option_group_new ("vnc",
 			      /* Translators: this is a command line option (run vinagre --help) */
@@ -200,13 +200,13 @@ impl_get_context_groups (VinagrePlugin *plugin)
 }
 
 static const gchar *
-impl_get_protocol (VinagrePlugin *plugin)
+impl_get_protocol (VinagreProtocol *plugin)
 {
   return "vnc";
 }
 
 static gchar **
-impl_get_public_description (VinagrePlugin *plugin)
+impl_get_public_description (VinagreProtocol *plugin)
 {
   gchar **result = g_new (gchar *, 3);
 
@@ -218,13 +218,13 @@ impl_get_public_description (VinagrePlugin *plugin)
 }
 
 static const gchar *
-impl_get_mdns_service (VinagrePlugin *plugin)
+impl_get_mdns_service (VinagreProtocol *plugin)
 {
   return "_rfb._tcp";
 }
 
 static VinagreConnection *
-impl_new_connection (VinagrePlugin *plugin)
+impl_new_connection (VinagreProtocol *plugin)
 {
   VinagreConnection *conn;
 
@@ -236,7 +236,7 @@ impl_new_connection (VinagrePlugin *plugin)
 }
 
 static VinagreConnection *
-impl_new_connection_from_file (VinagrePlugin *plugin,
+impl_new_connection_from_file (VinagreProtocol *plugin,
 			       const gchar   *data,
 			       gboolean       use_bookmarks,
 			       gchar        **error_msg)
@@ -335,7 +335,7 @@ the_end:
 }
 
 static GtkWidget *
-impl_new_tab (VinagrePlugin *plugin,
+impl_new_tab (VinagreProtocol *plugin,
 	      VinagreConnection *conn,
 	      VinagreWindow     *window)
 {
@@ -366,7 +366,7 @@ scaling_check_toggled_cb (GtkToggleButton *button, GObject *box)
 }
 
 static GtkWidget *
-impl_get_connect_widget (VinagrePlugin *plugin, VinagreConnection *conn)
+impl_get_connect_widget (VinagreProtocol *plugin, VinagreConnection *conn)
 {
   GtkWidget *box, *check, *label, *combo, *box2, *ssh_host_entry;
   GtkTable  *table;
@@ -494,13 +494,13 @@ impl_get_connect_widget (VinagrePlugin *plugin, VinagreConnection *conn)
 }
 
 static gint
-impl_get_default_port (VinagrePlugin *plugin)
+impl_get_default_port (VinagreProtocol *plugin)
 {
   return 5900;
 }
 
 static GtkFileFilter *
-impl_get_file_filter (VinagrePlugin *plugin)
+impl_get_file_filter (VinagreProtocol *plugin)
 {
   GtkFileFilter *filter;
 
@@ -513,39 +513,42 @@ impl_get_file_filter (VinagrePlugin *plugin)
 }
 
 static void
+vinagre_vnc_plugin_class_init (VinagreVncPluginClass *klass)
+{
+}
+static void
+vinagre_vnc_plugin_class_finalize (VinagreVncPluginClass *klass)
+{
+}
+static void
 vinagre_vnc_plugin_init (VinagreVncPlugin *plugin)
 {
-  vinagre_debug_message (DEBUG_PLUGINS, "VinagreVncPlugin initializing");
 }
 
 static void
-vinagre_vnc_plugin_finalize (GObject *object)
+vinagre_protocol_iface_init (VinagreProtocolInterface *iface)
 {
-  vinagre_debug_message (DEBUG_PLUGINS, "VinagreVncPlugin finalizing");
-
-  G_OBJECT_CLASS (vinagre_vnc_plugin_parent_class)->finalize (object);
+  //iface->activate   = impl_activate;
+  //iface->deactivate = impl_deactivate;
+  iface->get_context_groups = impl_get_context_groups;
+  iface->get_protocol  = impl_get_protocol;
+  iface->get_public_description  = impl_get_public_description;
+  iface->new_connection = impl_new_connection;
+  iface->new_connection_from_file = impl_new_connection_from_file;
+  iface->get_mdns_service  = impl_get_mdns_service;
+  iface->new_tab = impl_new_tab;
+  iface->get_connect_widget = impl_get_connect_widget;
+  iface->get_default_port = impl_get_default_port;
+  iface->get_file_filter = impl_get_file_filter;
 }
 
-static void
-vinagre_vnc_plugin_class_init (VinagreVncPluginClass *klass)
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
 {
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-  VinagrePluginClass *plugin_class = VINAGRE_PLUGIN_CLASS (klass);
-
-  object_class->finalize   = vinagre_vnc_plugin_finalize;
-
-  plugin_class->activate   = impl_activate;
-  plugin_class->deactivate = impl_deactivate;
-  plugin_class->update_ui  = impl_update_ui;
-  plugin_class->get_context_groups = impl_get_context_groups;
-  plugin_class->get_protocol  = impl_get_protocol;
-  plugin_class->get_public_description  = impl_get_public_description;
-  plugin_class->new_connection = impl_new_connection;
-  plugin_class->new_connection_from_file = impl_new_connection_from_file;
-  plugin_class->get_mdns_service  = impl_get_mdns_service;
-  plugin_class->new_tab = impl_new_tab;
-  plugin_class->get_connect_widget = impl_get_connect_widget;
-  plugin_class->get_default_port = impl_get_default_port;
-  plugin_class->get_file_filter = impl_get_file_filter;
+  vinagre_vnc_plugin_register_type (G_TYPE_MODULE (module));
+  peas_object_module_register_extension_type (module,
+					      VINAGRE_TYPE_PROTOCOL,
+					      VINAGRE_TYPE_VNC_PLUGIN);
 }
+
 /* vim: set ts=8: */
diff --git a/plugins/vnc/vinagre-vnc-plugin.h b/plugins/vnc/vinagre-vnc-plugin.h
index ac0d5ff..2ceaf45 100644
--- a/plugins/vnc/vinagre-vnc-plugin.h
+++ b/plugins/vnc/vinagre-vnc-plugin.h
@@ -3,6 +3,7 @@
  * This file is part of vinagre
  *
  * Copyright (C) 2009 Jorge Pereira <jorge jorgepereira com br>
+ * Copyright (C) 2010 Jonh Wendell <wendell bani com br>
  * 
  * vinagre-vnc-plugin.h is free software: you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -23,7 +24,7 @@
 
 #include <glib.h>
 #include <glib-object.h>
-#include <vinagre/vinagre-plugin.h>
+#include <libpeas/peas.h>
 
 G_BEGIN_DECLS
 
@@ -37,38 +38,25 @@ G_BEGIN_DECLS
 #define VINAGRE_IS_VNC_PLUGIN_CLASS(k)          (G_TYPE_CHECK_CLASS_TYPE ((k), VINAGRE_TYPE_VNC_PLUGIN))
 #define VINAGRE_VNC_PLUGIN_GET_CLASS(o)         (G_TYPE_INSTANCE_GET_CLASS ((o), VINAGRE_TYPE_VNC_PLUGIN, VinagreVncPluginClass))
 
-/* Private structure type */
-typedef struct _VinagreVncPluginPrivate	VinagreVncPluginPrivate;
-
-/*
- * Main object structure
- */
-typedef struct _VinagreVncPlugin		VinagreVncPlugin;
+typedef struct _VinagreVncPlugin	VinagreVncPlugin;
+typedef struct _VinagreVncPluginClass	VinagreVncPluginClass;
 
 struct _VinagreVncPlugin
 {
-  VinagrePlugin parent_instance;
+  PeasExtensionBase parent_instance;
 };
 
-/*
- * Class definition
- */
-typedef struct _VinagreVncPluginClass	VinagreVncPluginClass;
-
 struct _VinagreVncPluginClass
 {
-  VinagrePluginClass parent_class;
+  PeasExtensionBaseClass parent_class;
 };
 
-/*
- * Public methods
- */
-GType	vinagre_vnc_plugin_get_type		(void) G_GNUC_CONST;
+GType vinagre_vnc_plugin_get_type (void) G_GNUC_CONST;
 
-/* All the plugins must implement this function */
-G_MODULE_EXPORT GType register_vinagre_plugin (GTypeModule *module);
+G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
 
 G_END_DECLS
 
 #endif /* __VINAGRE_VNC_PLUGIN_H__ */
+
 /* vim: set ts=8: */
diff --git a/plugins/vnc/vnc.vinagre-plugin.desktop.in b/plugins/vnc/vnc.vinagre-plugin.desktop.in
index af5074f..e5712ca 100644
--- a/plugins/vnc/vnc.vinagre-plugin.desktop.in
+++ b/plugins/vnc/vnc.vinagre-plugin.desktop.in
@@ -7,5 +7,3 @@ Authors=Jonh Wendell
 Copyright=Copyright © 2009 Jonh Wendell
 Website=http://www.bani.com.br
 Version=1.0
-Engine=1
-Icon=vinagre



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