[polari] mainWindow: Notify users when establishing a connection
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] mainWindow: Notify users when establishing a connection
- Date: Thu, 8 Aug 2013 13:09:37 +0000 (UTC)
commit 19b6b4279747f5c0ffddc3b8284b7f8622a32967
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Aug 8 02:22:34 2013 +0200
mainWindow: Notify users when establishing a connection
Unfortunately connecting to a server can take a while, so use
in-app notifications to inform users about what's going on.
src/appNotifications.js | 31 +++++++++++++++++++++++++++++++
src/mainWindow.js | 14 ++++++++++++++
2 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/src/appNotifications.js b/src/appNotifications.js
index 7ca106b..e292d30 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -1,5 +1,6 @@
const Gtk = imports.gi.Gtk;
const Pango = imports.gi.Pango;
+const Tp = imports.gi.TelepathyGLib;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
@@ -91,6 +92,36 @@ const GridOutput = new Lang.Class({
}
});
+const ConnectingNotification = new Lang.Class({
+ Name: 'ConnectingNotification',
+ Extends: AppNotification,
+
+ _init: function(account) {
+ this.parent();
+
+ this._grid = new Gtk.Grid({ orientation: Gtk.Orientation.HORIZONTAL,
+ column_spacing: 12 });
+
+ this._grid.add(new Gtk.Spinner({ active: true }));
+
+ let text = _("Connecting to %s").format(account.display_name);
+ let label = new Gtk.Label({ label: text });
+ this._grid.add(label);
+
+ this.widget.add(this._grid);
+ this.widget.show_all();
+
+ account.connect('notify::connection-status',
+ Lang.bind(this, this._onConnectionStatusChanged));
+ },
+
+ _onConnectionStatusChanged: function(account) {
+ if (account.connection_status == Tp.ConnectionStatus.CONNECTING)
+ return;
+ this.close();
+ }
+});
+
const NotificationQueue = new Lang.Class({
Name: 'NotificationQueue',
diff --git a/src/mainWindow.js b/src/mainWindow.js
index ffca056..b65db4f 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -2,6 +2,7 @@ const Gdk = imports.gi.Gdk;
const Gtk = imports.gi.Gtk;
const Tp = imports.gi.TelepathyGLib;
+const AccountsMonitor = imports.accountsMonitor;
const AppNotifications = imports.appNotifications;
const ChatroomManager = imports.chatroomManager;
const ChatView = imports.chatView;
@@ -35,6 +36,10 @@ const MainWindow = new Lang.Class({
this._ircParser = new IrcParser.IrcParser();
+ this._accountsMonitor = new AccountsMonitor.getDefault();
+ this._accountsMonitor.connect('account-status-changed',
+ Lang.bind(this, this._accountStatusChanged));
+
this._roomManager = new ChatroomManager.getDefault();
this._roomManager.connect('room-added',
Lang.bind(this, this._roomAdded));
@@ -108,6 +113,15 @@ const MainWindow = new Lang.Class({
this.window.show_all();
},
+ _accountStatusChanged: function(am, account) {
+ if (account.connection_status != Tp.ConnectionStatus.CONNECTING)
+ return;
+
+ let notification = new AppNotifications.ConnectingNotification(account);
+ this._notifications.addNotification(notification);
+ },
+
+
_roomAdded: function(roomManager, room) {
let userList;
let chatView = new ChatView.ChatView(room);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]