Commit 114d082e by Florian Müllner Committed by Bastian Ilsø Hougaard

roomList: Add "Disconnect" to network context popover

It can be useful to temporarily disable an account - for instance a work network while being on vacation - but we lost the ability to do so from Polari itself when dropping the separate connections dialog in commit 263ff952. Re-expose the option by adding a "Disconnect" action to the network context popover that mirrors the existing "Connect" one, and let the actions control the account's :enabled property to preserve the connection state over restarts. https://bugzilla.gnome.org/show_bug.cgi?id=771889
parent 21bee722
Pipeline #2814 passed with stage
in 5 minutes 51 seconds
......@@ -155,6 +155,14 @@
</object>
</child>
<child>
<object class="GtkModelButton" id="popoverDisconnect">
<property name="xalign">0</property>
<property name="visible">True</property>
<property name="action-name">app.disconnect-account</property>
<property name="text" translatable="yes">Disconnect</property>
</object>
</child>
<child>
<object class="GtkModelButton" id="popoverRemove">
<property name="xalign">0</property>
<property name="visible">True</property>
......
......@@ -169,6 +169,9 @@ var Application = GObject.registerClass({
{ name: 'connect-account',
activate: this._onConnectAccount.bind(this),
parameter_type: GLib.VariantType.new('o') },
{ name: 'disconnect-account',
activate: this._onConnectAccount.bind(this),
parameter_type: GLib.VariantType.new('o') },
{ name: 'reconnect-account',
activate: this._onConnectAccount.bind(this),
parameter_type: GLib.VariantType.new('o') },
......
......@@ -208,6 +208,7 @@ var RoomListHeader = GObject.registerClass({
'popoverTitle',
'popoverPassword',
'popoverConnect',
'popoverDisconnect',
'popoverReconnect',
'popoverRemove',
'popoverProperties',
......@@ -233,6 +234,7 @@ var RoomListHeader = GObject.registerClass({
let target = new GLib.Variant('o', this._account.get_object_path());
this._popoverConnect.action_target = target;
this._popoverDisconnect.action_target = target;
this._popoverReconnect.action_target = target;
this._popoverRemove.action_target = target;
this._popoverProperties.action_target = target;
......@@ -370,6 +372,7 @@ var RoomListHeader = GObject.registerClass({
let presence = this._account.requested_presence_type;
let offline = presence == Tp.ConnectionPresenceType.OFFLINE;
this._popoverConnect.visible = offline;
this._popoverDisconnect.visible = !offline;
this._popoverReconnect.visible = !offline;
this._onConnectionStatusChanged();
}
......
......@@ -143,6 +143,8 @@ class TelepathyClient extends Tp.BaseClient {
handler: this._onLeaveActivated.bind(this) },
{ name: 'connect-account',
handler: this._onConnectAccountActivated.bind(this) },
{ name: 'disconnect-account',
handler: this._onDisconnectAccountActivated.bind(this) },
{ name: 'reconnect-account',
handler: this._onReconnectAccountActivated.bind(this) },
{ name: 'authenticate-account',
......@@ -340,7 +342,18 @@ class TelepathyClient extends Tp.BaseClient {
_onConnectAccountActivated(action, parameter) {
let accountPath = parameter.deep_unpack();
let account = this._accountsMonitor.lookupAccount(accountPath);
if (account.enabled)
this._connectAccount(account);
else
account.set_enabled_async(true, () => {});
}
_onDisconnectAccountActivated(action, parameter) {
let accountPath = parameter.deep_unpack();
let account = this._accountsMonitor.lookupAccount(accountPath);
account.set_enabled_async(false, () => {
this._setAccountPresence(account, Tp.ConnectionPresenceType.OFFLINE);
});
}
_onReconnectAccountActivated(action, parameter) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment