From 71bd78150cfc845f70d162b8bb49bc394584f0fe Mon Sep 17 00:00:00 2001
From: Simon Schampijer <simon@laptop.org>
Date: Tue, 23 Oct 2012 09:24:56 +0200
Subject: [PATCH toolkit-gtk3] Window: show unfullscreen button on button and
touch events
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
We did track mouse motion events so far to show the unfullscreen
button. This adds the tracking of button events (left, middle, right
click) and touch tap.
Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Manuel Quiñones <manuq@laptop.org>
---
src/sugar3/graphics/window.py | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/src/sugar3/graphics/window.py b/src/sugar3/graphics/window.py
index 1d45210..74b3b04 100644
a
|
b
|
class Window(Gtk.Window): |
112 | 112 | self.__vbox.pack_start(self.__hbox, True, True, 0) |
113 | 113 | self.__hbox.show() |
114 | 114 | |
115 | | self.add_events(Gdk.EventMask.POINTER_MOTION_HINT_MASK |
116 | | | Gdk.EventMask.POINTER_MOTION_MASK) |
| 115 | self.add_events(Gdk.EventMask.POINTER_MOTION_HINT_MASK | |
| 116 | Gdk.EventMask.POINTER_MOTION_MASK | |
| 117 | Gdk.EventMask.BUTTON_RELEASE_MASK | |
| 118 | Gdk.EventMask.TOUCH_MASK) |
117 | 119 | self.connect('motion-notify-event', self.__motion_notify_cb) |
| 120 | self.connect('button-release-event', self.__button_press_event_cb) |
118 | 121 | |
119 | 122 | self.add(self.__vbox) |
120 | 123 | self.__vbox.show() |
… |
… |
class Window(Gtk.Window): |
264 | 267 | def __unfullscreen_button_clicked(self, button): |
265 | 268 | self.unfullscreen() |
266 | 269 | |
| 270 | def __button_press_event_cb(self, widget, event): |
| 271 | self._show_unfullscreen_button() |
| 272 | return False |
| 273 | |
267 | 274 | def __motion_notify_cb(self, widget, event): |
| 275 | self._show_unfullscreen_button() |
| 276 | return False |
| 277 | |
| 278 | def _show_unfullscreen_button(self): |
268 | 279 | if self._is_fullscreen and self.props.enable_fullscreen_mode: |
269 | 280 | if not self._unfullscreen_button.props.visible: |
270 | 281 | self._unfullscreen_button.show() |
271 | | else: |
272 | | # Reset the timer |
273 | | if self._unfullscreen_button_timeout_id is not None: |
274 | | GObject.source_remove(self._unfullscreen_button_timeout_id) |
275 | | self._unfullscreen_button_timeout_id = None |
276 | 282 | |
| 283 | if self._unfullscreen_button_timeout_id is None: |
277 | 284 | self._unfullscreen_button_timeout_id = \ |
278 | 285 | GObject.timeout_add_seconds( \ |
279 | | _UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT, \ |
| 286 | _UNFULLSCREEN_BUTTON_VISIBILITY_TIMEOUT, \ |
280 | 287 | self.__unfullscreen_button_timeout_cb) |
281 | | return False |
282 | 288 | |
283 | 289 | def __unfullscreen_button_timeout_cb(self): |
284 | 290 | self._unfullscreen_button.hide() |
| 291 | GObject.source_remove(self._unfullscreen_button_timeout_id) |
285 | 292 | self._unfullscreen_button_timeout_id = None |
286 | 293 | return False |
287 | 294 | |