Skip to content
Snippets Groups Projects
Commit 15f73dad authored by Daniel Brötzmann's avatar Daniel Brötzmann
Browse files

Accounts: Add account switch description

parent b8690214
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@
from gajim.common import app
from gajim.common import passwords
from gajim.common.i18n import _
from gajim.common.i18n import Q_
from .dialogs import DialogButton
from .dialogs import ConfirmationDialog
......@@ -482,11 +483,17 @@ def __init__(self, account):
Gtk.IconSize.MENU)
next_icon.get_style_context().add_class('insensitive-fg-color')
account_enabled = app.settings.get_account_setting(
self._account, 'active')
self._switch = Gtk.Switch()
self._switch.set_active(
app.settings.get_account_setting(self._account, 'active'))
self._switch.set_active(account_enabled)
self._switch.set_vexpand(False)
self._switch_state_label = Gtk.Label()
self._switch_state_label.set_xalign(1)
self._switch_state_label.set_valign(Gtk.Align.CENTER)
self._set_label(account_enabled)
if (self._account == app.ZEROCONF_ACC_NAME and
not app.is_installed('ZEROCONF')):
self._switch.set_active(False)
......@@ -502,6 +509,8 @@ def __init__(self, account):
'state-set', self._on_enable_switch, self._account)
box.add(self._switch)
box.add(self._switch_state_label)
box.add(Gtk.Separator())
box.add(self._label)
box.add(next_icon)
self.add(box)
......@@ -519,12 +528,18 @@ def update_account_label(self):
def enable_account(self, state):
self._switch.set_state(state)
self._set_label(state)
def _set_label(self, active):
text = Q_('?switch:On') if active else Q_('?switch:Off')
self._switch_state_label.set_text(text)
def _on_enable_switch(self, switch, state, account):
def _disable():
app.connections[account].change_status('offline', 'offline')
app.interface.disable_account(account)
switch.set_state(state)
self._set_label(state)
old_state = app.settings.get_account_setting(account, 'active')
if old_state == state:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment