Cheese GSoC Report – Week 2

Second week of the (rather hot and sweaty) Summer of Code is over! And during this week….

  1. Replicated most of the UI of Cheese
  2. Learnt how to make C and Vala code co-exist (Thanks folks at #vala!)
  3. Made the thumbnail widget work, in both modes/orientations
  4. Implemented fullscreen mode, with autohiding of the action buttons
  5. Started modifying parts of libcheese to support clutter for video output

In last week’s report, I mentioned that I didn’t quite like my pace of work. I still don’t like it – Hamster reports I’ve spent 15.2 hours since Monday on Cheese, which is just about 3 hours a day! Totally unacceptable, and I’d like to increase that number considerably.

Last week’s predictions were for libcheese integration, UI replication and Thumbnail view implementation. I’ve finished the last two, and have made a start on the first. Needs improvement.

By next week, I hope to have accomplished…

  1. Working video preview showing up!
  2. Photo taking works
  3. Video taking works
  4. Burst mode works

Basically, it would be usable. In a basic way.

And what did I learn this week?

  1. Don’t try to be too clever. Clear Code > Lesser LoC.
  2. Ask first. Verify assumptions.
  3. Just because something can be rewritten, does not mean it should be :)

On an unrelated note, my sleep cycle is totally messed up – I’ve been sleeping at 6 AM and waking up at 2 PM. Sunlight feels weird to me. I haven’t been able to do my biweekly bicycle rides :( I should also try to fix that before the end of next week.

Cheese GSoC Report – Week 1

First week of official coding is over. What do I have to show for it?

  1. Moved code from Github to GNOME Git (Thanks fargiolas!)
  2. Learnt how to use GTKBuilder, and how to autoconnect signals to vala callback functions.
  3. Learnt some of the intricacies of Gtk+ Layouts (They still have a lot to teach me!)
  4. Got a very basic version of the basic Cheese window up and running.
  5. Learnt how to embed Clutter into the Gtk+ base of Cheese.

So far so good. I don’t quite like the pace of my work – I should be going faster. Hopefully I won’t be feeling like this at the end of next week :)

By next week, I hope to have accomplished…

  1. Pixel perfect UI, replicating exactly what is in cheese right now (except for the viewport, ofcourse)
  2. Vala bindings (.vapi files, basically) for libcheese
  3. Thumbnail View finished (either wrap and use current code, steal some some other project or write my own)
  4. Basic work on modifying libcheese to support video output to a ClutterTexture

GSoC is primarily about learning, so what have I learnt so far?

  1. git is a powerful tool, provided you do not fight it (thanks fargiolas!)
  2. Just because code works, doesn’t mean it is good enough! (thanks _ke!)
  3. When you are stuck, STOP AND ASK FOR DIRECTIONS! (thanks fargiolas!)

Vala, GTKBuilder and Autoconnecting Signal Handlers

Note: I’m not an expert on Vala, GTK+, or anything else for that matter. If I am off base someplace, comment.

I spent quite a some time today trying to get GTKBuilder to automagically connect all my signals to their handlers. I tripped up at a few places, and so recording them here for posterity.

  1. If you are using instance methods (like most of us are), you’ve to decorate your handler function with the attribute [CCode (instance_pos=-1)]. This makes sure that the function is passed the this pointer as last argument, rather than first. You’ve to do this because Builder.connect_signals passes the instance as last parameter (user_data), and by aligning your this pointer with user_data, you make sure the correct instance is called.

  2. Make sure your handler function signature matches what is expected. Ignore the user_data parameter of most signals – it is used internally by Builder.connect_signals (see above point).

  3. Make sure you pass --pkg gmodule-2.0 to your valac. If you’re using Autotools, this means you pass it to VALAFLAGS.

  4. sure your C compiler is called with -dynamic-export. I’m told this enabled support for dlopen in the binary produced.

  5. Mangle your names properly. Cheese.MainWindow.on_quit() becomes cheese_main_window_on_quit on C, and that is what GTKBuilder expects. If you are not sure how your function name is mangled by valac, checkout the generated .c file.

