Re: Patch for bug #103802



> I'm not sure this is the right approach. We don't want to rely on string
> matching like that (it'll be translated in other languages, and a real
> filename *might* correctly contain that text). 

For the i18n problem, isn't it OK to use gettext (" (invalid Unicode)")
? It seemed to work on my French-speaking desktop...

As for the other problem, you're right that if the filename really
contains " (invalid Unicode)", it will be removed... and that's bad.

Do you have any idea how to fix it in a better way ? I'd like to fix it
the correct way but don't have any idea how to do it...

> Also, why is the else part at the end duplicated three times?

I don't now :) I must have hit CTRL-V a few times by accident...

I attached a fixed patch.

-- 
Julien Olivier <julo altern org>
Index: nautilus/libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.365
diff -p -u -r1.365 nautilus-icon-container.c
--- nautilus/libnautilus-private/nautilus-icon-container.c	10 Feb 2004 11:33:40 -0000	1.365
+++ nautilus/libnautilus-private/nautilus-icon-container.c	8 Mar 2004 09:43:36 -0000
@@ -6043,6 +6043,7 @@ nautilus_icon_container_start_renaming_s
 	const char *editable_text;
 	int x, y, width;
 	int start_offset, end_offset;
+	gchar **split_editable_text;
 
 	/* Check if it already in renaming mode. */
 	details = container->details;
@@ -6072,6 +6073,14 @@ nautilus_icon_container_start_renaming_s
 	/* This could conceivably be NULL if a rename was triggered really early. */
 	if (editable_text == NULL) {
 		return;
+	}
+	else {
+		/* Remove the " (invalid Unicode)" part of the name*/
+		split_editable_text = g_strsplit (editable_text, gettext (" (invalid Unicode)"), 2);
+		if (split_editable_text [0] && split_editable_text [1]) {
+			editable_text = split_editable_text [0];
+		}
+		g_strfreev (split_editable_text);
 	}
 
 	details->original_text = g_strdup (editable_text);
Index: nautilus/src/file-manager/fm-properties-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-properties-window.c,v
retrieving revision 1.197
diff -p -u -r1.197 fm-properties-window.c
--- nautilus/src/file-manager/fm-properties-window.c	27 Feb 2004 21:42:36 -0000	1.197
+++ nautilus/src/file-manager/fm-properties-window.c	8 Mar 2004 09:43:45 -0000
@@ -543,6 +543,7 @@ update_name_field (FMPropertiesWindow *w
 	NautilusFile *file;
 	const char *original_name;
 	char *current_name, *displayed_name;
+	gchar **split_name;
 
 	if (is_multi_file_window (window)) {
 		/* Multifile property dialog, show all names */
@@ -594,6 +595,16 @@ update_name_field (FMPropertiesWindow *w
 		 * aspect of the file might have), then don't clobber changes.
 		 */
 		current_name = nautilus_file_get_display_name (file);
+
+		/* Remove the " (invalid Unicode)" part of the name*/
+		split_name = g_strsplit (current_name, gettext (" (invalid Unicode)"), 2);
+		if (split_name [0] && split_name [1]) {
+			g_free (current_name);
+			current_name = g_strdup_printf ("%s", split_name [0]);
+		}
+		g_strfreev (split_name);
+
+
 		if (original_name == NULL || 
 		    eel_strcmp (original_name, current_name) != 0) {
 			g_object_set_data_full (G_OBJECT (window->details->name_field),
@@ -3495,6 +3506,14 @@ fm_properties_window_present (GList *ori
 	/* Look to see if we're already waiting for a window for this file. */
 	if (g_hash_table_lookup (pending_lists, pending_key) != NULL) {
 		return;
+	}
+	else {
+		/* Remove the " (invalid Unicode)" part of the name*/
+		split_editable_text = g_strsplit (editable_text, gettext (" (invalid Unicode)"), 2);
+		if (split_editable_text [0] && split_editable_text [1]) {
+			editable_text = split_editable_text [0];
+		}
+		g_strfreev (split_editable_text);
 	}
 
 	target_files = get_target_file_list (original_files);


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