[gnome-commander] Move error message dialog out of the actual chmod action function



commit a4e3925396acb78f593442c1b1997b6b28cb8634
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Thu Jun 24 19:04:09 2021 +0200

    Move error message dialog out of the actual chmod action function

 src/dialogs/gnome-cmd-chmod-dialog.cc |  9 ++++++++-
 src/gnome-cmd-file.cc                 | 16 ----------------
 2 files changed, 8 insertions(+), 17 deletions(-)
---
diff --git a/src/dialogs/gnome-cmd-chmod-dialog.cc b/src/dialogs/gnome-cmd-chmod-dialog.cc
index b5e5deba..933f5eb1 100644
--- a/src/dialogs/gnome-cmd-chmod-dialog.cc
+++ b/src/dialogs/gnome-cmd-chmod-dialog.cc
@@ -64,13 +64,20 @@ G_DEFINE_TYPE (GnomeCmdChmodDialog, gnome_cmd_chmod_dialog, GNOME_CMD_TYPE_DIALO
 static void do_chmod (GnomeCmdFile *in, guint32 permissions, gboolean recursive, ChmodRecursiveMode mode)
 {
     g_return_if_fail (in != NULL);
+    GError *error = nullptr;
 
     if (!(recursive
           && mode == CHMOD_DIRS_ONLY
           && in->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) != G_FILE_TYPE_DIRECTORY))
     {
-        if (!in->chmod(permissions, nullptr))
+        if (!in->chmod(permissions, &error))
         {
+            auto filename = g_file_get_basename(in->gFile);
+            auto message = g_strdup_printf (_("Could not chmod %s"), filename);
+            gnome_cmd_show_message (nullptr, message, error->message);
+            g_error_free(error);
+            g_free(filename);
+            g_free(message);
             return;
         }
 
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index c44b3849..21e1ea18 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -358,14 +358,6 @@ gboolean GnomeCmdFile::chmod(guint32 permissions, GError **error)
                                             &tmp_error);
     if (tmp_error)
     {
-        g_message ("chmod: retrieving file info failed: %s", tmp_error->message);
-
-        gchar *fname = GetGfileAttributeString(G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
-        gchar *msg = g_strdup_printf (_("Could not chmod %s"), fname);
-        gnome_cmd_show_message (*main_win, msg, tmp_error->message);
-        g_free (msg);
-        g_free (fname);
-
         g_propagate_error (error, tmp_error);
         return false;
     }
@@ -383,14 +375,6 @@ gboolean GnomeCmdFile::chmod(guint32 permissions, GError **error)
                                     &tmp_error);
     if (tmp_error)
     {
-        g_message ("chmod: setting file mode failed: %s", tmp_error->message);
-
-        gchar *fname = GetGfileAttributeString(G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
-        gchar *msg = g_strdup_printf (_("Could not chmod %s"), fname);
-        gnome_cmd_show_message (*main_win, msg, tmp_error->message);
-        g_free (msg);
-        g_free (fname);
-
         g_object_unref(gFileInfoPerms);
         g_propagate_error (error, tmp_error);
         return false;


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