1 /*******************************************************************************
2 * Copyright (c) 2007-2008 INdT, (c) 2009 Nokia.
4 * This code example is licensed under a MIT-style license,
5 * that can be found in the file called "COPYING" in the package
10 ============================================================================
14 Description : Hildon GUI Application in C
15 ============================================================================
18 #include <hildon/hildon-program.h>
19 #include <gtk/gtkmain.h>
20 #include <gtk/gtkbutton.h>
25 #include "localisation.h"
26 /* Defines to add the application to dbus and keep it running
27 * Please do not modify "APP_NAME" (or other defines) to different name
29 #define APP_NAME "maevies"
31 #define APP_SERVICE "com.nokia.maevies"
32 #define APP_METHOD "/com/nokia/maevies"
35 static void button_clicked (GtkButton* button, gpointer data)
41 dbus_callback (const gchar *interface, const gchar *method,
42 GArray *arguments, gpointer data,
45 printf ("dbus: %s, %s\n", interface, method);
47 if (!strcmp (method, "top_application"))
48 gtk_window_present (GTK_WINDOW (data));
50 return DBUS_TYPE_INVALID;
53 int main( int argc, char* argv[] )
55 /* Create needed variables */
56 HildonProgram *program;
59 osso_context_t *osso_cont;
64 osso_cont = osso_initialize(APP_NAME, APP_VER, TRUE, NULL);
65 if (osso_cont == NULL)
67 fprintf (stderr, "osso_initialize failed.\n");
71 /* Initialize the GTK. */
72 gtk_init( &argc, &argv );
74 /* Create the hildon program and setup the title */
75 program = HILDON_PROGRAM(hildon_program_get_instance());
76 g_set_application_name("Maevies");
78 /* Create HildonWindow and set it to HildonProgram */
79 window = HILDON_WINDOW(hildon_window_new());
80 hildon_program_add_window(program, window);
82 /* Quit program when window is closed. */
83 g_signal_connect (G_OBJECT (window), "delete_event",
84 G_CALLBACK (gtk_main_quit), NULL);
86 /* Quit program when window is otherwise destroyed. */
87 g_signal_connect (G_OBJECT (window), "destroy",
88 G_CALLBACK (gtk_main_quit), NULL);
90 /* Create button and add it to main view */
91 button = gtk_button_new_with_label(_("Hello World!!!"));
92 gtk_container_add(GTK_CONTAINER(window),
95 g_signal_connect (G_OBJECT (button), "clicked",
96 G_CALLBACK (button_clicked), NULL);
98 ret = osso_rpc_set_cb_f (osso_cont,
102 dbus_callback, GTK_WIDGET( window ));
103 if (ret != OSSO_OK) {
104 fprintf (stderr, "osso_rpc_set_cb_f failed: %d.\n", ret);
108 /* Begin the main application */
109 gtk_widget_show_all ( GTK_WIDGET ( window ) );