[polari/wip/fmuellner/disconnect-accounts: 24/25] Use PolariAccount:visible instead of :enabled
- From: Bastian Ilsø Hougaard <bastianilso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/disconnect-accounts: 24/25] Use PolariAccount:visible instead of :enabled
- Date: Fri, 2 Feb 2018 21:21:26 +0000 (UTC)
commit f3e20b01f9c3dced9f89dad3cddf04628bcbfd75
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Nov 9 03:29:26 2017 +0100
Use PolariAccount:visible instead of :enabled
Return to showing disabled accounts in the UI by switching to the
:visible property to control an account's visibility. In a next
step, we will also expose enable and disable in the UI again.
https://bugzilla.gnome.org/show_bug.cgi?id=771889
src/accountsMonitor.js | 13 +++++++++++--
src/application.js | 15 ++++++++++-----
src/joinDialog.js | 2 +-
src/mainWindow.js | 4 ++--
src/roomList.js | 6 +++---
src/roomManager.js | 6 +++---
src/serverRoomManager.js | 2 +-
src/telepathyClient.js | 9 ++++++---
8 files changed, 37 insertions(+), 20 deletions(-)
---
diff --git a/src/accountsMonitor.js b/src/accountsMonitor.js
index 74341e5..70151be 100644
--- a/src/accountsMonitor.js
+++ b/src/accountsMonitor.js
@@ -35,8 +35,8 @@ var AccountsMonitor = class {
return [...this._accounts.values()];
}
- get enabledAccounts() {
- return [...this._accounts.values()].filter(a => a.enabled);
+ get visibleAccounts() {
+ return [...this._accounts.values()].filter(a => a.visible);
}
get accountManager() {
@@ -121,6 +121,12 @@ var AccountsMonitor = class {
account.connect('notify::connection-status', () => {
this.emit('account-status-changed', account);
});
+ account._visibleNotifyId =
+ account.connect('notify::visible', () => {
+ this.emit(account.visible ? 'account-shown'
+ : 'account-hidden', account);
+ this.emit('accounts-changed');
+ });
this._accounts.set(account.object_path, account);
this.emit('account-added', account);
@@ -134,6 +140,9 @@ var AccountsMonitor = class {
account.disconnect(account._statusNotifyId);
delete account._statusNotifyId;
+ account.disconnect(account._visibleNotifyId);
+ delete account._visibleNotifyId;
+
this.emit('account-removed', account);
this.emit('accounts-changed');
}
diff --git a/src/application.js b/src/application.js
index 254a130..f7f3576 100644
--- a/src/application.js
+++ b/src/application.js
@@ -345,7 +345,7 @@ var Application = GObject.registerClass({
_openURIs(uris, time) {
let map = {};
- this._accountsMonitor.enabledAccounts.forEach(a => {
+ this._accountsMonitor.visibleAccounts.forEach(a => {
let params = a.dup_parameters_vardict().deep_unpack();
map[a.get_object_path()] = {
server: params.server.deep_unpack(),
@@ -658,10 +658,14 @@ var Application = GObject.registerClass({
action.change_state(GLib.Variant.new('b', !state.get_boolean()));
}
- _onRemoveConnection(action, parameter){
+ _onRemoveConnection(action, parameter) {
let accountPath = parameter.deep_unpack();
let account = this._accountsMonitor.lookupAccount(accountPath);
- account.set_enabled_async(false, () => {
+
+ account.set_enabled_async(false, (o, res) => {
+ account.set_enabled_finish(res);
+ account.visible = false;
+
let label = _("%s removed.").format(account.display_name);
let n = new AppNotifications.UndoNotification(label);
this.notificationQueue.addNotification(n);
@@ -672,8 +676,9 @@ var Application = GObject.registerClass({
});
});
n.connect('undo', () => {
- account.set_enabled_async(true, (a, res) => {
- a.set_enabled_finish(res); // TODO: Check for errors
+ account.set_enabled_async(true, (o, res) => {
+ account.set_enabled_finish(res);
+ account.visible = true;
});
});
});
diff --git a/src/joinDialog.js b/src/joinDialog.js
index 7686ce9..6da6c4b 100644
--- a/src/joinDialog.js
+++ b/src/joinDialog.js
@@ -53,7 +53,7 @@ var JoinDialog = GObject.registerClass({
this._accountsMonitor = AccountsMonitor.getDefault();
this._accounts = new Map();
- this._accountsMonitor.enabledAccounts.forEach(a => {
+ this._accountsMonitor.visibleAccounts.forEach(a => {
this._accounts.set(a.display_name, a);
});
this._accountAddedId =
diff --git a/src/mainWindow.js b/src/mainWindow.js
index f12fd17..b03a7e6 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -273,7 +273,7 @@ var MainWindow = GObject.registerClass({
}
_onAccountsChanged(am) {
- let hasAccounts = this._accountsMonitor.enabledAccounts.length > 0;
+ let hasAccounts = this._accountsMonitor.visibleAccounts.length > 0;
this._roomListRevealer.reveal_child = hasAccounts;
}
@@ -351,7 +351,7 @@ var MainWindow = GObject.registerClass({
let roomId = null;
let account = this._accountsMonitor.lookupAccount(selectedRoom.account);
let channelName = selectedRoom.channel;
- if (account && account.enabled && channelName)
+ if (account && account.visible && channelName)
roomId = Polari.create_room_id(account, channelName, Tp.HandleType.ROOM);
this.active_room = this._roomManager.lookupRoom(roomId) ||
diff --git a/src/roomList.js b/src/roomList.js
index e7f6087..e5d0229 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -436,10 +436,10 @@ class RoomList extends Gtk.ListBox {
this._accountAdded.bind(this));
this._accountsMonitor.connect('account-removed',
this._accountRemoved.bind(this));
- this._accountsMonitor.connect('account-enabled', (mon, account) => {
+ this._accountsMonitor.connect('account-shown', (mon, account) => {
this._updatePlaceholderVisibility(account);
});
- this._accountsMonitor.connect('account-disabled', (mon, account) => {
+ this._accountsMonitor.connect('account-hidden', (mon, account) => {
this._updatePlaceholderVisibility(account);
});
this._accountsMonitor.prepare(() => {
@@ -620,7 +620,7 @@ class RoomList extends Gtk.ListBox {
}
_updatePlaceholderVisibility(account) {
- if (!account.enabled) {
+ if (!account.visible) {
this._placeholders.get(account).hide();
return;
}
diff --git a/src/roomManager.js b/src/roomManager.js
index 7344b07..9daeb4e 100644
--- a/src/roomManager.js
+++ b/src/roomManager.js
@@ -36,10 +36,10 @@ var RoomManager = class {
this._app.lookup_action(a.name).connect('activate', a.handler);
});
- this._accountsMonitor.connect('account-enabled', (mon, account) => {
+ this._accountsMonitor.connect('account-shown', (mon, account) => {
this._restoreRooms(account.object_path);
});
- this._accountsMonitor.connect('account-disabled', (mon, account) => {
+ this._accountsMonitor.connect('account-hidden', (mon, account) => {
this._removeRooms(account.object_path);
});
this._accountsMonitor.connect('account-removed', (mon, account) => {
@@ -164,7 +164,7 @@ var RoomManager = class {
return null;
}
- if (!account.enabled)
+ if (!account.visible)
return null;
let id = Polari.create_room_id(account, channelName, type);
diff --git a/src/serverRoomManager.js b/src/serverRoomManager.js
index 6c25179..1abb2be 100644
--- a/src/serverRoomManager.js
+++ b/src/serverRoomManager.js
@@ -29,7 +29,7 @@ var ServerRoomManager = class {
this._accountsMonitor.connect('account-removed',
this._onAccountRemoved.bind(this));
this._accountsMonitor.prepare(() => {
- this._accountsMonitor.enabledAccounts.forEach(a => {
+ this._accountsMonitor.visibleAccounts.forEach(a => {
this._onAccountStatusChanged(this._accountsMonitor, a);
});
});
diff --git a/src/telepathyClient.js b/src/telepathyClient.js
index f62b3b4..1f0f020 100644
--- a/src/telepathyClient.js
+++ b/src/telepathyClient.js
@@ -184,10 +184,10 @@ class TelepathyClient extends Tp.BaseClient {
this._accountsMonitor.connect('account-added', (mon, account) => {
this._connectAccount(account);
});
- this._accountsMonitor.connect('account-enabled', (mon, account) => {
+ this._accountsMonitor.connect('account-shown', (mon, account) => {
this._connectAccount(account);
});
- this._accountsMonitor.enabledAccounts.forEach(a => {
+ this._accountsMonitor.visibleAccounts.forEach(a => {
this._onAccountStatusChanged(this._accountsMonitor, a);
});
@@ -203,7 +203,7 @@ class TelepathyClient extends Tp.BaseClient {
debug('Network changed to %s'.format(connected ? 'available'
: 'unavailable'));
- this._accountsMonitor.enabledAccounts.forEach(a => {
+ this._accountsMonitor.visibleAccounts.forEach(a => {
this._setAccountPresence(a, presence);
});
}
@@ -225,6 +225,9 @@ class TelepathyClient extends Tp.BaseClient {
}
_setAccountPresence(account, presence) {
+ if (!account.enabled)
+ return;
+
let statuses = Object.keys(Tp.ConnectionPresenceType).map(s =>
s.replace(/_/g, '-').toLowerCase()
);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]