Diff of /trunk/src/notes.c

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

revision 190 by harbaum, Tue Nov 17 10:22:41 2009 UTC revision 221 by harbaum, Mon Nov 30 21:28:04 2009 UTC
# Line 198  static int notes_write_file(cache_contex Line 198  static int notes_write_file(cache_contex
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      printf("write\n");
206    
207    /* build local path */    /* build local path */
208    int path_len = strlen(context->appdata->image_path) +    int path_len = strlen(context->appdata->image_path) +
209      2 * strlen(context->cache->id) + 6;      2 * strlen(context->cache->id) + 6;
210      printf("plen = %d\n", path_len);
211    
212    char *path = malloc(path_len);    char *path = malloc(path_len);
213    snprintf(path, path_len, "%s%s/%s.gpx",    snprintf(path, path_len, "%s%s/%s.gpx",
214             context->appdata->image_path,             context->appdata->image_path,
# Line 212  static int notes_write_file(cache_contex Line 220  static int notes_write_file(cache_contex
220      return -1;      return -1;
221    }    }
222    
223      printf("still al\n");
224    
225    LIBXML_TEST_VERSION;    LIBXML_TEST_VERSION;
226    
227    xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");    xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
# Line 283  static void notes_save(cache_context_t * Line 293  static void notes_save(cache_context_t *
293                                            &start, &end, FALSE);                                            &start, &end, FALSE);
294    
295      pos_t pos;      pos_t pos;
296      pos.lat = lat_get(context->notes.latw);      pos.lat = lat_entry_get(context->notes.latw);
297      pos.lon = lon_get(context->notes.lonw);      pos.lon = lon_entry_get(context->notes.lonw);
298    
299      gboolean override =      gboolean override =
300        check_button_get_active(context->notes.overridew);        check_button_get_active(context->notes.overridew);
# Line 293  static void notes_save(cache_context_t * Line 303  static void notes_save(cache_context_t *
303      gboolean logged =      gboolean logged =
304        check_button_get_active(context->notes.loggedw);        check_button_get_active(context->notes.loggedw);
305    
306      /* required accuracy is 1/60000 degree */      if(pos_differ(&pos, &context->cache->pos))
307      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);  
308      if(override || found)      if(override || found)
309        printf("flags are set\n");        printf("flags are set\n");
310      if(strlen(text))      if(strlen(text))
311        printf("text is present\n");        printf("text is present\n");
312    
313      /* check if the notes are empty */      /* check if the notes are empty */
314      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)) &&  
315         !override && !found && !logged && (strlen(text) == 0)) {         !override && !found && !logged && (strlen(text) == 0)) {
316        printf("notes are in default state, removing them if present\n");        printf("notes are in default state, removing them if present\n");
317    
# Line 363  static void notes_save(cache_context_t * Line 364  static void notes_save(cache_context_t *
364        /* we have to do two things here: */        /* we have to do two things here: */
365        /* - update the notes.xml file on disk */        /* - update the notes.xml file on disk */
366        /* - update the notes entry in the loaded gpx tree */        /* - update the notes entry in the loaded gpx tree */
367    
368        /* update file on disk */        /* update file on disk */
369        notes_write_file(context, text, pos, override, found,        notes_write_file(context, text, pos, override, found,
370                         context->notes.ftime, logged);                         context->notes.ftime, logged);
371    
372        /* search for matching caches and replace note there */        /* search for matching caches and replace note there */
373        notes_t *note = NULL;        notes_t *note = NULL;
374        gpx_t *gpx = context->appdata->gpx;        gpx_t *gpx = context->appdata->gpx;
# Line 458  static void on_destroy_textview(GtkWidge Line 459  static void on_destroy_textview(GtkWidge
459  static void ftime_update(GtkWidget *widget, cache_context_t *context,  static void ftime_update(GtkWidget *widget, cache_context_t *context,
460                           gboolean update) {                           gboolean update) {
461    /* check if it has been selected */    /* check if it has been selected */
462    if(check_button_get_active(GTK_TOGGLE_BUTTON(widget))) {    if(check_button_get_active(widget)) {
463      printf("set active\n");      printf("set active\n");
464    
465      if(update)      if(update)
# Line 696  GtkWidget *cache_notes(cache_context_t * Line 697  GtkWidget *cache_notes(cache_context_t *
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 );
# Line 755  void notes_free(notes_t *notes) { Line 763  void notes_free(notes_t *notes) {
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  }  }
# Line 916  void notes_log_export(appdata_t *appdata Line 924  void notes_log_export(appdata_t *appdata
924    gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE,0);    gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE,0);
925    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);    gtk_misc_set_alignment(GTK_MISC(label), 0.f, 0.5f);
926    GtkWidget *button = gtk_button_new_with_label(_("Browse"));    GtkWidget *button = gtk_button_new_with_label(_("Browse"));
927    #if defined(USE_MAEMO) && (MAEMO_VERSION_MAJOR == 5)
928      hildon_gtk_widget_set_theme_size(button,
929               (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH));
930    #endif
931    gtk_signal_connect(GTK_OBJECT(button), "clicked",    gtk_signal_connect(GTK_OBJECT(button), "clicked",
932                       GTK_SIGNAL_FUNC(on_browse), (gpointer)&context);                       GTK_SIGNAL_FUNC(on_browse), (gpointer)&context);
933    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE,0);    gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE,0);

Legend:
Removed from v.190  
changed lines
  Added in v.221