View Single Post
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#13
Since the initial announcement, I have changed the code a bit to allow the on-demand activation and deactivation of the rotation support through MCE and for a user-configurable setting:

http://repo.or.cz/w/gpodder.git?a=bl...tl/portrait.py

Because of these changes, the usage has also changed a bit:

Code:
# import the module...

main_window = ... # your main hildon.StackableWindow
app_name = 'NameOfYourApp' # the name of your app
app_version = '1.0' # the version number of your app
initial_mode = FremantleRotation.AUTOMATIC

rotation_object = FremantleRotation(app_name, main_window, app_version, initial_mode)
The rotation object then takes care of enabling and disabling the accelerometer as it is needed. You can provide a preferences UI for your app (see gPodder for an example) and then set the mode of the rotation object like this:

Code:
rotation_object.set_mode(FremantleRotation.AUTOMATIC)
rotation_object.set_mode(FremantleRotation.NEVER)
rotation_object.set_mode(FremantleRotation.ALWAYS)
You can create a hildon.PickerButton and a hildon.TouchSelector for your preferences dialog to set the mode. As an example, consult the source code of gPodder's preferences dialog:

http://repo.or.cz/w/gpodder.git?a=bl...preferences.py
 

The Following 4 Users Say Thank You to thp For This Useful Post: