[vinagre] Make the Connect dialog work based on plugins.



commit 5bdc7724b98d189333e98a7ce799b1eb96849f81
Author: Jonh Wendell <jwendell gnome org>
Date:   Wed Jul 22 16:54:42 2009 -0300

    Make the Connect dialog work based on plugins.
    
    Now there is a "Protocol" combobox, based on active plugins. Also,
    there is a custom "options" widget, per plugin.

 data/vinagre.glade           |  125 +++++++++++++++++-----------
 vinagre/vinagre-connect.c    |  186 +++++++++++++++++++++++++++++++++++++++---
 vinagre/vinagre-connection.c |   22 ++++--
 vinagre/vinagre-connection.h |    4 +
 vinagre/vinagre-plugin.c     |   40 +++++++++
 vinagre/vinagre-plugin.h     |    6 ++
 6 files changed, 314 insertions(+), 69 deletions(-)
---
diff --git a/data/vinagre.glade b/data/vinagre.glade
index 7894dbb..5aee924 100644
--- a/data/vinagre.glade
+++ b/data/vinagre.glade
@@ -34,6 +34,7 @@
           <widget class="GtkTable" id="table1">
             <property name="visible">True</property>
             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+            <property name="n_rows">2</property>
             <property name="n_columns">4</property>
             <property name="column_spacing">6</property>
             <property name="row_spacing">6</property>
@@ -50,12 +51,14 @@
               <packing>
                 <property name="left_attach">3</property>
                 <property name="right_attach">4</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
                 <property name="x_options"></property>
                 <property name="y_options"></property>
               </packing>
             </child>
             <child>
-              <widget class="GtkLabel" id="label3">
+              <widget class="GtkLabel" id="host_label">
                 <property name="visible">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                 <property name="label" translatable="yes">_Host:</property>
@@ -65,6 +68,8 @@
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
                 <property name="x_options"></property>
                 <property name="y_options"></property>
               </packing>
@@ -89,9 +94,55 @@
               <packing>
                 <property name="left_attach">2</property>
                 <property name="right_attach">3</property>
+                <property name="top_attach">1</property>
+                <property name="bottom_attach">2</property>
                 <property name="y_options"></property>
               </packing>
             </child>
+            <child>
+              <widget class="GtkLabel" id="protocol_label">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">_Protocol:</property>
+                <property name="use_markup">True</property>
+                <property name="use_underline">True</property>
+                <property name="mnemonic_widget">protocol_combo</property>
+              </widget>
+              <packing>
+                <property name="left_attach">1</property>
+                <property name="right_attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkHBox" id="hbox1">
+                <property name="visible">True</property>
+                <child>
+                  <widget class="GtkComboBox" id="protocol_combo">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="protocol_description_label">
+                    <property name="visible">True</property>
+                    <property name="xalign">0</property>
+                    <property name="xpad">5</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="left_attach">2</property>
+                <property name="right_attach">4</property>
+              </packing>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="padding">4</property>
@@ -114,21 +165,18 @@
           </packing>
         </child>
         <child>
-          <widget class="GtkTable" id="table4">
+          <widget class="GtkHBox" id="hbox2">
             <property name="visible">True</property>
-            <property name="n_rows">3</property>
-            <property name="n_columns">2</property>
-            <property name="column_spacing">6</property>
-            <property name="row_spacing">2</property>
             <child>
-              <widget class="GtkLabel" id="label6">
+              <widget class="GtkLabel" id="label3">
                 <property name="visible">True</property>
                 <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
                 <property name="label">  </property>
               </widget>
               <packing>
-                <property name="x_options"></property>
-                <property name="y_options"></property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
@@ -141,48 +189,9 @@
                 <property name="draw_indicator">True</property>
               </widget>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkCheckButton" id="viewonly_check">
-                <property name="label" translatable="yes">_View only</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-              </widget>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="GtkCheckButton" id="scaling_check">
-                <property name="label" translatable="yes">_Scaling</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-              </widget>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
+                <property name="position">1</property>
               </packing>
             </child>
-            <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
-            </child>
           </widget>
           <packing>
             <property name="position">5</property>
