[nautilus/wip/alexpandelea/batchRename: 2/17] Limit the label size



commit bafc2b5285a341813351c92e702b5c6a67b8fc99
Author: Alexandru Pandelea <alexandru pandelea gmail com>
Date:   Wed Jun 8 22:52:28 2016 +0300

    Limit the label size
    
    Use predefined label functions to limit the label size instead of
    using memcpy to limit the label size.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768311

 src/nautilus-batch-rename.c     |    4 ++++
 src/nautilus-rename-utilities.c |    3 ---
 2 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/src/nautilus-batch-rename.c b/src/nautilus-batch-rename.c
index ec137cc..c3c2da3 100644
--- a/src/nautilus-batch-rename.c
+++ b/src/nautilus-batch-rename.c
@@ -27,6 +27,7 @@
 
 #define ADD_TEXT_ENTRY_SIZE 550
 #define REPLACE_ENTRY_SIZE  275
+#define MAX_DISPLAY_LEN 40
 
 struct _NautilusBatchRename
 {
@@ -287,6 +288,9 @@ nautilus_batch_rename_new (NautilusFilesView *view)
 
         gtk_widget_grab_focus (dialog->name_entry);
 
+        gtk_label_set_ellipsize (GTK_LABEL (dialog->error_label), PANGO_ELLIPSIZE_END);
+        gtk_label_set_max_width_chars (GTK_LABEL (dialog->error_label), MAX_DISPLAY_LEN);
+
         /* update display text */
         file_names_widget_entry_on_changed (dialog);
 
diff --git a/src/nautilus-rename-utilities.c b/src/nautilus-rename-utilities.c
index c9ec0f6..6db7ccb 100644
--- a/src/nautilus-rename-utilities.c
+++ b/src/nautilus-rename-utilities.c
@@ -159,8 +159,5 @@ get_new_display_name (NautilusBatchRenameModes    mode,
 
         result = get_new_name (mode, file_name, entry_text, replace_text);
 
-        if (strlen (result) >= MAX_DISPLAY_LEN)
-                memcpy (result + MAX_DISPLAY_LEN, "...\0",4);
-
         return result;
 }
\ No newline at end of file


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