[polari/wip/bastianilso/error-handling: 5/10] status icon sidebar changes + removed connecting notifications
- From: Bastian Ilsø Hougaard <bastianilso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/bastianilso/error-handling: 5/10] status icon sidebar changes + removed connecting notifications
- Date: Wed, 29 Jul 2015 22:26:40 +0000 (UTC)
commit 869965bef0c4a46d5b99590110a67f9de480cdfd
Author: Bastian Ilsø <bastianilso src gnome org>
Date: Tue Jul 28 12:01:58 2015 +0200
status icon sidebar changes + removed connecting notifications
src/appNotifications.js | 34 -----------------------------
src/mainWindow.js | 24 --------------------
src/roomList.js | 55 +++++++++++++++++++++++++++++++++++++++++++---
3 files changed, 51 insertions(+), 62 deletions(-)
---
diff --git a/src/appNotifications.js b/src/appNotifications.js
index 694c422..24d6009 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -89,40 +89,6 @@ 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();
-
- let id = account.connect('notify::connection-status',
- Lang.bind(this, this._onConnectionStatusChanged));
- this.widget.connect('destroy',
- function() {
- account.disconnect(id);
- });
- },
-
- _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 6e6ad86..2443d10 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -55,10 +55,6 @@ const MainWindow = new Lang.Class({
);
this._accountsMonitor = AccountsMonitor.getDefault();
- this._accountsMonitor.connect('account-status-changed',
- Lang.bind(this, this._onAccountChanged));
- this._accountsMonitor.connect('account-added',
- Lang.bind(this, this._onAccountChanged));
this._roomManager = ChatroomManager.getDefault();
this._roomManager.connect('active-changed',
@@ -119,26 +115,6 @@ const MainWindow = new Lang.Class({
GLib.Variant.new('ai', this._currentSize));
},
- _onAccountChanged: function(am, account) {
- if (account.connection_status != Tp.ConnectionStatus.CONNECTING)
- return;
-
- if (account._connectingNotification)
- return;
-
- let app = Gio.Application.get_default();
- let notification = new AppNotifications.ConnectingNotification(account);
- app.notificationQueue.addNotification(notification);
- app.mark_busy();
-
- account._connectingNotification = notification;
- notification.widget.connect('destroy',
- function() {
- app.unmark_busy();
- delete account._connectingNotification;
- });
- },
-
_updateDecorations: function() {
let layoutLeft = null;
let layoutRight = null;
diff --git a/src/roomList.js b/src/roomList.js
index f7ee09f..ea8dc25 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -281,14 +281,61 @@ const RoomList = new Lang.Class({
if (row.get_header())
return;
- let label = new Gtk.Label({ margin_bottom: 4, xalign: 0,
+ let hbox = new Gtk.Box({ margin_bottom: 4, spacing: 2, hexpand: true,
+ orientation: Gtk.Orientation.HORIZONTAL, visible: true });
+ hbox.get_style_context().add_class('room-list-header');
+
+ let label = new Gtk.Label({ xalign: 0, margin: 4,
max_width_chars: 15,
ellipsize: Pango.EllipsizeMode.END });
- label.get_style_context().add_class('room-list-header');
-
account.bind_property('display-name', label, 'label',
GObject.BindingFlags.SYNC_CREATE);
- row.set_header(label);
+ hbox.add(label);
+
+ let icon = new Gtk.Stack({ vhomogeneous: true, valign: Gtk.Align.CENTER });
+ let error = new Gtk.Image({icon_name: 'dialog-error-symbolic',halign: Gtk.Align.START });
+ icon.add_named(error, 'error');
+ let connecting = new Gtk.Spinner({active: true, halign: Gtk.Align.START });
+ icon.add_named(connecting, 'connecting');
+ icon.add_named(new Gtk.Box({visible: false}), 'none');
+ let displayStatus = function(binding) {
+ let child = 'none';
+ let status = binding.source.connection_status;
+ let reason = binding.source.connection_status_reason;
+ //log('transformTo called for' + account.get_path_suffix());
+ if (status == Tp.ConnectionStatus.CONNECTING) {
+ this._networkMonitor = Gio.NetworkMonitor.get_default();
+ if (this._networkMonitor.network_available)
+ child = 'connecting';
+ } else if (status == Tp.ConnectionStatus.DISCONNECTED) {
+ if (reason != Tp.ConnectionStatusReason.REQUESTED)
+ child = 'error';
+ }
+ binding.target.visible_child_name = child;
+ }
+ account.bind_property_full('connection-status', icon, 'visible-child-name',
+ GObject.BindingFlags.DEFAULT, displayStatus, function(){});
+ hbox.add(icon);
+ hbox.show_all();
+ let child;
+ if (account.connection_status == Tp.ConnectionStatus.CONNECTING) {
+ this._networkMonitor = Gio.NetworkMonitor.get_default();
+ //log('network_available: ' + this._networkMonitor.network_available);
+ if (this._networkMonitor.network_available)
+ icon.visible_child_name = 'connecting';
+ else
+ icon.visible_child_name = 'none';
+ } else if (account.connection_status == Tp.ConnectionStatus.DISCONNECTED) {
+ if (account.connection_status_reason == Tp.ConnectionStatusReason.REQUESTED)
+ icon.visible_child_name = 'none';
+ else
+ icon.visible_child_name = 'error';
+ }
+ //log('visible child name: ' + icon.visible_child_name);
+ row.set_header(hbox);
+ },
+
+ _evaluateStatus: function() {
},
_sort: function(row1, row2) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]