Last week I finally got around to downgrading my laptop from karmic to jaunty. I did this for a couple of reasons. For my laptop the control of external displays regressed from working flawlessly, to crashing everytime it tried to detect an external display that it didnt boot with.
Secondly,, eclipse has some major problems on karmic due to some changes. The fault is with eclipse, but it will be some time before any fixes work through to the eclipse based products I need to work with, so I downgraded.
Planet maemo: category "feed:85141068e640087e3494790d59181094"
I wrote a couple of weeks ago a little teaser about writing a custom cell renderer.
Once I got witter to the point that it had multiple views, I immediately wanted to have a nice way to switch between those views. In the first instance I just used buttons which have the advantage of being able to go direct to the view you want, but at the cost of screen space to show the button. Or alternatively needing to go via menus to get to the buttons.
Enter ‘gestures’ I wanted to be able to swipe left or right to switch views, much like on the multi-desktop of the N900. So I did some searching and eventually found reference to gPodder which is also written in python and introduced swipe gestures.
So i dug around the source and found that essentially they capture the position of a ‘pressed’ event and the position of the ‘released’ event and calculate the difference. If it’s over a certain threshold left or right then they trigger the appropriate method.
This seemed reasonable enough, but I couldn’t figure out what object was emitting those signals. As I looked into it I found something better.
The hildon pannableArea emits signals for horizontal scrolling and vertical scrolling. And it does so regardless of whether it will actually scroll.
What this means is that for witter, I use a pannableArea to do kinetic scrolling of the treeview which shows the tweets. There is no horizontal movement, but I can use the following:
pannedWindow.connect('horizontal-movement', self.gesture)
Then in the method gesture I get:
def gesture(self, widget, direction, startx, starty):
if (direction == 3):
#Go one way
if (direction == 2):
#Go rthe other
those numbers do have constants associated, but I haven’t figured out where I am supposed to reference them from, so I’m just using the numbers.
The cool thing about this is that it is quite selective about what constitutes horizontal movement. Going diagonally left and up or down does NOT trigger this signal.
So it’s a pretty nice way to switch between views. Now I need to figure out how to do the cool dragging of views like the desktop, rather than just a straight flip of views.
Posted in maemo, project, SoftwareEngineering Tagged: gestures, hildon, N900, pannablearea, Python, swipe, witter
As a teaser to a future post I thought I’d post an early screenshot of Witter using a custom cell renderer. This is about the first point at which my cell renderer is actually capable of showing tweets at all.
It completely lacks any layout of information, or colouring/sizing of text. But I wanted to put it up to a) contrast with when I’m done, and b) show that it took me nearly 200 lines of code, just to get this far…
Posted in maemo, project, SoftwareEngineering Tagged: custom cellrenderer, gtk, N900, treeview, witter