Re: [PATCH] Nautilus location bar



On Mon, 2007-01-29 at 20:18 +0300, Виталий Ищенко wrote:
> В Чтв, 18/01/2007 в 11:32 +0100, Alexander Larsson пишет:
> > Yes, this looks like the right approach. However, I don't think you
> > should add a copy of gnome_vfs_make_uri_from_input_internal. Just make
> > it take a base argument and then pass NULL for base in the other uses of
> > it.
> 
> Yeah I really did a stupid thing :)


 	case '~': {
-		char *path, *filesystem_path;
+		char *path, *locale_path;
 		if (!filenames_are_utf8) {
-			filesystem_path = g_convert (stripped, -1, filename_charset,
"UTF-8", NULL, NULL, NULL);
+			locale_path = g_convert (stripped, -1, filename_charset, "UTF-8",
NULL, NULL, NULL);
 		} else {
-			filesystem_path = g_strdup (stripped);
+			locale_path = g_strdup (stripped);


Why rename the variable? filesystem_path seems a better name (as its not
always in locale encoding).

+			} else {
+				base_scheme = gnome_vfs_get_uri_scheme (base);
+
+				g_return_val_if_fail (base_scheme != NULL, g_strconcat ("file:///", escaped, NULL));
+
+				path = g_strconcat (base + strlen(base_scheme) + 1 + 2, "/", escaped, NULL);
+				resolved_relative_uri = gnome_vfs_make_path_name_canonical (path);
+				/* gnome_vfs_make_path_name_canonical
+				 * can leave '..' at the beginning
+				 * of resolved_relative_uri */
+				resolved_relative_uri_offset = 0;
+				if (resolved_relative_uri[0] == '.')
+					if (resolved_relative_uri[1] == '.')
+						resolved_relative_uri_offset = 2;
+				/* After all transformations, we get
+				 * empty string, return base_scheme + ':///' */
+				if (resolved_relative_uri[resolved_relative_uri_offset] == '\0')
+					uri = g_strconcat (base_scheme, ":///", NULL);
+				else
+					uri = g_strconcat (base_scheme, "://", resolved_relative_uri + resolved_relative_uri_offset, NULL);
+				g_free (resolved_relative_uri);
+				g_free (path);
+				g_free (base_scheme);
+			}

This part looks overly complex. Why not just use
gnome_vfs_uri_append_path(), possibly with a call to
gnome_vfs_make_path_name_canonical() afterward.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's an obese vegetarian rock star trapped in a world he never made. She's a 
disco-crazy mute lawyer from aristocratic European stock. They fight crime! 




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