--- trunk/src/notes.c 2009/11/19 13:33:35 199 +++ trunk/src/notes.c 2009/11/30 21:28:04 221 @@ -198,9 +198,17 @@ char *text, pos_t pos, gboolean override, gboolean found, time_t ftime, gboolean logged) { + + g_assert(context); + g_assert(context->cache); + + printf("write\n"); + /* build local path */ int path_len = strlen(context->appdata->image_path) + 2 * strlen(context->cache->id) + 6; + printf("plen = %d\n", path_len); + char *path = malloc(path_len); snprintf(path, path_len, "%s%s/%s.gpx", context->appdata->image_path, @@ -212,6 +220,8 @@ return -1; } + printf("still al\n"); + LIBXML_TEST_VERSION; xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0"); @@ -283,8 +293,8 @@ &start, &end, FALSE); pos_t pos; - pos.lat = lat_get(context->notes.latw); - pos.lon = lon_get(context->notes.lonw); + pos.lat = lat_entry_get(context->notes.latw); + pos.lon = lon_entry_get(context->notes.lonw); gboolean override = check_button_get_active(context->notes.overridew); @@ -293,24 +303,15 @@ gboolean logged = check_button_get_active(context->notes.loggedw); - /* required accuracy is 1/60000 degree */ - if(((int)(pos.lat * 60000 + .5) != - (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); + if(pos_differ(&pos, &context->cache->pos)) + printf("position is modified\n"); if(override || found) printf("flags are set\n"); if(strlen(text)) printf("text is present\n"); /* check if the notes are empty */ - if(((int)(pos.lat * 60000 + .5) == - (int)(context->cache->pos.lat * 60000 + .5)) && - ((int)(pos.lon * 60000 + .5) == - (int)(context->cache->pos.lon * 60000 + .5)) && + if(!pos_differ(&pos, &context->cache->pos) && !override && !found && !logged && (strlen(text) == 0)) { printf("notes are in default state, removing them if present\n"); @@ -363,11 +364,11 @@ /* we have to do two things here: */ /* - update the notes.xml file on disk */ /* - update the notes entry in the loaded gpx tree */ - + /* update file on disk */ notes_write_file(context, text, pos, override, found, context->notes.ftime, logged); - + /* search for matching caches and replace note there */ notes_t *note = NULL; gpx_t *gpx = context->appdata->gpx; @@ -696,6 +697,13 @@ hildon_text_view_set_buffer(HILDON_TEXT_VIEW(view), context->notes.buffer); #endif + /* if the cache has been marked found in the logs already, there's */ + /* no need/use to be able to change all this */ + if(cache->found) { + gtk_widget_set_sensitive(table, FALSE); + gtk_widget_set_sensitive(view, FALSE); + } + gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(view), GTK_WRAP_WORD); gtk_text_view_set_editable(GTK_TEXT_VIEW(view), TRUE); gtk_text_view_set_left_margin(GTK_TEXT_VIEW(view), 2 ); @@ -755,8 +763,8 @@ pos_t notes_get_pos(cache_context_t *context) { pos_t pos = context->cache->pos; if(check_button_get_active(context->notes.overridew)) { - pos.lat = lat_get(context->notes.latw); - pos.lon = lon_get(context->notes.lonw); + pos.lat = lat_entry_get(context->notes.latw); + pos.lon = lon_entry_get(context->notes.lonw); } return pos; }