[polari/wip/bastianilso/error-handling: 6/7] make in-app notifications behave better with long text



commit cad2598fec8f48d49ef1fadac978927f77765ce1
Author: Bastian Ilsø <bastianilso src gnome org>
Date:   Fri Jul 17 14:10:24 2015 +0200

    make in-app notifications behave better with long text

 src/appNotifications.js |   60 +++++++++++++++++++++++++---------------------
 1 files changed, 33 insertions(+), 27 deletions(-)
---
diff --git a/src/appNotifications.js b/src/appNotifications.js
index f455a1f..73435f4 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -100,7 +100,7 @@ const ConnectingNotification = new Lang.Class({
 
     _init: function(account) {
         this.parent();
-
+        this._account = account;
         this._grid = new Gtk.Grid({ orientation: Gtk.Orientation.HORIZONTAL,
                                     column_spacing: 12 });
 
@@ -126,7 +126,12 @@ const ConnectingNotification = new Lang.Class({
         if (account.connection_status == Tp.ConnectionStatus.CONNECTING)
             return;
         this.close();
-    }
+    },
+
+    close: function() {
+        this.parent();
+        this._account.notification = null;
+    },
 
 });
 
@@ -136,12 +141,22 @@ const ErrorNotification = new Lang.Class({
 
     _init: function(account, window, statusReason) {
         this.parent();
+        this._account = account;
         this._grid = new Gtk.Grid({ orientation: Gtk.Orientation.HORIZONTAL,
                                     column_spacing: 12 });
 
         this._grid.add(new Gtk.Image({icon_name: 'dialog-error-symbolic' }));
 
-        let button = new Gtk.Button({label: "Edit Account"});
+        // Not sure if it is necessary to support all types of error messages.
+        // Telepathy-idle only emit a small subset of all of them..
+        this._connectionErrorMessages = {};
+        this._connectionErrorMessages[Tp.error_get_dbus_name(Tp.Error.NETWORK_ERROR)]
+          = _("Polari disconnected due to a network error. Please check if the address field is correct.");
+        this._connectionErrorMessages[Tp.error_get_dbus_name(Tp.Error.AUTHENTICATION_FAILED)]
+          = _("Authentication failed");
+
+        let button = new Gtk.Button({label: "Edit Account",
+                                     valign: Gtk.Align.CENTER });
         button.connect('clicked', Lang.bind(this, function() {
             log('clicked');
             let error = {message: this._getMessage(account.connection_error),
@@ -150,27 +165,18 @@ const ErrorNotification = new Lang.Class({
             let dialog = new Connections.ConnectionDetailsDialog(account);
             dialog.widget.transient_for = window;
             dialog.widget.show();
-            dialog.widget.connect('response', function(w, response) {
-                dialog.widget.destroy();
-                if (response != Gtk.ResponseType.OK)
-                    return;
-                    this.close();
-
-                    // should try to connect again but
-                    // we already try again when account info is updated in SSL patch
-                });
+            dialog.widget.connect('response', Lang.bind(this,
+                    function(w, response) {
+                    dialog.widget.destroy();
+                    if (response == Gtk.ResponseType.OK)
+                        this.close();
+                        // should try to connect again but
+                        // we already try again when account info is updated in SSL patch
+                }));
             }));
 
-        // Not sure if it is necessary to support all types of error messages.
-        // Telepathy-idle only emit a small subset of all of them..
-        this._connectionErrorMessages = {};
-        this._connectionErrorMessages[Tp.error_get_dbus_name(Tp.Error.NETWORK_ERROR)]
-          = _("Polari disconnected due to a network error. Please check if the address field is correct.");
-        this._connectionErrorMessages[Tp.error_get_dbus_name(Tp.Error.AUTHENTICATION_FAILED)]
-          = _("Authentication failed");
-
         let text = _("Unable to connect to %s").format(account.display_name);
-        let label = new Gtk.Label({ label: text });
+        let label = new Gtk.Label({ label: text, max_width_chars: 30, wrap: true });
         this._grid.add(label);
         this._grid.add(button);
         this.widget.add(this._grid);
@@ -200,11 +206,11 @@ const ErrorNotification = new Lang.Class({
         this.close();
     },
 
-    /*close: function() {
-        super();
-        account.notification = null;
-        account.error = null;
-    },*/
+    close: function() {
+        this.parent();
+        this._account.notification = null;
+        this._account.error = null;
+    },
 });
 
 const NotificationQueue = new Lang.Class({
@@ -213,7 +219,7 @@ const NotificationQueue = new Lang.Class({
     _init: function() {
         this.widget = new Gtk.Frame({ valign: Gtk.Align.START,
                                       halign: Gtk.Align.CENTER,
-                                      no_show_all: true });
+                                      no_show_all: false });
         this.widget.get_style_context().add_class('app-notification');
 
         this._grid = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL,


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