[nautilus] Bug 587316 – Truncate file names when deleting



commit 7c316ae074658c8927e48ea00f4305767ea9f7dd
Author: A. Walton <awalton gnome org>
Date:   Thu Aug 13 21:18:36 2009 -0400

    Bug 587316 â?? Truncate file names when deleting
    
    Files with extremely long file names could cause the dialog box to
    become wider than the screen. Based on a patch contributed by
    Marcus Carlson.

 libnautilus-private/nautilus-file-operations.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index 5051c72..29d5e12 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -178,6 +178,8 @@ typedef struct {
 #define NSEC_PER_SEC 1000000000
 #define NSEC_PER_MSEC 1000000
 
+#define MAXIMUM_DISPLAYED_FILE_NAME_LENGTH 50
+
 #define IS_IO_ERROR(__error, KIND) (((__error)->domain == G_IO_ERROR && (__error)->code == G_IO_ERROR_ ## KIND))
 
 #define SKIP _("_Skip")
@@ -819,6 +821,14 @@ custom_basename_to_string (char *format, va_list va)
 		name = g_uri_escape_string (name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, TRUE);
 		g_free (tmp);
 	}
+
+	/* Finally, if the string is too long, truncate it. */
+	if (name != NULL) {
+		tmp = name;
+		name = eel_str_middle_truncate (tmp, MAXIMUM_DISPLAYED_FILE_NAME_LENGTH);
+		g_free (tmp);
+	}
+
 	
 	return name;
 }



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