diff --git a/thunar/thunar-io-jobs-util.c b/thunar/thunar-io-jobs-util.c index d1200fc9380a7799f5c2d17468e35d309e07809e..67a9f5a3cbb61334e1c01d183428d53049cce6db 100644 --- a/thunar/thunar-io-jobs-util.c +++ b/thunar/thunar-io-jobs-util.c @@ -58,13 +58,12 @@ thunar_io_jobs_util_next_duplicate_file (ThunarJob *job, ThunarNextFileNameMode name_mode, GError **error) { - GFileInfo *info; GError *err = NULL; GFile *duplicate_file = NULL; GFile *parent_file = NULL; ThunarFile *thunar_parent_file; - const gchar *old_display_name; - gchar *display_name; + const gchar *old_filename; + gchar *filename; _thunar_return_val_if_fail (THUNAR_IS_JOB (job), NULL); _thunar_return_val_if_fail (G_IS_FILE (file), NULL); @@ -75,42 +74,27 @@ thunar_io_jobs_util_next_duplicate_file (ThunarJob *job, if (exo_job_set_error_if_cancelled (EXO_JOB (job), error)) return NULL; - /* query the source file info / display name */ - info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TYPE "," - G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, - G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, - exo_job_get_cancellable (EXO_JOB (job)), &err); - - /* abort on error */ - if (info == NULL) - { - g_propagate_error (error, err); - return NULL; - } - parent_file = g_file_get_parent (file); - old_display_name = g_file_info_get_display_name (info); + old_filename = g_file_get_basename (file); thunar_parent_file = thunar_file_get (parent_file, &err); if (thunar_parent_file == NULL) { - g_object_unref (info); g_object_unref (parent_file); g_propagate_error (error, err); return NULL; } - display_name = thunar_util_next_new_file_name (thunar_parent_file, - old_display_name, - name_mode); + filename = thunar_util_next_new_file_name (thunar_parent_file, + old_filename, + name_mode); g_object_unref (thunar_parent_file); /* create the GFile for the copy/link */ - duplicate_file = g_file_get_child (parent_file, display_name); + duplicate_file = g_file_get_child (parent_file, filename); g_object_unref (parent_file); /* free resources */ - g_object_unref (info); - g_free (display_name); + g_free (filename); return duplicate_file; } @@ -146,8 +130,8 @@ thunar_io_jobs_util_next_renamed_file (ThunarJob *job, GError *err = NULL; GFile *renamed_file = NULL; GFile *parent_file = NULL; - const gchar *old_display_name; - gchar *display_name; + const gchar *old_filename; + gchar *filename; gchar *file_basename; gchar *extension = NULL; @@ -176,32 +160,32 @@ thunar_io_jobs_util_next_renamed_file (ThunarJob *job, return NULL; } - old_display_name = g_file_info_get_display_name (info); + old_filename = g_file_get_basename (src_file); /* get file extension if file is not a directory */ if (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY) - extension = thunar_util_str_get_extension (old_display_name); + extension = thunar_util_str_get_extension (old_filename); if (extension != NULL) { - file_basename = g_strndup (old_display_name, extension - old_display_name); + file_basename = g_strndup (old_filename, extension - old_filename); /* I18N: put " (copy #)" between basename and extension */ - display_name = g_strdup_printf (_("%s (copy %u)%s"), file_basename, n, extension); + filename = g_strdup_printf (_("%s (copy %u)%s"), file_basename, n, extension); g_free(file_basename); } else { /* I18N: put " (copy #)" after filename (for files without extension) */ - display_name = g_strdup_printf (_("%s (copy %u)"), old_display_name, n); + filename = g_strdup_printf (_("%s (copy %u)"), old_filename, n); } /* create the GFile for the copy/move */ parent_file = g_file_get_parent (tgt_file); - renamed_file = g_file_get_child (parent_file, display_name); + renamed_file = g_file_get_child (parent_file, filename); g_object_unref (parent_file); /* free resources */ g_object_unref (info); - g_free (display_name); + g_free (filename); return renamed_file; } diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c index 4c655b96895d978971958f46b581ea70646c5f3f..67ff11246838809d367f07b32e0fd291102b07b7 100644 --- a/thunar/thunar-launcher.c +++ b/thunar/thunar-launcher.c @@ -2591,7 +2591,7 @@ thunar_launcher_action_create_document (ThunarLauncher *launcher, thunar_file_get_display_name (template_file)); /* ask the user to enter a name for the new document */ - generated_name = thunar_util_next_new_file_name (launcher->current_directory, thunar_file_get_display_name (template_file), THUNAR_NEXT_FILE_NAME_MODE_NEW); + generated_name = thunar_util_next_new_file_name (launcher->current_directory, g_file_get_basename (thunar_file_get_file (template_file)), THUNAR_NEXT_FILE_NAME_MODE_NEW); name = thunar_dialogs_show_create (launcher->widget, thunar_file_get_content_type (THUNAR_FILE (template_file)), generated_name, diff --git a/thunar/thunar-util.c b/thunar/thunar-util.c index b9d2560c5fb04f25c25a0a936b272ebc9c5e11a6..8d29659c263f937ce67637f40a9edf98c1811633 100644 --- a/thunar/thunar-util.c +++ b/thunar/thunar-util.c @@ -708,7 +708,7 @@ thunar_util_next_new_file_name (ThunarFile *dir, for (GList *files = thunar_folder_get_files (folder); files != NULL; files = files->next) { ThunarFile *file = files->data; - const gchar *name = thunar_file_get_display_name (file); + const gchar *name = g_file_get_basename (thunar_file_get_file (file)); if (g_strcmp0 (new_name, name) == 0) {