From 208dc89849111aff6f226197e7dbfecd7ab29085 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= <manuq@laptop.org>
Date: Tue, 29 May 2012 00:03:44 -0300
Subject: [PATCH Sugargame 2/2] Port to sugar-toolkit-gtk3
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Mail-Followup-To: <sugar-devel@lists.sugarlabs.org>
- changed sugar imports to sugar3
- changed GtkWidget set_flags(Gtk.CAN_FOCUS) to set_can_focus(True)
- changed GtkWidget signal 'expose-event' to 'draw'
- changed GdkWindow get_pointer() to get_device_position()
Signed-off-by: Manuel Quiñones <manuq@laptop.org>
---
sugargame/canvas.py | 4 ++--
sugargame/event.py | 9 +++++----
test/TestActivity.py | 12 ++++++------
test/setup.py | 2 +-
4 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/sugargame/canvas.py b/sugargame/canvas.py
index d070a96..1ce0250 100644
a
|
b
|
class PygameCanvas(Gtk.EventBox): |
23 | 23 | |
24 | 24 | self._mainwindow = mainwindow |
25 | 25 | |
26 | | self.set_flags(Gtk.CAN_FOCUS) |
| 26 | self.set_can_focus(True) |
27 | 27 | |
28 | 28 | self._socket = Gtk.Socket() |
29 | 29 | self.add(self._socket) |
… |
… |
class PygameCanvas(Gtk.EventBox): |
45 | 45 | pygame.init() |
46 | 46 | |
47 | 47 | # Restore the default cursor. |
48 | | self._socket.window.set_cursor(None) |
| 48 | self._socket.props.window.set_cursor(None) |
49 | 49 | |
50 | 50 | # Initialize the Pygame window. |
51 | 51 | r = self.get_allocation() |
diff --git a/sugargame/event.py b/sugargame/event.py
index 0aeee50..19ecf5d 100644
a
|
b
|
|
1 | 1 | from gi.repository import Gtk |
| 2 | from gi.repository import Gdk |
2 | 3 | from gi.repository import GObject |
3 | 4 | import pygame |
4 | 5 | import pygame.event |
… |
… |
class Translator(object): |
58 | 59 | Gdk.EventMask.BUTTON_RELEASE_MASK |
59 | 60 | ) |
60 | 61 | |
61 | | self._mainwindow.set_flags(Gtk.CAN_FOCUS) |
62 | | self._inner_evb.set_flags(Gtk.CAN_FOCUS) |
| 62 | self._mainwindow.set_can_focus(True) |
| 63 | self._inner_evb.set_can_focus(True) |
63 | 64 | |
64 | 65 | # Callback functions to link the event systems |
65 | 66 | self._mainwindow.connect('unrealize', self._quit_cb) |
… |
… |
class Translator(object): |
68 | 69 | self._inner_evb.connect('button_press_event', self._mousedown_cb) |
69 | 70 | self._inner_evb.connect('button_release_event', self._mouseup_cb) |
70 | 71 | self._inner_evb.connect('motion-notify-event', self._mousemove_cb) |
71 | | self._inner_evb.connect('expose-event', self._expose_cb) |
| 72 | self._inner_evb.connect('draw', self._expose_cb) |
72 | 73 | self._inner_evb.connect('configure-event', self._resize_cb) |
73 | 74 | |
74 | 75 | # Internal data |
… |
… |
class Translator(object): |
189 | 190 | # if this is a hint, then let's get all the necessary |
190 | 191 | # information, if not it's all we need. |
191 | 192 | if event.is_hint: |
192 | | x, y, state = event.window.get_pointer() |
| 193 | win, x, y, state = event.window.get_device_position(event.device) |
193 | 194 | else: |
194 | 195 | x = event.x |
195 | 196 | y = event.y |
diff --git a/test/TestActivity.py b/test/TestActivity.py
index a3981c4..cb67c3c 100644
a
|
b
|
import sys |
4 | 4 | from gi.repository import Gtk |
5 | 5 | import pygame |
6 | 6 | |
7 | | import sugar.activity.activity |
8 | | from sugar.graphics.toolbarbox import ToolbarBox |
9 | | from sugar.activity.widgets import ActivityToolbarButton |
10 | | from sugar.graphics.toolbutton import ToolButton |
11 | | from sugar.activity.widgets import StopButton |
| 7 | import sugar3.activity.activity |
| 8 | from sugar3.graphics.toolbarbox import ToolbarBox |
| 9 | from sugar3.activity.widgets import ActivityToolbarButton |
| 10 | from sugar3.graphics.toolbutton import ToolButton |
| 11 | from sugar3.activity.widgets import StopButton |
12 | 12 | |
13 | 13 | |
14 | 14 | sys.path.append('..') # Import sugargame package from top directory. |
… |
… |
import sugargame.canvas |
17 | 17 | import TestGame |
18 | 18 | |
19 | 19 | |
20 | | class TestActivity(sugar.activity.activity.Activity): |
| 20 | class TestActivity(sugar3.activity.activity.Activity): |
21 | 21 | def __init__(self, handle): |
22 | 22 | super(TestActivity, self).__init__(handle) |
23 | 23 | |
diff --git a/test/setup.py b/test/setup.py
index 6ed89aa..d290fe6 100755
a
|
b
|
|
1 | 1 | #!/usr/bin/env python |
2 | | from sugar.activity import bundlebuilder |
| 2 | from sugar3.activity import bundlebuilder |
3 | 3 | bundlebuilder.start() |
4 | 4 | |