| ... |
... |
@@ -26,6 +26,8 @@ |
|
26
|
26
|
|
|
27
|
27
|
from gajim.common import app
|
|
28
|
28
|
from gajim.common import ged
|
|
|
29
|
+from gajim.common.events import AccountDisabled
|
|
|
30
|
+from gajim.common.events import AccountEnabled
|
|
29
|
31
|
from gajim.common.events import StanzaReceived
|
|
30
|
32
|
from gajim.common.events import StanzaSent
|
|
31
|
33
|
from gajim.common.const import Direction
|
| ... |
... |
@@ -55,7 +57,7 @@ def __init__(self) -> None: |
|
55
|
57
|
self.set_show_menubar(False)
|
|
56
|
58
|
self.set_name('XMLConsoleWindow')
|
|
57
|
59
|
|
|
58
|
|
- self.selected_account = 'AllAccounts'
|
|
|
60
|
+ self._selected_account = 'AllAccounts'
|
|
59
|
61
|
self._selected_send_account: Optional[str] = None
|
|
60
|
62
|
self.presence = True
|
|
61
|
63
|
self.message = True
|
| ... |
... |
@@ -105,9 +107,11 @@ def __init__(self) -> None: |
|
105
|
107
|
self._ui.connect_signals(self)
|
|
106
|
108
|
|
|
107
|
109
|
self.register_events([
|
|
108
|
|
- ('stanza-received', ged.GUI1, self._nec_stanza_received),
|
|
109
|
|
- ('stanza-sent', ged.GUI1, self._nec_stanza_sent),
|
|
110
|
|
- ('style-changed', ged.GUI1, self._on_style_changed)
|
|
|
110
|
+ ('stanza-received', ged.GUI1, self._on_stanza_received),
|
|
|
111
|
+ ('stanza-sent', ged.GUI1, self._on_stanza_sent),
|
|
|
112
|
+ ('style-changed', ged.GUI1, self._on_style_changed),
|
|
|
113
|
+ ('account-enabled', ged.GUI1, self._on_account_changed),
|
|
|
114
|
+ ('account-disabled', ged.GUI1, self._on_account_changed)
|
|
111
|
115
|
])
|
|
112
|
116
|
|
|
113
|
117
|
def _on_destroy(self, *args: Any) -> None:
|
| ... |
... |
@@ -124,14 +128,25 @@ def _on_value_change(self, combo: Gtk.ComboBox) -> None: |
|
124
|
128
|
self._selected_send_account = combo.get_active_id()
|
|
125
|
129
|
|
|
126
|
130
|
def _set_titlebar(self) -> None:
|
|
127
|
|
- if self.selected_account == 'AllAccounts':
|
|
|
131
|
+ if self._selected_account == 'AllAccounts':
|
|
128
|
132
|
title = _('All Accounts')
|
|
129
|
|
- elif self.selected_account == 'AccountWizard':
|
|
|
133
|
+ elif self._selected_account == 'AccountWizard':
|
|
130
|
134
|
title = _('Account Wizard')
|
|
131
|
135
|
else:
|
|
132
|
|
- title = app.get_jid_from_account(self.selected_account)
|
|
|
136
|
+ title = app.get_jid_from_account(self._selected_account)
|
|
133
|
137
|
self._ui.headerbar.set_subtitle(title)
|
|
134
|
138
|
|
|
|
139
|
+ def _on_account_changed(self,
|
|
|
140
|
+ event: Union[AccountEnabled, AccountDisabled]
|
|
|
141
|
+ ) -> None:
|
|
|
142
|
+ buf = self._ui.sourceview.get_buffer()
|
|
|
143
|
+
|
|
|
144
|
+ if isinstance(event, AccountEnabled):
|
|
|
145
|
+ buf.create_tag(event.account)
|
|
|
146
|
+ else:
|
|
|
147
|
+ start, end = buf.get_bounds()
|
|
|
148
|
+ buf.remove_tag_by_name(event.account, start, end)
|
|
|
149
|
+
|
|
135
|
150
|
def _create_tags(self) -> None:
|
|
136
|
151
|
tags = [
|
|
137
|
152
|
'incoming',
|
| ... |
... |
@@ -141,6 +156,12 @@ def _create_tags(self) -> None: |
|
141
|
156
|
'stream',
|
|
142
|
157
|
'iq'
|
|
143
|
158
|
]
|
|
|
159
|
+
|
|
|
160
|
+ for account in app.settings.get_active_accounts():
|
|
|
161
|
+ tags.append(account)
|
|
|
162
|
+
|
|
|
163
|
+ tags.append('AccountWizard')
|
|
|
164
|
+
|
|
144
|
165
|
for tag_name in tags:
|
|
145
|
166
|
self._ui.sourceview.get_buffer().create_tag(tag_name)
|
|
146
|
167
|
|
| ... |
... |
@@ -328,7 +349,7 @@ def _on_filter_options(self, _button: Gtk.Button) -> None: |
|
328
|
349
|
|
|
329
|
350
|
settings = [
|
|
330
|
351
|
Setting(SettingKind.COMBO, _('Account'),
|
|
331
|
|
- SettingType.VALUE, self.selected_account,
|
|
|
352
|
+ SettingType.VALUE, self._selected_account,
|
|
332
|
353
|
callback=self._set_account,
|
|
333
|
354
|
props={'combo_items': combo_accounts}),
|
|
334
|
355
|
|
| ... |
... |
@@ -359,7 +380,7 @@ def _on_filter_options(self, _button: Gtk.Button) -> None: |
|
359
|
380
|
_('Filter'),
|
|
360
|
381
|
Gtk.DialogFlags.DESTROY_WITH_PARENT,
|
|
361
|
382
|
settings,
|
|
362
|
|
- self.selected_account or 'AllAccounts')
|
|
|
383
|
+ self._selected_account or 'AllAccounts')
|
|
363
|
384
|
self.filter_dialog.connect('destroy', self._on_filter_destroyed)
|
|
364
|
385
|
|
|
365
|
386
|
def _on_filter_destroyed(self, _widget: Gtk.Widget) -> None:
|
| ... |
... |
@@ -369,9 +390,26 @@ def _on_clear(self, _button: Gtk.Button) -> None: |
|
369
|
390
|
self._ui.sourceview.get_buffer().set_text('')
|
|
370
|
391
|
|
|
371
|
392
|
def _set_account(self, value: str, _data: Any) -> None:
|
|
372
|
|
- self.selected_account = value
|
|
|
393
|
+ self._selected_account = value
|
|
373
|
394
|
self._set_titlebar()
|
|
374
|
395
|
|
|
|
396
|
+ active_accounts = app.settings.get_active_accounts()
|
|
|
397
|
+ active_accounts.append('AccountWizard')
|
|
|
398
|
+
|
|
|
399
|
+ table = self._ui.sourceview.get_buffer().get_tag_table()
|
|
|
400
|
+
|
|
|
401
|
+ if value == 'AllAccounts':
|
|
|
402
|
+ for account in active_accounts:
|
|
|
403
|
+ tag = table.lookup(account)
|
|
|
404
|
+ if tag is not None:
|
|
|
405
|
+ tag.set_property('invisible', False)
|
|
|
406
|
+ return
|
|
|
407
|
+
|
|
|
408
|
+ for account in active_accounts:
|
|
|
409
|
+ tag = table.lookup(account)
|
|
|
410
|
+ if tag is not None:
|
|
|
411
|
+ tag.set_property('invisible', account != value)
|
|
|
412
|
+
|
|
375
|
413
|
def _on_setting(self, value: bool, data: str) -> None:
|
|
376
|
414
|
setattr(self, data, value)
|
|
377
|
415
|
value = not value
|
| ... |
... |
@@ -379,23 +417,19 @@ def _on_setting(self, value: bool, data: str) -> None: |
|
379
|
417
|
tag = table.lookup(data)
|
|
380
|
418
|
if tag is None:
|
|
381
|
419
|
return
|
|
|
420
|
+
|
|
382
|
421
|
if data in ('incoming', 'outgoing'):
|
|
383
|
422
|
if value:
|
|
384
|
423
|
tag.set_priority(table.get_size() - 1)
|
|
385
|
424
|
else:
|
|
386
|
425
|
tag.set_priority(0)
|
|
|
426
|
+
|
|
387
|
427
|
tag.set_property('invisible', value)
|
|
388
|
428
|
|
|
389
|
|
- def _nec_stanza_received(self, event: StanzaReceived):
|
|
390
|
|
- if self.selected_account != 'AllAccounts':
|
|
391
|
|
- if event.account != self.selected_account:
|
|
392
|
|
- return
|
|
|
429
|
+ def _on_stanza_received(self, event: StanzaReceived):
|
|
393
|
430
|
self._print_stanza(event, 'incoming')
|
|
394
|
431
|
|
|
395
|
|
- def _nec_stanza_sent(self, event: StanzaSent):
|
|
396
|
|
- if self.selected_account != 'AllAccounts':
|
|
397
|
|
- if event.account != self.selected_account:
|
|
398
|
|
- return
|
|
|
432
|
+ def _on_stanza_sent(self, event: StanzaSent):
|
|
399
|
433
|
self._print_stanza(event, 'outgoing')
|
|
400
|
434
|
|
|
401
|
435
|
def _print_stanza(self,
|
| ... |
... |
@@ -435,7 +469,8 @@ def _print_stanza(self, |
|
435
|
469
|
time=time.strftime('%c'),
|
|
436
|
470
|
account=account_label,
|
|
437
|
471
|
stanza=stanza)
|
|
438
|
|
- buffer_.insert_with_tags_by_name(end_iter, stanza, type_, kind)
|
|
|
472
|
+ buffer_.insert_with_tags_by_name(
|
|
|
473
|
+ end_iter, stanza, type_, kind, event.account)
|
|
439
|
474
|
|
|
440
|
475
|
if is_at_the_end:
|
|
441
|
476
|
GLib.idle_add(scroll_to_end, self._ui.scrolled) |