#include "map.h"
#include "track.h"
#include "route.h"
-
+#include "gps-panels.h"
#include "settings.h"
gint track_drop_cnt=0;
token = strsep(&sentence, DELIM);
if (token && *token) {
MACRO_PARSE_FLOAT(_gps.speed, token);
- if (_gps.fix > 1)
+ if (_gps.fix > 1) {
_gps.maxspeed = MAX(_gps.maxspeed, _gps.speed);
+ gps_display_data_speed(info_banner.speed, _gps.speed);
+ }
}
/* Parse heading, degrees from true north. */
#include "mapper-types.h"
#include "ui-common.h"
+void
+gps_display_data_speed(GtkWidget *widget, gfloat s)
+{
+gchar *buffer;
+gfloat speed = s * UNITS_CONVERT[_units];
+
+switch (_units) {
+ case UNITS_MI:
+ buffer = g_strdup_printf("%.1f mph", speed);
+ break;
+ case UNITS_NM:
+ buffer = g_strdup_printf("%.1f kn", speed);
+ break;
+ default:
+ buffer = g_strdup_printf("%.1f km/h", speed);
+ break;
+ }
+
+gtk_label_set_label(GTK_LABEL(widget), buffer);
+g_free(buffer);
+}
+
void
gps_display_data(void)
{
gtk_label_set_label(GTK_LABEL(_text_alt), " --- ");
gtk_label_set_label(GTK_LABEL(_text_dop), "0/0/0");
} else {
- gfloat speed = _gps.speed * UNITS_CONVERT[_units];
-
/* latitude */
lat_format(_gps.lat, litbuf);
gtk_label_set_label(GTK_LABEL(_text_lat), litbuf);
gtk_label_set_label(GTK_LABEL(_text_lon), litbuf);
/* speed */
- switch (_units) {
- case UNITS_MI:
- buffer = g_strdup_printf("Spd: %.1f mph", speed);
- break;
- case UNITS_NM:
- buffer = g_strdup_printf("Spd: %.1f kn", speed);
- break;
- default:
- buffer = g_strdup_printf("Spd: %.1f km/h", speed);
- break;
- }
- gtk_label_set_label(GTK_LABEL(_text_speed), buffer);
- g_free(buffer);
+ gps_display_data_speed(_text_speed, _gps.speed);
/* altitude */
switch (_units) {
case UNITS_MI:
case UNITS_NM:
- buffer = g_strdup_printf("Alt: %.1f ft",
- _pos.altitude * 3.2808399f);
+ buffer = g_strdup_printf("Alt: %.1f ft", _pos.altitude * 3.2808399f);
break;
default:
buffer = g_strdup_printf("Alt: %.1f m", _pos.altitude);
guint x, y;
printf("%s()\n", __PRETTY_FUNCTION__);
-draw_sat_info(widget,
- 0, 0,
+draw_sat_info(widget, 0, 0,
widget->allocation.width,
widget->allocation.height, FALSE);
gtk_label_set_label(GTK_LABEL(_sdi_hea), " --- ");
gtk_label_set_label(GTK_LABEL(_sdi_tim), " --:--:-- ");
} else {
- gfloat speed = _gps.speed * UNITS_CONVERT[_units];
-
/* latitude */
lat_format(_gps.lat, litbuf);
gtk_label_set_label(GTK_LABEL(_sdi_lat), litbuf);
gtk_label_set_label(GTK_LABEL(_sdi_lon), litbuf);
/* speed */
- switch (_units) {
- case UNITS_MI:
- buffer = g_strdup_printf("%.1f mph", speed);
- break;
- case UNITS_NM:
- buffer = g_strdup_printf("%.1f kn", speed);
- break;
- default:
- buffer = g_strdup_printf("%.1f km/h", speed);
- break;
- }
- gtk_label_set_label(GTK_LABEL(_sdi_spd), buffer);
- g_free(buffer);
+ gps_display_data_speed(_sdi_spd, _gps.speed);
/* altitude */
switch (_units) {
g_free(buffer);
/* max speed */
- {
- gfloat maxspeed = _gps.maxspeed * UNITS_CONVERT[_units];
-
- /* speed */
- switch (_units) {
- case UNITS_MI:
- buffer = g_strdup_printf("%.1f mph", maxspeed);
- break;
- case UNITS_NM:
- buffer = g_strdup_printf("%.1f kn", maxspeed);
- break;
- default:
- buffer = g_strdup_printf("%.1f km/h", maxspeed);
- break;
- }
- gtk_label_set_label(GTK_LABEL(_sdi_msp), buffer);
- g_free(buffer);
- }
+ gps_display_data_speed(_sdi_msp, _gps.maxspeed);
/* refresh sat panel */
gtk_widget_queue_draw_area(GTK_WIDGET(_sat_details_panel),
--- /dev/null
+#ifndef _GPS_PANELS_H
+#define _GPS_PANELS_H
+
+void gps_display_data_speed(GtkWidget *widget, gfloat s);
+void gps_display_data(void);
+
+#endif
(mp && mp->name) ? " in " : "",
(mp && mp->name) ? mp->name : "");
}
-gtk_label_set_label(GTK_LABEL(_info_banner), buffer);
+gtk_label_set_label(GTK_LABEL(info_banner.location), buffer);
}
/* XXX: Move this to osm-db.c */
_map_location_known=map_loc.street ? TRUE : FALSE;
_map_location_dist=map_loc.street ? map_loc.street->dist : 900000.0;
+#if 0
p=poi_find_nearest(lat, lon);
+#else
+p=NULL;
+#endif
fs=osm_find_nearest_place(NODE_PLACE_SUBURB, ilat, ilon, &map_loc.secondary);
if (fs==TRUE && map_loc.secondary && map_loc.secondary->isin!=0) {
gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Distance to OSM Data")),
0, 1, 4, 5, GTK_FILL, 0, 2, 4);
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f);
- gtk_table_attach(GTK_TABLE(table), num_osm_dist = gtk_hscale_new_with_range(0, 5000, 1),
+ gtk_table_attach(GTK_TABLE(table), num_osm_dist = gtk_hscale_new_with_range(0, 5000, 50),
1, 2, 4, 5, GTK_EXPAND | GTK_FILL, 0, 2, 4);
/* Auto-Center page. */
g_signal_connect (item, "clicked", G_CALLBACK (cb_add_poi), NULL);
gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
+item = gtk_tool_button_new_from_stock (GTK_STOCK_INFO);
+g_signal_connect (item, "clicked", G_CALLBACK (menu_cb_gps_details), NULL);
+gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
+
item = gtk_separator_tool_item_new();
gtk_toolbar_insert (GTK_TOOLBAR (_toolbar), item, -1);
#endif
}
-/**
- * Initialize everything required in preparation for calling gtk_main().
- */
-void mapper_init(gint argc, gchar ** argv)
+void mapper_init_variables(void)
{
- GtkWidget *hbox, *mapvbox, *label, *vbox, *vbox_main;
- GtkWidget *notebook;
- GdkColor color;
- printf("%s()\n", __PRETTY_FUNCTION__);
-
/* Set enum-based constants. */
UNITS_TEXT[UNITS_KM] = _("km");
UNITS_TEXT[UNITS_MI] = _("mi.");
SPEED_LOCATION_TEXT[SPEED_LOCATION_TOP_RIGHT] = _("Top-Right");
SPEED_LOCATION_TEXT[SPEED_LOCATION_BOTTOM_RIGHT] = _("Bottom-Right");
SPEED_LOCATION_TEXT[SPEED_LOCATION_BOTTOM_LEFT] = _("Bottom-Left");
+}
+
+/**
+ * Initialize everything required in preparation for calling gtk_main().
+ */
+void mapper_init(gint argc, gchar ** argv)
+{
+ GtkWidget *hbox, *mapvbox, *label, *vbox, *vbox_main;
+ GtkWidget *notebook, *hbanner;
+ GdkColor color;
+ printf("%s()\n", __PRETTY_FUNCTION__);
+
+ mapper_init_variables();
/* Set up track array (must be done before config). */
memset(&_track, 0, sizeof(_track));
label = gtk_label_new("Map");
hbox = gtk_hpaned_new();
- _info_banner = gtk_label_new("");
+
+ info_banner.container=gtk_hbox_new(FALSE, 0);
+ info_banner.location=gtk_label_new("");
+ info_banner.speed=gtk_label_new("");
+ gtk_label_set_max_width_chars(info_banner.speed, 16);
+ gtk_label_set_width_chars(info_banner.speed, 14);
+ gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.speed, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(info_banner.container), info_banner.location, TRUE, TRUE, 0);
mapvbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show_all(vbox_main);
#endif
- gtk_box_pack_start(GTK_BOX(mapvbox), _info_banner, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(mapvbox), info_banner.container, FALSE, FALSE, 0);
+
gtk_box_pack_start(GTK_BOX(mapvbox), hbox, TRUE, TRUE, 0);
gtk_notebook_append_page(GTK_WIDGET(notebook), mapvbox, label);
gtk_widget_show_all(mapvbox);
/* Banners/Progress bars */
GtkWidget *_download_banner;
-
GtkWidget *_status_bar;
-GtkWidget *_info_banner;
+
+struct _info_banner {
+ GtkWidget *container;
+ GtkWidget *location;
+ GtkWidget *speed;
+};
+struct _info_banner info_banner;
GtkMenu *_menu_map;