[nautilus] batch-rename: show error on empty name



commit 0e21d1877e267edf7fa9d8e5dee734b223fc0eda
Author: Diana Grecu <dianagrecu07 gmail com>
Date:   Sat Apr 22 14:07:04 2017 +0300

    batch-rename: show error on empty name
    
    When the destination name is empty, the "Rename" button goes
    insensitive without explaining the user why it happened.
    
    To explain what happened show a descriptive message to inform
    the user.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=772435

 src/nautilus-batch-rename-dialog.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c
index c3a4be2..ddc1942 100644
--- a/src/nautilus-batch-rename-dialog.c
+++ b/src/nautilus-batch-rename-dialog.c
@@ -1354,10 +1354,12 @@ have_unallowed_character (NautilusBatchRenameDialog *dialog)
     GList *names;
     GString *new_name;
     const gchar *entry_text;
+    gboolean have_empty_name;
     gboolean have_unallowed_character_slash;
     gboolean have_unallowed_character_dot;
     gboolean have_unallowed_character_dotdot;
 
+    have_empty_name = FALSE;
     have_unallowed_character_slash = FALSE;
     have_unallowed_character_dot = FALSE;
     have_unallowed_character_dotdot = FALSE;
@@ -1404,6 +1406,12 @@ have_unallowed_character (NautilusBatchRenameDialog *dialog)
         {
             new_name = names->data;
 
+            if (g_strcmp0 (new_name->str, "") == 0)
+            {
+                have_empty_name = TRUE;
+                break;
+            }
+
             if (g_strcmp0 (new_name->str, "..") == 0)
             {
                 have_unallowed_character_dotdot = TRUE;
@@ -1412,6 +1420,12 @@ have_unallowed_character (NautilusBatchRenameDialog *dialog)
         }
     }
 
+    if (have_empty_name)
+    {
+        gtk_label_set_label (GTK_LABEL (dialog->conflict_label),
+                             _("A file must have a name"));
+    }
+
     if (have_unallowed_character_slash)
     {
         gtk_label_set_label (GTK_LABEL (dialog->conflict_label),
@@ -1430,7 +1444,8 @@ have_unallowed_character (NautilusBatchRenameDialog *dialog)
                              "“..” is an unallowed file name");
     }
 
-    if (have_unallowed_character_slash || have_unallowed_character_dot || have_unallowed_character_dotdot)
+    if (have_unallowed_character_slash || have_unallowed_character_dot || have_unallowed_character_dotdot
+        || have_empty_name)
     {
         gtk_widget_set_sensitive (dialog->rename_button, FALSE);
         gtk_widget_set_sensitive (dialog->conflict_down, FALSE);


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