git-svn-id: file:///svnroot/speedometer/trunk@38 df364472-da61-43ef-8a67-511c89aa921b
[speedometer] / util.c
diff --git a/util.c b/util.c
index a20f0b1..671f9cc 100644 (file)
--- a/util.c
+++ b/util.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 <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"
 
-
-gdouble unit_array[] = {3.6};
+/* 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"
 
@@ -64,6 +72,11 @@ 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);
@@ -83,7 +96,7 @@ void interpret_speed_from_gps(AppData* appdata, gdouble speed) {
 }
 
 
-static show_dialog() {
+static void show_dialog() {
        GtkWidget *dialog = gtk_message_dialog_new(
                        NULL,
                        GTK_DIALOG_MODAL,
@@ -93,7 +106,7 @@ static show_dialog() {
                        "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. (or a speeding ticket :)\n\n"
+                       "can always drop me a postcard.\n\n"
                        "Wellu Mäkinen\n"
                        "PO BOX\n"
                        "33580 Tampere\n"
@@ -117,3 +130,6 @@ void show_cardware_dialog() {
        g_object_unref(client);
 }
 
+void load_settings() {
+
+}