Daniel Brötzmann pushed to branch mainwindow at gajim / gajim
Commits:
898eedee by wurstsalat at 2021-05-29T11:41:42+02:00
SearchView: Search within active accounts only
- - - - -
2 changed files:
- gajim/common/storage/archive.py
- gajim/gtk/search_view.py
Changes:
=====================================
gajim/common/storage/archive.py
=====================================
@@ -258,6 +258,12 @@ def get_account_id(self, account,
type_=JIDConstant.NORMAL_TYPE):
jid = app.get_jid_from_account(account)
return self.get_jid_id(jid, type_=type_)
+ def get_active_account_ids(self):
+ account_ids = []
+ for account in app.settings.get_active_accounts():
+ account_ids.append(self.get_account_id(account))
+ return account_ids
+
@timeit
def get_jid_id(self, jid, kind=None, type_=None):
"""
@@ -549,15 +555,18 @@ def search_all_logs(self, query):
returns a list of namedtuples
"""
+ account_ids = self.get_active_account_ids()
kinds = map(str, [KindConstant.STATUS,
KindConstant.GCSTATUS])
sql = '''
SELECT account_id, jid_id, contact_name, time, kind, show, message,
subject, additional_data, log_line_id
FROM logs WHERE message LIKE like(?)
+ AND account_id IN ({account_ids})
AND kind NOT IN ({kinds})
ORDER BY time DESC, log_line_id
- '''.format(kinds=', '.join(kinds))
+ '''.format(account_ids=', '.join(map(str, account_ids)),
+ kinds=', '.join(kinds))
return self._con.execute(sql, (query,)).fetchall()
=====================================
gajim/gtk/search_view.py
=====================================
@@ -20,6 +20,7 @@
from gi.repository import Gtk
from gajim.common import app
+from gajim.common import ged
from gajim.common.const import AvatarSize
from gajim.common.const import KindConstant
from gajim.common.i18n import _
@@ -55,12 +56,22 @@ def __init__(self):
self._ui.connect_signals(self)
self.connect('key-press-event', self._on_key_press)
+
+ app.ged.register_event_handler('account-enabled',
+ ged.GUI1,
+ self._on_account_state)
+ app.ged.register_event_handler('account-disabled',
+ ged.GUI1,
+ self._on_account_state)
self.show_all()
def _on_key_press(self, _widget, event):
if event.keyval == Gdk.KEY_Escape:
self.emit('hide-search')
+ def _on_account_state(self, _event):
+ self.clear()
+
@staticmethod
def _header_func(row, before):
if before is None:
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/898eedee2d9f00409d6ecd06d4c6a7001527d6be
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/898eedee2d9f00409d6ecd06d4c6a7001527d6be
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits