Diff of /trunk/src/notes.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 7 by harbaum, Thu Jun 25 15:24:24 2009 UTC revision 233 by harbaum, Wed Dec 9 19:45:36 2009 UTC
# Line 27  Line 27 
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    
# Line 157  void notes_load_all(appdata_t *appdata, Line 167  void notes_load_all(appdata_t *appdata,
167    }    }
168  }  }
169    
170  static int notes_save(cache_context_t *context,  static int notes_write_file(cache_context_t *context,
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,
# Line 230  static int notes_save(cache_context_t *c Line 245  static int notes_save(cache_context_t *c
245    return 0;    return 0;
246  }  }
247    
248  /* 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");  
   
249    /* only save if: there is a text which has been changed or */    /* only save if: there is a text which has been changed or */
250    /* there is a position which differs from the original one */    /* there is a position which differs from the original one */
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;
# Line 251  gint notes_destroy_event(GtkWidget *widg Line 265  gint notes_destroy_event(GtkWidget *widg
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    
# Line 331  gint notes_destroy_event(GtkWidget *widg Line 336  gint notes_destroy_event(GtkWidget *widg
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 */
   
       /* update file on disk */  
       notes_save(context, text, pos, override, found,  
                  context->notes.ftime, logged);  
339    
340          /* update file on disk */
341          notes_write_file(context, text, pos, override, found,
342                           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;
# Line 382  gint notes_destroy_event(GtkWidget *widg Line 387  gint notes_destroy_event(GtkWidget *widg
387    
388      if(text) free(text);      if(text) free(text);
389    }    }
390    }
391    
392    /* this is called from the destroy event of the entire notebook */
393    gint notes_destroy_event(GtkWidget *widget, gpointer data ) {
394      cache_context_t *context = (cache_context_t*)data;
395    
396      printf("about to destroy notes view\n");
397      notes_save(context);
398    
399    return FALSE;    return FALSE;
400  }  }
# Line 418  static void on_destroy_textview(GtkWidge Line 431  static void on_destroy_textview(GtkWidge
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)
# Line 450  static void callback_modified(GtkWidget Line 463  static void callback_modified(GtkWidget
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,
# Line 464  static void callback_modified(GtkWidget Line 478  static void callback_modified(GtkWidget
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    
# Line 474  static void callback_modified(GtkWidget Line 499  static void callback_modified(GtkWidget
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,
# Line 493  static void callback_modified(GtkWidget Line 519  static void callback_modified(GtkWidget
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    }    }
# Line 519  static gboolean focus_in(GtkWidget *widg Line 562  static gboolean focus_in(GtkWidget *widg
562  }  }
563  #endif  #endif
564    
565    static gboolean focus_out(GtkWidget *widget, GdkEventFocus *event,
566                             gpointer data) {
567      cache_context_t *context = (cache_context_t*)data;
568    
569      notes_save(context);
570    #if !defined(USE_MAEMO) && defined(ENABLE_OSM_GPS_MAP)
571      map_update(context->appdata);
572    #endif
573    
574      return FALSE;
575    }
576    
577  GtkWidget *cache_notes(cache_context_t *context) {  GtkWidget *cache_notes(cache_context_t *context) {
   appdata_t *appdata = context->appdata;  
578    cache_t *cache = context->cache;    cache_t *cache = context->cache;
579    
580    context->notes.modified = FALSE;    context->notes.modified = FALSE;
# Line 535  GtkWidget *cache_notes(cache_context_t * Line 589  GtkWidget *cache_notes(cache_context_t *
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);
# Line 567  GtkWidget *cache_notes(cache_context_t * Line 624  GtkWidget *cache_notes(cache_context_t *
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);
# Line 576  GtkWidget *cache_notes(cache_context_t * Line 633  GtkWidget *cache_notes(cache_context_t *
633    if(cache->notes) pos = cache->notes->pos;    if(cache->notes) pos = cache->notes->pos;
634    
635    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_table_attach_defaults(GTK_TABLE(table),
636              context->notes.latw = lat_entry_new(pos.lat), 2, 3, 0, 1);              context->notes.latw = lat_entry_new(pos.lat), 0, 1, 1, 2);
637      g_signal_connect(G_OBJECT(context->notes.latw), "focus-out-event",
638                       G_CALLBACK(focus_out), context);
639    
640    gtk_table_attach_defaults(GTK_TABLE(table),    gtk_table_attach_defaults(GTK_TABLE(table),
641              context->notes.lonw = lon_entry_new(pos.lon), 2, 3, 1, 2);              context->notes.lonw = lon_entry_new(pos.lon), 2, 3, 1, 2);
642      g_signal_connect(G_OBJECT(context->notes.lonw), "focus-out-event",
643                       G_CALLBACK(focus_out), context);
644    
645    #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
646    hbox = gtk_hbox_new(FALSE, 0);    hbox = gtk_hbox_new(FALSE, 0);
647    gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(hbox), table, FALSE, FALSE, 0);
648    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
649    #else
650      gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
651    #endif
652    
653  #ifndef USE_PANNABLE_AREA  #ifndef USE_PANNABLE_AREA
654    GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);    GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL);
# Line 598  GtkWidget *cache_notes(cache_context_t * Line 663  GtkWidget *cache_notes(cache_context_t *
663    if(cache->notes && cache->notes->text)    if(cache->notes && cache->notes->text)
664      gtk_text_buffer_set_text(context->notes.buffer, cache->notes->text, -1);      gtk_text_buffer_set_text(context->notes.buffer, cache->notes->text, -1);
665    
666  #ifndef USE_MAEMO  #ifndef USE_HILDON_TEXT_VIEW
667    GtkWidget *view = gtk_text_view_new_with_buffer(context->notes.buffer);    GtkWidget *view = gtk_text_view_new_with_buffer(context->notes.buffer);
668  #else  #else
669    GtkWidget *view = hildon_text_view_new();    GtkWidget *view = hildon_text_view_new();
670    hildon_text_view_set_buffer(HILDON_TEXT_VIEW(view), context->notes.buffer);    hildon_text_view_set_buffer(HILDON_TEXT_VIEW(view), context->notes.buffer);
671  #endif  #endif
672    
673      /* if the cache has been marked found in the logs already, there's */
674      /* no need/use to be able to change all this */
675      if(cache->found) {
676        gtk_widget_set_sensitive(table, FALSE);
677        gtk_widget_set_sensitive(view, FALSE);
678      }
679    
680    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);
681    gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE);    gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE);
682    gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 );    gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 );
# Line 618  GtkWidget *cache_notes(cache_context_t * Line 690  GtkWidget *cache_notes(cache_context_t *
690    
691  #ifndef NO_COPY_N_PASTE  #ifndef NO_COPY_N_PASTE
692    g_signal_connect(G_OBJECT(view), "focus-in-event",    g_signal_connect(G_OBJECT(view), "focus-in-event",
693                     G_CALLBACK(focus_in), appdata);                     G_CALLBACK(focus_in), context->appdata);
694    g_signal_connect(G_OBJECT(view), "destroy",    g_signal_connect(G_OBJECT(view), "destroy",
695                     G_CALLBACK(on_destroy_textview), appdata);                     G_CALLBACK(on_destroy_textview), context->appdata);
696  #endif  #endif
697    
698  #ifndef USE_PANNABLE_AREA  #ifndef USE_PANNABLE_AREA
# Line 663  void notes_free(notes_t *notes) { Line 735  void notes_free(notes_t *notes) {
735    
736  pos_t notes_get_pos(cache_context_t *context) {  pos_t notes_get_pos(cache_context_t *context) {
737    pos_t pos = context->cache->pos;    pos_t pos = context->cache->pos;
738    if(gtk_toggle_button_get_active(    if(check_button_get_active(context->notes.overridew)) {
739                   GTK_TOGGLE_BUTTON(context->notes.overridew))) {      pos.lat = lat_entry_get(context->notes.latw);
740      pos.lat = lat_get(context->notes.latw);      pos.lon = lon_entry_get(context->notes.lonw);
     pos.lon = lon_get(context->notes.lonw);  
741    }    }
742    return pos;    return pos;
743  }  }
744    
745  gboolean notes_get_override(cache_context_t *context) {  gboolean notes_get_override(cache_context_t *context) {
746    /* get override value */    /* get override value */
747    return gtk_toggle_button_get_active(    return check_button_get_active(context->notes.overridew);
                       GTK_TOGGLE_BUTTON(context->notes.overridew));  
   
748  }  }
749    
750  typedef struct {  typedef struct {
751    GtkWidget *info_label;    GtkWidget *info_label;
752    GtkWidget *dialog;    GtkWidget *dialog;
753    appdata_t *appdata;    appdata_t *appdata;
   GtkWidget *path_label;  
754  } export_context_t;  } export_context_t;
755    
 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);  
 }  
   