@@ -204,6 +213,8 @@
                 <property name="use_stock">True</property>
               </widget>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -220,6 +231,8 @@
                 <property name="use_stock">True</property>
               </widget>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">1</property>
               </packing>
             </child>
@@ -441,6 +454,8 @@
                 <property name="use_stock">True</property>
               </widget>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -458,6 +473,8 @@
                 <property name="use_underline">True</property>
               </widget>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">1</property>
               </packing>
             </child>
@@ -738,6 +755,8 @@
                 <property name="use_stock">True</property>
               </widget>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -754,6 +773,8 @@
                 <property name="use_stock">True</property>
               </widget>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">1</property>
               </packing>
             </child>
@@ -880,6 +901,8 @@
                 <property name="use_stock">True</property>
               </widget>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -1031,6 +1054,8 @@
                 <property name="use_stock">True</property>
               </widget>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">0</property>
               </packing>
             </child>
@@ -1047,6 +1072,8 @@
                 <property name="use_stock">True</property>
               </widget>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">1</property>
               </packing>
             </child>
diff --git a/vinagre/vinagre-connect.c b/vinagre/vinagre-connect.c
index 912a505..234b842 100644
--- a/vinagre/vinagre-connect.c
+++ b/vinagre/vinagre-connect.c
@@ -36,15 +36,18 @@
 #include "vinagre-utils.h"
 #include "vinagre-bookmarks.h"
 #include "vinagre-prefs.h"
+#include "vinagre-plugins-engine.h"
+#include "vinagre-plugin.h"
 
 typedef struct {
   GladeXML  *xml;
   GtkWidget *dialog;
+  GtkWidget *protocol_combo;
+  GtkWidget *protocol_description_label;
+  GtkListStore *protocol_store;
   GtkWidget *host_entry;
   GtkWidget *find_button;
   GtkWidget *fullscreen_check;
-  GtkWidget *scaling_check;
-  GtkWidget *viewonly_check;
 } VinagreConnectDialog;
 
 enum {
@@ -52,6 +55,15 @@ enum {
   N_COLUMNS
 };
 
+enum {
+  PROTOCOL_NAME,
+  PROTOCOL_DESCRIPTION,
+  PROTOCOL_MDNS,
+  PROTOCOL_OPTIONS,
+  PROTOCOL_PLUGIN,
+  N_PROTOCOLS
+};
+
 static gchar*
 history_filename () {
   return g_build_filename (g_get_user_data_dir (),
@@ -60,6 +72,109 @@ history_filename () {
 			   NULL);
 }
 
+static void
+protocol_combo_changed (GtkComboBox *combo, VinagreConnectDialog *dialog)
+{
+  GtkTreeIter tree_iter;
+  gchar       *description, *label, *service;
+  GtkWidget   *options, *vbox;
+
+  if (!gtk_combo_box_get_active_iter (combo, &tree_iter))
+    {
+      g_warning (_("Could not get the active protocol in the protocol list."));
+      return;
+    }
+
+  gtk_tree_model_get (GTK_TREE_MODEL (dialog->protocol_store), &tree_iter,
+		      PROTOCOL_DESCRIPTION, &description,
+		      PROTOCOL_MDNS, &service,
+		      PROTOCOL_OPTIONS, &options,
+		      -1);
+
+  label = g_strdup_printf ("<i><small>%s</small></i>", description);
+  gtk_label_set_markup (GTK_LABEL (dialog->protocol_description_label),
+			label);
+
+#ifdef VINAGRE_ENABLE_AVAHI
+  if (service)
+    gtk_widget_show (dialog->find_button);
+  else
+    gtk_widget_hide (dialog->find_button);
+#endif
+
+  vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog->dialog));
+  if (options)
+    {
+      gtk_box_pack_end (GTK_BOX (vbox), options, TRUE, TRUE, 0);
+      g_object_unref (options);
+    }
+
+  g_free (label);
+  g_free (description);
+  g_free (service);
+}
+
+static void
+setup_protocol (VinagreConnectDialog *dialog)
+{
+  GHashTable      *plugins;
+  GHashTableIter  hash_iter;
+  gpointer        key, value;
+  GtkTreeIter     tree_iter;
+  GtkCellRenderer *rend;
+  gchar           *last_protocol;
+  gint            selected, i;
+
+  dialog->protocol_store = gtk_list_store_new (N_PROTOCOLS, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_OBJECT, G_TYPE_OBJECT);
+  plugins = vinagre_plugin_engine_get_plugins_by_protocol (vinagre_plugins_engine_get_default ());
+  g_object_get (vinagre_prefs_get_default (), "last-protocol", &last_protocol, NULL);
+
+  g_hash_table_iter_init (&hash_iter, plugins);
+  selected = 0;
+  i = 0;
+  while (g_hash_table_iter_next (&hash_iter, &key, &value)) 
+    {
+      gchar         **description;
+      VinagrePlugin *plugin = VINAGRE_PLUGIN (value);
+      GtkWidget     *widget;
+
+      description = vinagre_plugin_get_public_description (plugin);
+      if (!description || !description[0])
+	continue;
+
+      widget = vinagre_plugin_get_connect_widget (plugin);
+
+      gtk_list_store_append (dialog->protocol_store, &tree_iter);
+      gtk_list_store_set (dialog->protocol_store, &tree_iter,
+			  PROTOCOL_NAME, description[0],
+			  PROTOCOL_DESCRIPTION, description[1],
+			  PROTOCOL_MDNS, vinagre_plugin_get_mdns_service (plugin),
+			  PROTOCOL_OPTIONS, widget,
+			  PROTOCOL_PLUGIN, plugin,
+			  -1);
+
+      if (last_protocol && g_str_equal (last_protocol, description[0]))
+        selected = i;
+
+      g_strfreev (description);
+      g_object_unref (widget);
+      i++;
+    }
+
+  gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->protocol_combo),
+			   GTK_TREE_MODEL (dialog->protocol_store));
+  rend = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (dialog->protocol_combo), rend, TRUE);
+  gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (dialog->protocol_combo), rend, "text", 0);
+
+  g_signal_connect (dialog->protocol_combo,
+		    "changed",
+		    G_CALLBACK (protocol_combo_changed),
+		    dialog);
+  gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->protocol_combo), selected);
+  g_free (last_protocol);
+}
+
 static GPtrArray *
 saved_history (void)
 {
@@ -138,7 +253,7 @@ setup_combo (GtkWidget *combo)
   gtk_entry_set_activates_default (GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo))), TRUE);
 }
 
