2019-07-10 01:51:41 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import gi
|
|
|
|
import sys
|
|
|
|
import os
|
2019-08-19 03:59:02 +02:00
|
|
|
from pathlib import Path
|
2019-07-10 01:51:41 +02:00
|
|
|
|
2019-08-27 05:40:07 +02:00
|
|
|
try:
|
|
|
|
# 3.30 is the first one with Gtk.Template
|
|
|
|
gi.check_version('3.30') # NOQA
|
|
|
|
except ValueError as e:
|
|
|
|
print(e, file=sys.stderr)
|
|
|
|
sys.exit(1)
|
|
|
|
|
2019-08-13 04:53:26 +02:00
|
|
|
gi.require_version('Gio', '2.0') # NOQA
|
|
|
|
gi.require_version('Gtk', '3.0') # NOQA
|
2019-07-10 01:51:41 +02:00
|
|
|
from gi.repository import Gio, Gtk, Gdk
|
|
|
|
|
2019-08-13 04:53:26 +02:00
|
|
|
|
|
|
|
@devel@ # NOQA
|
2019-08-19 03:59:02 +02:00
|
|
|
resource = Gio.resource_load(os.fspath(Path('@pkgdatadir@', 'tuhi.gresource')))
|
2019-07-10 01:51:41 +02:00
|
|
|
Gio.Resource._register(resource)
|
|
|
|
|
2019-08-13 04:53:26 +02:00
|
|
|
|
2019-07-10 01:51:41 +02:00
|
|
|
def install_excepthook():
|
|
|
|
old_hook = sys.excepthook
|
2019-08-13 04:53:26 +02:00
|
|
|
|
2019-07-10 01:51:41 +02:00
|
|
|
def new_hook(etype, evalue, etb):
|
|
|
|
old_hook(etype, evalue, etb)
|
|
|
|
while Gtk.main_level():
|
|
|
|
Gtk.main_quit()
|
|
|
|
sys.exit()
|
|
|
|
sys.excepthook = new_hook
|
|
|
|
|
2019-08-13 04:53:26 +02:00
|
|
|
|
2019-07-10 01:51:41 +02:00
|
|
|
def gtk_style():
|
|
|
|
css = b"""
|
2019-07-23 04:58:08 +02:00
|
|
|
flowboxchild:selected {
|
|
|
|
background-color: white;
|
|
|
|
}
|
2019-07-10 01:51:41 +02:00
|
|
|
.bg-white {
|
|
|
|
background-color: white;
|
|
|
|
}
|
2019-07-19 03:04:20 +02:00
|
|
|
.bg-paper {
|
2019-07-19 08:43:54 +02:00
|
|
|
border-radius: 5px;
|
2019-07-19 03:04:20 +02:00
|
|
|
background-color: #ebe9e8;
|
|
|
|
}
|
2019-07-18 10:26:31 +02:00
|
|
|
.drawing {
|
2019-07-19 03:24:37 +02:00
|
|
|
background-color: white;
|
2019-07-18 10:26:31 +02:00
|
|
|
border-radius: 5px;
|
|
|
|
}
|
2019-07-10 01:51:41 +02:00
|
|
|
"""
|
|
|
|
|
2019-08-09 07:26:43 +02:00
|
|
|
screen = Gdk.Screen.get_default()
|
|
|
|
if screen is None:
|
|
|
|
print('Error: Unable to connect to screen. Make sure DISPLAY or WAYLAND_DISPLAY are set', file=sys.stderr)
|
|
|
|
sys.exit(1)
|
2019-07-10 01:51:41 +02:00
|
|
|
style_provider = Gtk.CssProvider()
|
|
|
|
style_provider.load_from_data(css)
|
|
|
|
Gtk.StyleContext.add_provider_for_screen(
|
2019-08-09 07:26:43 +02:00
|
|
|
screen,
|
2019-07-10 01:51:41 +02:00
|
|
|
style_provider,
|
|
|
|
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
|
|
|
|
)
|
|
|
|
|
2019-08-13 04:53:26 +02:00
|
|
|
|
2019-07-10 01:51:41 +02:00
|
|
|
if __name__ == "__main__":
|
|
|
|
import gettext
|
|
|
|
import locale
|
|
|
|
import signal
|
2019-08-13 03:10:53 +02:00
|
|
|
from tuhi.gui.application import Application
|
2019-07-10 01:51:41 +02:00
|
|
|
|
|
|
|
install_excepthook()
|
|
|
|
gtk_style()
|
|
|
|
|
2019-07-17 13:10:36 +02:00
|
|
|
locale.bindtextdomain('tuhi', '@localedir@')
|
|
|
|
locale.textdomain('tuhi')
|
|
|
|
gettext.bindtextdomain('tuhi', '@localedir@')
|
|
|
|
gettext.textdomain('tuhi')
|
2019-07-10 01:51:41 +02:00
|
|
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
|
|
|
exit_status = Application().run(sys.argv)
|
|
|
|
sys.exit(exit_status)
|