Philipp Hörist pushed to branch master at gajim / gajim
Commits:
2c09bba5 by lovetox at 2022-03-06T14:02:12+01:00
StartChat: Improve performance
- Load contacts before calling show_all()
- Remove incremental load
- - - - -
1 changed file:
- gajim/gtk/start_chat.py
Changes:
=====================================
gajim/gtk/start_chat.py
=====================================
@@ -16,7 +16,6 @@
from typing import cast
from typing import Any
-from typing import Generator
from typing import Optional
from typing import Union
@@ -84,7 +83,6 @@ def __init__(self) -> None:
self._destroyed = False
self._search_stopped = False
self._redirected = False
- self._source_id: Optional[int] = None
self._ui = get_builder('start_chat_dialog.ui')
self.add(self._ui.stack)
@@ -136,13 +134,13 @@ def __init__(self) -> None:
self.connect('key-press-event', self._on_key_press)
self.connect('destroy', self._on_destroy)
+ if rows:
+ self._load_contacts(rows)
+
self.select_first_row()
self._ui.connect_signals(self)
self.show_all()
- if rows:
- self._load_contacts(rows)
-
def set_search_text(self, text: str) -> None:
self._ui.search_entry.set_text(text)
@@ -195,19 +193,10 @@ def _add_groupchats(self, rows: list[ContactRow]) -> None:
groupchat=True))
def _load_contacts(self, rows: list[ContactRow]) -> None:
- generator = self._incremental_add(rows)
- self._source_id = GLib.idle_add(lambda: next(generator, False),
- priority=GLib.PRIORITY_LOW)
-
- def _incremental_add(self,
- rows: list[ContactRow]
- ) -> Generator[bool, None, None]:
for row in rows:
self._ui.listbox.add(row)
- yield True
self._ui.listbox.set_sort_func(self._sort_func, None)
- self._source_id = None
def _on_page_changed(self, stack: Gtk.Stack, _param: Any) -> None:
if stack.get_visible_child_name() == 'account':
@@ -760,8 +749,6 @@ def _process_search_result(self,
def _on_destroy(self, *args: Any) -> None:
self._ui.listbox.set_filter_func(None)
self._ui.listbox.destroy()
- if self._source_id is not None:
- GLib.source_remove(self._source_id)
self._destroyed = True
app.cancel_tasks(self)
app.check_finalize(self)
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/2c09bba5b4b89b049a250d5be320ba2b4d28a5b2
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/2c09bba5b4b89b049a250d5be320ba2b4d28a5b2
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