in Geeky

N900 development Part 2

Before you continue on reading, understand that a prerequisite is for you to start with part 1 and especially Maemo’s Getting Started guide.

For this guide, I’ll be showing how to create multiple widgets in one window. The code from Maemo provides you one window with one widget (the button). You cannot add on more widgets to the example just like that. Adding >1 widget to a HildonWindow will still allow the program to compile, however if you run it you will have to expect an error message that looks something like “… as a GtkBin subclass a HildonWindow can only contain one widget at a time; it already contains a widget of type …”

So the alternative is to create one vBox (or hBox) and pack all other widgets (including other hBox and vBox) inside of it. The end result from the sample should be an applicati
on with an interface that looks like this

3-button hello world app on N900 emulator
3-button hello world app on N900 emulator

The blog formatting makes it a bitch to paste my code here, so just download the code into scratchbox environment with something like this:

wget http://dartarrow.net/wp-content/uploads/2010/03/hworld.c

You should now be able to compile the program with the following line:

gcc hworld.c `pkg-config hildon-1 --cflags  --libs` -o hworld 

Execute the programe

 ./hworld 

And voila.

Take note of how the hbox is prepared and then packed into the vbox. Understanding the interaction is key to your own gui development with C, GTK, and Hildon.

Credit where credit’s due, I stole and modified the code from Maemo’s Wiki

Related Posts

Written By:

Add a Comment