vinagre r163 - in trunk: data src



Author: jwendell
Date: Wed Jan 30 21:26:27 2008
New Revision: 163
URL: http://svn.gnome.org/viewvc/vinagre?rev=163&view=rev

Log:
more work on vnc:// handler

Modified:
   trunk/data/vinagre.schemas.in
   trunk/src/vinagre-connection.c
   trunk/src/vinagre-main.c
   trunk/src/vinagre-tab.c

Modified: trunk/data/vinagre.schemas.in
==============================================================================
--- trunk/data/vinagre.schemas.in	(original)
+++ trunk/data/vinagre.schemas.in	Wed Jan 30 21:26:27 2008
@@ -6,7 +6,7 @@
 			<applyto>/desktop/gnome/url-handlers/vnc/command</applyto>
 			<owner>vinagre</owner>
 			<type>string</type>
-			<default>vinagre -u %s</default>
+			<default>vinagre %s</default>
 			<locale name="C">
 				<short>The handler for "vnc://" URLs</short>
 				<long></long>

Modified: trunk/src/vinagre-connection.c
==============================================================================
--- trunk/src/vinagre-connection.c	(original)
+++ trunk/src/vinagre-connection.c	Wed Jan 30 21:26:27 2008
@@ -180,6 +180,8 @@
   char              *data = NULL;
   GFile             *file_a;
 
+  *error_msg = NULL;
+
   file_a = g_file_new_for_commandline_arg (uri);
   loaded = g_file_load_contents (file_a,
 				 NULL,
@@ -238,7 +240,6 @@
 
   g_key_file_free (file);
   g_object_unref (file_a);
-  *error_msg = NULL;
 
   return conn;
 }

Modified: trunk/src/vinagre-main.c
==============================================================================
--- trunk/src/vinagre-main.c	(original)
+++ trunk/src/vinagre-main.c	Wed Jan 30 21:26:27 2008
@@ -33,7 +33,6 @@
 
 /* command line */
 static gchar **files = NULL;
-static gchar **urls = NULL;
 static gchar **remaining_args = NULL;
 static GSList *servers = NULL;
 
@@ -42,9 +41,6 @@
   { "file", 'f', 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
     N_("Opens a .vnc file"), N_("filename")},
 
-  { "url", 'u', 0, G_OPTION_ARG_STRING_ARRAY, &urls,
-    N_("Handles an URL like vnc://host[:port]"), N_("url")},
-
   { 
     G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args,
     NULL, N_("[server:port]") },
@@ -58,9 +54,9 @@
   gint               i;
   VinagreConnection *conn;
   gchar             *error;
+  gchar             *host;
   gchar             **url;
-  GSList            *file_errors = NULL;
-  GSList            *url_errors = NULL;
+  GSList            *errors = NULL;
 
   if (files)
     {
@@ -71,7 +67,10 @@
 	    servers = g_slist_prepend (servers, conn);
 	  else
 	    {
-	      file_errors = g_slist_prepend (file_errors, g_strdup (files[i]));
+	      errors = g_slist_prepend (errors,
+					g_strdup_printf ("%s: %s",
+							files[i],
+							error ? error : _("Unknown error")));
 	      if (error)
 	        g_free (error);
 	    }
@@ -79,57 +78,45 @@
       g_strfreev (files);
     }
 
-  if (urls)
+  if (remaining_args)
     {
-      for (i = 0; urls[i]; i++) 
+      for (i = 0; remaining_args[i]; i++) 
 	{
-	  url = g_strsplit (urls[i], "://", 2);
+	  url = g_strsplit (remaining_args[i], "://", 2);
 	  if (g_strv_length (url) == 2)
 	    {
-	      conn = vinagre_connection_new_from_string (url[1]);
-	      if (conn)
-		servers = g_slist_prepend (servers, conn);
+	      if (g_strcmp0 (url[0], "vnc"))
+		{
+		  errors = g_slist_prepend (errors,
+					    g_strdup_printf ("The protocol %s is not supported.",
+					    		     url[0]));
+		  g_strfreev (url);
+		  continue;
+		}
+	      host = url[1];
 	    }
 	  else
-	    {
-	      url_errors = g_slist_prepend (url_errors, g_strdup (urls[i]));
-	    }
-	  g_strfreev (url);
-	}
-      g_strfreev (urls);
-    }
+	    host = remaining_args[i];
 
-  if (remaining_args)
-    {
-      for (i = 0; remaining_args[i]; i++) 
-	{
-	  conn = vinagre_connection_new_from_string (remaining_args[i]);
+	  conn = vinagre_connection_new_from_string (host);
 	  if (conn)
 	    servers = g_slist_prepend (servers, conn);
+
+	  g_strfreev (url);
 	}
-      g_strfreev (remaining_args);
-    }
 
-  if (file_errors)
-    {
-      vinagre_utils_show_many_errors (ngettext ("The following file could not be opened:",
-						"The following files could not be opened:",
-						g_slist_length (file_errors)),
-				      file_errors,
-				      GTK_WINDOW (window));
-      g_slist_free (file_errors);
+      g_strfreev (remaining_args);
     }
 
-  if (url_errors)
+  if (errors)
     {
-      vinagre_utils_show_many_errors (ngettext ("The following URL could not be opened:",
-						"The following URL's could not be opened:",
-						g_slist_length (url_errors)),
-				      url_errors,
+      vinagre_utils_show_many_errors (ngettext ("The following error has occurred:",
+						"The following errors has occurred:",
+						g_slist_length (errors)),
+				      errors,
 				      GTK_WINDOW (window));
-      g_slist_free (url_errors);
+      g_slist_free (errors);
     }
-
 }
 
 int main (int argc, char **argv) {

Modified: trunk/src/vinagre-tab.c
==============================================================================
--- trunk/src/vinagre-tab.c	(original)
+++ trunk/src/vinagre-tab.c	Wed Jan 30 21:26:27 2008
@@ -362,7 +362,7 @@
   data = g_slice_new (GtkRecentData);
 
   uri = g_string_new (NULL);
-  g_string_printf (uri, "%s:%d", tab->priv->conn->host, tab->priv->conn->port);
+  g_string_printf (uri, "vnc://%s:%d", tab->priv->conn->host, tab->priv->conn->port);
 
   data->display_name = vinagre_connection_best_name (tab->priv->conn);
   data->description = NULL;



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