Philipp Hörist pushed to branch gtk4 at gajim / gajim


Commits:
ae0d54c6 by Philipp Hörist at 2024-11-10T00:56:06+01:00
fix: Lazy Load tooltips

- - - - -


1 changed file:

- gajim/gtk/tooltips.py


Changes:

=====================================
gajim/gtk/tooltips.py
=====================================
@@ -27,6 +27,7 @@
 from gajim.common import types
 from gajim.common.const import AvatarSize
 from gajim.common.i18n import _
+from gajim.common.modules.contacts import GroupchatParticipant
 from gajim.common.util.status import get_uf_show
 from gajim.common.util.user_strings import get_uf_affiliation
 from gajim.common.util.user_strings import get_uf_sub
@@ -44,14 +45,14 @@
 
 class GCTooltip:
     def __init__(self) -> None:
-        self._contact = None
-
-        self._ui = get_builder("groupchat_roster_tooltip.ui")
+        self._contact: GroupchatParticipant | None = None
 
     def clear_tooltip(self) -> None:
         self._contact = None
 
-    def get_tooltip(self, contact: types.GroupchatParticipant) -> tuple[bool, 
Gtk.Grid]:
+    def get_tooltip(self, contact: GroupchatParticipant) -> tuple[bool, 
Gtk.Grid]:
+        if not hasattr(self, "_ui"):
+            self._ui = get_builder("groupchat_roster_tooltip.ui")
 
         if self._contact == contact:
             return True, self._ui.tooltip_grid
@@ -67,7 +68,7 @@ def _hide_grid_children(self) -> None:
         for widget in iterate_children(self._ui.tooltip_grid):
             widget.hide()
 
-    def _populate_grid(self, contact: types.GroupchatParticipant) -> None:
+    def _populate_grid(self, contact: GroupchatParticipant) -> None:
         """
         Populate the Tooltip Grid with data of from the contact
         """
@@ -130,15 +131,19 @@ def _populate_grid(self, contact: 
types.GroupchatParticipant) -> None:
 class ContactTooltip:
     def __init__(self) -> None:
         self._contact = None
-        self._ui = get_builder("contact_tooltip.ui")
 
     def clear_tooltip(self) -> None:
         self._contact = None
+        if not hasattr(self, "_ui"):
+            return
         container_remove_all(self._ui.resources_box)
         for widget in iterate_children(self._ui.tooltip_grid):
             widget.hide()
 
     def get_tooltip(self, contact: types.BareContact) -> tuple[bool, Gtk.Grid]:
+        if not hasattr(self, "_ui"):
+            self._ui = get_builder("contact_tooltip.ui")
+
         if self._contact == contact:
             return True, self._ui.tooltip_grid
 



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/ae0d54c63ff844ac6ec8803f65678ca98c01f966

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/ae0d54c63ff844ac6ec8803f65678ca98c01f966
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to