gui: print a warning when we can't connect to the screen

Because the exception thrown is less than obvious.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
pull/145/head
Peter Hutterer 2019-08-09 15:26:43 +10:00
parent ee5640b783
commit 3641afc8bf
1 changed files with 5 additions and 1 deletions

View File

@ -39,10 +39,14 @@ def gtk_style():
}
"""
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)
style_provider = Gtk.CssProvider()
style_provider.load_from_data(css)
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(),
screen,
style_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)