58 | | rectangle = self._create_rectangle(0, 0, Gdk.Screen.width(), |
59 | | style.GRID_CELL_SIZE) |
60 | | swipe = SugarGestures.SwipeController( \ |
61 | | directions=SugarGestures.SwipeDirectionFlags.DOWN) |
62 | | swipe.connect('swipe-ended', self.__top_show_cb) |
63 | | self._gesture_grabber.add(swipe, rectangle) |
64 | | |
65 | | rectangle = self._create_rectangle(0, 0, Gdk.Screen.width(), |
66 | | style.GRID_CELL_SIZE * 2) |
67 | | swipe = SugarGestures.SwipeController( \ |
68 | | directions=SugarGestures.SwipeDirectionFlags.UP) |
69 | | swipe.connect('swipe-ended', self.__top_hide_cb) |
70 | | self._gesture_grabber.add(swipe, rectangle) |
71 | | |
72 | | rectangle = self._create_rectangle( \ |
73 | | 0, Gdk.Screen.height() - style.GRID_CELL_SIZE, |
74 | | Gdk.Screen.width(), style.GRID_CELL_SIZE) |
75 | | swipe = SugarGestures.SwipeController( \ |
76 | | directions=SugarGestures.SwipeDirectionFlags.UP) |
77 | | swipe.connect('swipe-ended', self.__bottom_show_cb) |
78 | | self._gesture_grabber.add(swipe, rectangle) |
79 | | |
80 | | rectangle = self._create_rectangle( \ |
81 | | 0, Gdk.Screen.height() - style.GRID_CELL_SIZE * 2, |
82 | | Gdk.Screen.width(), style.GRID_CELL_SIZE * 2) |
83 | | swipe = SugarGestures.SwipeController( \ |
84 | | directions=SugarGestures.SwipeDirectionFlags.DOWN) |
85 | | swipe.connect('swipe-ended', self.__bottom_hide_cb) |
86 | | self._gesture_grabber.add(swipe, rectangle) |
87 | | |
88 | | rectangle = self._create_rectangle( \ |
89 | | 0, 0, style.GRID_CELL_SIZE, Gdk.Screen.height()) |
90 | | swipe = SugarGestures.SwipeController( \ |
91 | | directions=SugarGestures.SwipeDirectionFlags.RIGHT) |
92 | | swipe.connect('swipe-ended', self.__left_show_cb) |
| 55 | self._track_gesture_for_area(SugarGestures.SwipeDirectionFlags.DOWN, |
| 56 | 0, 0, Gdk.Screen.width(), |
| 57 | style.GRID_CELL_SIZE) |
| 58 | |
| 59 | def _track_gesture_for_area(self, directions, x, y, width, height): |
| 60 | rectangle = Gdk.Rectangle() |
| 61 | rectangle.x = x |
| 62 | rectangle.y = y |
| 63 | rectangle.width = width |
| 64 | rectangle.height = height |
| 65 | swipe = SugarGestures.SwipeController(directions=directions) |
| 66 | swipe.connect('swipe-ended', self.__swipe_ended_cb) |
95 | | rectangle = self._create_rectangle( \ |
96 | | 0, 0, style.GRID_CELL_SIZE * 2, Gdk.Screen.height()) |
97 | | swipe = SugarGestures.SwipeController( \ |
98 | | directions=SugarGestures.SwipeDirectionFlags.LEFT) |
99 | | swipe.connect('swipe-ended', self.__left_hide_cb) |
100 | | self._gesture_grabber.add(swipe, rectangle) |
101 | | |
102 | | rectangle = self._create_rectangle( \ |
103 | | Gdk.Screen.width() - style.GRID_CELL_SIZE, 0, |
104 | | style.GRID_CELL_SIZE, Gdk.Screen.height()) |
105 | | swipe = SugarGestures.SwipeController( \ |
106 | | directions=SugarGestures.SwipeDirectionFlags.LEFT) |
107 | | swipe.connect('swipe-ended', self.__right_show_cb) |
108 | | self._gesture_grabber.add(swipe, rectangle) |
109 | | |
110 | | rectangle = self._create_rectangle( \ |
111 | | Gdk.Screen.width() - style.GRID_CELL_SIZE * 2, 0, |
112 | | style.GRID_CELL_SIZE * 2, Gdk.Screen.height()) |
113 | | swipe = SugarGestures.SwipeController( \ |
114 | | directions=SugarGestures.SwipeDirectionFlags.RIGHT) |
115 | | swipe.connect('swipe-ended', self.__right_hide_cb) |
116 | | self._gesture_grabber.add(swipe, rectangle) |
117 | | |
118 | | def _create_rectangle(self, x, y, width, height): |
119 | | rect = Gdk.Rectangle() |
120 | | rect.x = x |
121 | | rect.y = y |
122 | | rect.width = width |
123 | | rect.height = height |
124 | | return rect |
125 | | |
126 | | def __top_show_cb(self, controller, event_direction): |
127 | | self._frame.show() |
128 | | |
129 | | def __top_hide_cb(self, controller, event_direction): |
130 | | self._frame.hide() |
131 | | |
132 | | def __bottom_show_cb(self, controller, event_direction): |
133 | | self._frame.show() |
134 | | |
135 | | def __bottom_hide_cb(self, controller, event_direction): |
136 | | self._frame.hide() |
137 | | |
138 | | def __left_show_cb(self, controller, event_direction): |
139 | | self._frame.show() |
140 | | |
141 | | def __left_hide_cb(self, controller, event_direction): |
142 | | self._frame.hide() |
143 | | |
144 | | def __right_show_cb(self, controller, event_direction): |
145 | | self._frame.show() |
146 | | |
147 | | def __right_hide_cb(self, controller, event_direction): |
148 | | self._frame.hide() |
| 70 | def __swipe_ended_cb(self, controller, event_direction): |
| 71 | if self._frame.is_visible(): |
| 72 | self._frame.hide() |
| 73 | else: |
| 74 | self._frame.show() |