Active Topics

 


Reply
Thread Tools
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#1
Hello!

Now that python-hildon has got support for portrait mode, I've added portrait mode support and auto-rotation to gPodder for Maemo 5, and in order to make my life easier, I've come up with a nice object that you can throw into your own code and that will take care of auto-rotation:

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

The only thing you (might) need to do is to connect your windows to the configure-event signal and check the ratio of the width and height to determine if you need to relayout your window. For some windows (i.e. a window with just a treeview) you don't need to do anything

Usage: Save the code as "portrait.py" or find some nice place in the module structure of you project, then use something like the following, and you're done:

Code:
from portrait import FremantleAutoRotation
FremantleAutoRotation()
Just make sure your windows are real hildon.StackableWindow, and everything should work out of the box.
 

The Following 41 Users Say Thank You to thp For This Useful Post:
Posts: 540 | Thanked: 387 times | Joined on May 2009
#2
Screenshots please
 
pycage's Avatar
Posts: 3,404 | Thanked: 4,474 times | Joined on Oct 2005 @ Germany
#3
Good to hear that autorotation finally made it into python-hildon. No more need for setting XAtoms on the GdkWindow.
I like the idea of iterating through the whole window stack on rotation signal. This makes it really easy.
 
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#4
Heh, 3 months after N900 sales start, Nokia will think that nobody cares about rotation anymore. But the truth will be that everyone will be using community apps that do the same thing and that have auto-rotation built-in...
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 

The Following 2 Users Say Thank You to qole For This Useful Post:
thp's Avatar
Posts: 1,391 | Thanked: 4,272 times | Joined on Sep 2007 @ Vienna, Austria
#5
Originally Posted by pycage View Post
I like the idea of iterating through the whole window stack on rotation signal. This makes it really easy.
I've been thinking about LD_PRELOAD and some funky gtk_main overloading to achieve auto-rotation for binaries using the same technique of getting the window stack and setting flags on all windows. It's just an idea, and some rough code, but that might be something that will enable more auto-rotation in the future...
 
timsamoff's Avatar
Posts: 1,605 | Thanked: 1,601 times | Joined on Mar 2007 @ Southern California
#6
Originally Posted by qole View Post
Heh, 3 months after N900 sales start, Nokia will think that nobody cares about rotation anymore. But the truth will be that everyone will be using community apps that do the same thing and that have auto-rotation built-in...
This is very possible. When I showed Peter Schneider ConBoy and how it rotated, he was floored.

Tim
__________________
http://samoff.com
 

The Following User Says Thank You to timsamoff For This Useful Post:
Jack6428's Avatar
Posts: 635 | Thanked: 282 times | Joined on Sep 2009 @ Black Mesa Research Facility
#7
Originally Posted by timsamoff View Post
This is very possible. When I showed Peter Schneider ConBoy and how it rotated, he was floored.

Tim
Peter is a great guy...i watched all the N900 videos that came out and he was the best promoter lol..give him regards if you see him again...
 
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:
christexaport's Avatar
Posts: 1,589 | Thanked: 720 times | Joined on Aug 2009 @ Arlington (DFW), Texas
#9
I'm trying to draw support for THIS BRAINSTORM IDEA about Nokia supporting Automatic Screen Rotation in the entire UI of Maemo 5/N900. Please give it a look and give me a hand. I thought since this thread mentioned rotation, maybe someone might be interested.
__________________
Maemo-Freak.com
"...and the Freaks shall inherit the Earth."
 
YoDude's Avatar
Posts: 2,869 | Thanked: 1,784 times | Joined on Feb 2007 @ Po' Bo'. PA
#10
Originally Posted by christexaport View Post
I'm trying to draw support for THIS BRAINSTORM IDEA about Nokia supporting Automatic Screen Rotation in the entire UI of Maemo 5/N900. Please give it a look and give me a hand. I thought since this thread mentioned rotation, maybe someone might be interested.
This thread didn't just mention rotation it is an actual "HowTo" posted by thp on 09-21-09 06:54 PM 3 days before your posted Brainstorm on 2009-09-24 21:42 UTC


What's up with that? I'm confused.
 
Reply

Tags
code, fremantle, howto, portrait mode, python


 
Forum Jump


All times are GMT. The time now is 13:48.