gnome-music.in 1.02 KB
Newer Older
Vadim Rutkovsky's avatar
Vadim Rutkovsky committed
1
#!/usr/bin/env python3
Guillaume Quintard's avatar
Guillaume Quintard committed
2

3
import sys, signal
4
from gi.repository import Gio, Gtk
Guillaume Quintard's avatar
Guillaume Quintard committed
5 6 7 8
sys.path.insert(1, '@pythondir@')

from gnomemusic.application import Application

9 10
def install_excepthook():
    """ Make sure we exit when an unhandled exception occurs. """
11
    from gi.repository import Gtk
12 13 14 15 16 17 18 19
    old_hook = sys.excepthook
    def new_hook(etype, evalue, etb):
        old_hook(etype, evalue, etb)
        while Gtk.main_level():
            Gtk.main_quit()
        sys.exit()
    sys.excepthook = new_hook

Guillaume Quintard's avatar
Guillaume Quintard committed
20
if __name__ == "__main__":
21 22
    install_excepthook()

23
    # We use our own libgd.so, so let gi.repository find it
Vadim Rutkovsky's avatar
Vadim Rutkovsky committed
24
    from gi.repository import GIRepository
25 26
    GIRepository.Repository.prepend_search_path('@libdir@/gnome-music')
    GIRepository.Repository.prepend_library_path('@libdir@/gnome-music')
Vadim Rutkovsky's avatar
Vadim Rutkovsky committed
27

28 29 30
    resource = Gio.resource_load("data/gnome-music.gresource")
    Gio.Resource._register(resource)

31
    app = Application()
Vadim Rutkovsky's avatar
Vadim Rutkovsky committed
32
    signal.signal(signal.SIGINT, signal.SIG_DFL)
33 34
    exit_status = app.run(sys.argv)
    sys.exit(exit_status)