-void
+static void
 save_history (GtkWidget *combo) {
   gchar *host;
   GPtrArray *history;
@@ -188,9 +303,24 @@ static void
 vinagre_connect_find_button_cb (GtkButton            *button,
 				VinagreConnectDialog *dialog)
 {
-  GtkWidget *d;
+  GtkWidget   *d;
+  GtkTreeIter tree_iter;
+  gchar       *service;
+
+  if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->protocol_combo),
+				      &tree_iter))
+    {
+      g_warning (_("Could not get the active protocol in the protocol list."));
+      return;
+    }
 
-  d = aui_service_dialog_new (_("Choose a VNC Server"),
+  gtk_tree_model_get (GTK_TREE_MODEL (dialog->protocol_store), &tree_iter,
+		      PROTOCOL_MDNS, &service,
+		      -1);
+  if (!service)
+    return;
+
+  d = aui_service_dialog_new (_("Choose a Remote Desktop"),
 				GTK_WINDOW(dialog->dialog),
 				GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 				GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
@@ -199,7 +329,7 @@ vinagre_connect_find_button_cb (GtkButton            *button,
   aui_service_dialog_set_resolve_service (AUI_SERVICE_DIALOG(d), TRUE);
   aui_service_dialog_set_resolve_host_name (AUI_SERVICE_DIALOG(d), TRUE);
   aui_service_dialog_set_browse_service_types (AUI_SERVICE_DIALOG(d),
-					       "_rfb._tcp",
+					       service,
 					       NULL);
 
   if (gtk_dialog_run(GTK_DIALOG(d)) == GTK_RESPONSE_ACCEPT)
@@ -216,6 +346,7 @@ vinagre_connect_find_button_cb (GtkButton            *button,
       g_free (tmp);
     }
 
+  g_free (service);
   gtk_widget_destroy (d);
 }
 #endif
@@ -230,12 +361,13 @@ VinagreConnection *vinagre_connect (VinagreWindow *window)
   dialog.dialog = glade_xml_get_widget (dialog.xml, "connect_dialog");
   gtk_window_set_transient_for (GTK_WINDOW (dialog.dialog), GTK_WINDOW (window));
 
+  dialog.protocol_combo = glade_xml_get_widget (dialog.xml, "protocol_combo");
+  dialog.protocol_description_label = glade_xml_get_widget (dialog.xml, "protocol_description_label");
   dialog.host_entry  = glade_xml_get_widget (dialog.xml, "host_entry");
   dialog.find_button = glade_xml_get_widget (dialog.xml, "find_button");
   dialog.fullscreen_check = glade_xml_get_widget (dialog.xml, "fullscreen_check");
-  dialog.viewonly_check = glade_xml_get_widget (dialog.xml, "viewonly_check");
-  dialog.scaling_check = glade_xml_get_widget (dialog.xml, "scaling_check");
 
+  setup_protocol (&dialog);
   setup_combo (dialog.host_entry);
 
 #ifdef VINAGRE_ENABLE_AVAHI
@@ -253,7 +385,11 @@ VinagreConnection *vinagre_connect (VinagreWindow *window)
 
   if (result == GTK_RESPONSE_OK)
     {
-      gchar *host = NULL, *error_msg = NULL;
+      gchar         *host = NULL, *error_msg = NULL, *protocol = NULL, *actual_host;
+      gint          port;
+      VinagrePlugin *plugin;
+      GtkWidget     *options;
+      GtkTreeIter   iter;
 
       host = gtk_combo_box_get_active_text (GTK_COMBO_BOX (dialog.host_entry));
       gtk_widget_hide (GTK_WIDGET (dialog.dialog));
@@ -263,20 +399,44 @@ VinagreConnection *vinagre_connect (VinagreWindow *window)
 
       save_history (dialog.host_entry);
 
-      conn = vinagre_connection_new_from_string (host, &error_msg, TRUE);
-      if (conn)
+      if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog.protocol_combo), &iter))
+	{
+	  g_warning (_("Could not get the active protocol in the protocol list."));
+	  goto fail;
+	}
+
+      gtk_tree_model_get (GTK_TREE_MODEL (dialog.protocol_store), &iter,
+			  PROTOCOL_NAME, &protocol,
+			  PROTOCOL_OPTIONS, &options,
+			  PROTOCOL_PLUGIN, &plugin,
+		      -1);
+
+      g_object_set (vinagre_prefs_get_default (), "last-protocol", protocol, NULL);
+      g_free (protocol);
+
+      conn = vinagre_plugin_new_connection (plugin);
+      if (vinagre_connection_split_string (host, &protocol, &actual_host, &port, &error_msg))
 	{
 	  g_object_set (conn,
-			"scaling", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog.scaling_check)),
-			"view-only", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog.viewonly_check)),
+			"host", actual_host,
+			"port", port,
 			"fullscreen", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog.fullscreen_check)),
 			NULL);
