Long press GTK+ TreeView on Maemo

Yesterday was a holiday so I got some time to hack a bit in SeriesFinale.
One of the things I wanted to do was to have a context menu for shows and seasons. Something to apply individual actions like deleting, updating, viewing information, etc when there is a long press on a tree view’s item.

In Maemo the way to do this is to use the TreeView’s tap_and_hold_setup method but the problem is that I hate how this context menu is implemented: I have accidentally deleted stuff because of this menu. Can you think of a less intuitive widget for a touch screen? One that shows below your thumbs, only while you’re touching the screen and triggers some action when you lift it.
Instead, I wanted to show a dialog with the different actions so users could easily know what their doing.
Also, the fact that the API only allows me to use this long-press action to trigger a menu widget doesn’t seem like the best design…

Because of this I decided to implement a TreeView’s subclass that makes it better!
In my opinion, the way to implement this in the TreeView is to treat it like any other functionality: emit a signal when it occurs.

Though it wasn’t difficult, I thought the job would be easier. I had already implemented the “long-press” signal emission but the “row-activated” signal kept being emitted as well. Contrary to what I thought, re-implementing do_row_activated didn’t do it so I had to take a look at the GTK+’s source and though the row_activated method is indeed the one that emits the signal, there is also a “hildon-row-tapped” signal being emitted from the button_release_event. I don’t know if this signal is related or if it is the Python bindings fault but I had to prevent the “row-activated” signal from the mouse_released_event method in a hackish way

Finally, when running the dialog, the application would freeze and not respond after this.
It was related to the emission being done from the timeout callback which, without having the time to look further, smelled like some race condition so I had to wrap the signal emission with the threads_enter/leave.
After this, everything worked well.

Like the “row-activated”, the “long-press” signal gives the tree path and the column that was pressed. It is emitted after pressing for 0.5 seconds and is cancelled if meanwhile the user moves the finger more than 25 pixels. These values are completely arbitrary and have just worked good enough for me. Of course you can easily change them.

And that’s it. I’ve called it EnhancedTreeView and if you want to use it in your Maemo application go ahead and copy/tweak the file (it has less than 60 lines).

SeriesFinale 0.6.8 and the revenge of the clones

Finally I could get a little time to finish SF 0.6.8 release.

In this release one thing I wanted to improve was the startup time. With the number of TV shows I have in my SF, it was taking around 25 seconds before showing me the list of shows. Part of this is due to the deserialization from the DB (no, it’s not using SQLite and I have no time to make the switch) which takes its time but also because it was attempting to sort the list of shows every time a show was added and it also took some time loading the shows’ covers from disk.
This fix was basically loading of the covers asynchronously and sorting the shows only after they are added to the tree view. It improved from 25 seconds to 12 seconds more or less.

While the shows’ covers are being loaded on startup or downloaded from the web, it displays something like shown on the following screenshot:

One of the features people like more is the display of the next episode’s air date. To improve this, I’ve added a small tweak to humanize the dates close to today so it displays “Yesterday” instead of “20 Jul”.

The covers retrieval was broken for a while and this is fixed too. What happened was that TheTVDB started redirecting images to a mirror and SF was not following redirected links… It should follow them now, so it is unlikely to happen again.
I’m also including the French translation kindly sent by David Landreau.

Other important improvements and fixes are:
* Fix deleting seasons;
* Add sorting options to the seasons view;
* Fix infinite loop when updating episodes (it happened when there were two shows with the same name);
* Consider next episode to watch only when it has an air date;

There are also some good news from other platforms’ ports. Nacho has created a branch where he is porting the GNOME version to GTK3/PyGI. A user named Micke Prag is porting it to QML which means it will be available on MeeGo one of these days. I wanted to apply for the developer’s N950 program (to port SF) but I was on honey-moon when it was announced and I ended up forgetting about it…

Revenge of the clones

When I first developed SF in 2009, I did it to scratch an itch and I couldn’t find such an app when I googled for it, I even wondered if anyone apart from me would be interested in such an app. Short after, my friend and colleague from the University, Paulo Cabido told me how much he liked the idea and created DroidSeries, a SF’s clone for Android. After a while I also found SeriesWatcher, a clone in Qt that also ran on the Linux desktop, Windows and Mac OSX.
What surprised me was that last week I was browsing the Android Market (out of curiosity, I don’t own an Android phone) and found out that there are:
* Series Droid (notice the name? If my friend Paulo was M$ or Apple, he would sue their asses 😀 )
* TV Show Favs
* TV Start
* Episode Calendar (this seems to be the only Open Source one in the list)

Although only DroidSeries and SeriesWatcher say they are based in SF, I like to think the others do as well (maybe indirectly like being based on another clone 🙂 ). Or maybe those were developed before SF and I didn’t notice… What I’m trying to say is that not only from mainstream platforms come nice end user apps. In the Maemo world, even though we have problems of other nature, we also have good ideas and good applications for end user.

Get SeriesFinale 0.6.8 soon from your N900’s updates or here.

SeriesFinale version 0.6.7

In the last release of SeriesFinale some nice new features were introduced like live search of TV shows but there was a problem: I messed it up. Basically, you could live search but once you pressed on a show, a different would be selected… good job, I know… 🙂

Anyway, the live search is fixed in this new version.

It also has some new cool changes by Juan:
* Covers are now kept back when the application is upgraded
* The database is now saved automatically every 5 minutes
* To prevent database corruption, the database is saved in a temporary file and if everything when well it is then moved to the right file name
* It now checks if other instances of SF are running and hangs newer instances until the old ones are finished
* Buttons whose actions depend on the connection are now only visible when the device is online

Since last version, it is possible to navigate to the next and previous episodes when viewing an episode details but one thing that was a real pain was to have to go back to the full list of episodes in order to mark them as watched so I’ve added a menu that lets users check the episode as watched.

The episodes’ titles are now also stroked when they are watched:

If you use the extras-testing repository, be sure to give it a try and vote to promote it.