756  typedef struct log_chain_s {  typedef struct log_chain_s {
757    cache_t *cache;    cache_t *cache;
758    struct log_chain_s *next;    struct log_chain_s *next;
# Line 823  void notes_log_export(appdata_t *appdata Line 842  void notes_log_export(appdata_t *appdata
842    /* ------------------ path/file ------------------ */    /* ------------------ path/file ------------------ */
843    gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_hseparator_new());    gtk_box_pack_start_defaults(GTK_BOX(vbox), gtk_hseparator_new());
844    
845    GtkWidget *hbox = gtk_hbox_new(FALSE, 0);    gtk_box_pack_start_defaults(GTK_BOX(vbox),
846    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);  
847    
848    label = gtk_label_new(_("(a %s in the filename will be replaced by the "    GtkWidget *label =
849                            "current date and time)"));      gtk_label_new(_("(a %s in the filename will be replaced by the "
850                        "current date and time)"));
851    gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD);    gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD);
852    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
853    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
# Line 947  void notes_log_export(appdata_t *appdata Line 954  void notes_log_export(appdata_t *appdata
954          ccontext.appdata = appdata;          ccontext.appdata = appdata;
955          ccontext.cache = llog->cache;          ccontext.cache = llog->cache;
956    
957          notes_save(&ccontext,          notes_write_file(&ccontext,
958                     llog->cache->notes->text, llog->cache->notes->pos,                     llog->cache->notes->text, llog->cache->notes->pos,
959                     llog->cache->notes->override, llog->cache->notes->found,                     llog->cache->notes->override, llog->cache->notes->found,
960                     llog->cache->notes->ftime, llog->cache->notes->logged);                     llog->cache->notes->ftime, llog->cache->notes->logged);

Legend:
Removed from v.7  
changed lines
  Added in v.233