Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2013-05-29 19:15:01 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2013-05-29 21:04:39 (GMT)
commit8d21cdabafd50dff20eba452922aceed02cffdb5 (patch)
treedb5ed52b26d1ec13927cffddf132b3016a13b647
parentf66d4010cd230c22397a653577dfe3db43822b4c (diff)
Rotate the canvas when the screen is rotated
Signed-off-by: Walter Bender <walter@sugarlabs.org>
-rw-r--r--OficinaActivity.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/OficinaActivity.py b/OficinaActivity.py
index 5e4528f..b30b203 100644
--- a/OficinaActivity.py
+++ b/OficinaActivity.py
@@ -62,6 +62,8 @@ Walter Bender (walter@laptop.org)
"""
from gi.repository import Gtk
+from gi.repository import Gdk
+from gi.repository import GObject
import logging
from sugar3.activity import activity
@@ -86,6 +88,8 @@ class OficinaActivity(activity.Activity):
logging.debug('Starting Paint activity (Oficina)')
self.fixed = Gtk.Fixed()
+ self._width = Gdk.Screen.width()
+ self._height = Gdk.Screen.height()
self.fixed.show()
self.fixed.modify_bg(Gtk.StateType.NORMAL,
style.COLOR_WHITE.get_gdk_color())
@@ -129,6 +133,18 @@ class OficinaActivity(activity.Activity):
self._setup_handle = self.connect('map', map_cp)
+ # Handle screen rotation
+ Gdk.Screen.get_default().connect('size-changed', self._configure_cb)
+
+ def _configure_cb(self, event):
+ ''' Rotate the drawing after a screen rotation '''
+ width = Gdk.Screen.width()
+ height = Gdk.Screen.height()
+ if (self._width > self._height) != (width > height):
+ GObject.timeout_add(100, self.area.rotate_right, self.area)
+ self._width = width
+ self._height = height
+
def key_press(self, widget, event):
print event.keyval
if event.keyval == 45: