| ... |
... |
@@ -39,6 +39,8 @@ from gajim.gtk.dialogs import ConfirmationDialog |
|
39
|
39
|
from gajim.gtk.dialogs import ConfirmationDialogDoubleRadio
|
|
40
|
40
|
from gajim.gtk.dialogs import ErrorDialog
|
|
41
|
41
|
from gajim.gtk.dialogs import YesNoDialog
|
|
|
42
|
+from gajim.gtk.dialogs import DialogButton
|
|
|
43
|
+from gajim.gtk.dialogs import NewConfirmationDialog
|
|
42
|
44
|
from gajim.gtk.util import get_icon_name
|
|
43
|
45
|
from gajim.gtk.util import get_builder
|
|
44
|
46
|
|
| ... |
... |
@@ -512,7 +514,7 @@ class GenericOptionPage(Gtk.Box): |
|
512
|
514
|
switch.set_sensitive(False)
|
|
513
|
515
|
switch.set_active(False)
|
|
514
|
516
|
|
|
515
|
|
- switch.connect('notify::active', self._on_enable_switch, self.account)
|
|
|
517
|
+ switch.connect('state-set', self._on_enable_switch, self.account)
|
|
516
|
518
|
box.pack_start(switch, False, False, 0)
|
|
517
|
519
|
if self.account != app.ZEROCONF_ACC_NAME:
|
|
518
|
520
|
button = Gtk.Button(label=_('Remove'))
|
| ... |
... |
@@ -524,18 +526,34 @@ class GenericOptionPage(Gtk.Box): |
|
524
|
526
|
box.pack_end(button, False, False, 0)
|
|
525
|
527
|
self.pack_start(box, True, True, 0)
|
|
526
|
528
|
|
|
527
|
|
- def _on_enable_switch(self, switch, param, account):
|
|
|
529
|
+ def _on_enable_switch(self, switch, state, account):
|
|
|
530
|
+ def _disable():
|
|
|
531
|
+ app.connections[account].change_status('offline', 'offline')
|
|
|
532
|
+ app.connections[account].disconnect(reconnect=False)
|
|
|
533
|
+ self.parent.disable_account(account)
|
|
|
534
|
+ app.config.set_per('accounts', account, 'active', False)
|
|
|
535
|
+ switch.set_state(state)
|
|
|
536
|
+
|
|
528
|
537
|
old_state = app.config.get_per('accounts', account, 'active')
|
|
529
|
|
- state = switch.get_active()
|
|
530
|
538
|
if old_state == state:
|
|
531
|
539
|
return
|
|
532
|
540
|
|
|
533
|
541
|
if (account in app.connections and
|
|
534
|
542
|
app.connections[account].connected > 0):
|
|
535
|
|
- # connecting or connected
|
|
536
|
|
- app.interface.raise_dialog('connected-on-disable-account')
|
|
537
|
|
- switch.set_active(not state)
|
|
538
|
|
- return
|
|
|
543
|
+ # Connecting or connected
|
|
|
544
|
+ NewConfirmationDialog(
|
|
|
545
|
+ _('Disable Account'),
|
|
|
546
|
+ _('Account %s is still connected') % account,
|
|
|
547
|
+ _('All chat and group chat windows will be closed. '
|
|
|
548
|
+ 'Do you want to continue?'),
|
|
|
549
|
+ [DialogButton.make('Cancel',
|
|
|
550
|
+ callback=lambda: switch.set_active(True)),
|
|
|
551
|
+ DialogButton.make('Remove',
|
|
|
552
|
+ text=_('Disable Account'),
|
|
|
553
|
+ callback=_disable)],
|
|
|
554
|
+ transient_for=self.parent).show()
|
|
|
555
|
+ return Gdk.EVENT_STOP
|
|
|
556
|
+
|
|
539
|
557
|
if state:
|
|
540
|
558
|
self.parent.enable_account(account)
|
|
541
|
559
|
else:
|