Implement the Gtk.Application instance in emmental.py
We don't use this during testing, so put it here instead of in a submodule. Implements #26 (Move the EmmentalApplication into emmental.py) Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
db2d122211
commit
beca08b833
23
emmental.py
23
emmental.py
|
@ -3,5 +3,26 @@
|
||||||
import lib
|
import lib
|
||||||
lib.settings.load()
|
lib.settings.load()
|
||||||
|
|
||||||
|
import db
|
||||||
import ui
|
import ui
|
||||||
ui.Application.run()
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
class Application(Gtk.Application):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
app_id = f"org.gtk.emmental{'-debug' if __debug__ else ''}"
|
||||||
|
Gtk.Application.__init__(self, *args, application_id=app_id, **kwargs)
|
||||||
|
|
||||||
|
def do_startup(self):
|
||||||
|
Gtk.Application.do_startup(self)
|
||||||
|
self.add_window(ui.window.Window())
|
||||||
|
|
||||||
|
def do_activate(self):
|
||||||
|
for window in self.get_windows():
|
||||||
|
window.present()
|
||||||
|
|
||||||
|
def do_shutdown(self):
|
||||||
|
Gtk.Application.do_shutdown(self)
|
||||||
|
db.sql.optimize()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
Application().run()
|
||||||
|
|
|
@ -1,24 +1,3 @@
|
||||||
# Copyright 2021 (c) Anna Schumaker.
|
# Copyright 2021 (c) Anna Schumaker.
|
||||||
from . import icons
|
from . import icons
|
||||||
from . import window
|
from . import window
|
||||||
from gi.repository import Gtk
|
|
||||||
import audio
|
|
||||||
import db
|
|
||||||
|
|
||||||
class EmmentalApplication(Gtk.Application):
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
Gtk.Application.__init__(self, *args, application_id="org.gtk.emmental", **kwargs)
|
|
||||||
|
|
||||||
def do_activate(self):
|
|
||||||
self.window.present()
|
|
||||||
|
|
||||||
def do_startup(self):
|
|
||||||
self.window = window.Window()
|
|
||||||
Gtk.Application.do_startup(self)
|
|
||||||
self.add_window(self.window)
|
|
||||||
|
|
||||||
def do_shutdown(self):
|
|
||||||
db.sql.optimize()
|
|
||||||
Gtk.Application.do_shutdown(self)
|
|
||||||
|
|
||||||
Application = EmmentalApplication()
|
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
# Copyright 2021 (c) Anna Schumaker.
|
|
||||||
import unittest
|
|
||||||
import ui
|
|
||||||
from gi.repository import Gtk
|
|
||||||
|
|
||||||
class TestEmmentalApplication(unittest.TestCase):
|
|
||||||
def test_application(self):
|
|
||||||
app = ui.EmmentalApplication()
|
|
||||||
self.assertIsInstance(app, Gtk.Application)
|
|
Loading…
Reference in New Issue