emmental/emmental.py
Anna Schumaker 328dce0be2 scanner: Fix scanner.update_library() function
We were scheduling the CheckTask, but not following up with a
DirectoryTask to scan for new files. I use this function during the
Gtk.Application startup to automatically update the libraries.

Implements #31 (Automatically update the database during startup)
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2021-12-28 15:50:11 -05:00

33 lines
887 B
Python
Executable File

#!/usr/bin/python
# Copyright 2021 (c) Anna Schumaker.
import lib
lib.settings.load()
import db
import scanner
import ui
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())
for i in range(db.library.Table.get_n_items()):
scanner.update_library(db.library.Table.get_item(i))
def do_activate(self):
for window in self.get_windows():
window.present()
def do_shutdown(self):
Gtk.Application.do_shutdown(self)
scanner.Queue.clear()
db.sql.optimize()
if __name__ == "__main__":
Application().run()