View Single Post
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#8
I have updated the code to support forced-portrait and forced-landscape mode in addition to the auto-rotation mode (auto-rotation is still the default). You can now also pass your main window to the constructor which will be slightly more efficient than querying the HildonWindowStack for rotation (it still works without passing the main window if for any reason you cannot get a reference to it..). Usage:

Code:
main_window = .... # set this to your main window

rotation = FremantleRotation(main_window)
# we're in auto-rotation mode now

rotation.set_mode(FremantleRotation.ALWAYS)
# we're now forcing portrait mode

rotation.set_mode(FremantleRotation.NEVER)
# we're now forcing landscape mode

rotation.set_mode(FremantleRotation.AUTOMATIC)
# and automatic mode again

# you can also get the mode
mode = rotation.get_mode()
if mode == FremantleRotation.AUTOMATIC:
    # do something here
elif mode == FremantleRotation.ALWAYS:
    # something else here
elif mode == FremantleRotation.NEVER:
    # you get the idea...
You can use this to add a "Orientation" setting to your preferences dialog and let the user decide what works best for him/her. The code is at the same link as the original post (you can also simply git clone the gPodder source repository and find the code in src/gpodder/gtkui/frmntl/portrait.py).
 

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