gedit r6912 - in trunk: . gedit



Author: pborelli
Date: Sun Feb 22 17:00:21 2009
New Revision: 6912
URL: http://svn.gnome.org/viewvc/gedit?rev=6912&view=rev

Log:
2009-02-22  Paolo Borelli  <pborelli katamail com>

	* gedit/gedit-utils.c:
	* gedit/gedit.c:
	* gedit/gedit-document.c:
	* gedit/gedit-commands.h:
	* gedit/gedit-commands-file.c:

	Try to handle better strange filenames passed on the command line that
	contain	columns. Fixes bug #572746. I think there are still corner
	cases where we do not properly handle uri vs filename-with-columns,
	but probably the logic (if solvable at all) should go in
	g_file_new_for_command_line_arg. 



Modified:
   trunk/ChangeLog
   trunk/gedit/gedit-commands-file.c
   trunk/gedit/gedit-commands.h
   trunk/gedit/gedit-document.c
   trunk/gedit/gedit-utils.c
   trunk/gedit/gedit.c

Modified: trunk/gedit/gedit-commands-file.c
==============================================================================
--- trunk/gedit/gedit-commands-file.c	(original)
+++ trunk/gedit/gedit-commands-file.c	Sun Feb 22 17:00:21 2009
@@ -292,7 +292,12 @@
 
 	for (u = uris; u != NULL; u = u->next)
 	{
-		files = g_slist_prepend (files, g_file_new_for_uri (u->data));
+		gchar *uri = u->data;
+
+		if (gedit_utils_is_valid_uri (uri))
+			files = g_slist_prepend (files, g_file_new_for_uri (uri));
+		else
+			g_warning ("invalid uri: %s", uri);
 	}
 	files = g_slist_reverse (files);
 
@@ -356,13 +361,13 @@
  */
 gint
 _gedit_cmd_load_files_from_prompt (GeditWindow         *window,
-				   const GSList        *uris,
+				   GSList              *files,
 				   const GeditEncoding *encoding,
 				   gint                 line_pos)
 {
 	gedit_debug (DEBUG_COMMANDS);
 
-	return load_uri_list (window, uris, encoding, line_pos, TRUE);
+	return load_file_list (window, files, encoding, line_pos, TRUE);
 }
 
 static void

Modified: trunk/gedit/gedit-commands.h
==============================================================================
--- trunk/gedit/gedit-commands.h	(original)
+++ trunk/gedit/gedit-commands.h	Sun Feb 22 17:00:21 2009
@@ -54,14 +54,10 @@
 /*
  * Non-exported functions
  */
- 
-gint		_gedit_cmd_load_files			(GeditWindow         *window,
-							 const GSList        *uris,
-							 const GeditEncoding *encoding);
-							 
+
 /* Create titled documens for non-existing URIs */
 gint		_gedit_cmd_load_files_from_prompt	(GeditWindow         *window,
-							 const GSList        *uris,
+							 GSList              *files,
 							 const GeditEncoding *encoding,
 							 gint                 line_pos);
 

Modified: trunk/gedit/gedit-document.c
==============================================================================
--- trunk/gedit/gedit-document.c	(original)
+++ trunk/gedit/gedit-document.c	Sun Feb 22 17:00:21 2009
@@ -900,7 +900,7 @@
 
 	if (doc->priv->uri == NULL)
 		return g_strdup_printf (_("Unsaved Document %d"),
-					doc->priv->untitled_number);	      
+					doc->priv->untitled_number);
 	else
 		return gedit_utils_basename_for_display (doc->priv->uri);
 }
@@ -1138,6 +1138,8 @@
 {
 	g_return_if_fail (doc->priv->loader == NULL);
 
+	gedit_debug_message (DEBUG_DOCUMENT, "load_real: uri = %s", uri);
+
 	/* create a loader. It will be destroyed when loading is completed */
 	doc->priv->loader = gedit_document_loader_new (doc, uri, encoding);
 

Modified: trunk/gedit/gedit-utils.c
==============================================================================
--- trunk/gedit/gedit-utils.c	(original)
+++ trunk/gedit/gedit-utils.c	Sun Feb 22 17:00:21 2009
@@ -622,7 +622,7 @@
 
 	string = NULL;
 	remainder = name;
-	remaining_bytes = strlen (name);
+	remaining_bytes = name ? strlen (name) : 0;
 
 	while (remaining_bytes != 0) {
 		if (g_utf8_validate (remainder, remaining_bytes, &invalid)) {

Modified: trunk/gedit/gedit.c
==============================================================================
--- trunk/gedit/gedit.c	(original)
+++ trunk/gedit/gedit.c	Sun Feb 22 17:00:21 2009
@@ -132,16 +132,10 @@
 			}
 			else
 			{
-				gchar *canonical_uri;
-				
-				canonical_uri = gedit_utils_make_canonical_uri_from_shell_arg (remaining_args[i]);
-				
-				if (canonical_uri != NULL)
-					file_list = g_slist_prepend (file_list, 
-								     canonical_uri);
-				else
-					g_print (_("%s: malformed file name or URI.\n"),
-						 remaining_args[i]);
+				GFile *file;
+
+				file = g_file_new_for_commandline_arg (remaining_args[i]);
+				file_list = g_slist_prepend (file_list, file);
 			} 
 		}
 
@@ -291,7 +285,13 @@
 			uris = g_strsplit (params[4], " ", n_uris);
 
 			for (j = 0; j < n_uris; j++)
-				file_list = g_slist_prepend (file_list, uris[j]);
+			{
+				GFile *file;
+
+				file = g_file_new_for_uri (uris[j]);
+				file_list = g_slist_prepend (file_list, file);
+			}
+
 			file_list = g_slist_reverse (file_list);
 
 			/* the list takes ownerhip of the strings,
@@ -365,7 +365,7 @@
 	gtk_window_present (GTK_WINDOW (window));
 
 	/* free the file list and reset to default */
-	g_slist_foreach (file_list, (GFunc) g_free, NULL);
+	g_slist_foreach (file_list, (GFunc) g_object_unref, NULL);
 	g_slist_free (file_list);
 	file_list = NULL;
 
@@ -457,9 +457,14 @@
 
 		for (l = file_list; l != NULL; l = l->next)
 		{
-			command = g_string_append (command, l->data);
+			gchar *uri;
+
+			uri = g_file_get_uri (G_FILE (l->data));
+			command = g_string_append (command, uri);
 			if (l->next != NULL)
 				command = g_string_append_c (command, ' ');
+
+			g_free (uri);
 		}
 	}
 
@@ -658,7 +663,7 @@
 		gedit_debug_message (DEBUG_APP, "Show window");
 		gtk_widget_show (GTK_WIDGET (window));
 
-		g_slist_foreach (file_list, (GFunc) g_free, NULL);
+		g_slist_foreach (file_list, (GFunc) g_object_unref, NULL);
 		g_slist_free (file_list);
 		file_list = NULL;
 



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