Daniel Brötzmann pushed to branch generate-ogp-previews at gajim / gajim
Commits:
991011d2 by cal0pteryx at 2026-02-16T20:54:47+01:00
other: Add loading spinner and honor minimal mode
- - - - -
2 changed files:
- gajim/data/gui/preview/open_graph.ui
- gajim/gtk/preview/open_graph.py
Changes:
=====================================
gajim/data/gui/preview/open_graph.ui
=====================================
@@ -19,6 +19,11 @@
</style>
</object>
</child>
+ <child>
+ <object class="AdwSpinner" id="_loading_spinner">
+ <property name="visible">false</property>
+ </object>
+ </child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
@@ -40,6 +45,7 @@
<property name="wrap-mode">word-char</property>
<property name="max-width-chars">42</property>
<property name="xalign">0</property>
+ <property name="visible">false</property>
<style>
<class name="dimmed"/>
</style>
=====================================
gajim/gtk/preview/open_graph.py
=====================================
@@ -4,6 +4,7 @@
from __future__ import annotations
+from gi.repository import Adw
from gi.repository import Gdk
from gi.repository import GLib
from gi.repository import GObject
@@ -28,6 +29,7 @@ class OpenGraphPreviewWidget(Gtk.Box, SignalManager):
}
_content_box: Gtk.Box = Gtk.Template.Child()
+ _loading_spinner: Adw.Spinner = Gtk.Template.Child()
_title_label: Gtk.Label = Gtk.Template.Child()
_description_label: Gtk.Label = Gtk.Template.Child()
_close_button: Gtk.Button = Gtk.Template.Child()
@@ -68,22 +70,25 @@ def set_open_graph(self, og_data: OpenGraphData | None, *,
minimal: bool) -> Non
self._og_data = og_data
if og_data is None:
- # TODO DISPLAY Spinner
- self._title_label.set_text("Download in progress")
+ self._loading_spinner.set_visible(True)
return
+ self._loading_spinner.set_visible(False)
self._title_label.set_text(og_data.title or "")
+ if minimal:
+ return
+
if description := og_data.description:
self._description_label.set_text(f"{description[:100]}…")
- else:
- self._description_label.set_visible(False)
+ self._description_label.set_visible(True)
def get_open_graph(self) -> OpenGraphData | None:
return self._og_data
def set_error(self) -> None:
- print("TODO SET ERROR")
+ self._loading_spinner.set_visible(False)
+ self._title_label.set_text(_("Could not generate link preview"))
def _on_primary_clicked(
self,
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/991011d280ee17a44eaa21d807eb57f7f9f7ed19
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/991011d280ee17a44eaa21d807eb57f7f9f7ed19
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]