39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
# Copyright 2022 (c) Anna Schumaker.
|
|
"""A custom Gtk.HeaderBar configured for our application."""
|
|
from gi.repository import GObject
|
|
from gi.repository import Gtk
|
|
from gi.repository import Adw
|
|
from .. import db
|
|
if __debug__:
|
|
from . import settings
|
|
|
|
SUBTITLE = "The Cheesy Music Player"
|
|
|
|
|
|
class Header(Gtk.HeaderBar):
|
|
"""Our custom Gtk.HeaderBar containing window title and volume controls."""
|
|
|
|
sql = GObject.Property(type=db.Connection)
|
|
title = GObject.Property(type=str)
|
|
subtitle = GObject.Property(type=str)
|
|
|
|
def __init__(self, sql: db.Connection, title: str):
|
|
"""Initialize the HeaderBar."""
|
|
super().__init__(title=title, subtitle=SUBTITLE, sql=sql)
|
|
self._title = Adw.WindowTitle(title=self.title, subtitle=self.subtitle)
|
|
|
|
self.bind_property("title", self._title, "title")
|
|
self.bind_property("subtitle", self._title, "subtitle")
|
|
|
|
if __debug__:
|
|
self._window = settings.Window(sql)
|
|
self._settings = Gtk.Button.new_from_icon_name("settings-symbolic")
|
|
self._settings.connect("clicked", self.__run_settings)
|
|
self.pack_start(self._settings)
|
|
|
|
self.set_title_widget(self._title)
|
|
|
|
def __run_settings(self, button: Gtk.Button) -> None:
|
|
if __debug__:
|
|
self._window.present()
|