[polari/wip/bastianilso/error-handling: 9/10] connection details error information



commit 8a853b037ea1954a66e6f2d338a6a42709cacf8c
Author: Bastian Ilsø <bastianilso src gnome org>
Date:   Tue Jul 28 14:24:01 2015 +0200

    connection details error information

 data/resources/application.css |   11 +++++++++++
 src/appNotifications.js        |    8 ++++++--
 src/connections.js             |   20 ++++++++++++++++++++
 3 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/data/resources/application.css b/data/resources/application.css
index 96eddcf..5dc070d 100644
--- a/data/resources/application.css
+++ b/data/resources/application.css
@@ -131,3 +131,14 @@
 .polari-background-description {
     font-size: larger;
 }
+
+.polari-error-information {
+    background-color: @polari_dark_bg_color;
+    border-style: solid;
+    border-color: @borders;
+    border-width: 1px 0 0 0;
+}
+.polari-error-information GtkLabel {
+    color: @theme_fg_color;
+    font-size: smaller;
+}
diff --git a/src/appNotifications.js b/src/appNotifications.js
index de37c1a..9fd5c8f 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -127,8 +127,9 @@ const ErrorNotification = new Lang.Class({
             // - when you disconnect while connecting and reconnect (then you disconnect temporarily again 
with this error and reconnect shortly after)
             // - when you try to connect to a port that only supports SSL, but didn't check off "use-ssl" 
(fx by specifying a wrong port number).
             this._label.label = _("Unable to connect to %s").format(this._account.display_name);
+            let details = _("Polari disconnected due to a network error. Please check if the address field 
is correct.");
             this._button.label =  _("Edit Account");
-            this._button.connect('clicked', Lang.bind(this, this._editAccountAction));
+            this._button.connect('clicked', Lang.bind(this, this._editAccountAction, details));
         } else if (error == Tp.error_get_dbus_name(Tp.Error.AUTHENTICATION_FAILED)) {
             this._label.label = _("Authentication failed for %s.").format(this._account.display_name);
             this._button.label =  _("Retry");
@@ -179,7 +180,10 @@ const ErrorNotification = new Lang.Class({
         }
     },
 
-    _editAccountAction: function(button) {
+    _editAccountAction: function(button, details) {
+        let error = {message: details,
+                     icon_name: 'dialog-error-symbolic', widget: 'serverEntry'};
+        this._account.error = error;
         let dialog = new Connections.ConnectionDetailsDialog(this._account);
         dialog.widget.transient_for = this._window;
         dialog.widget.show();
diff --git a/src/connections.js b/src/connections.js
index c65fe5e..0caa2d0 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -255,6 +255,10 @@ const ConnectionDetails = new Lang.Class({
 
         if (server != account.display_name)
             this._descEntry.text = account.display_name;
+
+        if (!account.error)
+            return;
+        this._serverEntry.get_style_context().add_class('error');
     },
 
     get can_confirm() {
@@ -357,5 +361,21 @@ const ConnectionDetailsDialog = new Lang.Class({
                                     this._confirmButton, 'sensitive',
                                     GObject.BindingFlags.SYNC_CREATE);
         this.widget.get_content_area().add(this._details);
+        if (account && account.error)
+            this.widget.get_content_area().add(this._createErrorMessage(account.error));
+    },
+
+    _createErrorMessage: function(error) {
+        let icon = new Gtk.Image({ icon_name: error.icon_name,
+                                   icon_size: 5, margin_start: 18 });
+        let label = new Gtk.Label({ label: error.message, xalign: 0, wrap: true,
+                                    vexpand: true, max_width_chars: 37, margin: 12 });
+        let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL,
+                                 spacing: 12, sensitive: false, vexpand: true });
+        hbox.add(icon);
+        hbox.add(label);
+        hbox.get_style_context().add_class('polari-error-information');
+        hbox.show_all();
+        return hbox;
     }
 });


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