forked from aseempatni/lollypop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lollypop.in
60 lines (49 loc) · 1.68 KB
/
lollypop.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
import sys
import signal
import os
import locale
import gettext
if 'LOLLYPOP_TRACE' in os.environ:
from pycallgraph import PyCallGraph
from pycallgraph.output import GraphvizOutput
# Disable ubuntu overlay scrollbars
#FIXME remove this later
os.environ['LIBOVERLAY_SCROLLBAR'] = '0'
# Make sure we'll find the pygobject module, even in JHBuild
sys.path.insert(1, '@pyexecdir@')
# Make sure we'll find the lollypop modules, even in JHBuild
sys.path.insert(1, '@pythondir@')
from gi.repository import Gio
localedir = '@localedir@'
pkgdatadir = '@pkgdatadir@'
from lollypop.application import Application
def install_excepthook():
""" Make sure we exit when an unhandled exception occurs. """
from gi.repository import Gtk
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
if __name__ == "__main__":
install_excepthook()
locale.bindtextdomain('lollypop', localedir)
locale.textdomain('lollypop')
gettext.bindtextdomain('lollypop', localedir)
gettext.textdomain('lollypop')
resource = Gio.resource_load(os.path.join(pkgdatadir, 'lollypop.gresource'))
Gio.Resource._register(resource)
app = Application()
signal.signal(signal.SIGINT, signal.SIG_DFL)
if 'LOLLYPOP_TRACE' in os.environ:
graphviz = GraphvizOutput()
graphviz.output_file = 'lollypop.png'
with PyCallGraph(output=graphviz):
exit_status = app.run(sys.argv)
sys.exit(exit_status)
else:
exit_status = app.run(sys.argv)
sys.exit(exit_status)