#include <stdlib.h>
#include "localisation.h"
+#include "extra_scenes_provider.h"
+#include "maevies_window.h"
+
/* Defines to add the application to dbus and keep it running
* Please do not modify "APP_NAME" (or other defines) to different name
*/
#define APP_METHOD "/com/nokia/maevies"
/* end defines */
-static void button_clicked (GtkButton* button, gpointer data)
-{
- gtk_main_quit();
-}
+typedef struct _AppData AppData;
-static gint
-dbus_callback (const gchar *interface, const gchar *method,
- GArray *arguments, gpointer data,
- osso_rpc_t *retval)
-{
- printf ("dbus: %s, %s\n", interface, method);
+struct _AppData {
- if (!strcmp (method, "top_application"))
- gtk_window_present (GTK_WINDOW (data));
+ HildonProgram *program;
+ MaeviesWindow *window;
- return DBUS_TYPE_INVALID;
-}
+};
+
+static gint dbus_callback(const gchar *interface, const gchar *method,
+ GArray *arguments, gpointer data, osso_rpc_t *retval);
+
+gint main(gint argc, gchar* argv[]) {
-int main( int argc, char* argv[] )
-{
- /* Create needed variables */
- HildonProgram *program;
- HildonWindow *window;
- GtkWidget *button;
- osso_context_t *osso_cont;
+ osso_context_t *osso_cont;
osso_return_t ret;
+ AppData *data = g_new0(AppData,1);
locale_init();
- osso_cont = osso_initialize(APP_NAME, APP_VER, TRUE, NULL);
- if (osso_cont == NULL)
- {
- fprintf (stderr, "osso_initialize failed.\n");
- exit (1);
- }
-
- /* 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("Maevies");
-
- /* Create HildonWindow and set it to HildonProgram */
- window = HILDON_WINDOW(hildon_window_new());
- hildon_program_add_window(program, window);
-
- /* Quit program when window is closed. */
- g_signal_connect (G_OBJECT (window), "delete_event",
- G_CALLBACK (gtk_main_quit), NULL);
-
- /* Quit program when window is otherwise destroyed. */
- g_signal_connect (G_OBJECT (window), "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
-
- /* Create button and add it to main view */
- button = gtk_button_new_with_label(_("Hello World!!!"));
- gtk_container_add(GTK_CONTAINER(window),
- button);
-
- g_signal_connect (G_OBJECT (button), "clicked",
- G_CALLBACK (button_clicked), NULL);
-
- ret = osso_rpc_set_cb_f (osso_cont,
- APP_SERVICE,
- APP_METHOD,
- APP_SERVICE,
- dbus_callback, GTK_WIDGET( window ));
+ osso_cont = osso_initialize(APP_NAME, APP_VER, TRUE, NULL);
+ g_assert(osso_cont);
+
+ /* Initialize the GTK. */
+ gtk_init(&argc, &argv);
+
+ /* Initialize thread system */
+ g_thread_init(NULL);
+
+ /* Create the hildon program and setup the title */
+ data->program = HILDON_PROGRAM(hildon_program_get_instance());
+ g_set_application_name("Maevies");
+
+ /* Create HildonWindow and set it to HildonProgram */
+ data->window = maevies_window_new(osso_cont);
+ hildon_program_add_window(data->program, HILDON_WINDOW(data->window));
+
+ ret = osso_rpc_set_cb_f(data->window->osso, APP_SERVICE, APP_METHOD,
+ APP_SERVICE, dbus_callback, GTK_WIDGET(data->window));
if (ret != OSSO_OK) {
- fprintf (stderr, "osso_rpc_set_cb_f failed: %d.\n", ret);
- exit (1);
+ fprintf(stderr, "osso_rpc_set_cb_f failed: %d.\n", ret);
+ exit(1);
}
- /* Begin the main application */
- gtk_widget_show_all ( GTK_WIDGET ( window ) );
- gtk_main();
+ /* Begin the main application */
+ gtk_widget_show_all(GTK_WIDGET(data->window));
+
+ /* Quit program when window is closed. */
+ g_signal_connect(G_OBJECT(data->window), "delete_event",
+ G_CALLBACK(gtk_main_quit), NULL);
+
+ /* Quit program when window is otherwise destroyed. */
+ g_signal_connect(G_OBJECT(data->window), "destroy", G_CALLBACK(gtk_main_quit),
+ NULL);
+
+ gtk_main();
+
+ /* Clean up: */
+ gtk_widget_destroy(GTK_WIDGET (data->window));
+ g_free(data);
+
+ /* Exit */
+ return 0;
+}
+
+static gint dbus_callback(const gchar *interface, const gchar *method,
+ GArray *arguments, gpointer data, osso_rpc_t *retval) {
+ printf("dbus: %s, %s\n", interface, method);
+
+ if (!strcmp(method, "top_application"))
+ gtk_window_present(GTK_WINDOW(data));
- /* Exit */
- return 0;
+ return DBUS_TYPE_INVALID;
}