summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Curley <charlescurley@charlescurley.com>2017-10-31 17:26:53 -0600
committerCharles Curley <charlescurley@charlescurley.com>2017-10-31 17:26:53 -0600
commitcb3bf5cc9ed87b925ce8acb7af3bf4978e188f00 (patch)
tree6c10e857e8ab86c104f946aa214b41ef074ef8cf
parentd2c9578378ab0c6e25b80771b43513b48832aabd (diff)
downloadnavit-cb3bf5cc9ed87b925ce8acb7af3bf4978e188f00.tar.gz
fix:gtk:fixed missing imperial units in the GTK ui.
modified: navit/gui/gtk/gui_gtk_statusbar.c
-rw-r--r--navit/gui/gtk/gui_gtk_statusbar.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/navit/gui/gtk/gui_gtk_statusbar.c b/navit/gui/gtk/gui_gtk_statusbar.c
index 0f0dcc0e8..b246f1deb 100644
--- a/navit/gui/gtk/gui_gtk_statusbar.c
+++ b/navit/gui/gtk/gui_gtk_statusbar.c
@@ -22,6 +22,7 @@
#include <time.h>
#include <math.h>
#include <gtk/gtk.h>
+#include <gps.h> /* Not the same as gpsd.h. Get converion constants. */
#include "item.h"
#include "coord.h"
#include "debug.h"
@@ -98,6 +99,11 @@ statusbar_route_update(struct statusbar_priv *this, struct navit *navit, struct
const char *dir;
int dir_idx;
+ /* Respect the Imperial attribute as we enlighten the user. */
+ int imperial = FALSE; /* default to using metric measures. */
+ if (navit_get_attr(navit, attr_imperial, &attr, NULL))
+ imperial=attr.u.num;
+
if (navit)
nav=navit_get_navigation(navit);
if (nav)
@@ -116,7 +122,13 @@ statusbar_route_update(struct statusbar_priv *this, struct navit *navit, struct
}
if (mr)
map_rect_destroy(mr);
- sprintf(buffer,_("Route %4.0fkm %02d:%02d ETA" ),route_len/1000, eta_tm ? eta_tm->tm_hour : 0 , eta_tm ? eta_tm->tm_min : 0);
+
+ sprintf(buffer,_("Route %4.1f%s %02d:%02d ETA" ),
+ imperial == TRUE ? route_len*METERS_TO_MILES : route_len/1000,
+ imperial == TRUE ? "mi" : "km",
+ eta_tm ? eta_tm->tm_hour : 0 ,
+ eta_tm ? eta_tm->tm_min : 0);
+
if (strcmp(buffer, this->route_text)) {
strcpy(this->route_text, buffer);
gtk_label_set_text(GTK_LABEL(this->route), this->route_text);
@@ -145,10 +157,17 @@ statusbar_route_update(struct statusbar_priv *this, struct navit *navit, struct
if (vehicle_get_attr(v, attr_position_qual, &attr, NULL))
qual=attr.u.num;
coord_format(lat,lng,DEGREES_MINUTES_SECONDS,buffer,sizeof(buffer));
- sprintf(this->gps_text,"GPS:%s %02d/%02d HD:%02.2f %s %4.0fm %3.0f°%-2s %3.0fkm/h",
- status_fix2str(status),
- sats, qual, hdop, buffer, height,
- direction, dir, speed);
+
+ sprintf(this->gps_text,"GPS:%s %02d/%02d HD:%02.2f %s %4.0f%s %3.0f°%-2s %3.1f%s",
+ status_fix2str(status),
+ sats, qual, hdop, buffer,
+ imperial ? height * METERS_TO_FEET : height,
+ imperial == TRUE ? "\'" : "m",
+ direction, dir,
+ imperial == TRUE ? speed * (METERS_TO_MILES * 1000) : speed, /* hard-coded. Ugly */
+ imperial == TRUE ? " mph" : "km/h"
+ );
+
gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text);
}