27 |
|
|
28 |
#include <math.h> |
#include <math.h> |
29 |
|
|
30 |
|
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5) |
31 |
|
#include <hildon/hildon-note.h> |
32 |
|
#include <hildon/hildon-entry.h> |
33 |
|
#include <hildon/hildon-check-button.h> |
34 |
|
#endif |
35 |
|
|
36 |
#if !defined(LIBXML_TREE_ENABLED) || !defined(LIBXML_OUTPUT_ENABLED) |
#if !defined(LIBXML_TREE_ENABLED) || !defined(LIBXML_OUTPUT_ENABLED) |
37 |
#error "libxml doesn't support required tree or output" |
#error "libxml doesn't support required tree or output" |
38 |
#endif |
#endif |
39 |
|
|
40 |
#include "gpxview.h" |
#include "gpxview.h" |
41 |
|
|
42 |
|
#if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR >= 5) |
43 |
|
#include <hildon/hildon-note.h> |
44 |
|
#endif |
45 |
|
|
46 |
void gtk_text_buffer_set_can_paste_rich_text(GtkTextBuffer *buffer, gboolean); |
void gtk_text_buffer_set_can_paste_rich_text(GtkTextBuffer *buffer, gboolean); |
47 |
void gtk_text_buffer_set_rich_text_format(GtkTextBuffer *buffer, const gchar *); |
void gtk_text_buffer_set_rich_text_format(GtkTextBuffer *buffer, const gchar *); |
48 |
|
|
171 |
char *text, pos_t pos, |
char *text, pos_t pos, |
172 |
gboolean override, gboolean found, |
gboolean override, gboolean found, |
173 |
time_t ftime, gboolean logged) { |
time_t ftime, gboolean logged) { |
174 |
|
|
175 |
|
g_assert(context); |
176 |
|
g_assert(context->cache); |
177 |
|
|
178 |
/* build local path */ |
/* build local path */ |
179 |
int path_len = strlen(context->appdata->image_path) + |
int path_len = strlen(context->appdata->image_path) + |
180 |
2 * strlen(context->cache->id) + 6; |
2 * strlen(context->cache->id) + 6; |
181 |
|
|
182 |
char *path = malloc(path_len); |
char *path = malloc(path_len); |
183 |
snprintf(path, path_len, "%s%s/%s.gpx", |
snprintf(path, path_len, "%s%s/%s.gpx", |
184 |
context->appdata->image_path, |
context->appdata->image_path, |
251 |
/* or has been changed */ |
/* or has been changed */ |
252 |
|
|
253 |
if(context->notes.modified) { |
if(context->notes.modified) { |
254 |
|
#ifdef USE_STACKABLE_WINDOW |
255 |
|
context->notes_have_been_changed = TRUE; |
256 |
|
#endif |
257 |
|
|
258 |
printf("something has been modified, saving notes\n"); |
printf("something has been modified, saving notes\n"); |
259 |
|
|
260 |
GtkTextIter start; |
GtkTextIter start; |
265 |
&start, &end, FALSE); |
&start, &end, FALSE); |
266 |
|
|
267 |
pos_t pos; |
pos_t pos; |
268 |
pos.lat = lat_get(context->notes.latw); |
pos.lat = lat_entry_get(context->notes.latw); |
269 |
pos.lon = lon_get(context->notes.lonw); |
pos.lon = lon_entry_get(context->notes.lonw); |
270 |
|
|
271 |
gboolean override = |
gboolean override = |
272 |
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context->notes.overridew)); |
check_button_get_active(context->notes.overridew); |
273 |
gboolean found = |
gboolean found = |
274 |
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context->notes.foundw)); |
check_button_get_active(context->notes.foundw); |
275 |
gboolean logged = |
gboolean logged = |
276 |
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(context->notes.loggedw)); |
check_button_get_active(context->notes.loggedw); |
277 |
|
|
278 |
/* required accuracy is 1/60000 degree */ |
if(pos_differ(&pos, &context->cache->pos)) |
279 |
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); |
|
280 |
if(override || found) |
if(override || found) |
281 |
printf("flags are set\n"); |
printf("flags are set\n"); |
282 |
if(strlen(text)) |
if(strlen(text)) |
283 |
printf("text is present\n"); |
printf("text is present\n"); |
284 |
|
|
285 |
/* check if the notes are empty */ |
/* check if the notes are empty */ |
286 |
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)) && |
|
287 |
!override && !found && !logged && (strlen(text) == 0)) { |
!override && !found && !logged && (strlen(text) == 0)) { |
288 |
printf("notes are in default state, removing them if present\n"); |
printf("notes are in default state, removing them if present\n"); |
289 |
|
|
336 |
/* we have to do two things here: */ |
/* we have to do two things here: */ |
337 |
/* - update the notes.xml file on disk */ |
/* - update the notes.xml file on disk */ |
338 |
/* - update the notes entry in the loaded gpx tree */ |
/* - update the notes entry in the loaded gpx tree */ |
339 |
|
|
340 |
/* update file on disk */ |
/* update file on disk */ |
341 |
notes_write_file(context, text, pos, override, found, |
notes_write_file(context, text, pos, override, found, |
342 |
context->notes.ftime, logged); |
context->notes.ftime, logged); |
343 |
|
|
344 |
/* search for matching caches and replace note there */ |
/* search for matching caches and replace note there */ |
345 |
notes_t *note = NULL; |
notes_t *note = NULL; |
346 |
gpx_t *gpx = context->appdata->gpx; |
gpx_t *gpx = context->appdata->gpx; |
431 |
static void ftime_update(GtkWidget *widget, cache_context_t *context, |
static void ftime_update(GtkWidget *widget, cache_context_t *context, |
432 |
gboolean update) { |
gboolean update) { |
433 |
/* check if it has been selected */ |
/* check if it has been selected */ |
434 |
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { |
if(check_button_get_active(widget)) { |
435 |
printf("set active\n"); |
printf("set active\n"); |
436 |
|
|
437 |
if(update) |
if(update) |
463 |
printf("was foundw\n"); |
printf("was foundw\n"); |
464 |
|
|
465 |
/* about to remove "found" flag -> ask for confirmation */ |
/* about to remove "found" flag -> ask for confirmation */ |
466 |
if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { |
if(!check_button_get_active(widget)) { |
467 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
468 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
469 |
GTK_WINDOW(context->appdata->window), |
GTK_WINDOW(context->appdata->window), |
470 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
478 |
if(GTK_RESPONSE_NO == gtk_dialog_run(GTK_DIALOG(dialog))) |
if(GTK_RESPONSE_NO == gtk_dialog_run(GTK_DIALOG(dialog))) |
479 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); |
480 |
|
|
481 |
|
#else |
482 |
|
GtkWidget *dialog = |
483 |
|
hildon_note_new_confirmation(GTK_WINDOW(context->appdata->window), |
484 |
|
_("Do you really want to remove the \"found\" flag? " |
485 |
|
"This will void the recorded date of your find!")); |
486 |
|
|
487 |
|
/* set the active flag again if the user answered "no" */ |
488 |
|
if(GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(dialog))) |
489 |
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); |
490 |
|
#endif |
491 |
|
|
492 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
493 |
} |
} |
494 |
|
|
499 |
printf("was loggedw\n"); |
printf("was loggedw\n"); |
500 |
|
|
501 |
/* about to remove "found" flag -> ask for confirmation */ |
/* about to remove "found" flag -> ask for confirmation */ |
502 |
if(!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) { |
if(!check_button_get_active(widget)) { |
503 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
504 |
GtkWidget *dialog = gtk_message_dialog_new( |
GtkWidget *dialog = gtk_message_dialog_new( |
505 |
GTK_WINDOW(context->appdata->window), |
GTK_WINDOW(context->appdata->window), |
506 |
GTK_DIALOG_DESTROY_WITH_PARENT, |
GTK_DIALOG_DESTROY_WITH_PARENT, |
519 |
gtk_widget_set_sensitive(context->notes.foundw, TRUE); |
gtk_widget_set_sensitive(context->notes.foundw, TRUE); |
520 |
} |
} |
521 |
|
|
522 |
|
#else |
523 |
|
GtkWidget *dialog = |
524 |
|
hildon_note_new_confirmation(GTK_WINDOW(context->appdata->window), |
525 |
|
_("Do you really want to remove the \"logged\" flag? " |
526 |
|
"This may cause problems on your next Garmin Field " |
527 |
|
"Notes upload!")); |
528 |
|
|
529 |
|
/* set the active flag again if the user answered "no" */ |
530 |
|
if(GTK_RESPONSE_OK != gtk_dialog_run(GTK_DIALOG(dialog))) |
531 |
|
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE); |
532 |
|
else { |
533 |
|
gtk_widget_set_sensitive(widget, FALSE); |
534 |
|
gtk_widget_set_sensitive(context->notes.foundw, TRUE); |
535 |
|
} |
536 |
|
|
537 |
|
#endif |
538 |
|
|
539 |
gtk_widget_destroy(dialog); |
gtk_widget_destroy(dialog); |
540 |
} |
} |
541 |
} |
} |
589 |
/* -------------- custom coordinate ---------------- */ |
/* -------------- custom coordinate ---------------- */ |
590 |
|
|
591 |
GtkWidget *table = gtk_table_new(2, 4, FALSE); |
GtkWidget *table = gtk_table_new(2, 4, FALSE); |
592 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
593 |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 16); |
gtk_table_set_col_spacing(GTK_TABLE(table), 0, 16); |
594 |
|
#endif |
595 |
|
|
596 |
gtk_table_set_col_spacing(GTK_TABLE(table), 2, 16); |
gtk_table_set_col_spacing(GTK_TABLE(table), 2, 16); |
597 |
|
|
598 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
599 |
gtk_label_new(_("New coordinate:")), 0, 1, 0, 1); |
gtk_label_new(_("New coordinate:")), 0, 1, 0, 1); |
600 |
context->notes.overridew = gtk_check_button_new_with_label(_("Override")); |
context->notes.overridew = check_button_new_with_label(_("Override")); |
601 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context->notes.overridew), |
check_button_set_active(context->notes.overridew, |
602 |
cache->notes && cache->notes->override); |
cache->notes && cache->notes->override); |
603 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
604 |
context->notes.overridew, 0, 1, 1, 2); |
context->notes.overridew, 2, 3, 0, 1); |
605 |
|
|
606 |
GtkWidget *hbox = gtk_hbox_new(FALSE, 2); |
GtkWidget *hbox = gtk_hbox_new(FALSE, 2); |
607 |
|
|
608 |
context->notes.foundw = gtk_check_button_new_with_label(_("Found")); |
context->notes.foundw = check_button_new_with_label(_("Found")); |
609 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context->notes.foundw), |
check_button_set_active(context->notes.foundw, |
610 |
cache->notes && cache->notes->found); |
cache->notes && cache->notes->found); |
611 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->notes.foundw); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->notes.foundw); |
612 |
|
|
613 |
context->notes.loggedw = gtk_check_button_new_with_label(_("Logged")); |
context->notes.loggedw = check_button_new_with_label(_("Logged")); |
614 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(context->notes.loggedw), |
check_button_set_active(context->notes.loggedw, |
615 |
cache->notes && cache->notes->logged); |
cache->notes && cache->notes->logged); |
616 |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->notes.loggedw); |
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->notes.loggedw); |
617 |
|
|
618 |
gtk_table_attach_defaults(GTK_TABLE(table), hbox, 3, 4, 0, 1); |
gtk_table_attach_defaults(GTK_TABLE(table), hbox, 3, 4, 0, 1); |
624 |
gtk_widget_set_sensitive(context->notes.foundw, FALSE); |
gtk_widget_set_sensitive(context->notes.foundw, FALSE); |
625 |
|
|
626 |
context->notes.datew = gtk_label_new(""); |
context->notes.datew = gtk_label_new(""); |
627 |
gtk_misc_set_alignment(GTK_MISC(context->notes.datew), 0.0f, 0.5f); |
gtk_misc_set_alignment(GTK_MISC(context->notes.datew), 0.5f, 0.5f); |
628 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
629 |
context->notes.datew, 3, 4, 1, 2); |
context->notes.datew, 3, 4, 1, 2); |
630 |
ftime_update(context->notes.foundw, context, FALSE); |
ftime_update(context->notes.foundw, context, FALSE); |
632 |
pos_t pos = gpx_cache_pos(cache); |
pos_t pos = gpx_cache_pos(cache); |
633 |
if(cache->notes) pos = cache->notes->pos; |
if(cache->notes) pos = cache->notes->pos; |
634 |
|
|
635 |
gtk_table_attach_defaults(GTK_TABLE(table), |
context->notes.latw = lat_entry_new(pos.lat); |
636 |
context->notes.latw = lat_entry_new(pos.lat), 2, 3, 0, 1); |
context->notes.lonw = lon_entry_new(pos.lon); |
637 |
|
GtkWidget *picker = |
638 |
|
preset_coordinate_picker(context->appdata, |
639 |
|
context->notes.latw, context->notes.lonw); |
640 |
|
|
641 |
g_signal_connect(G_OBJECT(context->notes.latw), "focus-out-event", |
g_signal_connect(G_OBJECT(context->notes.latw), "focus-out-event", |
642 |
G_CALLBACK(focus_out), context); |
G_CALLBACK(focus_out), context); |
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(table), |
|
|
context->notes.lonw = lon_entry_new(pos.lon), 2, 3, 1, 2); |
|
643 |
g_signal_connect(G_OBJECT(context->notes.lonw), "focus-out-event", |
g_signal_connect(G_OBJECT(context->notes.lonw), "focus-out-event", |
644 |
G_CALLBACK(focus_out), context); |
G_CALLBACK(focus_out), context); |
645 |
|
|
646 |
|
|
647 |
|
GtkWidget *ihbox = gtk_hbox_new(FALSE, 0); |
648 |
|
|
649 |
|
gtk_box_pack_start_defaults(GTK_BOX(ihbox), context->notes.latw); |
650 |
|
gtk_box_pack_start_defaults(GTK_BOX(ihbox), context->notes.lonw); |
651 |
|
gtk_box_pack_start_defaults(GTK_BOX(ihbox), picker); |
652 |
|
|
653 |
|
gtk_table_attach_defaults(GTK_TABLE(table), |
654 |
|
ihbox, 0, 3, 1, 2); |
655 |
|
|
656 |
|
#if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5) |
657 |
hbox = gtk_hbox_new(FALSE, 0); |
hbox = gtk_hbox_new(FALSE, 0); |
658 |
gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); |
gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0); |
659 |
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
660 |
|
#else |
661 |
|
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
662 |
|
#endif |
663 |
|
|
664 |
#ifndef USE_PANNABLE_AREA |
#ifndef USE_PANNABLE_AREA |
665 |
GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
681 |
hildon_text_view_set_buffer(HILDON_TEXT_VIEW(view), context->notes.buffer); |
hildon_text_view_set_buffer(HILDON_TEXT_VIEW(view), context->notes.buffer); |
682 |
#endif |
#endif |
683 |
|
|
684 |
|
/* if the cache has been marked found in the logs already, there's */ |
685 |
|
/* no need/use to be able to change all this */ |
686 |
|
if(cache->found) { |
687 |
|
gtk_widget_set_sensitive(table, FALSE); |
688 |
|
gtk_widget_set_sensitive(view, FALSE); |
689 |
|
} |
690 |
|
|
691 |
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); |
692 |
gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE); |
gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE); |
693 |
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 ); |
gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 ); |
746 |
|
|
747 |
pos_t notes_get_pos(cache_context_t *context) { |
pos_t notes_get_pos(cache_context_t *context) { |
748 |
pos_t pos = context->cache->pos; |
pos_t pos = context->cache->pos; |
749 |
if(gtk_toggle_button_get_active( |
if(check_button_get_active(context->notes.overridew)) { |
750 |
GTK_TOGGLE_BUTTON(context->notes.overridew))) { |
pos.lat = lat_entry_get(context->notes.latw); |
751 |
pos.lat = lat_get(context->notes.latw); |
pos.lon = lon_entry_get(context->notes.lonw); |
|
pos.lon = lon_get(context->notes.lonw); |
|
752 |
} |
} |
753 |
return pos; |
return pos; |
754 |
} |
} |
755 |
|
|
756 |
gboolean notes_get_override(cache_context_t *context) { |
gboolean notes_get_override(cache_context_t *context) { |
757 |
/* get override value */ |
/* get override value */ |
758 |
return gtk_toggle_button_get_active( |
return check_button_get_active(context->notes.overridew); |
|
GTK_TOGGLE_BUTTON(context->notes.overridew)); |
|
|
|
|
759 |
} |
} |
760 |
|
|
761 |
typedef struct { |
typedef struct { |
762 |
GtkWidget *info_label; |
GtkWidget *info_label; |
763 |
GtkWidget *dialog; |
GtkWidget *dialog; |
764 |
appdata_t *appdata; |
appdata_t *appdata; |
|
GtkWidget *path_label; |
|
765 |
} export_context_t; |
} export_context_t; |
766 |
|
|
|
static void on_browse(GtkWidget *widget, gpointer data) { |
|
|
GtkWidget *dialog; |
|
|
|
|
|
export_context_t *context = (export_context_t*)data; |
|
|
|
|
|
#ifdef USE_MAEMO |
|
|
dialog = hildon_file_chooser_dialog_new(GTK_WINDOW(context->dialog), |
|
|
GTK_FILE_CHOOSER_ACTION_SAVE); |
|
|
#else |
|
|
dialog = gtk_file_chooser_dialog_new(_("Save POI database"), |
|
|
GTK_WINDOW(context->dialog), |
|
|
GTK_FILE_CHOOSER_ACTION_SAVE, |
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
|
|
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, |
|
|
NULL); |
|
|
#endif |
|
|
|
|
|
printf("set filename <%s>\n", context->appdata->fieldnotes_path); |
|
|
|
|
|
if(!g_file_test(context->appdata->fieldnotes_path, G_FILE_TEST_EXISTS)) { |
|
|
char *last_sep = strrchr(context->appdata->fieldnotes_path, '/'); |
|
|
if(last_sep) { |
|
|
*last_sep = 0; // seperate path from file |
|
|
|
|
|
/* the user just created a new document */ |
|
|
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), |
|
|
context->appdata->fieldnotes_path); |
|
|
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), last_sep+1); |
|
|
|
|
|
/* restore full filename */ |
|
|
*last_sep = '/'; |
|
|
} |
|
|
} else |
|
|
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), |
|
|
context->appdata->fieldnotes_path); |
|
|
|
|
|
if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_FM_OK) { |
|
|
gchar *name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
|
|
if(name) { |
|
|
free(context->appdata->fieldnotes_path); |
|
|
context->appdata->fieldnotes_path = strdup(name); |
|
|
gtk_label_set_text(GTK_LABEL(context->path_label), |
|
|
context->appdata->fieldnotes_path); |
|
|
} |
|
|
} |
|
|
|
|
|
gtk_widget_destroy (dialog); |
|
|
} |
|
|
|
|
767 |
typedef struct log_chain_s { |
typedef struct log_chain_s { |
768 |
cache_t *cache; |
cache_t *cache; |
769 |
struct log_chain_s *next; |
struct log_chain_s *next; |
853 |
/* ------------------ path/file ------------------ */ |
/* ------------------ path/file ------------------ */ |
854 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_hseparator_new()); |
gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_hseparator_new()); |
855 |
|
|
856 |
GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
gtk_box_pack_start_defaults(GTK_BOX(vbox), |
857 |
GtkWidget *label = gtk_label_new(_("Export to:")); |
export_file(_("Save POI database"), &appdata->fieldnotes_path)); |
|
gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE,0); |
|
|
gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f); |
|
|
GtkWidget *button = gtk_button_new_with_label(_("Browse")); |
|
|
gtk_signal_connect(GTK_OBJECT(button), "clicked", |
|
|
GTK_SIGNAL_FUNC(on_browse), (gpointer)&context); |
|
|
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE,0); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), hbox); |
|
|
|
|
|
context.path_label = gtk_label_new(appdata->fieldnotes_path); |
|
|
gtk_misc_set_alignment(GTK_MISC(context.path_label), 0.f, 0.5f); |
|
|
gtk_label_set_ellipsize(GTK_LABEL(context.path_label), |
|
|
PANGO_ELLIPSIZE_MIDDLE); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), context.path_label); |
|
858 |
|
|
859 |
label = gtk_label_new(_("(a %s in the filename will be replaced by the " |
GtkWidget *label = |
860 |
"current date and time)")); |
gtk_label_new(_("(a %s in the filename will be replaced by the " |
861 |
|
"current date and time)")); |
862 |
gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD); |
gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD); |
863 |
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
864 |
gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f); |
gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f); |
877 |
time_t now = time(NULL); |
time_t now = time(NULL); |
878 |
struct tm *tm_now = localtime(&now); |
struct tm *tm_now = localtime(&now); |
879 |
char now_str[32]; |
char now_str[32]; |
880 |
strftime(now_str, sizeof(now_str)-1, "%F_%H:%M", tm_now); |
strftime(now_str, sizeof(now_str)-1, "%F_%H-%M", tm_now); |
881 |
char *fname = g_strdup_printf(appdata->fieldnotes_path, now_str); |
char *fname = g_strdup_printf(appdata->fieldnotes_path, now_str); |
882 |
|
|
883 |
printf("--- about to export logs to %s ---\n", fname); |
printf("--- about to export logs to %s ---\n", fname); |
884 |
FILE *file = fopen(fname, "w"); |
FILE *file = fopen(fname, "w"); |
885 |
g_free(fname); |
g_free(fname); |
886 |
|
|
887 |
if(file) { |
if(file) { |
|
|
|
888 |
llog = log; |
llog = log; |
889 |
while(llog) { |
while(llog) { |
890 |
printf("Exporting %s\n", llog->cache->id); |
printf("Exporting %s\n", llog->cache->id); |
974 |
} |
} |
975 |
|
|
976 |
fclose(file); |
fclose(file); |
977 |
} |
} else |
978 |
|
errorf(_("Can't open file:\n\n%s"), strerror(errno)); |
979 |
|
|
980 |
} else { |
} else { |
981 |
/* restore old path, in case it has been altered but not been used */ |
/* restore old path, in case it has been altered but not been used */ |
982 |
free(appdata->fieldnotes_path); |
free(appdata->fieldnotes_path); |