Moved lots of UI stuff to ui.c.
[speedometer] / util.c
diff --git a/util.c b/util.c
index 671f9cc..0cda59d 100644 (file)
--- a/util.c
+++ b/util.c
 #include <math.h>
 #include <location/location-gps-device.h>
 #include <location/location-gpsd-control.h>
-#include <gconf/gconf-client.h>
-#include <glib/gprintf.h>
 
 #include "util.h"
 #include "appdata.h"
 #include "callbacks.h"
 #include "ui.h"
 
-/* This is used when converting to other units
- * number represents a multiplier which is used
- * when converting the base unit to other units.
- * Base unit is m/s thus the first multiplier is
- * one. Units are in following order:
- *
- * m/s, km/h, mph
- */
-gdouble conversion[] = { 1, 3.6, 2.237 };
-
-#define GCONF_KEY "/apps/Maemo/speedometer/disclaimer"
-
-static LocationGPSDevice *device = NULL;
-static LocationGPSDControl *control = NULL;
+#ifdef __arm__
+       static LocationGPSDevice *device = NULL;
+       static LocationGPSDControl *control = NULL;
+#endif
 
-void start_gps(AppData* appdata) {
+void start_gps() {
 #ifdef __arm__
-       g_assert(appdata);
        if(!device) {
                device = g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
-               g_signal_connect(device, "changed", G_CALLBACK(location_changed), appdata);
+               g_signal_connect(device, "changed", G_CALLBACK(location_changed), NULL);
        }
        control = location_gpsd_control_get_default();
        location_gpsd_control_request_status(control);
@@ -57,9 +44,8 @@ void start_gps(AppData* appdata) {
 #endif // __arm__
 }
 
-void stop_gps(AppData* appdata) {
+void stop_gps() {
 #ifdef __arm__
-       g_assert(appdata);
        control = location_gpsd_control_get_default();
        location_gpsd_control_request_status(control);
        if(control->can_control) {
@@ -68,68 +54,9 @@ void stop_gps(AppData* appdata) {
 #endif // __arm__
 }
 
-void interpret_speed_from_gps(AppData* appdata, gdouble speed) {
-       g_assert(appdata);
-       g_assert(!isnan(speed));
-
-       /* speed is in m/s so let's convert
-        * it to the unit that we are using
-        */
-       speed *= conversion[appdata->unit];
-
-       // convert float to a 6 digits (including dot) wide string with leading zeros
-       gchar* charspeed = g_malloc(10); // alloc
-       g_sprintf(charspeed, "%0*.2f", 6, speed);
-
-       g_print("Speed is %s km/h\n", charspeed);
-
-       // set the main digits
-       guint i = 3;
-       while(i) {
-               i--;
-               set_nth_digit(appdata, i, g_ascii_digit_value(charspeed[i]));
-       }
-
-       repaint_all_digits(appdata);
-
-       g_free(charspeed);
-}
-
-
-static void show_dialog() {
-       GtkWidget *dialog = gtk_message_dialog_new(
-                       NULL,
-                       GTK_DIALOG_MODAL,
-                       GTK_MESSAGE_INFO,
-                       GTK_BUTTONS_OK,
-                       "This program is licensed under GNU General Public License, "
-                       "which means (among other things) that you don't have to pay "
-                       "a dime for it. "
-                       "If you think, however, that this software is worth it, you "
-                       "can always drop me a postcard.\n\n"
-                       "Wellu Mäkinen\n"
-                       "PO BOX\n"
-                       "33580 Tampere\n"
-                       "FINLAND");
-       gtk_dialog_run(GTK_DIALOG(dialog));
-       gtk_widget_destroy(dialog);
-}
-
-void show_cardware_dialog() {
-       GConfClient* client = gconf_client_get_default();
-       g_assert(GCONF_IS_CLIENT(client));
-
-       GConfValue* gcvalue = NULL;
-       gcvalue = gconf_client_get_without_default(client, GCONF_KEY, NULL);
-
-       if(gcvalue == NULL) {
-               g_print("GConf key not found so show dialog.");
-               show_dialog();
-               gconf_client_set_bool(client, GCONF_KEY, TRUE, NULL);
-       }
-       g_object_unref(client);
-}
-
+/* Loads the settings from GConf
+ *
+ */
 void load_settings() {
 
 }