[gnome-commander] Show the GIO error when a remote connection failed



commit b726eed5d9bef092ecdc28e0ae5993a48a0775cf
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Fri Oct 1 23:50:33 2021 +0200

    Show the GIO error when a remote connection failed
    
    Had to change the setup of the OPEN_FAILED signal; copied from OPEN_DONE

 src/gnome-cmd-con-remote.cc |  4 +++-
 src/gnome-cmd-con.cc        | 11 +++++------
 src/gnome-cmd-con.h         |  2 +-
 src/gnome-cmd-file-list.cc  |  7 ++-----
 4 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/src/gnome-cmd-con-remote.cc b/src/gnome-cmd-con-remote.cc
index b05b32ae..341047f2 100644
--- a/src/gnome-cmd-con-remote.cc
+++ b/src/gnome-cmd-con-remote.cc
@@ -63,8 +63,10 @@ static void get_file_info_func (GnomeCmdCon *con)
         else
         {
             con->state = GnomeCmdCon::STATE_CLOSED;
-            con->open_failed_error = error;
+            con->open_failed_error = g_error_copy(error);
             con->open_result = GnomeCmdCon::OPEN_FAILED;
+            con->open_failed_msg = g_strdup (con->open_failed_error->message);
+            g_error_free(error);
         }
     }
     else
diff --git a/src/gnome-cmd-con.cc b/src/gnome-cmd-con.cc
index 14a36b71..dbaa421a 100644
--- a/src/gnome-cmd-con.cc
+++ b/src/gnome-cmd-con.cc
@@ -70,11 +70,10 @@ static void on_open_done (GnomeCmdCon *con)
 }
 
 
-static void on_open_failed (GnomeCmdCon *con, const gchar *msg, GnomeVFSResult result)
+static void on_open_failed (GnomeCmdCon *con)
 {
     // gnome_cmd_con_updated (con);
-    // ToDo: Show error and later on g_error_free con->open_failed_error
-    g_critical("open_failed - error: %s\n", con->open_failed_error->message);
+    // Free the error because the error handling is done now. (Logging happened already.)
     g_error_free(con->open_failed_error);
     con->open_failed_msg = nullptr;
 }
@@ -155,9 +154,9 @@ static void class_init (GnomeCmdConClass *klass)
             GTK_RUN_LAST,
             G_OBJECT_CLASS_TYPE (object_class),
             GTK_SIGNAL_OFFSET (GnomeCmdConClass, open_failed),
-            gtk_marshal_NONE__POINTER_INT,
+            gtk_marshal_NONE__NONE,
             GTK_TYPE_NONE,
-            2, GTK_TYPE_POINTER, GTK_TYPE_INT);
+            0);
 
     object_class->destroy = destroy;
 
@@ -278,7 +277,7 @@ static gboolean check_con_open_progress (GnomeCmdCon *con)
             {
                 DEBUG ('m', "GnomeCmdCon::OPEN_FAILED detected\n");
                 DEBUG ('m', "Emitting 'open-failed' signal\n");
-                gtk_signal_emit (GTK_OBJECT (con), signals[OPEN_FAILED], con->open_failed_msg, 
con->open_failed_error->code);
+                gtk_signal_emit (GTK_OBJECT (con), signals[OPEN_FAILED]);
             }
             return FALSE;
 
diff --git a/src/gnome-cmd-con.h b/src/gnome-cmd-con.h
index 1b960dbe..65b6de31 100644
--- a/src/gnome-cmd-con.h
+++ b/src/gnome-cmd-con.h
@@ -127,7 +127,7 @@ struct GnomeCmdConClass
     /* signals */
     void (* updated) (GnomeCmdCon *con);
     void (* open_done) (GnomeCmdCon *con);
-    void (* open_failed) (GnomeCmdCon *con, const gchar *msg, GnomeVFSResult result);
+    void (* open_failed) (GnomeCmdCon *con);
 
     /* virtual functions */
     void (* open) (GnomeCmdCon *con);
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index 4d844992..47cd4c8a 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -1711,7 +1711,7 @@ static void on_con_open_done (GnomeCmdCon *con, GnomeCmdFileList *fl)
 }
 
 
-static void on_con_open_failed (GnomeCmdCon *con, const gchar *msg, GnomeVFSResult result, GnomeCmdFileList 
*fl)
+static void on_con_open_failed (GnomeCmdCon *con, GnomeCmdFileList *fl)
 {
     DEBUG('m', "on_con_open_failed\n");
 
@@ -1722,10 +1722,7 @@ static void on_con_open_failed (GnomeCmdCon *con, const gchar *msg, GnomeVFSResu
 
     g_signal_handlers_disconnect_matched (con, G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, fl);
 
-    if (msg)
-        gnome_cmd_show_message (nullptr, msg);
-    else
-        gnome_cmd_show_message (nullptr, _("Failed to open connection."), gnome_vfs_result_to_string 
(result));
+    gnome_cmd_show_message (nullptr,  _("Failed to open connection."), con->open_failed_msg);
 
     fl->priv->con_open_dialog = nullptr;
     fl->priv->con_opening = nullptr;


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