summaryrefslogtreecommitdiff
path: root/src/nautilus-rename-file-popover-controller.c
diff options
context:
space:
mode:
authorHarish Nair <harishnair96@gmail.com>2018-05-15 11:27:41 +0530
committerCarlos Soriano <csoriano1618@gmail.com>2018-05-18 14:51:31 +0000
commit122f201dcf356460a30a7b260730bcfc7246a614 (patch)
tree97fee992f5723738770f90c8a2b569c97f99a1d1 /src/nautilus-rename-file-popover-controller.c
parentbfc3aebe049ce395d58465a40e08e46f449cdf3a (diff)
downloadnautilus-122f201dcf356460a30a7b260730bcfc7246a614.tar.gz
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
Diffstat (limited to 'src/nautilus-rename-file-popover-controller.c')
-rw-r--r--src/nautilus-rename-file-popover-controller.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nautilus-rename-file-popover-controller.c b/src/nautilus-rename-file-popover-controller.c
index 2c10e07e2..a651200a0 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;
}