+
+	  vinagre_connection_parse_options_widget (conn, options);
+
+	  g_free (protocol);
+	  g_free (actual_host);
 	}
       else
 	{
 	  vinagre_utils_show_error (NULL, error_msg ? error_msg : _("Unknown error"),
 				    GTK_WINDOW (window));
 	}
+
+      g_object_unref (plugin);
+      g_object_unref (options);
+
 fail:
       g_free (host);
       g_free (error_msg);
diff --git a/vinagre/vinagre-connection.c b/vinagre/vinagre-connection.c
index 550bd5f..1daa392 100644
--- a/vinagre/vinagre-connection.c
+++ b/vinagre/vinagre-connection.c
@@ -214,11 +214,6 @@ default_parse_item (VinagreConnection *conn, xmlNode *root)
 
       xmlFree (s_value);
     }
-
-// TODO:
-//  if (conn->priv->port <= 0)
-//    vinagre_connection_set_port (conn, vinagre_connection_default_port [conn->priv->protocol-1]);
-
 }
 
 static gchar *
@@ -234,6 +229,11 @@ default_get_best_name (VinagreConnection *conn)
 }
 
 static void
+default_parse_options_widget (VinagreConnection *conn, GtkWidget *widget)
+{
+}
+
+static void
 vinagre_connection_class_init (VinagreConnectionClass *klass)
 {
   GObjectClass* object_class = G_OBJECT_CLASS (klass);
@@ -248,6 +248,7 @@ vinagre_connection_class_init (VinagreConnectionClass *klass)
   klass->impl_parse_item = default_parse_item;
   klass->impl_get_best_name = default_get_best_name;
   klass->impl_fill_conn_from_file = NULL;
+  klass->impl_parse_options_widget = default_parse_options_widget;
 
   g_object_class_install_property (object_class,
                                    PROP_PROTOCOL,
@@ -707,14 +708,14 @@ vinagre_connection_get_string_rep (VinagreConnection *conn,
 
 void
 vinagre_connection_fill_writer (VinagreConnection *conn,
-				xmlTextWriter *writer)
+				xmlTextWriter     *writer)
 {
   VINAGRE_CONNECTION_GET_CLASS (conn)->impl_fill_writer (conn, writer);
 }
 
 void
 vinagre_connection_parse_item (VinagreConnection *conn,
-			       xmlNode *root)
+			       xmlNode           *root)
 {
   VINAGRE_CONNECTION_GET_CLASS (conn)->impl_parse_item (conn, root);
 }
@@ -724,4 +725,11 @@ vinagre_connection_get_best_name (VinagreConnection *conn)
 {
   return VINAGRE_CONNECTION_GET_CLASS (conn)->impl_get_best_name (conn);
 }
+
+void
+vinagre_connection_parse_options_widget (VinagreConnection *conn,
+					 GtkWidget         *widget)
+{
+  VINAGRE_CONNECTION_GET_CLASS (conn)->impl_parse_options_widget (conn, widget);
+}
 /* vim: set ts=8: */
diff --git a/vinagre/vinagre-connection.h b/vinagre/vinagre-connection.h
index 765f852..26cd0c4 100644
--- a/vinagre/vinagre-connection.h
+++ b/vinagre/vinagre-connection.h
@@ -23,6 +23,7 @@
 #define __VINAGRE_CONNECTION_H__
 
 #include <glib.h>
+#include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 #include <libxml/xmlwriter.h>
 
@@ -48,6 +49,7 @@ struct _VinagreConnectionClass
   void		(*impl_parse_item)		(VinagreConnection *conn, xmlNode *root);
   gchar *	(*impl_get_best_name)		(VinagreConnection *conn);
   void		(*impl_fill_conn_from_file)	(VinagreConnection *conn, GKeyFile *file);
+  void		(*impl_parse_options_widget)	(VinagreConnection *conn, GtkWidget *widget);
 };
 
 struct _VinagreConnection
