diff options
author | akashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2010-03-29 12:19:04 +0000 |
---|---|---|
committer | akashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2010-03-29 12:19:04 +0000 |
commit | c49040ddea1ead5815f1178a52bbb1e20316c29f (patch) | |
tree | 86468bce9d615fa8d6407874ac9ebd13cf680bc8 | |
parent | ecfbf9a951fefb7ce96c0a1801f9a69137c4b93c (diff) | |
download | navit-c49040ddea1ead5815f1178a52bbb1e20316c29f.tar.gz |
Add:core:Added bookmark rename function
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@3099 ffa7fe5e-494d-0410-b361-a75ebd5db220
-rw-r--r-- | navit/bookmarks.c | 41 | ||||
-rw-r--r-- | navit/bookmarks.h | 1 |
2 files changed, 42 insertions, 0 deletions
diff --git a/navit/bookmarks.c b/navit/bookmarks.c index 6a5e4bb61..71e28ca58 100644 --- a/navit/bookmarks.c +++ b/navit/bookmarks.c @@ -390,6 +390,47 @@ bookmarks_del_bookmark(struct bookmarks *this_, const char *description) { return FALSE; } + +int +bookmarks_rename_bookmark(struct bookmarks *this_, const char *oldName, const char* newName) { + struct bookmark_item_priv *b_item; + struct pcoord pc; + 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); + } + + 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_); + + } + + return result; +} + /** * @param limit Limits the number of entries in the "backlog". Set to 0 for "infinite" */ diff --git a/navit/bookmarks.h b/navit/bookmarks.h index 8b1c83c76..bba42f3bc 100644 --- a/navit/bookmarks.h +++ b/navit/bookmarks.h @@ -33,6 +33,7 @@ int bookmarks_add_bookmark(struct bookmarks *this_, struct pcoord *c, const char int bookmarks_cut_bookmark(struct bookmarks *this_, const char *description); int bookmarks_copy_bookmark(struct bookmarks *this_, const char *description); int bookmarks_paste_bookmark(struct bookmarks *this_, const char *path); +int bookmarks_rename_bookmark(struct bookmarks *this_, const char *oldName, const char* newName); int bookmarks_del_bookmark(struct bookmarks *this_, const char *description); struct map* bookmarks_get_map(struct bookmarks *this_); |