From 122f201dcf356460a30a7b260730bcfc7246a614 Mon Sep 17 00:00:00 2001 From: Harish Nair Date: Tue, 15 May 2018 11:27:41 +0530 Subject: [PATCH] rename-file-popover: Warn when name exceeds size limit When a file is renamed if the name entered by user has a length that exceeds maximum limit then it shows a window with a warning. The problem is that once the user has acknowledged the warning, the file name goes back to its original name. The user is not given a chance to make slight modifications in the name that was entered. To fix this problem, a warning will be given in the popup itself where the new filename is entered. That way the user will be able to make slight changes so that the file name is within the size limit. https://gitlab.gnome.org/GNOME/nautilus/issues/148 --- src/nautilus-rename-file-popover-controller.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/nautilus-rename-file-popover-controller.c b/src/nautilus-rename-file-popover-controller.c index 2c10e07e2f..a651200a0a 100644 --- a/src/nautilus-rename-file-popover-controller.c +++ b/src/nautilus-rename-file-popover-controller.c @@ -103,8 +103,14 @@ nautilus_rename_file_popover_controller_name_is_valid (NautilusFileNameWidgetCon gchar **error_message) { NautilusRenameFilePopoverController *self; + NautilusDirectory *directory; + glong max_name_length; + size_t name_length; self = NAUTILUS_RENAME_FILE_POPOVER_CONTROLLER (controller); + directory = nautilus_file_get_directory (self->target_file); + name_length = strlen (name); + max_name_length = nautilus_directory_get_max_child_name_length (directory); if (strlen (name) == 0) { @@ -144,6 +150,17 @@ nautilus_rename_file_popover_controller_name_is_valid (NautilusFileNameWidgetCon *error_message = _("A file cannot be called “..”."); } } + else if (name_length > max_name_length + 1 && max_name_length != -1) + { + if (self->target_is_folder) + { + *error_message = _("Folder name is too long."); + } + else + { + *error_message = _("File name is too long."); + } + } return *error_message == NULL; } -- GitLab