Browse Source

fix: support libadwaita versions without Adw.Banner

master
Matteo Benedetto 2 weeks ago
parent
commit
595917db76
  1. 33
      cellar-gtk.py

33
cellar-gtk.py

@ -156,6 +156,34 @@ def _load_css() -> None:
)
class CompatBanner(Gtk.Revealer):
"""Fallback banner for libadwaita versions that don't provide `Adw.Banner`."""
def __init__(self) -> None:
super().__init__()
self.set_transition_type(Gtk.RevealerTransitionType.SLIDE_DOWN)
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)
box.set_margin_top(8)
box.set_margin_bottom(8)
box.set_margin_start(12)
box.set_margin_end(12)
box.add_css_class("toolbar")
self._label = Gtk.Label(xalign=0)
self._label.set_wrap(True)
self._label.set_hexpand(True)
box.append(self._label)
self.set_child(box)
def set_title(self, title: str) -> None:
self._label.set_text(title)
def set_revealed(self, revealed: bool) -> None:
self.set_reveal_child(revealed)
# ── Settings Dialog ─────────────────────────────────────────────
class SettingsWindow(Adw.Window):
"""Preferences dialog using libadwaita widgets."""
@ -377,7 +405,10 @@ class CellarWindow(Adw.ApplicationWindow):
# ── Outer box (banner + progress + scrolled content) ──
outer_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
self.banner = Adw.Banner()
if hasattr(Adw, "Banner"):
self.banner = Adw.Banner()
else:
self.banner = CompatBanner()
self.banner.set_revealed(False)
outer_box.append(self.banner)

Loading…
Cancel
Save