If you do all these 5 things right and you’re still having trouble, turn up on #vala at irc.gimp.net and ask the helpful folks there :)

GSoC Milestones – Vala Build using AutoTools

I’m using a RTM List to track my milestones for this my GSoC this year. I’ll be making a blog post for each item ticked off that list, to share what I’ve learnt in my journey from n00b to someone whose code is good enough to be included in GNOME. This is part 1 in the series, where I tell you about autotools

My GSoC project involves, moving major parts (UI) of Cheese to a new language – Vala. Vala is more an extremely glorious C preprocessor than a language of its own – it just translates down to GObject based C code, rather than bytecode/objectcode. The syntax is very C#ish – I was using csharp-mode in emacs to code vala till I got bored enough to download vala-mode. It’s got closures – haven’t used them yet, here is to hoping they’re real closures. It has tons of libraries – it takes a few (minutes|hours) to write a binding for any C library, so many bindings already exist. You don’t lose speed – Vala is compiled down to C code. It also has one of Java’s suckiest features – Checked Exceptions. The documentation is non existent – you’ve to pretty much read through the bindings, or the original C library’s documentation to get anything done. And not many people know such a language exists (Kausik for example – but he also didn’t know you could output pdf from latex, so I don’t think his opinion counts :D)

Cheese uses autotools for building. I had to tweak their script to make it build my Vala code as well. I’ve never worked with any of the autotools stuff before – I didn’t even know .ac stood for autoconf and .am stood for automake. No big deal – Google knows it all and will tell you for free. I JFGI and found a bunch of articles about using autotools to successfully build vala projects. After reading this monstrous (180+ slides, but ~500 pages) Autotools presentation (which is actually very, very good, btw), I had a working build script. It built my single cheese.vala file that did nothing but run a loop and wait to be terminated. It had a place where I could add more .vala files and they should (should) be included in the build. It was hackish, but like most hacks, it worked. On My Machine(tm).

Nowhere else. Turned out my script wasn’t working at all – just faking it to me. I had initially tested out valac (the vala compiler), which had produced a .c file. Since make was supposed to produce the same file, and it wasn’t stale (I hadn’t touched my cheese.vala), it just proceeded to compiling the .c files with gcc. The Vala part of the build script wasn’t being executed at all. Removing the .c file told me that my hackish script hadn’t worked at all.

After banging my head for a while to figure out why it wasn’t working, I finally landed up on the official autotools docs. Autotools had added native vala support. The hack I found was not necessary.

facepalm

Moral of the Story: RTFM comes first, not JFGI.

Anyway, I rewrote the build script to be much more cleaner in a couple of minutes. And it worked.

Build systems are actually a lot of fun once you get the hang of it. A black screen with fast scrolling green text cryptic to everyone else but totally sensible to you is incredibly attractive, no? :)

GSoC Milestone 0 – What does my project do?

I’m using a RTM List to track my milestones for this my GSoC this year. I’ll be making a blog post for each item ticked off that list, to share what I’ve learnt in my journey from n00b to someone whose code is good enough to be included in GNOME. This is part 0 in the series, where I tell you what my project is all about and how Cheese is going to become awesomer.

So, what exactly does my proposal mean for Cheese?

  1. Moving the UI to Vala (from C)
  2. Move display bits from GTK+ to clutter
  3. Implement Live Preview to show people how applying an effect will look before applying it
  4. Implement loadable effects so you aren’t stuck with just 12 preloaded effects.

I’m told that the scope is kinda too big for 3 months – but I’m sure that with careful planning (hah!), around 40 hours of work a week (haha!), lots of time away from college (hahaha!) I can do this stuff :)

I’m keeping my code in a github repo, so watch that for code updates. And will be updating this blog at the completion of every milestone, so subscribe if you haven’t :)

Note: My exams are still going on. Won’t be coding much till they end (May 19th).

