[nautilus/ellipsization-truncation-a-united-nation: 5/5] general: truncate messages used in dialogs



commit bdb5f7bac0d4bd850bbf84842747843b84850695
Author: Ernestas Kulik <ernestask gnome org>
Date:   Mon Feb 19 21:33:16 2018 +0200

    general: truncate messages used in dialogs
    
    This is most notably a problem with paths that are approaching PATH_MAX
    in length. Cairo surface creation fails due to its internal size limit
    being reached and GTK+ promptly crashes after trying to dereference a
    null pointer. Besides, the window can get ridiculously long even if
    Nautilus doesn’t crash.

 src/nautilus-error-reporting.c | 147 +++++++++++++++++++++++------------------
 src/nautilus-error-reporting.h |   3 +
 src/nautilus-file-operations.c | 121 +++++++++++++++++++++------------
 3 files changed, 162 insertions(+), 109 deletions(-)
---
diff --git a/src/nautilus-error-reporting.c b/src/nautilus-error-reporting.c
index e2e4cfe8b..50a979d93 100644
--- a/src/nautilus-error-reporting.c
+++ b/src/nautilus-error-reporting.c
@@ -34,19 +34,30 @@
 #include "nautilus-debug.h"
 
 #define NEW_NAME_TAG "Nautilus: new name"
-#define MAXIMUM_DISPLAYED_FILE_NAME_LENGTH      50
 
 static void finish_rename (NautilusFile *file,
                            gboolean      stop_timer,
                            GError       *error);
 
