Getting started with Maemo development using C
The article is believed to be still valid for the original topic scope.
Contents |
Overview
This article provides an overview on how to develop for Maemo using C.
Tools
Scratchbox which is a cross compilation tool is required. Check www.scratchbox.org for more details.
Xephyr is required to launch the application framework and execute GUI applications.
Install the Maemo SDK (( you need to have a Linux OS to install the SDK though Debian and Ubuntu are recommended and Xephyr is included in most of the Linux distributions). Also if you want to install SDK on your windows machine you have to emulate a Linux environment to be able to work with maemo SDK. For that pupose you need to set up the VMWARE player).
Creating a Helloworld application
After you have installed all the packages log into the scratchbox then select the x86 SDK target.
Create a folder in your scratchbox home directory and then move to that folder. Now create the file with the below source code
include <hildon/hildon-program.h>
#include <gtk/gtkmain.h>
#include <gtk/gtkbutton.h>
void button_pressed()
{
int i = 0;
int p=100/i;
HildonProgram *program;
g_print ("%s - %d","Hello World-",p);
program = HILDON_PROGRAM(hildon_program_get_instance());
}
int main(int argc, char *argv[])
{
/* Create needed variables */
HildonProgram *program;
HildonWindow *window;
GtkWidget *button;
/* Initialize the GTK. */
gtk_init(&argc, &argv);
/* Create the hildon program and setup the title */
program = HILDON_PROGRAM(hildon_program_get_instance());
g_set_application_name("Hello Wiki!");
/* Create HildonWindow and set it to HildonProgram */
window = HILDON_WINDOW(hildon_window_new());
hildon_program_add_window(program, window);
/* Create button and add it to main view */
button = gtk_button_new_with_label("Hello!");
gtk_container_add(GTK_CONTAINER(window), button);
g_signal_connect(G_OBJECT(button),"pressed",G_CALLBACK(button_pressed),NULL);
/* Connect signal to X in the upper corner */
g_signal_connect(G_OBJECT(window), "delete_event",
G_CALLBACK(gtk_main_quit), NULL);
/* Begin the main application */
gtk_widget_show_all(GTK_WIDGET(window));
gtk_main();
/* Exit */
}


(no comments yet)