Monthly Archives: October 2007

Totem YouTube plugin

Update (2011-08-27): A lot has happened to the Totem YouTube plugin since this blog post. It's been ported to C, extended to do HD videos, trimmed down to no longer do HD, and then moved to Grilo, where it now lives. It can be used in Totem from the Grilo plugin, which provides a unified UI for accessing video websites like YouTube from Totem. For more information on the history of the plugin, see my blog posts about Totem.

YouTube has come to Totem…

…in the form of a plugin I've written which allows you to browse YouTube from the comfort of everyone's favourite movie player. It allows searching for videos, and when you play a video, it displays its related videos.

The feature I'm most proud of though, is the fact that it automatically paginates when you scroll down the search results, loading more results as you go down. With a hint from Patrys in the comments in my blog post on it (and thanks to the other guys who left comments :)), it works by loading results immediately if you scroll 80% or more of the way down the treeview with the mouse or keyboard, or if you let go of the scrollbar handle more than 80% of the way down when moving it with the mouse. Query pages are loaded in a separate thread, and then the results are brought in with an idle function. This isn't quite as lag-free as I'd've wanted, but I can't see much more I can do to improve things.

Anyway, try things out by downloading and compiling SVN Totem, then enabling the "YouTube browser" plugin. You'll need the GData Python library (that's what the YouTube API uses, PyGTK 2.12 and Python 2.5. Before anyone asks, there's no way to sanely support video uploading yet, as Google unfortunately haven't yet exposed a public upload API. :(

Oh, and the cake is a lie.

17th birthday

It was my 17th birthday today. I wouldn't've classed this as such a big occasion, since the only new thing I'm now allowed to do is learn to drive, and all that'll do is drain my pockets.

In fact, it would've been quite an uneventful day, if it weren't for the ridiculous birthday card I got from everyone at school. I believe one of my friends (who was conspicuously absent today) was thrown underneath a car by everyone to delay me in the morning, while a birthday card was passed around a large number of people in the common room (including Michelle Pfeiffer and some other people I don't personally know).

It was given to me at break time, along with an impromptu chorus of "happy birthday", and various odd looks at us from people who didn't know what was going on. This would've been great, if it weren't for the actual content of the card, which is the greatest achievement in in-joke-mongering I've seen in my entire life. So here for your viewing (dis)pleasure it is…though it's not for the faint-of-heart.

OK; I think that's enough. They're gone. :)

I should remind people that it's all in-jokes, and the only real part of the image on the front is the head, and even that's a crap picture. :D

After school, I celebrated the event with my family by having home-made sushi. Considering this was the first time we'd had sushi, and the first time we'd made sushi, I think it went OK. It was certainly passable, if a little strong. I definitely won't be diving into a blob of wasabi paste again like I did today. ;)

Anyway, an enjoyable day, and even though my friends didn't buy me an Aston Martin, I'll forgive them, eventually. :)

Adding to a GtkTreeView as you scroll?

I'm writing something for Totem, and I want a GtkTreeView to have more rows added to it as you scroll down.

So far I've got it adding more rows nicely when you get to about 80% of the way down the GtkAdjustment, by listening to the adjustment's "changed" signal, but then it keeps on adding rows (ideally it should only add 20 at a time then stop), and the handle of the scrollbar screws up. I presume this is something to do with the fact that the handle is grabbed at the time, and so probably can't resize, or something.

Anyway, has anybody implemented anything similar before (or seen such a feature somewhere) so that I can see where I'm going wrong? I could've sworn I'd seen something similar before (I'm not original enough to think up such features myself :D), but I can't find it. Answers on a postcard, please. :)