+static char *
+get_truncated_name_for_file (NautilusFile *file)
+{
+    g_autofree char *file_name = NULL;
+
+    g_assert (NAUTILUS_IS_FILE (file));
+
+    file_name = nautilus_file_get_display_name (file);
+
+    return eel_str_middle_truncate (file_name, MAXIMUM_DISPLAYED_FILE_NAME_LENGTH);
+}
+
 void
 nautilus_report_error_loading_directory (NautilusFile *file,
                                          GError       *error,
                                          GtkWindow    *parent_window)
 {
-    char *file_name;
-    char *message;
+    g_autofree char *truncated_name = NULL;
+    g_autofree char *message = NULL;
 
     if (error == NULL ||
         error->message == NULL)
@@ -61,7 +72,7 @@ nautilus_report_error_loading_directory (NautilusFile *file,
         return;
     }
 
-    file_name = nautilus_file_get_display_name (file);
+    truncated_name = get_truncated_name_for_file (file);
 
     if (error->domain == G_IO_ERROR)
     {
@@ -70,20 +81,28 @@ nautilus_report_error_loading_directory (NautilusFile *file,
             case G_IO_ERROR_PERMISSION_DENIED:
             {
                 message = g_strdup_printf (_("You do not have the permissions necessary to view the contents 
of “%s”."),
-                                           file_name);
+                                           truncated_name);
             }
             break;
 
             case G_IO_ERROR_NOT_FOUND:
             {
                 message = g_strdup_printf (_("“%s” could not be found. Perhaps it has recently been 
deleted."),
-                                           file_name);
+                                           truncated_name);
             }
             break;
 
             default:
-                message = g_strdup_printf (_("Sorry, could not display all the contents of “%s”: %s"), 
file_name,
-                                           error->message);
+            {
+                g_autofree char *truncated_error_message = NULL;
+
+                truncated_error_message = eel_str_middle_truncate (error->message,
+                                                                   MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
+
+                message = g_strdup_printf (_("Sorry, could not display all the contents of “%s”: %s"), 
truncated_name,
+                                           truncated_error_message);
+            }
+            break;
         }
     }
     else
@@ -92,9 +111,6 @@ nautilus_report_error_loading_directory (NautilusFile *file,
     }
 
     eel_show_error_dialog (_("This location could not be displayed."), message, parent_window);
-
-    g_free (file_name);
-    g_free (message);
 }
 
 void
@@ -102,17 +118,16 @@ nautilus_report_error_setting_group (NautilusFile *file,
                                      GError       *error,
                                      GtkWindow    *parent_window)
 {
-    char *file_name;
-    char *message;
+    g_autofree char *truncated_name = NULL;
+    g_autofree char *message = NULL;
 
     if (error == NULL)
     {
         return;
     }
 
-    file_name = nautilus_file_get_display_name (file);
+    truncated_name = get_truncated_name_for_file (file);
 
-    message = NULL;
     if (error->domain == G_IO_ERROR)
     {
         switch (error->code)
@@ -120,7 +135,7 @@ nautilus_report_error_setting_group (NautilusFile *file,
             case G_IO_ERROR_PERMISSION_DENIED:
             {
                 message = g_strdup_printf (_("You do not have the permissions necessary to change the group 
of “%s”."),
-                                           file_name);
+                                           truncated_name);
             }
             break;
 
@@ -133,19 +148,21 @@ nautilus_report_error_setting_group (NautilusFile *file,
 
     if (message == NULL)
     {
+        g_autofree char *truncated_error_message = NULL;
+
+        truncated_error_message = eel_str_middle_truncate (error->message,
+                                                           MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
+
         /* We should invent decent error messages for every case we actually experience. */
         g_warning ("Hit unhandled case %s:%d in nautilus_report_error_setting_group",
                    g_quark_to_string (error->domain), error->code);
         /* fall through */
-        message = g_strdup_printf (_("Sorry, could not change the group of “%s”: %s"), file_name,
-                                   error->message);
+        message = g_strdup_printf (_("Sorry, could not change the group of “%s”: %s"), truncated_name,
+                                   truncated_error_message);
     }
 
 
     eel_show_error_dialog (_("The group could not be changed."), message, parent_window);
-
-    g_free (file_name);
-    g_free (message);
 }
 
 void
@@ -153,22 +170,23 @@ nautilus_report_error_setting_owner (NautilusFile *file,
                                      GError       *error,
                                      GtkWindow    *parent_window)
 {
-    char *file_name;
-    char *message;
+    g_autofree char *truncated_name = NULL;
+    g_autofree char *truncated_error_message = NULL;
+    g_autofree char *message = NULL;
 
     if (error == NULL)
     {
         return;
     }
 
-    file_name = nautilus_file_get_display_name (file);
+    truncated_name = get_truncated_name_for_file (file);
 
-    message = g_strdup_printf (_("Sorry, could not change the owner of “%s”: %s"), file_name, 
error->message);
+    truncated_error_message = eel_str_middle_truncate (error->message,
+                                                       MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
+    message = g_strdup_printf (_("Sorry, could not change the owner of “%s”: %s"),
+                               truncated_name, truncated_error_message);
 
     eel_show_error_dialog (_("The owner could not be changed."), message, parent_window);
-
-    g_free (file_name);
-    g_free (message);
 }
 
 void
@@ -176,22 +194,23 @@ nautilus_report_error_setting_permissions (NautilusFile *file,
                                            GError       *error,
                                            GtkWindow    *parent_window)
 {
-    char *file_name;
-    char *message;
+    g_autofree char *truncated_name = NULL;
+    g_autofree char *truncated_error_message = NULL;
+    g_autofree char *message = NULL;
 
     if (error == NULL)
     {
         return;
     }
 
-    file_name = nautilus_file_get_display_name (file);
+    truncated_name = get_truncated_name_for_file (file);
 
-    message = g_strdup_printf (_("Sorry, could not change the permissions of “%s”: %s"), file_name, 
error->message);
+    truncated_error_message = eel_str_middle_truncate (error->message,
+                                                       MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
+    message = g_strdup_printf (_("Sorry, could not change the permissions of “%s”: %s"),
+                               truncated_name, truncated_error_message);
 
     eel_show_error_dialog (_("The permissions could not be changed."), message, parent_window);
-
-    g_free (file_name);
-    g_free (message);
 }
 
 typedef struct _NautilusRenameData
@@ -207,20 +226,16 @@ nautilus_report_error_renaming_file (NautilusFile *file,
                                      GError       *error,
                                      GtkWindow    *parent_window)
 {
-    char *original_name, *original_name_truncated;
-    char *new_name_truncated;
-    char *message;
+    g_autofree char *truncated_old_name = NULL;
+    g_autofree char *truncated_new_name = NULL;
+    g_autofree char *message = NULL;
 
     /* Truncate names for display since very long file names with no spaces
      * in them won't get wrapped, and can create insanely wide dialog boxes.
      */
-    original_name = nautilus_file_get_display_name (file);
-    original_name_truncated = eel_str_middle_truncate (original_name, MAXIMUM_DISPLAYED_FILE_NAME_LENGTH);
-    g_free (original_name);
-
-    new_name_truncated = eel_str_middle_truncate (new_name, MAXIMUM_DISPLAYED_FILE_NAME_LENGTH);
+    truncated_old_name = get_truncated_name_for_file (file);
+    truncated_new_name = eel_str_middle_truncate (new_name, MAXIMUM_DISPLAYED_FILE_NAME_LENGTH);
 
-    message = NULL;
     if (error->domain == G_IO_ERROR)
     {
         switch (error->code)
@@ -229,7 +244,7 @@ nautilus_report_error_renaming_file (NautilusFile *file,
             {
                 message = g_strdup_printf (_("The name “%s” is already used in this location. "
                                              "Please use a different name."),
-                                           new_name_truncated);
+                                           truncated_new_name);
             }
             break;
 
@@ -237,14 +252,14 @@ nautilus_report_error_renaming_file (NautilusFile *file,
             {
                 message = g_strdup_printf (_("There is no “%s” in this location. "
                                              "Perhaps it was just moved or deleted?"),
-                                           original_name_truncated);
+                                           truncated_old_name);
             }
             break;
 
             case G_IO_ERROR_PERMISSION_DENIED:
             {
                 message = g_strdup_printf (_("You do not have the permissions necessary to rename “%s”."),
-                                           original_name_truncated);
+                                           truncated_old_name);
             }
             break;
 
@@ -254,13 +269,13 @@ nautilus_report_error_renaming_file (NautilusFile *file,
                 {
                     message = g_strdup_printf (_("The name “%s” is not valid because it contains the 
character “/”. "
                                                  "Please use a different name."),
-                                               new_name_truncated);
+                                               truncated_new_name);
                 }
                 else
                 {
                     message = g_strdup_printf (_("The name “%s” is not valid. "
                                                  "Please use a different name."),
-                                               new_name_truncated);
+                                               truncated_new_name);
                 }
             }
             break;
@@ -269,7 +284,7 @@ nautilus_report_error_renaming_file (NautilusFile *file,
             {
                 message = g_strdup_printf (_("The name “%s” is too long. "
                                              "Please use a different name."),
-                                           new_name_truncated);
+                                           truncated_new_name);
             }
             break;
 
@@ -282,20 +297,21 @@ nautilus_report_error_renaming_file (NautilusFile *file,
 
     if (message == NULL)
     {
+        g_autofree char *truncated_error_message = NULL;
+
+        truncated_error_message = eel_str_middle_truncate (error->message,
+                                                           MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
+
         /* We should invent decent error messages for every case we actually experience. */
         g_warning ("Hit unhandled case %s:%d in nautilus_report_error_renaming_file",
                    g_quark_to_string (error->domain), error->code);
         /* fall through */
         message = g_strdup_printf (_("Sorry, could not rename “%s” to “%s”: %s"),
-                                   original_name_truncated, new_name_truncated,
-                                   error->message);
+                                   truncated_old_name, truncated_new_name,
+                                   truncated_error_message);
     }
 
-    g_free (original_name_truncated);
-    g_free (new_name_truncated);
-
     eel_show_error_dialog (_("The item could not be renamed."), message, parent_window);
-    g_free (message);
 }
 
 static void
@@ -377,10 +393,12 @@ nautilus_rename_file (NautilusFile                  *file,
                       NautilusFileOperationCallback  callback,
                       gpointer                       callback_data)
 {
-    char *old_name, *wait_message;
+    g_autoptr (GError) error = NULL;
     NautilusRenameData *data;
-    char *uri;
-    GError *error;
+    g_autofree char *truncated_old_name = NULL;
+    g_autofree char *truncated_new_name = NULL;
+    g_autofree char *wait_message = NULL;
+    g_autofree char *uri = NULL;
 
     g_return_if_fail (NAUTILUS_IS_FILE (file));
     g_return_if_fail (new_name != NULL);
@@ -388,7 +406,6 @@ nautilus_rename_file (NautilusFile                  *file,
     /* Stop any earlier rename that's already in progress. */
     error = g_error_new (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Cancelled");
     finish_rename (file, TRUE, error);
-    g_error_free (error);
 
     data = g_new0 (NautilusRenameData, 1);
     data->name = g_strdup (new_name);
@@ -401,18 +418,16 @@ nautilus_rename_file (NautilusFile                  *file,
                             data, (GDestroyNotify) nautilus_rename_data_free);
 
     /* Start the timed wait to cancel the rename. */
-    old_name = nautilus_file_get_display_name (file);
+    truncated_old_name = get_truncated_name_for_file (file);
+    truncated_new_name = eel_str_middle_truncate (new_name, MAXIMUM_DISPLAYED_FILE_NAME_LENGTH);
     wait_message = g_strdup_printf (_("Renaming “%s” to “%s”."),
-                                    old_name,
-                                    new_name);
-    g_free (old_name);
+                                    truncated_old_name,
+                                    truncated_new_name);
     eel_timed_wait_start (cancel_rename_callback, file, wait_message,
                           NULL);     /* FIXME bugzilla.gnome.org 42395: Parent this? */
-    g_free (wait_message);
 
     uri = nautilus_file_get_uri (file);
     DEBUG ("Renaming file %s to %s", uri, new_name);
-    g_free (uri);
 
     /* Start the rename. */
     nautilus_file_rename (file, new_name,
diff --git a/src/nautilus-error-reporting.h b/src/nautilus-error-reporting.h
index 955b937ac..55514907c 100644
--- a/src/nautilus-error-reporting.h
+++ b/src/nautilus-error-reporting.h
@@ -27,6 +27,9 @@
 #include <gtk/gtk.h>
 #include "nautilus-file.h"
 
+#define MAXIMUM_DISPLAYED_FILE_NAME_LENGTH      50
+#define MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH  400
+
 void nautilus_report_error_loading_directory    (NautilusFile   *file,
                                                  GError         *error,
                                                  GtkWindow      *parent_window);
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index eb5c8deec..e73806410 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -49,6 +49,7 @@
 #include <gio/gio.h>
 #include <glib.h>
 
+#include "nautilus-error-reporting.h"
 #include "nautilus-operations-ui-manager.h"
 #include "nautilus-file-changes-queue.h"
 #include "nautilus-file-private.h"
@@ -211,8 +212,6 @@ typedef struct
 #define NSEC_PER_MICROSEC 1000
 #define PROGRESS_NOTIFY_INTERVAL 100 * NSEC_PER_MICROSEC
 
-#define MAXIMUM_DISPLAYED_FILE_NAME_LENGTH 50
-
 #define IS_IO_ERROR(__error, KIND) (((__error)->domain == G_IO_ERROR && (__error)->code == G_IO_ERROR_ ## 
KIND))
 
 #define CANCEL _("_Cancel")
@@ -1863,7 +1862,7 @@ file_deleted_callback (GFile    *file,
     GFileType file_type;
     char *primary;
     char *secondary;
-    char *details = NULL;
+    g_autofree char *details = NULL;
     int response;
     g_autofree gchar *basename = NULL;
 
@@ -1918,8 +1917,8 @@ file_deleted_callback (GFile    *file,
                                      basename);
     }
 
-    details = error->message;
-
+    details = eel_str_middle_truncate (error->message,
+                                       MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
     response = run_cancel_or_skip_warning (job,
                                            primary,
                                            secondary,
@@ -2169,7 +2168,8 @@ trash_file (CommonJob     *job,
             GList        **to_delete)
 {
     GError *error;
-    char *primary, *secondary, *details;
+    char *primary, *secondary;
+    g_autofree char *details = NULL;
     int response;
     g_autofree gchar *basename = NULL;
 
@@ -2213,11 +2213,11 @@ trash_file (CommonJob     *job,
                                  "to delete it immediately?"),
                                basename);
 
-    details = NULL;
     secondary = NULL;
     if (!IS_IO_ERROR (error, NOT_SUPPORTED))
     {
-        details = error->message;
+        details = eel_str_middle_truncate (error->message,
+                                           MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
     }
     else if (!g_file_is_native (file))
     {
@@ -2572,8 +2572,10 @@ unmount_mount_callback (GObject      *source_object,
         if (error->code != G_IO_ERROR_FAILED_HANDLED)
         {
             g_autofree gchar *mount_name = NULL;
+            g_autofree char *details = NULL;
 
             mount_name = g_mount_get_name (G_MOUNT (source_object));
+            details = eel_str_middle_truncate (error->message, MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
             if (data->eject)
             {
                 primary = g_strdup_printf (_("Unable to eject %s"),
@@ -2584,9 +2586,7 @@ unmount_mount_callback (GObject      *source_object,
                 primary = g_strdup_printf (_("Unable to unmount %s"),
                                            mount_name);
             }
-            show_error_dialog (primary,
-                               error->message,
-                               data->parent_window);
+            show_error_dialog (primary, details, data->parent_window);
             g_free (primary);
         }
     }
@@ -2903,15 +2903,16 @@ volume_mount_cb (GObject      *source_object,
             error->code != G_IO_ERROR_ALREADY_MOUNTED)
         {
             GtkWindow *parent;
+            g_autofree char *details = NULL;
 
             parent = gtk_mount_operation_get_parent (GTK_MOUNT_OPERATION (mount_op));
+            details = eel_str_middle_truncate (error->message,
+                                               MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
             name = g_volume_get_name (G_VOLUME (source_object));
             primary = g_strdup_printf (_("Unable to access “%s”"), name);
             g_free (name);
             success = FALSE;
-            show_error_dialog (primary,
-                               error->message,
-                               parent);
+            show_error_dialog (primary, details, parent);
             g_free (primary);
         }
         g_error_free (error);
@@ -3101,7 +3102,7 @@ scan_dir (GFile      *dir,
     GError *error;
     GFile *subdir;
     GFileEnumerator *enumerator;
-    char *primary, *secondary, *details;
+    char *primary, *secondary;
     int response;
     SourceInfo saved_info;
 
@@ -3154,6 +3155,7 @@ retry:
         else if (error)
         {
             g_autofree gchar *basename = NULL;
+            g_autofree char *details = NULL;
 
             primary = get_scan_primary (source_info->op);
             details = NULL;
@@ -3169,7 +3171,8 @@ retry:
             {
                 secondary = g_strdup_printf (_("There was an error getting information about the "
                                                "files in the folder “%s”."), basename);
-                details = error->message;
+                details = eel_str_middle_truncate (error->message,
+                                                   MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
             }
 
             response = run_warning (job,
@@ -3213,6 +3216,7 @@ retry:
     else
     {
         g_autofree gchar *basename = NULL;
+        g_autofree char *details = NULL;
 
         primary = get_scan_primary (source_info->op);
         details = NULL;
@@ -3227,7 +3231,8 @@ retry:
         {
             secondary = g_strdup_printf (_("There was an error reading the folder “%s”."),
                                          basename);
-            details = error->message;
+            details = eel_str_middle_truncate (error->message,
+                                               MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
         }
         /* set show_all to TRUE here, as we don't know how many
          * files we'll end up processing yet.
@@ -3277,7 +3282,6 @@ scan_file (GFile      *file,
     GFile *dir;
     char *primary;
     char *secondary;
-    char *details;
     int response;
 
     dirs = g_queue_new ();
@@ -3323,6 +3327,7 @@ retry:
     else
     {
         g_autofree gchar *basename = NULL;
+        g_autofree char *details = NULL;
 
         primary = get_scan_primary (source_info->op);
         details = NULL;
@@ -3337,7 +3342,8 @@ retry:
         {
             secondary = g_strdup_printf (_("There was an error getting information about “%s”."),
                                          basename);
-            details = error->message;
+            details = eel_str_middle_truncate (error->message,
+                                               MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
         }
         /* set show_all to TRUE here, as we don't know how many
          * files we'll end up processing yet.
@@ -3430,7 +3436,7 @@ verify_destination (CommonJob  *job,
     GError *error;
     guint64 free_size;
     guint64 size_difference;
-    char *primary, *secondary, *details;
+    char *primary, *secondary;
     int response;
     GFileType file_type;
     gboolean dest_is_symlink = FALSE;
@@ -3453,6 +3459,7 @@ retry:
     if (info == NULL)
     {
         g_autofree gchar *basename = NULL;
+        g_autofree char *details = NULL;
 
         if (IS_IO_ERROR (error, CANCELLED))
         {
@@ -3471,7 +3478,8 @@ retry:
         else
         {
             secondary = g_strdup (_("There was an error getting information about the destination."));
-            details = error->message;
+            details = eel_str_middle_truncate (error->message,
+                                               MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
         }
 
         response = run_error (job,
@@ -3567,6 +3575,7 @@ retry:
         {
             g_autofree gchar *basename = NULL;
             g_autofree gchar *formatted_size = NULL;
+            g_autofree char *details = NULL;
 
             basename = get_basename (dest);
             size_difference = required_size - free_size;
@@ -4454,7 +4463,7 @@ create_dest_dir (CommonJob  *job,
 {
     GError *error;
     GFile *new_dest, *dest_dir;
-    char *primary, *secondary, *details;
+    char *primary, *secondary;
     int response;
     gboolean handled_invalid_filename;
     gboolean res;
@@ -4487,6 +4496,7 @@ retry:
     if (!res)
     {
         g_autofree gchar *basename = NULL;
+        g_autofree char *details = NULL;
 
         if (IS_IO_ERROR (error, CANCELLED))
         {
@@ -4524,7 +4534,6 @@ retry:
         }
 
         primary = g_strdup (_("Error while copying."));
-        details = NULL;
         basename = get_basename (src);
 
         if (IS_IO_ERROR (error, PERMISSION_DENIED))
@@ -4537,7 +4546,8 @@ retry:
         {
             secondary = g_strdup_printf (_("There was an error creating the folder “%s”."),
                                          basename);
-            details = error->message;
+            details = eel_str_middle_truncate (error->message,
+                                               MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
         }
 
         response = run_warning (job,
@@ -4602,7 +4612,7 @@ copy_move_directory (CopyMoveJob   *copy_job,
     GError *error;
     GFile *src_file;
     GFileEnumerator *enumerator;
-    char *primary, *secondary, *details;
+    char *primary, *secondary;
     char *dest_fs_type;
     int response;
     gboolean skip_error;
@@ -4687,6 +4697,7 @@ retry:
         else if (error)
         {
             g_autofree gchar *basename = NULL;
+            g_autofree char *details = NULL;
 
             if (copy_job->is_move)
             {
@@ -4696,7 +4707,6 @@ retry:
             {
                 primary = g_strdup (_("Error while copying."));
             }
-            details = NULL;
             basename = get_basename (src);
 
             if (IS_IO_ERROR (error, PERMISSION_DENIED))
@@ -4709,7 +4719,8 @@ retry:
                 secondary = g_strdup_printf (_("There was an error getting information about "
                                                "the files in the folder “%s”."),
                                              basename);
-                details = error->message;
+                details = eel_str_middle_truncate (error->message,
+                                                   MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
             }
 
             response = run_warning (job,
@@ -4753,6 +4764,7 @@ retry:
     else
     {
         g_autofree gchar *basename = NULL;
+        g_autofree char *details = NULL;
 
         if (copy_job->is_move)
         {
@@ -4775,7 +4787,8 @@ retry:
             secondary = g_strdup_printf (_("There was an error reading the folder “%s”."),
                                          basename);
 
-            details = error->message;
+            details = eel_str_middle_truncate (error->message,
+                                               MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
         }
 
         response = run_warning (job,
@@ -4824,6 +4837,7 @@ retry:
         if (!g_file_delete (src, job->cancellable, &error))
         {
             g_autofree gchar *basename = NULL;
+            g_autofree char *details = NULL;
 
             if (job->skip_all_error)
             {
@@ -4832,7 +4846,8 @@ retry:
             basename = get_basename (src);
             primary = g_strdup_printf (_("Error while moving “%s”."), basename);
             secondary = g_strdup (_("Could not remove the source folder."));
-            details = error->message;
+            details = eel_str_middle_truncate (error->message,
+                                               MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
 
             response = run_cancel_or_skip_warning (job,
                                                    primary,
@@ -5023,7 +5038,7 @@ copy_move_file (CopyMoveJob   *copy_job,
     g_autofree gchar *dest_uri = NULL;
     GError *error;
     GFileCopyFlags flags;
-    char *primary, *secondary, *details;
+    char *primary, *secondary;
     int response;
     ProgressData pdata;
     gboolean would_recurse, is_merge;
@@ -5369,6 +5384,7 @@ retry:
             {
                 g_autofree gchar *basename = NULL;
                 g_autofree gchar *filename = NULL;
+                g_autofree char *details = NULL;
 
                 if (job->skip_all_error)
                 {
@@ -5389,7 +5405,8 @@ retry:
                 secondary = g_strdup_printf (_("Could not remove the already existing file "
                                                "with the same name in %s."),
                                              filename);
-                details = error->message;
+                details = eel_str_middle_truncate (error->message,
+                                                   MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
 
                 /* setting TRUE on show_all here, as we could have
                  * another error on the same file later.
@@ -5463,6 +5480,7 @@ retry:
     {
         g_autofree gchar *basename = NULL;
         g_autofree gchar *filename = NULL;
+        g_autofree char *details = NULL;
 
         if (job->skip_all_error)
         {
@@ -5474,7 +5492,8 @@ retry:
         filename = g_file_get_parse_name (dest_dir);
         secondary = g_strdup_printf (_("There was an error copying the file into %s."),
                                      filename);
-        details = error->message;
+        details = eel_str_middle_truncate (error->message,
+                                           MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
 
         response = run_cancel_or_skip_warning (job,
                                                primary,
@@ -5832,7 +5851,7 @@ move_file_prepare (CopyMoveJob  *move_job,
     GError *error;
     CommonJob *job;
     gboolean overwrite;
-    char *primary, *secondary, *details;
+    char *primary, *secondary;
     int response;
     GFileCopyFlags flags;
     MoveFileCopyFallback *fallback;
@@ -6047,6 +6066,7 @@ retry:
     {
         g_autofree gchar *basename = NULL;
         g_autofree gchar *filename = NULL;
+        g_autofree char *details = NULL;
 
         if (job->skip_all_error)
         {
@@ -6059,7 +6079,8 @@ retry:
         secondary = g_strdup_printf (_("There was an error moving the file into %s."),
                                      filename);
 
-        details = error->message;
+        details = eel_str_middle_truncate (error->message,
+                                           MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
 
         response = run_warning (job,
                                 primary,
@@ -6403,7 +6424,7 @@ link_file (CopyMoveJob  *job,
     gboolean not_local;
     GError *error;
     CommonJob *common;
-    char *primary, *secondary, *details;
+    char *primary, *secondary;
     int response;
     gboolean handled_invalid_filename;
 
@@ -6495,6 +6516,7 @@ retry:
     else if (error != NULL)
     {
         g_autofree gchar *basename = NULL;
+        g_autofree char *details = NULL;
 
         if (common->skip_all_error)
         {
@@ -6520,7 +6542,8 @@ retry:
             filename = g_file_get_parse_name (dest_dir);
             secondary = g_strdup_printf (_("There was an error creating the symlink in %s."),
                                          filename);
-            details = error->message;
+            details = eel_str_middle_truncate (error->message,
+                                               MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
         }
 
         response = run_warning (common,
@@ -7071,7 +7094,7 @@ create_task_thread_func (GTask        *task,
     GError *error;
     gboolean res;
     gboolean filename_is_utf8;
-    char *primary, *secondary, *details;
+    char *primary, *secondary;
     int response;
     char *data;
     int length;
@@ -7402,6 +7425,7 @@ retry:
         {
             g_autofree gchar *basename = NULL;
             g_autofree gchar *filename = NULL;
+            g_autofree char *details = NULL;
 
             basename = get_basename (dest);
             if (job->make_dir)
@@ -7417,8 +7441,8 @@ retry:
             filename = g_file_get_parse_name (job->dest_dir);
             secondary = g_strdup_printf (_("There was an error creating the directory in %s."),
                                          filename);
-
-            details = error->message;
+            details = eel_str_middle_truncate (error->message,
+                                               MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
 
             response = run_warning (common,
                                     primary,
@@ -7739,9 +7763,14 @@ retry:
 
     if (interactive && error != NULL)
     {
+        g_autofree char *details = NULL;
+
+        details = eel_str_middle_truncate (error->message,
+                                           MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
+
         response = run_error (common,
                               g_strdup (_("Unable to mark launcher trusted (executable)")),
-                              error->message,
+                              details,
                               NULL,
                               FALSE,
                               CANCEL, RETRY,
@@ -7975,6 +8004,7 @@ extract_job_on_error (AutoarExtractor *extractor,
 {
     ExtractJob *extract_job = user_data;
     GFile *source_file;
+    g_autofree char *details = NULL;
     gint response_id;
     g_autofree gchar *basename = NULL;
 
@@ -7992,11 +8022,12 @@ extract_job_on_error (AutoarExtractor *extractor,
     nautilus_progress_info_take_status (extract_job->common.progress,
                                         g_strdup_printf (_("Error extracting “%s”"),
                                                          basename));
-
+    details = eel_str_middle_truncate (error->message,
+                                       MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
     response_id = run_warning ((CommonJob *) extract_job,
                                g_strdup_printf (_("There was an error while extracting “%s”."),
                                                 basename),
-                               g_strdup (error->message),
+                               details,
                                NULL,
                                FALSE,
                                CANCEL,
@@ -8459,8 +8490,12 @@ compress_job_on_error (AutoarCompressor *compressor,
     CompressJob *compress_job = user_data;
     char *status;
     g_autofree gchar *basename_output_file = NULL;
+    g_autofree char *details = NULL;
 
     basename_output_file = get_basename (compress_job->output_file);
+    details = eel_str_middle_truncate (error->message,
+                                       MAXIMUM_DISPLAYED_ERROR_MESSAGE_LENGTH);
+
     if (compress_job->total_files == 1)
     {
         g_autofree gchar *basename_data = NULL;
@@ -8483,7 +8518,7 @@ compress_job_on_error (AutoarCompressor *compressor,
 
     run_error ((CommonJob *) compress_job,
                g_strdup (_("There was an error while compressing files.")),
-               g_strdup (error->message),
+               details,
                NULL,
                FALSE,
                CANCEL,


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