parent
74ed71f57e
commit
2080495efc
|
@ -48,11 +48,6 @@ messages = {
|
||||||
_('Read all pending events before removing this account.'),
|
_('Read all pending events before removing this account.'),
|
||||||
ErrorDialog),
|
ErrorDialog),
|
||||||
|
|
||||||
'connected-on-disable-account': Message(
|
|
||||||
_('You are currently connected to the server'),
|
|
||||||
_('To disable the account, you must be disconnected.'),
|
|
||||||
ErrorDialog),
|
|
||||||
|
|
||||||
'invalid-form': Message(
|
'invalid-form': Message(
|
||||||
_('Invalid Form'),
|
_('Invalid Form'),
|
||||||
_('The form is not filled correctly.'),
|
_('The form is not filled correctly.'),
|
||||||
|
|
|
@ -39,6 +39,8 @@ from gajim.gtk.dialogs import ConfirmationDialog
|
||||||
from gajim.gtk.dialogs import ConfirmationDialogDoubleRadio
|
from gajim.gtk.dialogs import ConfirmationDialogDoubleRadio
|
||||||
from gajim.gtk.dialogs import ErrorDialog
|
from gajim.gtk.dialogs import ErrorDialog
|
||||||
from gajim.gtk.dialogs import YesNoDialog
|
from gajim.gtk.dialogs import YesNoDialog
|
||||||
|
from gajim.gtk.dialogs import DialogButton
|
||||||
|
from gajim.gtk.dialogs import NewConfirmationDialog
|
||||||
from gajim.gtk.util import get_icon_name
|
from gajim.gtk.util import get_icon_name
|
||||||
from gajim.gtk.util import get_builder
|
from gajim.gtk.util import get_builder
|
||||||
|
|
||||||
|
@ -512,7 +514,7 @@ class GenericOptionPage(Gtk.Box):
|
||||||
switch.set_sensitive(False)
|
switch.set_sensitive(False)
|
||||||
switch.set_active(False)
|
switch.set_active(False)
|
||||||
|
|
||||||
switch.connect('notify::active', self._on_enable_switch, self.account)
|
switch.connect('state-set', self._on_enable_switch, self.account)
|
||||||
box.pack_start(switch, False, False, 0)
|
box.pack_start(switch, False, False, 0)
|
||||||
if self.account != app.ZEROCONF_ACC_NAME:
|
if self.account != app.ZEROCONF_ACC_NAME:
|
||||||
button = Gtk.Button(label=_('Remove'))
|
button = Gtk.Button(label=_('Remove'))
|
||||||
|
@ -524,18 +526,34 @@ class GenericOptionPage(Gtk.Box):
|
||||||
box.pack_end(button, False, False, 0)
|
box.pack_end(button, False, False, 0)
|
||||||
self.pack_start(box, True, True, 0)
|
self.pack_start(box, True, True, 0)
|
||||||
|
|
||||||
def _on_enable_switch(self, switch, param, account):
|
def _on_enable_switch(self, switch, state, account):
|
||||||
|
def _disable():
|
||||||
|
app.connections[account].change_status('offline', 'offline')
|
||||||
|
app.connections[account].disconnect(reconnect=False)
|
||||||
|
self.parent.disable_account(account)
|
||||||
|
app.config.set_per('accounts', account, 'active', False)
|
||||||
|
switch.set_state(state)
|
||||||
|
|
||||||
old_state = app.config.get_per('accounts', account, 'active')
|
old_state = app.config.get_per('accounts', account, 'active')
|
||||||
state = switch.get_active()
|
|
||||||
if old_state == state:
|
if old_state == state:
|
||||||
return
|
return
|
||||||
|
|
||||||
if (account in app.connections and
|
if (account in app.connections and
|
||||||
app.connections[account].connected > 0):
|
app.connections[account].connected > 0):
|
||||||
# connecting or connected
|
# Connecting or connected
|
||||||
app.interface.raise_dialog('connected-on-disable-account')
|
NewConfirmationDialog(
|
||||||
switch.set_active(not state)
|
_('Disable Account'),
|
||||||
return
|
_('Account %s is still connected') % account,
|
||||||
|
_('All chat and group chat windows will be closed. '
|
||||||
|
'Do you want to continue?'),
|
||||||
|
[DialogButton.make('Cancel',
|
||||||
|
callback=lambda: switch.set_active(True)),
|
||||||
|
DialogButton.make('Remove',
|
||||||
|
text=_('Disable Account'),
|
||||||
|
callback=_disable)],
|
||||||
|
transient_for=self.parent).show()
|
||||||
|
return Gdk.EVENT_STOP
|
||||||
|
|
||||||
if state:
|
if state:
|
||||||
self.parent.enable_account(account)
|
self.parent.enable_account(account)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue