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"
27 #include "maevies_window.h"
29 /* Defines to add the application to dbus and keep it running
30 * Please do not modify "APP_NAME" (or other defines) to different name
32 #define APP_NAME "maevies"
34 #define APP_SERVICE "com.nokia.maevies"
35 #define APP_METHOD "/com/nokia/maevies"
38 typedef struct _AppData AppData;
42 HildonProgram *program;
43 MaeviesWindow *window;
47 static gint dbus_callback(const gchar *interface, const gchar *method,
48 GArray *arguments, gpointer data, osso_rpc_t *retval);
50 gint main(gint argc, gchar* argv[]) {
52 osso_context_t *osso_cont;
54 AppData *data = g_new0(AppData,1);
58 osso_cont = osso_initialize(APP_NAME, APP_VER, TRUE, NULL);
61 /* Initialize the GTK. */
62 gtk_init(&argc, &argv);
64 /* Initialize thread system */
67 /* Create the hildon program and setup the title */
68 data->program = HILDON_PROGRAM(hildon_program_get_instance());
69 g_set_application_name("Maevies");
71 /* Create HildonWindow and set it to HildonProgram */
72 data->window = maevies_window_new(osso_cont);
73 hildon_program_add_window(data->program, HILDON_WINDOW(data->window));
75 ret = osso_rpc_set_cb_f(data->window->osso, APP_SERVICE, APP_METHOD,
76 APP_SERVICE, dbus_callback, GTK_WIDGET(data->window));
78 fprintf(stderr, "osso_rpc_set_cb_f failed: %d.\n", ret);
82 /* Begin the main application */
83 gtk_widget_show_all(GTK_WIDGET(data->window));
85 /* Quit program when window is closed. */
86 g_signal_connect(G_OBJECT(data->window), "delete_event",
87 G_CALLBACK(gtk_main_quit), NULL);
89 /* Quit program when window is otherwise destroyed. */
90 g_signal_connect(G_OBJECT(data->window), "destroy", G_CALLBACK(gtk_main_quit),
96 gtk_widget_destroy(GTK_WIDGET (data->window));
103 static gint dbus_callback(const gchar *interface, const gchar *method,
104 GArray *arguments, gpointer data, osso_rpc_t *retval) {
105 printf("dbus: %s, %s\n", interface, method);
107 if (!strcmp(method, "top_application"))
108 gtk_window_present(GTK_WINDOW(data));
110 return DBUS_TYPE_INVALID;