From c9975a7c356b6c7d81473560cd7d5d611c82bfcb Mon Sep 17 00:00:00 2001 From: Manuel Kaufmann Date: Tue, 16 Oct 2012 12:21:59 +0000 Subject: Touch: Get out of activity fullscreen mode SL #4013 Show the Unfullscreen button (with a timeout to hide it) when the user clicks over the canvas. Signed-off-by: Manuel Kaufmann Acked-by: Manuel QuiƱones --- (limited to 'webactivity.py') diff --git a/webactivity.py b/webactivity.py index 0fbf858..81ec4fd 100644 --- a/webactivity.py +++ b/webactivity.py @@ -54,6 +54,7 @@ from sugar3.graphics.icon import Icon from sugar3 import mime from sugar3.graphics.toolbarbox import ToolbarButton +from sugar3.graphics.window import _UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT PROFILE_VERSION = 2 @@ -207,6 +208,9 @@ class WebActivity(activity.Activity): self.model = Model() self.model.connect('add_link', self._add_link_model_cb) + self.set_events(Gdk.EventMask.TOUCH_MASK) + self.connect('event', self.__event_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) @@ -431,6 +435,20 @@ class WebActivity(activity.Activity): def _go_home_button_cb(self, button): self._tabbed_view.load_homepage() + def __event_cb(self, widget, event): + if self._is_fullscreen and event.type == Gdk.EventType.TOUCH_END: + # Show Unfullscreen button when the user clicks over the canvas + self._unfullscreen_button.show() + + if self._unfullscreen_button_timeout_id is not None: + GObject.source_remove(self._unfullscreen_button_timeout_id) + self._unfullscreen_button_timeout_id = None + + self._unfullscreen_button_timeout_id = \ + GObject.timeout_add_seconds( \ + _UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT, \ + self._Window__unfullscreen_button_timeout_cb) + def _key_press_cb(self, widget, event): # HACK: this is the hacked version of # sugar3.graphics.Window.__key_press_cb function to allow stop -- cgit v0.9.1