xfstestsdb/xfstestsdb/gtk/window.py

43 lines
1.6 KiB
Python

# Copyright 2023 (c) Anna Schumaker.
"""The main Adw.Window implementation for our application."""
import typing
from gi.repository import GObject
from gi.repository import Gtk
from gi.repository import Adw
class Window(Adw.Window):
"""Our customized Window displayed to the user."""
child = GObject.Property(type=Gtk.Widget)
headerbar = GObject.Property(type=Adw.HeaderBar)
title = GObject.Property(type=Adw.WindowTitle)
runid = GObject.Property(type=int)
def __init__(self, **kwargs):
"""Set up our Window."""
super().__init__(default_height=1000, default_width=1600,
content=Gtk.Box(orientation=Gtk.Orientation.VERTICAL),
title=Adw.WindowTitle(title="xfstestsdb gtk"),
headerbar=Adw.HeaderBar(), **kwargs)
self._splitview = Adw.OverlaySplitView(content=self.child,
collapsed=True,
show_sidebar=False)
self.headerbar.props.title_widget = self.title
self.headerbar.add_css_class("flat")
self.props.content.append(self.headerbar)
self.props.content.append(self._splitview)
self.bind_property("child", self._splitview, "content")
self.connect("notify::runid", self.__notify_runid)
if __debug__:
self.add_css_class("devel")
def __notify_runid(self, window: typing.Self,
param: GObject.ParamSpec) -> None:
text = f"runid #{self.runid}" if self.runid > 0 else ""
self.title.props.subtitle = text