198 |
char *text, pos_t pos, |
char *text, pos_t pos, |
199 |
gboolean override, gboolean found, |
gboolean override, gboolean found, |
200 |
time_t ftime, gboolean logged) { |
time_t ftime, gboolean logged) { |
201 |
|
|
202 |
|
g_assert(context); |
203 |
|
g_assert(context->cache); |
204 |
|
|
205 |
/* build local path */ |
/* build local path */ |
206 |
int path_len = strlen(context->appdata->image_path) + |
int path_len = strlen(context->appdata->image_path) + |
207 |
2 * strlen(context->cache->id) + 6; |
2 * strlen(context->cache->id) + 6; |
208 |
|
|
209 |
char *path = malloc(path_len); |
char *path = malloc(path_len); |
210 |
snprintf(path, path_len, "%s%s/%s.gpx", |
snprintf(path, path_len, "%s%s/%s.gpx", |
211 |
context->appdata->image_path, |
context->appdata->image_path, |
278 |
/* or has been changed */ |
/* or has been changed */ |
279 |
|
|
280 |
if(context->notes.modified) { |
if(context->notes.modified) { |
281 |
|
#ifdef USE_STACKABLE_WINDOW |
282 |
|
context->notes_have_been_changed = TRUE; |
283 |
|
#endif |
284 |
|
|
285 |
printf("something has been modified, saving notes\n"); |
printf("something has been modified, saving notes\n"); |
286 |
|
|
287 |
GtkTextIter start; |
GtkTextIter start; |
292 |
&start, &end, FALSE); |
&start, &end, FALSE); |
293 |
|
|
294 |
pos_t pos; |
pos_t pos; |
295 |
pos.lat = lat_get(context->notes.latw); |
pos.lat = lat_entry_get(context->notes.latw); |
296 |
pos.lon = lon_get(context->notes.lonw); |
pos.lon = lon_entry_get(context->notes.lonw); |
297 |
|
|
298 |
gboolean override = |
gboolean override = |
299 |
check_button_get_active(context->notes.overridew); |
check_button_get_active(context->notes.overridew); |
302 |
gboolean logged = |
gboolean logged = |
303 |
check_button_get_active(context->notes.loggedw); |
check_button_get_active(context->notes.loggedw); |
304 |
|
|
305 |
/* required accuracy is 1/60000 degree */ |
if(pos_differ(&pos, &context->cache->pos)) |
306 |
if(((int)(pos.lat * 60000 + .5) != |
printf("position is modified\n"); |
|
(int)(context->cache->pos.lat * 60000 + .5)) || |
|
|
((int)(pos.lon * 60000 + .5) != |
|
|
(int)(context->cache->pos.lon * 60000 + .5))) |
|
|
printf("position is modified %f != %f / %f != %f\n", |
|
|
pos.lat * 60000 + .5, context->cache->pos.lat * 60000 + .5, |
|
|
pos.lon * 60000 + .5, context->cache->pos.lon * 60000 + .5); |
|
307 |
if(override || found) |
if(override || found) |
308 |
printf("flags are set\n"); |
printf("flags are set\n"); |
309 |
if(strlen(text)) |
if(strlen(text)) |
310 |
printf("text is present\n"); |
printf("text is present\n"); |
311 |
|
|
312 |
/* check if the notes are empty */ |
/* check if the notes are empty */ |
313 |
if(((int)(pos.lat * 60000 + .5) == |
if(!pos_differ(&pos, &context->cache->pos) && |
|
(int)(context->cache->pos.lat * 60000 + .5)) && |
|
|
((int)(pos.lon * 60000 + .5) == |
|
|
(int)(context->cache->pos.lon * 60000 + .5)) && |
|
314 |
!override && !found && !logged && (strlen(text) == 0)) { |
!override && !found && !logged && (strlen(text) == 0)) { |
315 |
printf("notes are in default state, removing them if present\n"); |
printf("notes are in default state, removing them if present\n"); |
316 |
|
|
363 |
/* we have to do two things here: */ |
/* we have to do two things here: */ |
364 |
/* - update the notes.xml file on disk */ |
/* - update the notes.xml file on disk */ |
365 |
/* - update the notes entry in the loaded gpx tree */ |
/* - update the notes entry in the loaded gpx tree */ |
366 |
|
|
367 |
/* update file on disk */ |
/* update file on disk */ |
368 |
notes_write_file(context, text, pos, override, found, |
notes_write_file(context, text, pos, override, found, |
369 |
context->notes.ftime, logged); |
context->notes.ftime, logged); |
370 |
|
|
371 |
/* search for matching caches and replace note there */ |
/* search for matching caches and replace note there */ |
372 |
notes_t *note = NULL; |
notes_t *note = NULL; |
373 |
gpx_t *gpx = context->appdata->gpx; |
gpx_t *gpx = context->appdata->gpx; |
618 |
GtkWidget *table = gtk_table_new(2, 4, FALSE); |
GtkWidget *table = gtk_table_new(2, 4, FALSE); |
619 |
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
620 |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 16); |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 16); |
|
gtk_table_set_col_spacing(GTK_TABLE(table), 2, 16); |
|
621 |
#endif |
#endif |
622 |
|
|
623 |
|
gtk_table_set_col_spacing(GTK_TABLE(table), 2, 16); |
624 |
|
|
625 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
626 |
gtk_label_new(_("New coordinate:")), 0, 1, 0, 1); |
gtk_label_new(_("New coordinate:")), 0, 1, 0, 1); |
627 |
context->notes.overridew = check_button_new_with_label(_("Override")); |
context->notes.overridew = check_button_new_with_label(_("Override")); |
628 |
check_button_set_active(context->notes.overridew, |
check_button_set_active(context->notes.overridew, |
629 |
cache->notes && cache->notes->override); |
cache->notes && cache->notes->override); |
630 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
631 |
context->notes.overridew, 0, 1, 1, 2); |
context->notes.overridew, 2, 3, 0, 1); |
632 |
|
|
633 |
GtkWidget *hbox = gtk_hbox_new(FALSE, 2); |
GtkWidget *hbox = gtk_hbox_new(FALSE, 2); |
634 |
|
|
660 |
if(cache->notes) pos = cache->notes->pos; |
if(cache->notes) pos = cache->notes->pos; |
661 |
|
|
662 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
663 |
context->notes.latw = lat_entry_new(pos.lat), 2, 3, 0, 1); |
context->notes.latw = lat_entry_new(pos.lat), 0, 1, 1, 2); |
664 |
g_signal_connect(G_OBJECT(context->notes.latw), "focus-out-event", |
g_signal_connect(G_OBJECT(context->notes.latw), "focus-out-event", |
665 |
G_CALLBACK(focus_out), context); |
G_CALLBACK(focus_out), context); |
666 |
|
|
697 |
hildon_text_view_set_buffer(HILDON_TEXT_VIEW(view), context->notes.buffer); |
hildon_text_view_set_buffer(HILDON_TEXT_VIEW(view), context->notes.buffer); |
698 |
#endif |
#endif |
699 |
|
|
700 |
|
/* if the cache has been marked found in the logs already, there's */ |
701 |
|
/* no need/use to be able to change all this */ |
702 |
|
if(cache->found) { |
703 |
|
gtk_widget_set_sensitive(table, FALSE); |
704 |
|
gtk_widget_set_sensitive(view, FALSE); |
705 |
|
} |
706 |
|
|
707 |
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD); |
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD); |
708 |
gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE); |
gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE); |
709 |
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 ); |
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 ); |
763 |
pos_t notes_get_pos(cache_context_t *context) { |
pos_t notes_get_pos(cache_context_t *context) { |
764 |
pos_t pos = context->cache->pos; |
pos_t pos = context->cache->pos; |
765 |
if(check_button_get_active(context->notes.overridew)) { |
if(check_button_get_active(context->notes.overridew)) { |
766 |
pos.lat = lat_get(context->notes.latw); |
pos.lat = lat_entry_get(context->notes.latw); |
767 |
pos.lon = lon_get(context->notes.lonw); |
pos.lon = lon_entry_get(context->notes.lonw); |
768 |
} |
} |
769 |
return pos; |
return pos; |
770 |
} |
} |