/usr/share/pyshared/jarabe/view/gesturehandler.py is in python-jarabe-0.98 0.98.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | # Copyright (C) 2012 One Laptop Per Child
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from gi.repository import Gdk
from gi.repository import SugarExt
from gi.repository import SugarGestures
from sugar3.graphics import style
_instance = None
class GestureHandler(object):
'''Handling gestures to show/hide the frame
We use SugarExt.GestureGrabber to listen for
gestures on the root window. We use a toggle
gesture to either hide or show the frame: Swiping
from the frame area at the top towards the center
does reveal the Frame or hide it.
'''
def __init__(self, frame):
self._frame = frame
self._gesture_grabber = SugarExt.GestureGrabber()
self._controller = []
screen = Gdk.Screen.get_default()
screen.connect('size-changed', self.__size_changed_cb)
self._add_controller()
def __size_changed_cb(self, screen):
self._add_controller()
def _add_controller(self):
for controller in self._controller:
self._gesture_grabber.remove(controller)
self._track_gesture_for_area(SugarGestures.SwipeDirectionFlags.DOWN,
0, 0, Gdk.Screen.width(),
style.GRID_CELL_SIZE)
def _track_gesture_for_area(self, directions, x, y, width, height):
rectangle = Gdk.Rectangle()
rectangle.x = x
rectangle.y = y
rectangle.width = width
rectangle.height = height
swipe = SugarGestures.SwipeController(directions=directions)
swipe.connect('swipe-ended', self.__swipe_ended_cb)
self._gesture_grabber.add(swipe, rectangle)
self._controller.append(swipe)
def __swipe_ended_cb(self, controller, event_direction):
if self._frame.is_visible():
self._frame.hide()
else:
self._frame.show()
def setup(frame):
global _instance
if _instance:
del _instance
_instance = GestureHandler(frame)
|