49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
import logging
|
|
import sys
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "4.0")
|
|
gi.require_version("Adw", "1")
|
|
|
|
from gi.repository import Gtk, Adw, Gio, GLib
|
|
|
|
from cht.config import APP_ID, APP_NAME
|
|
from cht.window import ChtWindow
|
|
|
|
|
|
class ChtApp(Adw.Application):
|
|
def __init__(self):
|
|
super().__init__(
|
|
application_id=APP_ID,
|
|
flags=Gio.ApplicationFlags.DEFAULT_FLAGS,
|
|
)
|
|
|
|
def do_activate(self):
|
|
win = self.props.active_window
|
|
if not win:
|
|
win = ChtWindow(application=self)
|
|
win.present()
|
|
|
|
|
|
def _suppress_egl_warnings(domain, level, message, user_data):
|
|
if b"eglExportDMABUFImage" in message:
|
|
return
|
|
GLib.log_default_handler(domain, level, message, user_data)
|
|
|
|
|
|
def main():
|
|
GLib.log_set_handler("Gdk", GLib.LogLevelFlags.LEVEL_WARNING, _suppress_egl_warnings, None)
|
|
logging.basicConfig(
|
|
level=logging.DEBUG,
|
|
format="%(asctime)s %(levelname)-7s %(name)s: %(message)s",
|
|
datefmt="%H:%M:%S",
|
|
)
|
|
log = logging.getLogger("cht")
|
|
log.info("CHT starting")
|
|
app = ChtApp()
|
|
return app.run(sys.argv)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|