Diff of /trunk/src/notes.c

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

revision 233 by harbaum, Wed Dec 9 19:45:36 2009 UTC revision 303 by harbaum, Tue Sep 14 09:28:57 2010 UTC
# Line 19  Line 19 
19    
20  #include <stdio.h>  #include <stdio.h>
21  #include <string.h>  #include <string.h>
22    #include <errno.h>
23    
24  #include <glib/gunicode.h>  #include <glib/gunicode.h>
25    
# Line 562  static gboolean focus_in(GtkWidget *widg Line 563  static gboolean focus_in(GtkWidget *widg
563  }  }
564  #endif  #endif
565    
566    #ifndef FREMANTLE
567  static gboolean focus_out(GtkWidget *widget, GdkEventFocus *event,  static gboolean focus_out(GtkWidget *widget, GdkEventFocus *event,
568                           gpointer data) {                           gpointer data) {
569    cache_context_t *context = (cache_context_t*)data;    cache_context_t *context = (cache_context_t*)data;
# Line 573  static gboolean focus_out(GtkWidget *wid Line 575  static gboolean focus_out(GtkWidget *wid
575    
576    return FALSE;    return FALSE;
577  }  }
578    #else
579    static void coo_changed(GtkWidget *widget, gpointer data) {
580      notes_save((cache_context_t*)data);
581    }
582    #endif
583    
584  GtkWidget *cache_notes(cache_context_t *context) {  GtkWidget *cache_notes(cache_context_t *context) {
585    cache_t *cache = context->cache;    cache_t *cache = context->cache;
# Line 632  GtkWidget *cache_notes(cache_context_t * Line 639  GtkWidget *cache_notes(cache_context_t *
639    pos_t pos = gpx_cache_pos(cache);    pos_t pos = gpx_cache_pos(cache);
640    if(cache->notes) pos = cache->notes->pos;    if(cache->notes) pos = cache->notes->pos;
641    
642    gtk_table_attach_defaults(GTK_TABLE(table),    context->notes.latw = lat_entry_new(pos.lat);
643              context->notes.latw = lat_entry_new(pos.lat), 0, 1, 1, 2);    context->notes.lonw = lon_entry_new(pos.lon);
644      GtkWidget *picker =
645        preset_coordinate_picker(context->appdata,
646                                 context->notes.latw, context->notes.lonw);
647    
648      /* on fremantle we react on "changed" event instead since this */
649      /* means that editing is done */
650    #ifdef FREMANTLE
651      g_signal_connect(G_OBJECT(context->notes.latw), "changed",
652                       G_CALLBACK(coo_changed), context);
653      g_signal_connect(G_OBJECT(context->notes.lonw), "changed",
654                       G_CALLBACK(coo_changed), context);
655    #else
656    g_signal_connect(G_OBJECT(context->notes.latw), "focus-out-event",    g_signal_connect(G_OBJECT(context->notes.latw), "focus-out-event",
657                     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);  
658    g_signal_connect(G_OBJECT(context->notes.lonw), "focus-out-event",    g_signal_connect(G_OBJECT(context->notes.lonw), "focus-out-event",
659                     G_CALLBACK(focus_out), context);                     G_CALLBACK(focus_out), context);
660    #endif
661    
662      GtkWidget *ihbox = gtk_hbox_new(FALSE, 0);
663    
664      gtk_box_pack_start_defaults(GTK_BOX(ihbox), context->notes.latw);
665      gtk_box_pack_start_defaults(GTK_BOX(ihbox), context->notes.lonw);
666      gtk_box_pack_start_defaults(GTK_BOX(ihbox), picker);
667    
668      gtk_table_attach_defaults(GTK_TABLE(table),
669                                ihbox, 0, 3, 1, 2);
670    
671  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)  #if !defined(USE_MAEMO) || (MAEMO_VERSION_MAJOR < 5)
672    hbox = gtk_hbox_new(FALSE, 0);    hbox = gtk_hbox_new(FALSE, 0);
# Line 673  GtkWidget *cache_notes(cache_context_t * Line 699  GtkWidget *cache_notes(cache_context_t *
699    /* if the cache has been marked found in the logs already, there's */    /* if the cache has been marked found in the logs already, there's */
700    /* no need/use to be able to change all this */    /* no need/use to be able to change all this */
701    if(cache->found) {    if(cache->found) {
702        check_button_set_active(context->notes.loggedw, TRUE);
703        check_button_set_active(context->notes.foundw, TRUE);
704      gtk_widget_set_sensitive(table, FALSE);      gtk_widget_set_sensitive(table, FALSE);
705      gtk_widget_set_sensitive(view, FALSE);  
706    }      gtk_text_view_set_editable(GTK_TEXT_VIEW(view), FALSE);
707        gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(view), FALSE);
708      } else
709        gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE);
710    
711    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);
   gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE);  
712    gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 );    gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 );
713    gtk_text_view_set_right_margin(GTK_TEXT_VIEW(view), 2 );    gtk_text_view_set_right_margin(GTK_TEXT_VIEW(view), 2 );
714    
# Line 726  GtkWidget *cache_notes(cache_context_t * Line 756  GtkWidget *cache_notes(cache_context_t *
756    return vbox;    return vbox;
757  }  }
758    
759    void notes_logged(cache_context_t *context) {
760    
761      /* if you log it, you sure also found it */
762      check_button_set_active(context->notes.foundw, TRUE);
763      check_button_set_active(context->notes.loggedw, TRUE);
764    
765      gtk_widget_set_sensitive(context->notes.foundw, FALSE);
766      gtk_widget_set_sensitive(context->notes.loggedw, TRUE);
767    
768      ftime_update(context->notes.foundw, context, TRUE);
769    }
770    
771  void notes_free(notes_t *notes) {  void notes_free(notes_t *notes) {
772    if(notes) {    if(notes) {
773      if(notes->text) xmlFree(notes->text);      if(notes->text) xmlFree(notes->text);
# Line 866  void notes_log_export(appdata_t *appdata Line 908  void notes_log_export(appdata_t *appdata
908      time_t now = time(NULL);      time_t now = time(NULL);
909      struct tm *tm_now = localtime(&now);      struct tm *tm_now = localtime(&now);
910      char now_str[32];      char now_str[32];
911      strftime(now_str, sizeof(now_str)-1, "%F_%H:%M", tm_now);      strftime(now_str, sizeof(now_str)-1, "%F_%H-%M", tm_now);
912      char *fname = g_strdup_printf(appdata->fieldnotes_path, now_str);      char *fname = g_strdup_printf(appdata->fieldnotes_path, now_str);
913    
914      printf("--- about to export logs to %s ---\n", fname);      printf("--- about to export logs to %s ---\n", fname);
915      FILE *file = fopen(fname, "w");      FILE *file = fopen(fname, "w");
916      g_free(fname);      g_free(fname);
917    
918      if(file) {      if(file) {
   
919        llog = log;        llog = log;
920        while(llog) {        while(llog) {
921          printf("Exporting %s\n", llog->cache->id);          printf("Exporting %s\n", llog->cache->id);
# Line 963  void notes_log_export(appdata_t *appdata Line 1005  void notes_log_export(appdata_t *appdata
1005        }        }
1006    
1007        fclose(file);        fclose(file);
1008      }      } else
1009          errorf(_("Can't open file:\n\n%s"), strerror(errno));
1010    
1011    } else {    } else {
1012      /* 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 */
1013      free(appdata->fieldnotes_path);      free(appdata->fieldnotes_path);

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