157 |
} |
} |
158 |
} |
} |
159 |
|
|
160 |
static int notes_save(cache_context_t *context, |
static int notes_write_file(cache_context_t *context, |
161 |
char *text, pos_t pos, |
char *text, pos_t pos, |
162 |
gboolean override, gboolean found, |
gboolean override, gboolean found, |
163 |
time_t ftime, gboolean logged) { |
time_t ftime, gboolean logged) { |
230 |
return 0; |
return 0; |
231 |
} |
} |
232 |
|
|
233 |
/* this is called from the destroy event of the entire notebook */ |
static void notes_save(cache_context_t *context) { |
|
gint notes_destroy_event(GtkWidget *widget, gpointer data ) { |
|
|
cache_context_t *context = (cache_context_t*)data; |
|
|
|
|
|
printf("about to destroy notes view\n"); |
|
|
|
|
234 |
/* only save if: there is a text which has been changed or */ |
/* only save if: there is a text which has been changed or */ |
235 |
/* there is a position which differs from the original one */ |
/* there is a position which differs from the original one */ |
236 |
/* or has been changed */ |
/* or has been changed */ |
328 |
/* - update the notes entry in the loaded gpx tree */ |
/* - update the notes entry in the loaded gpx tree */ |
329 |
|
|
330 |
/* update file on disk */ |
/* update file on disk */ |
331 |
notes_save(context, text, pos, override, found, |
notes_write_file(context, text, pos, override, found, |
332 |
context->notes.ftime, logged); |
context->notes.ftime, logged); |
333 |
|
|
334 |
/* search for matching caches and replace note there */ |
/* search for matching caches and replace note there */ |
335 |
notes_t *note = NULL; |
notes_t *note = NULL; |
377 |
|
|
378 |
if(text) free(text); |
if(text) free(text); |
379 |
} |
} |
380 |
|
} |
381 |
|
|
382 |
|
/* this is called from the destroy event of the entire notebook */ |
383 |
|
gint notes_destroy_event(GtkWidget *widget, gpointer data ) { |
384 |
|
cache_context_t *context = (cache_context_t*)data; |
385 |
|
|
386 |
|
printf("about to destroy notes view\n"); |
387 |
|
notes_save(context); |
388 |
|
|
389 |
return FALSE; |
return FALSE; |
390 |
} |
} |
522 |
} |
} |
523 |
#endif |
#endif |
524 |
|
|
525 |
|
static gboolean focus_out(GtkWidget *widget, GdkEventFocus *event, |
526 |
|
gpointer data) { |
527 |
|
cache_context_t *context = (cache_context_t*)data; |
528 |
|
|
529 |
|
notes_save(context); |
530 |
|
#if !defined(USE_MAEMO) && defined(ENABLE_OSM_GPS_MAP) |
531 |
|
map_update(context->appdata); |
532 |
|
#endif |
533 |
|
|
534 |
|
return FALSE; |
535 |
|
} |
536 |
|
|
537 |
GtkWidget *cache_notes(cache_context_t *context) { |
GtkWidget *cache_notes(cache_context_t *context) { |
538 |
cache_t *cache = context->cache; |
cache_t *cache = context->cache; |
539 |
|
|
590 |
if(cache->notes) pos = cache->notes->pos; |
if(cache->notes) pos = cache->notes->pos; |
591 |
|
|
592 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
593 |
context->notes.latw = lat_entry_new(pos.lat), 2, 3, 0, 1); |
context->notes.latw = lat_entry_new(pos.lat), 2, 3, 0, 1); |
594 |
|
g_signal_connect(G_OBJECT(context->notes.latw), "focus-out-event", |
595 |
|
G_CALLBACK(focus_out), context); |
596 |
|
|
597 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
598 |
context->notes.lonw = lon_entry_new(pos.lon), 2, 3, 1, 2); |
context->notes.lonw = lon_entry_new(pos.lon), 2, 3, 1, 2); |
599 |
|
g_signal_connect(G_OBJECT(context->notes.lonw), "focus-out-event", |
600 |
|
G_CALLBACK(focus_out), context); |
601 |
|
|
602 |
hbox = gtk_hbox_new(FALSE, 0); |
hbox = gtk_hbox_new(FALSE, 0); |
603 |
gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); |
gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); |
965 |
ccontext.appdata = appdata; |
ccontext.appdata = appdata; |
966 |
ccontext.cache = llog->cache; |
ccontext.cache = llog->cache; |
967 |
|
|
968 |
notes_save(&ccontext, |
notes_write_file(&ccontext, |
969 |
llog->cache->notes->text, llog->cache->notes->pos, |
llog->cache->notes->text, llog->cache->notes->pos, |
970 |
llog->cache->notes->override, llog->cache->notes->found, |
llog->cache->notes->override, llog->cache->notes->found, |
971 |
llog->cache->notes->ftime, llog->cache->notes->logged); |
llog->cache->notes->ftime, llog->cache->notes->logged); |