@@ -115,6 +117,8 @@ void                vinagre_connection_parse_item	(VinagreConnection *conn,
 
 gchar*		    vinagre_connection_get_best_name    (VinagreConnection *conn);
 
+void                vinagre_connection_parse_options_widget (VinagreConnection *conn, GtkWidget *widget);
+
 G_END_DECLS
 
 #endif /* __VINAGRE_CONNECTION_H__  */
diff --git a/vinagre/vinagre-plugin.c b/vinagre/vinagre-plugin.c
index 776bc1e..460e813 100644
--- a/vinagre/vinagre-plugin.c
+++ b/vinagre/vinagre-plugin.c
@@ -70,6 +70,12 @@ default_get_protocol (VinagrePlugin *plugin)
   return NULL;
 }
 
+static gchar **
+default_get_public_description (VinagrePlugin *plugin)
+{
+  return NULL;
+}
+
 static VinagreConnection *
 default_new_connection (VinagrePlugin *plugin)
 {
@@ -167,11 +173,13 @@ vinagre_plugin_class_init (VinagrePluginClass *klass)
 	klass->update_ui = dummy;
 	klass->get_context_group = default_context_group;
 	klass->get_protocol = default_get_protocol;
+	klass->get_public_description = default_get_public_description;
 	klass->get_default_port = default_get_default_port;
 	klass->new_connection = default_new_connection;
 	klass->new_connection_from_file = default_new_connection_from_file;
 	klass->get_mdns_service = default_get_protocol;
 	klass->new_tab = default_new_tab;
+	klass->get_connect_widget = create_configure_dialog;
 	
 	klass->create_configure_dialog = create_configure_dialog;
 	klass->is_configurable = is_configurable;
@@ -401,6 +409,23 @@ vinagre_plugin_get_protocol (VinagrePlugin *plugin)
 }
 
 /**
+ * vinagre_plugin_get_public_description
+ * @plugin: a #VinagrePlugin
+ *
+ *
+ * Returns: an array of strings:
+ * [0] -> the protocol name, like VNC, or SSH
+ * [1] -> the protocol description, like "A secure shell access"
+ */
+gchar **
+vinagre_plugin_get_public_description (VinagrePlugin *plugin)
+{
+  g_return_val_if_fail (VINAGRE_IS_PLUGIN (plugin), NULL);
+	
+  return VINAGRE_PLUGIN_GET_CLASS (plugin)->get_public_description (plugin);
+}
+
+/**
  * vinagre_plugin_new_connection
  * @plugin: a #VinagrePlugin
  *
@@ -480,4 +505,19 @@ vinagre_plugin_new_tab (VinagrePlugin     *plugin,
   return VINAGRE_PLUGIN_GET_CLASS (plugin)->new_tab (plugin, conn, window);
 }
 
+/**
+ * vinagre_plugin_get_connect_widget
+ * @plugin: a #VinagreTab
+ *
+ *
+ * Returns: a widget to be put inside connect dialog
+ */
+GtkWidget *
+vinagre_plugin_get_connect_widget (VinagrePlugin *plugin)
+{
+  g_return_val_if_fail (VINAGRE_IS_PLUGIN (plugin), NULL);
+
+  return VINAGRE_PLUGIN_GET_CLASS (plugin)->get_connect_widget (plugin);
+}
+
 /* vim: set ts=8: */
