Initial Commit
[celltowerinfo] / src / main.c
1 #include "cellinfo-window.h"
2
3 #include <gtk/gtk.h>
4 #include <libosso.h>
5
6 #include <locale.h>
7
8 #include <config.h>
9 #define OSSO_SERVICE "org.debuntu."PACKAGE
10
11
12 #include <glib/gi18n.h>
13
14 typedef struct _AppData AppData;
15
16 struct _AppData
17 {
18   HildonProgram *program; /* handle to application */
19   CellinfoWindow *window; /* handle to app's window */
20 };
21
22 /* Stop the mainloop whenever the window is hidden, 
23  * however it is hidden.
24  */
25 static void on_main_window_hide (GtkWidget *widget, gpointer user_data)
26 {
27   gtk_main_quit ();
28 }
29
30 int main (int argc, char **argv)
31 {
32   osso_context_t *osso = NULL;
33   AppData *data = g_new0 (AppData, 1);
34
35   /* Initialize the locale stuff: */
36   setlocale (LC_ALL, "");
37   bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
38   bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
39   textdomain (GETTEXT_PACKAGE);
40
41   /* Inititialize GTK+ and hildon: */
42   hildon_gtk_init (&argc, &argv);
43
44   if (!g_thread_supported()) {
45     g_thread_init (NULL);
46   }
47
48   /* Create the hildon application and setup the title: */
49   data->program = HILDON_PROGRAM (hildon_program_get_instance ());
50   g_set_application_name (_("Cell Tower Info"));
51
52   /* osso initialization */
53   osso = osso_initialize (OSSO_SERVICE, VERSION, TRUE, NULL);
54   g_assert (osso);
55   
56   /* Create the window for our application: */
57   data->window = cellinfo_window_new (osso);
58   /* Show the main window and start the mainloop, 
59   * quitting the mainloop when it the main window is hidden:
60   */
61   gtk_widget_show (GTK_WIDGET (data->window));
62   g_signal_connect(data->window, "hide", G_CALLBACK (&on_main_window_hide), NULL);
63   g_signal_connect(data->window, "delete_event", 
64     G_CALLBACK (&gtk_widget_hide_on_delete), NULL);
65   gtk_main();
66   
67   /* Clean up: */
68   gtk_widget_destroy (GTK_WIDGET (data->window));
69   g_free (data);
70
71   return 0;
72 }
73