Beispiel #1
0
class Trough(Gtk.Application):
    """ Beginning of the application: init -> run() -> startup signal -> activate signal """

    def __init__(self):
        super().__init__(application_id='org.glu10.trough', flags=Gio.ApplicationFlags.FLAGS_NONE)
        self.main_window = None
        self.preferences = None
        self.cache = None
        self.connect('activate', self.do_activate)

    def do_startup(self) -> None:
        Gtk.Application.do_startup(self)
        self.preferences = Preferences(load_from_file=True)
        self.cache = Cache(load_from_file=True)

    def do_activate(self, *args) -> None:
        if not self.main_window and self.preferences and self.cache:
            self.main_window = MainWindow(
                self.preferences,
                self.cache,
                application=self,
                title='Trough')
            self.main_window.connect('delete_event', self.on_quit)
            self.add_window(self.main_window)
            self.main_window.present()

    def on_quit(self, widget: Gtk.Widget, event: Gdk.Event) -> None:
        self.cache.write_cache()
        self.quit()
Beispiel #2
0
def main():
    #checking projects integrity
    if not os.path.isdir("games"):
        print("There's no game directory")
        os.makedirs("games")

        #create game file
        gf = open("games/games.xml", "w")
        gf.write('<?xml version="1.0"?>\n<all>\n</all>\n')
        gf.close()

    #creating windows
    mainwin = MainWindow()
    mainwin.connect("delete-event", Gtk.main_quit)
    mainwin.show_all()
    Gtk.main()
Beispiel #3
0
class Trough(Gtk.Application):
    """ Beginning of the application: init -> run() -> startup signal -> activate signal """
    def __init__(self):
        super().__init__(application_id='org.glu10.trough', flags=Gio.ApplicationFlags.FLAGS_NONE)
        self.main_window = None
        self.preferences = None
        self.cache = None
        self.connect('activate', self.do_activate)

    def do_startup(self):
        Gtk.Application.do_startup(self)
        self.preferences = Preferences(load_from_file=True)
        self.cache = Cache(load_from_file=True)

    def do_activate(self, *args):
        if not self.main_window and self.preferences and self.cache:
            self.main_window = MainWindow(self.preferences, self.cache, application=self, title='Trough')
            self.main_window.connect('delete_event', self.on_quit)
            self.add_window(self.main_window)
            self.main_window.present()

    def on_quit(self, action, param):
        self.cache.write_cache()
        self.quit()