diff --git a/vinagre/vinagre-plugin.h b/vinagre/vinagre-plugin.h
index 5badbbb..5e78174 100644
--- a/vinagre/vinagre-plugin.h
+++ b/vinagre/vinagre-plugin.h
@@ -75,6 +75,7 @@ struct _VinagrePluginClass
   /* Virtual methods specific to 'engine' plugins */
   GOptionGroup	*(*get_context_group)		(VinagrePlugin *plugin);
   const gchar	*(*get_protocol)		(VinagrePlugin *plugin);
+  gchar		**(*get_public_description)	(VinagrePlugin *plugin);
   gint		(*get_default_port)		(VinagrePlugin *plugin);
   VinagreConnection *(*new_connection)		(VinagrePlugin *plugin);
   VinagreConnection *(*new_connection_from_file)(VinagrePlugin *plugin,
@@ -86,6 +87,8 @@ struct _VinagrePluginClass
 						 VinagreConnection *conn,
 						 VinagreWindow     *window);
 
+  GtkWidget 	*(*get_connect_widget)		(VinagrePlugin     *plugin);
+
   /* Plugins should not override this, it's handled automatically by
      the VinagrePluginClass */
   gboolean 	(*is_configurable)		(VinagrePlugin *plugin);
@@ -118,6 +121,7 @@ GtkWidget	*vinagre_plugin_create_configure_dialog	(VinagrePlugin *plugin);
 
 GOptionGroup	*vinagre_plugin_get_context_group	(VinagrePlugin *plugin);
 const gchar	*vinagre_plugin_get_protocol		(VinagrePlugin *plugin);
+gchar		**vinagre_plugin_get_public_description	(VinagrePlugin *plugin);
 gint		 vinagre_plugin_get_default_port	(VinagrePlugin *plugin);
 VinagreConnection *vinagre_plugin_new_connection	(VinagrePlugin *plugin);
 VinagreConnection *vinagre_plugin_new_connection_from_file (VinagrePlugin *plugin,
@@ -130,6 +134,8 @@ GtkWidget 	*vinagre_plugin_new_tab			(VinagrePlugin     *plugin,
 							 VinagreConnection *conn,
 							 VinagreWindow     *window);
 
+GtkWidget 	*vinagre_plugin_get_connect_widget	(VinagrePlugin     *plugin);
+
 /**
  * VINAGRE_PLUGIN_REGISTER_TYPE_WITH_CODE(PluginName, plugin_name, CODE):
  *



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