quit on ctrl-q

This commit is contained in:
j 2015-11-18 13:36:24 +01:00
parent 26da12dedd
commit 7e86e68101

View file

@ -5,7 +5,7 @@ import subprocess
import gi import gi
gi.require_version('WebKit2', '4.0') gi.require_version('WebKit2', '4.0')
from gi.repository import WebKit2, Gtk from gi.repository import WebKit2, Gtk, Gdk
base = dirname(dirname(dirname(abspath(__file__)))) base = dirname(dirname(dirname(abspath(__file__))))
@ -17,7 +17,12 @@ def drop_cb(wid, context, x, y, time):
context.finish(True, False, time) context.finish(True, False, time)
return True return True
def on_key_press_event(widget, event):
if event.state & Gdk.ModifierType.CONTROL_MASK and event.keyval == 113:
Gtk.main_quit()
wnd = Gtk.Window() wnd = Gtk.Window()
wnd.set_icon_from_file(icon) wnd.set_icon_from_file(icon)
wnd.set_wmclass(title, title) wnd.set_wmclass(title, title)
wnd.set_title(title) wnd.set_title(title)
@ -26,6 +31,7 @@ wnd.set_default_size(1366, 768)
ctx = WebKit2.WebContext.get_default() ctx = WebKit2.WebContext.get_default()
web = WebKit2.WebView.new_with_context(ctx) web = WebKit2.WebView.new_with_context(ctx)
wnd.connect("destroy", Gtk.main_quit) wnd.connect("destroy", Gtk.main_quit)
wnd.connect('key_press_event', on_key_press_event)
wnd.add(web) wnd.add(web)
wnd.show_all() wnd.show_all()