import osso
# Replace this with your own gettext() functionality
-import gpodder
-_ = gpodder.gettext
+#import gpodder
+#_ = gpodder.gettext
class FremantleRotation(object):
You can set the mode for rotation to AUTOMATIC (default), NEVER or
ALWAYS with the set_mode() method.
"""
+
AUTOMATIC, NEVER, ALWAYS = range(3)
- # Human-readable captions for the above constants
- MODE_CAPTIONS = (_('Automatic'), _('Landscape'), _('Portrait'))
+ MODE_CAPTIONS = ('Automatic', 'Landscape', 'Portrait')
# Privately-used constants
_PORTRAIT, _LANDSCAPE = ('portrait', 'landscape')
"""
self._orientation = None
self._main_window = main_window
- self._stack = hildon.WindowStack.get_default()
self._mode = -1
self._last_dbus_orientation = None
self._keyboard_state = self._get_keyboard_state()
path='/org/freedesktop/Hal/devices/platform_slide')
self.set_mode(mode)
+ self._send_mce_request(self._ENABLE_ACCEL)
+
+ def set_mode(self, new_mode):
+ self._mode=new_mode
+
def get_mode(self):
"""Get the currently-set rotation mode
"""
return self._mode
- def set_mode(self, new_mode):
- """Set the rotation mode
-
- You can set the rotation mode to AUTOMATIC (use hardware rotation
- info), ALWAYS (force portrait) and NEVER (force landscape).
- """
- if new_mode not in (self.AUTOMATIC, self.ALWAYS, self.NEVER):
- raise ValueError('Unknown rotation mode')
-
- if self._mode != new_mode:
- if self._mode == self.AUTOMATIC:
- # Remember the current "automatic" orientation for later
- self._last_dbus_orientation = self._orientation
- # Tell MCE that we don't need the accelerometer anymore
- self._send_mce_request(self._DISABLE_ACCEL)
-
- if new_mode == self.NEVER:
- self._orientation_changed(self._LANDSCAPE)
- elif new_mode == self.ALWAYS and \
- self._keyboard_state != self._KBD_OPEN:
- self._orientation_changed(self._PORTRAIT)
- elif new_mode == self.AUTOMATIC:
- # Restore the last-known "automatic" orientation
- self._orientation_changed(self._last_dbus_orientation)
- # Tell MCE that we need the accelerometer again
- self._send_mce_request(self._ENABLE_ACCEL)
-
- self._mode = new_mode
-
def _send_mce_request(self, request):
rpc = osso.Rpc(self._osso_context)
rpc.rpc_run(self._MCE_SERVICE, \
else:
self._send_mce_request(self._DISABLE_ACCEL)
- def _get_main_window(self):
+ def NO_get_main_window(self):
if self._main_window:
# If we have gotten the main window as parameter, return it and
# don't try "harder" to find another window using the stack
if orientation == self._PORTRAIT:
flags |= hildon.PORTRAIT_MODE_REQUEST
- window = self._get_main_window()
- if window is not None:
- hildon.hildon_gtk_window_set_portrait_flags(window, flags)
+# window = self._get_main_window()
+# if window is not None:
+# hildon.hildon_gtk_window_set_portrait_flags(window, flags)
self._orientation = orientation
+ self.on_orientation_changed(orientation)
+
def _get_keyboard_state(self):
# For sbox, if the device does not exist assume that it's closed
try:
self._keyboard_state_changed()
def _on_orientation_signal(self, orientation, stand, face, x, y, z):
+ print "orsignal"
if orientation in (self._PORTRAIT, self._LANDSCAPE):
if self._mode == self.AUTOMATIC and \
self._keyboard_state != self._KBD_OPEN: