GtkWidget *speed_val_label, *track_val_label, *climb_val_label;
//GtkWidget *wp_label;
GtkButton *wp_set_btn;
- GString *wp_marker_str;
+ GString *wp_marker_str, *waypoint_block_str;
gboolean tracking_is_on, has_fix;
FILE *outf_p;
guint points_recorded_in_current_segment;
return filename;
}
-static void write_gpx_header(FILE *fp)
+static void write_gpx_header(AppData *app_data)
{
+ FILE *fp = app_data->outf_p;
g_return_if_fail(fp);
g_fprintf(fp,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
);
}
-static void write_gpx_footer(FILE *fp)
+static void write_gpx_footer(AppData *app_data)
{
+ FILE *fp = app_data->outf_p;
g_return_if_fail(fp);
- g_fprintf(fp, "</trkseg>\n</trk>\n</gpx>\n");
+ g_fprintf(fp, "</trkseg>\n</trk>\n");
+ g_fprintf(fp, app_data->waypoint_block_str->str);
+ g_fprintf(fp, "</gpx>\n");
}
static void cb_wp_set_btn (GtkWidget * w, AppData * data)
data->outf_p = fopen(data->intermediate_gpx_data_filename, "w");
data->points_recorded_in_current_segment = 0;
data->last_device_status = LOCATION_GPS_DEVICE_STATUS_NO_FIX;
- write_gpx_header(data->outf_p);
+ write_gpx_header(data);
//hildon_banner_show_information(GTK_WIDGET(data->window), NULL, "Tracking started");
gtk_button_set_label (data->start_stop_button, "Stop");
gtk_widget_set_sensitive(GTK_WIDGET(data->save_button), FALSE);
data->points_recorded_in_current_segment = 0;
data->last_device_status = LOCATION_GPS_DEVICE_STATUS_NO_FIX;
if(data->outf_p) {
- write_gpx_footer(data->outf_p);
+ write_gpx_footer(data);
fclose(data->outf_p);
data->outf_p = NULL;
}
gtk_widget_set_sensitive(GTK_WIDGET(data->wp_set_btn), FALSE);
}
g_string_truncate(data->wp_marker_str, 0);
+ g_string_truncate(data->waypoint_block_str, 0);
}
static void cb_file_save (GtkWidget * w, AppData * data)
g_rename(data->intermediate_gpx_data_filename, filename);
//g_print ("File saved as %s\n", filename);
hildon_banner_show_information(GTK_WIDGET(data->window), NULL, filename);
+ gtk_widget_set_sensitive(GTK_WIDGET(data->save_button), FALSE);
}
else {
hildon_banner_show_information(GTK_WIDGET(data->window), NULL, "Temp file not found");
(! device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET) &&
(device->fix->mode == LOCATION_GPS_DEVICE_MODE_2D))) {
app_data->has_fix = FALSE;
- hildon_banner_show_information(GTK_WIDGET(app_data->window), NULL, "WARNING: Lost fix");
+ //hildon_banner_show_information(GTK_WIDGET(app_data->window), NULL, "WARNING: Lost fix");
app_data->last_device_status = LOCATION_GPS_DEVICE_STATUS_NO_FIX;
}
else if (device->fix) {
if(app_data->wp_marker_str->len) {
g_fprintf(fp, "<name>%s</name>\n", app_data->wp_marker_str->str);
hildon_banner_show_information(GTK_WIDGET(app_data->window), NULL, app_data->wp_marker_str->str);
+ g_string_append_printf(app_data->waypoint_block_str, "<wpt lat=\"%s\" lon=\"%s\"><name>%s</name></wpt>\n",
+ sbuf1, sbuf2, app_data->wp_marker_str->str);
g_string_truncate(app_data->wp_marker_str, 0);
}
}
}
}
}
+ else {
+ app_data->has_fix = FALSE;
+ app_data->last_device_status = LOCATION_GPS_DEVICE_STATUS_NO_FIX;
+ }
//g_print ("Satellites in view: %d\n", device->satellites_in_view);
//g_print ("Satellites in use: %d\n", device->satellites_in_use);
CHANGE_LABEL(app_data->alt_val_label, " ?", NULL);
CHANGE_LABEL(app_data->speed_val_label, " ?", NULL);
CHANGE_LABEL(app_data->track_val_label, " ?", NULL);
+ CHANGE_LABEL(app_data->climb_val_label, " ?", NULL);
}
}
hildon_program_add_window (data->program, HILDON_WINDOW (data->window));
data->wp_marker_str = g_string_sized_new(64);
+ data->waypoint_block_str = g_string_sized_new(32<<10);
data->main_vbox = (gpointer)gtk_vbox_new(FALSE, 0);
data->loc_hbox = (gpointer)gtk_hbox_new(FALSE, 0);
data->loc_gps_data_table = (gpointer)gtk_table_new(4, 2, FALSE);
g_free(data->working_dir);
g_free(data->intermediate_gpx_data_filename);
g_string_free(data->wp_marker_str, TRUE);
+ g_string_free(data->waypoint_block_str, TRUE);
g_free(data);
g_object_unref (device);
g_object_unref (control);