From 81534becf54cfb0c7f3fdf3a2096e49a89dbfcb2 Mon Sep 17 00:00:00 2001 From: "Dr. Johann Pfefferl" Date: Tue, 22 Jun 2010 17:41:25 +0200 Subject: [PATCH] The recorded waypoints are put at the end of the gpx file --- debian/changelog | 6 ++++++ gps-tracker.c | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0d5a665..ccf7036 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +gps-tracker (1.1-1) unstable; urgency=low + + * The recorded waypoints are put at the end of the gpx file + + -- Dr. Johann Pfefferl Tue, 22 Jun 2010 17:40:02 +0200 + gps-tracker (1.0-14) unstable; urgency=low * Reset the climb value to unknown if no fix is detected diff --git a/gps-tracker.c b/gps-tracker.c index 57e8f3b..252cd84 100644 --- a/gps-tracker.c +++ b/gps-tracker.c @@ -21,7 +21,7 @@ typedef struct { 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; @@ -54,8 +54,9 @@ static gchar * interface_file_chooser (AppData * appdata, GtkFileChooserAction a 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, "\n" @@ -71,10 +72,14 @@ static void write_gpx_header(FILE *fp) ); } -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, "\n\n\n"); + g_fprintf(fp, "\n\n"); + g_fprintf(fp, app_data->waypoint_block_str->str); + g_fprintf(fp, "\n"); + g_string_truncate(app_data->waypoint_block_str, 0); } static void cb_wp_set_btn (GtkWidget * w, AppData * data) @@ -99,7 +104,7 @@ static void cb_start_stop (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); @@ -109,7 +114,7 @@ static void cb_start_stop (GtkWidget * w, AppData * data) 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; } @@ -193,6 +198,8 @@ static void on_gps_device_changed (LocationGPSDevice *device, gpointer data) if(app_data->wp_marker_str->len) { g_fprintf(fp, "%s\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, "%s\n", + sbuf1, sbuf2, app_data->wp_marker_str->str); g_string_truncate(app_data->wp_marker_str, 0); } } @@ -342,6 +349,7 @@ int main (int argc, char **argv) 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); @@ -482,6 +490,7 @@ int main (int argc, char **argv) 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); -- 1.7.9.5