From 41968d61a320632cabc0dd7ad2805c9f6fedb54c Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Mon, 24 Sep 2012 18:52:04 +0000 Subject: Escape key stops page loading SL #3373 Allow Esc key to stop page loading. If the activity is on fullscreen mode, the first time that Esc key is pressed the page loading will stop and the second time it will call unfullscreen mode. Signed-off-by: Manuel Kaufmann Acked-by: Manuel QuiƱones --- (limited to 'webactivity.py') diff --git a/webactivity.py b/webactivity.py index 24f3b44..cdd556f 100644 --- a/webactivity.py +++ b/webactivity.py @@ -204,6 +204,9 @@ class WebActivity(activity.Activity): self.model = Model() self.model.connect('add_link', self._add_link_model_cb) + # HACK to allow Escape key stop loading on fullscreen mode + # http://bugs.sugarlabs.org/ticket/1434 + self.disconnect_by_func(self._Window__key_press_cb) self.connect('key-press-event', self._key_press_cb) if handle.uri: @@ -426,6 +429,29 @@ class WebActivity(activity.Activity): self._tabbed_view.load_homepage() def _key_press_cb(self, widget, event): + # HACK: this is the hacked version of + # sugar3.graphics.Window.__key_press_cb function to allow stop + # loading on fullscreen + def __key_press_cb(widget, event): + status = self._tabbed_view.props.current_browser.get_load_status() + loading = WebKit.LoadStatus.PROVISIONAL <= status \ + < WebKit.LoadStatus.FINISHED + + key = Gdk.keyval_name(event.keyval) + if event.get_state() & Gdk.ModifierType.MOD1_MASK: + if self.tray is not None and key == 'space': + self.tray.props.visible = not self.tray.props.visible + return True + elif key == 'Escape' and self._is_fullscreen and \ + self.props.enable_fullscreen_mode and \ + not loading: + self.unfullscreen() + return True + return False + + # Call the original sugar3.graphics.Window.__key_press_cb function + __key_press_cb(widget, event) + key_name = Gdk.keyval_name(event.keyval) browser = self._tabbed_view.props.current_browser @@ -482,6 +508,10 @@ class WebActivity(activity.Activity): return True + elif key_name == 'Escape': + _logger.debug('keyboard: Stop loading') + browser.stop_loading() + return False def _add_link(self): -- cgit v0.9.1