Graphix are shown for testing purposes.
[speedometer] / main.c
diff --git a/main.c b/main.c
index f7c2597..a3c6de0 100644 (file)
--- a/main.c
+++ b/main.c
 
        You should have received a copy of the GNU General Public License
        along with this program.  If not, see <http://www.gnu.org/licenses/>.
-****/
-
-
+ ****/
 
+#include <hildon/hildon-program.h>
+#include <hildon/hildon-window.h>
 #include <stdlib.h>
 #include <gtk/gtk.h>
 #include <location/location-gps-device.h>
 #include <location/location-gpsd-control.h>
 
-static void location_changed (LocationGPSDevice *device, gpointer userdata) {
-        g_print ("Latitude: %.2f\nLongitude: %.2f\nAltitude: %.2f\n",
-                 device->fix->latitude, device->fix->longitude, device->fix->altitude);
-}
-
-
-
-
+#include "callbacks.h"
 
+int main(int argc, char** argv) {
 
 
-int main(int argc, char** argv) {
+       HildonProgram *program;
+       HildonWindow *window;
 
-  /* We'll have two references to two GTK+ widgets. */
-  GtkWindow* window;
-  GtkLabel* label;
+       gtk_init(&argc, &argv);
 
-  /* Initialize the GTK+ library. */
-  gtk_init(&argc, &argv);
+       GtkWidget *i1, *i2, *i3;
+       GtkWidget *box;
 
+       program = HILDON_PROGRAM(hildon_program_get_instance());
+       g_set_application_name("Speedometer");
 
+       window = HILDON_WINDOW(hildon_window_new());
+       hildon_program_add_window(program, window);
 
+       i1 = gtk_image_new_from_file("data/1.png");
+       i2 = gtk_image_new_from_file("data/3.png");
+       i3 = gtk_image_new_from_file("data/4.png");
 
+       box = gtk_hbox_new(TRUE, 0);
+       gtk_box_pack_end(box, i1, FALSE, FALSE, 0);
+       gtk_box_pack_end(box, i2, FALSE, FALSE, 0);
+       gtk_box_pack_end(box, i3, FALSE, FALSE, 0);
 
-  /* Create a window with window border width of 12 pixels and a
-     title text. */
-  window = g_object_new(GTK_TYPE_WINDOW,
-    "border-width", 12,
-    "title", "Hello GTK+",
-    NULL);
+       gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(box));
 
-  /* Create the label widget. */
-  label = g_object_new(GTK_TYPE_LABEL,
-    "label", "Hello World!",
-    NULL);
+       // set the background color to black
+       GdkColor black;
+       black.red = 0x0000;
+       black.blue = 0x0000;
+       black.green = 0x0000;
+       gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &black);
 
-  /* Pack the label into the window layout. */
-  gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(label));
+       // set the window fullscreen
+       gtk_window_fullscreen(GTK_WINDOW(window));
 
-  /* Show all widgets that are contained by the window. */
-  gtk_widget_show_all(GTK_WIDGET(window));
+       gtk_widget_show_all(GTK_WIDGET(window));
 
 
 
-  g_thread_init(NULL);
+       g_thread_init(NULL);
 
-  // gps device
-  LocationGPSDevice *device;
-  device = g_object_new (LOCATION_TYPE_GPS_DEVICE, NULL);
 
-  g_signal_connect (device, "changed", G_CALLBACK (location_changed), NULL);
+#ifdef __arm__
+       // gps device
+       LocationGPSDevice *device;
+       device = g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
 
+       // connect some signal handlers
+       g_signal_connect (device, "changed", G_CALLBACK (location_changed), NULL);
 
-  LocationGPSDControl *control;
+    g_signal_connect(G_OBJECT(window),  "key_press_event", G_CALLBACK(key_press_cb), window);
 
-  control = location_gpsd_control_get_default ();
-  location_gpsd_control_start(control);
+       LocationGPSDControl *control;
 
+       control = location_gpsd_control_get_default();
+       location_gpsd_control_start(control);
+#endif // __arm__
 
+       /* Connect signal to X in the upper corner */
+       g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL);
 
-  /* Start the main event loop. */
-  gtk_main();
+       /* Start the main event loop. */
+       gtk_main();
 
-  return EXIT_SUCCESS;
+       return EXIT_SUCCESS;
 }