diff options
author | akashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2010-04-28 13:54:24 +0000 |
---|---|---|
committer | akashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2010-04-28 13:54:24 +0000 |
commit | 9185bc36a4b377631b8223a0ea08dba7c7b2a047 (patch) | |
tree | 9980b50b6201fccdecaf1a4bc79c954eeb403cc9 /navit/bookmarks.c | |
parent | f3e14f0b6e622975370168fe74e5cabf620fda92 (diff) | |
download | navit-9185bc36a4b377631b8223a0ea08dba7c7b2a047.tar.gz |
Fix:core:Bookmark renaming is now hierarchy aware
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@3205 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/bookmarks.c')
-rw-r--r-- | navit/bookmarks.c | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/navit/bookmarks.c b/navit/bookmarks.c index 32cdc49a0..289fba6ac 100644 --- a/navit/bookmarks.c +++ b/navit/bookmarks.c @@ -561,37 +561,28 @@ bookmarks_rename_bookmark(struct bookmarks *this_, const char *oldName, const ch char *path; int result; - b_item=(struct bookmark_item_priv*)g_hash_table_lookup(this_->bookmarks_hash,oldName); - if (b_item) { - this_->bookmarks_list=g_list_first(this_->bookmarks_list); - this_->bookmarks_list=g_list_remove(this_->bookmarks_list,b_item); - - pc.x=this_->clipboard->c.x; - pc.y=this_->clipboard->c.y; - pc.pro=projection_mg; //Bookmarks are always stored in mg - - //Check if we have to parse the tree - if ((path=strrchr(oldName,'/'))) { - char *fullName=g_new0(char,path-oldName+strlen(newName)+2); - memcpy(fullName,oldName,path-oldName); - memcpy(fullName+(path-oldName),"/",1); - memcpy(fullName+(path-oldName)+1,newName,strlen(newName)); - bookmarks_add_bookmark(this_,&pc,fullName); - - g_free(fullName); - } else { - bookmarks_add_bookmark(this_,&pc,newName); - } + bookmarks_item_rewind(this_); + if (this_->current->children==NULL) { + return 0; + } + while (this_->current->iter!=NULL) { + struct bookmark_item_priv* data=(struct bookmark_item_priv*)this_->current->iter->data; + if (!strcmp(data->label,oldName)) { + g_free(data->label); + data->label=g_strdup(newName); - result=bookmarks_store_bookmarks_to_file(this_,0,0); + result=bookmarks_store_bookmarks_to_file(this_,0,0); - callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map); - bookmarks_clear_hash(this_); - bookmarks_load_hash(this_); + callback_list_call_attr_0(this_->attr_cbl, attr_bookmark_map); + bookmarks_clear_hash(this_); + bookmarks_load_hash(this_); + return result; + } + this_->current->iter=g_list_next(this_->current->iter); } - return result; + return FALSE; } /** |