My First Accepted Patch!

As part of my GSoC preparations, I wrote a few patches for Cheese. One of them (a one liner to fix a crash) has made it to GNOME 2.30.1 – the other two (1 and 2) are slightly more significant and involve UI changes, and so will be integrated later.

Free beer to everyone who can catch me in a bar! Free Pepsi/Sprite/Egg Puff to anyone who can catch me in the College Stores ;)

P.S. Obligatory thanks to _ke and fargiolas for guiding me through the difficult bits :)

GSoC 2010 – The Beginning

I mentioned this in passing in my earlier post, and was tweeting about it quite furiously – I’ve been selected to work on Cheese for this year’s Google Summer of Code :D

Link to my, uhm, cheesy proposal

What Now?

Getting accepted doesn’t mean shit. Actually finishing whatever I was supposed to within 3 months does mean something – especially since I’ve taken on quite a bit of stuff to do (Move to new language + 2 new features). I’m quite the n00b – first time I’ll be doing just one thing over 3 months. Will be setting up a way of monitoring progress (probably via set milestones) soon enough. Will keep this place posted :)

Also, say Hi to my mentor daniel siegel. Him and fellow cheese-dev Flippio Argiolas, who were extremely helpful in getting my proposal whipped into shape (It’s a gist, so you can see how it eveolved over time).

The Oscar acceptance style blog post will be turned in once the three months are over and the newer, improved Cheese is accepted as good enough :D

Hacking more!

Quoting from Steven Levy‘s Hackers:

[..] a project undertaken or a product built not solely to fulfill

some constructive goal, but with some wild pleasure taken in mere

involvement, was called a “hack.”

Building things for the fun of building them is hacking. And hacking is not illegally breaking into computers.

I like hacking. I want to be a real hacker. I can’t call myself one yet.

I’m putting this up as a reminder to myself – about what is important and what isn’t. Here is to hoping I remember to say No more often. Here is to hoping that the next time I’m bored, I write something rather than idle on IRC. GSoC (a bigger post about it coming up) is helping – a lot.

I’ll do a monthly ‘things I’ve hacked on’ post, and see how many things turn up on that :)

How I spent the Day today

Wake up at 10. Roll around bed for half an hour. Chase brother away from your computer (on which he was playing GTA (or NFS)). Check mail. Find something to code on, code. Check mail. Check proggit. Check HN. Waste some time on Twitter. Waste some more time on IRC. Check mail. Check proggit. Check HN. Tab around, really fast. Tab around, really fast. Go have breakfast. Or lunch – doesn’t matter what you call it.

Finish eating, watch TV a bit. Bitch about how nothing on TV is worth watching. Come back to room, chase away brother playin games again. Start codin something. Tab to Firefox to read some docs. Check mail. Check proggit. Check HN. Check Twitter. Check IRC. Check mail. Read the documentation I really opened Firefox for. Edit a bit more code. Check mail. Check proggit. Check HN. Check Twitter. Check IRC.

Go upstairs. Bitch about how there was nothing to eat. Grab biscuits and water. Look at the time. Look at the date. Feel Ghosh! My exams are nearing! Maybe I should start studying?!. Go back to computer. Check mail. Check proggit. Check HN. Check Twitter. Check IRC. Bitch about exams on IRC. Feel Fuck exams! Fuck marks! I don’t need none of that shit!. Feel good about yorself. Check mail. Check proggit. Check twitter. Congratulate yourself on skipping HN. Go back to IRC.

Get on Facebook. Reply to comments. Post vague sounding status messages. Comment on pictures, randomly varying between variants of Cute! and lol rofl look at that haha!. Brag on Facebook. Check proggit. Check HN. Check Twitter. Congratulate self on skipping IRC.

Go back to code. Read documentation. Check mail. IM people and have philosophical discussions. Flirt around. Feel tired. Think about wasted day. Resolve to make next day better. Think about studying. Decide it is too late. Go to sleep.

Repeat :D