2023-11-25 00:55:01 +00:00
|
|
|
#!/usr/bin/env python3
|
2023-11-21 17:13:30 +00:00
|
|
|
|
2023-12-01 12:15:34 +00:00
|
|
|
|
2023-11-25 00:55:01 +00:00
|
|
|
import gi
|
2023-11-21 17:13:30 +00:00
|
|
|
|
2023-11-25 00:55:01 +00:00
|
|
|
gi.require_version("Gtk", "3.0")
|
2023-11-28 17:19:01 +00:00
|
|
|
from gi.repository import Gio, Gtk
|
|
|
|
|
|
|
|
from .constants import constants
|
|
|
|
|
2023-11-28 18:55:40 +00:00
|
|
|
|
2023-11-28 17:19:01 +00:00
|
|
|
class Application(Gtk.Application):
|
2023-12-06 17:38:19 +00:00
|
|
|
def __init__(self, window: Gtk.ApplicationWindow) -> None:
|
2023-11-28 17:19:01 +00:00
|
|
|
super().__init__(
|
|
|
|
application_id=constants["APPID"], flags=Gio.ApplicationFlags.FLAGS_NONE
|
|
|
|
)
|
|
|
|
self.init_style()
|
2023-12-06 17:38:19 +00:00
|
|
|
self.window = window
|
2023-11-28 17:19:01 +00:00
|
|
|
|
2023-11-30 12:42:15 +00:00
|
|
|
def do_startup(self) -> None:
|
2023-11-28 17:19:01 +00:00
|
|
|
Gtk.Application.do_startup(self)
|
2023-12-06 17:38:19 +00:00
|
|
|
Gtk.init()
|
2023-11-28 17:19:01 +00:00
|
|
|
|
2023-11-30 12:42:15 +00:00
|
|
|
def do_activate(self) -> None:
|
2023-11-28 17:19:01 +00:00
|
|
|
win = self.props.active_window
|
|
|
|
if not win:
|
2023-12-08 10:56:27 +00:00
|
|
|
win = self.window
|
|
|
|
win.set_application(self)
|
2023-11-28 17:19:01 +00:00
|
|
|
win.present()
|
|
|
|
|
|
|
|
# TODO: For css styling
|
2023-11-30 12:42:15 +00:00
|
|
|
def init_style(self) -> None:
|
2023-11-28 17:19:01 +00:00
|
|
|
pass
|
|
|
|
# css_provider = Gtk.CssProvider()
|
|
|
|
# css_provider.load_from_resource(constants['RESOURCEID'] + '/style.css')
|
|
|
|
# screen = Gdk.Screen.get_default()
|
|
|
|
# style_context = Gtk.StyleContext()
|
|
|
|
# style_context.add_provider_for_screen(screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|