diff options
author | Charles Curley <charlescurley@users.noreply.github.com> | 2017-10-31 22:09:41 -0600 |
---|---|---|
committer | Pierre GRANDIN <pgrandin@users.noreply.github.com> | 2017-10-31 21:09:41 -0700 |
commit | b1cbc462186edd6343e3601856409d40b025b677 (patch) | |
tree | 6019b5d151fac7c76897ed4a82b8ef676d002146 /navit/gui | |
parent | 81b6055df58c290981e579c80ffa999c149319ab (diff) | |
download | navit-b1cbc462186edd6343e3601856409d40b025b677.tar.gz |
fix:gtk:fixed missing imperial units in the GTK ui. (#359)roadbook.imperial.fix
Diffstat (limited to 'navit/gui')
-rw-r--r-- | navit/gui/gtk/gui_gtk_statusbar.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/navit/gui/gtk/gui_gtk_statusbar.c b/navit/gui/gtk/gui_gtk_statusbar.c index 0f0dcc0e8..aa70c6332 100644 --- a/navit/gui/gtk/gui_gtk_statusbar.c +++ b/navit/gui/gtk/gui_gtk_statusbar.c @@ -98,6 +98,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 +121,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_PER_MILE : 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 +156,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 * FEET_PER_METER : height, + imperial == TRUE ? "\'" : "m", + direction, dir, + imperial == TRUE ? speed / (METERS_PER_MILE / 1000) : speed, /* hard-coded. Ugly */ + imperial == TRUE ? " mph" : "km/h" + ); + gtk_label_set_text(GTK_LABEL(this->gps), this->gps_text); } |