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 #include "extra_scenes_provider.h"
28 /* Defines to add the application to dbus and keep it running
29 * Please do not modify "APP_NAME" (or other defines) to different name
31 #define APP_NAME "maevies"
33 #define APP_SERVICE "com.nokia.maevies"
34 #define APP_METHOD "/com/nokia/maevies"
37 static void button_clicked (GtkButton* button, gpointer data)
39 if(has_stingers("Zombieland"))
40 printf("Movie has stingers\n");
42 printf("Movie doesn't have stingers\n");
47 dbus_callback (const gchar *interface, const gchar *method,
48 GArray *arguments, gpointer data,
51 printf ("dbus: %s, %s\n", interface, method);
53 if (!strcmp (method, "top_application"))
54 gtk_window_present (GTK_WINDOW (data));
56 return DBUS_TYPE_INVALID;
59 int main( int argc, char* argv[] )
61 /* Create needed variables */
62 HildonProgram *program;
65 osso_context_t *osso_cont;
70 osso_cont = osso_initialize(APP_NAME, APP_VER, TRUE, NULL);
71 if (osso_cont == NULL)
73 fprintf (stderr, "osso_initialize failed.\n");
77 /* Initialize the GTK. */
78 gtk_init( &argc, &argv );
80 /* Create the hildon program and setup the title */
81 program = HILDON_PROGRAM(hildon_program_get_instance());
82 g_set_application_name("Maevies");
84 /* Create HildonWindow and set it to HildonProgram */
85 window = HILDON_WINDOW(hildon_window_new());
86 hildon_program_add_window(program, window);
88 /* Quit program when window is closed. */
89 g_signal_connect (G_OBJECT (window), "delete_event",
90 G_CALLBACK (gtk_main_quit), NULL);
92 /* Quit program when window is otherwise destroyed. */
93 g_signal_connect (G_OBJECT (window), "destroy",
94 G_CALLBACK (gtk_main_quit), NULL);
96 /* Create button and add it to main view */
97 button = gtk_button_new_with_label(_("Hello World!!!"));
98 gtk_container_add(GTK_CONTAINER(window),
101 g_signal_connect (G_OBJECT (button), "clicked",
102 G_CALLBACK (button_clicked), NULL);
104 ret = osso_rpc_set_cb_f (osso_cont,
108 dbus_callback, GTK_WIDGET( window ));
109 if (ret != OSSO_OK) {
110 fprintf (stderr, "osso_rpc_set_cb_f failed: %d.\n", ret);
114 /* Begin the main application */
115 gtk_widget_show_all ( GTK_WIDGET ( window ) );