summaryrefslogtreecommitdiff
path: root/navit/bookmarks.c
diff options
context:
space:
mode:
authorakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>2010-03-29 12:19:04 +0000
committerakashihi <akashihi@ffa7fe5e-494d-0410-b361-a75ebd5db220>2010-03-29 12:19:04 +0000
commitc49040ddea1ead5815f1178a52bbb1e20316c29f (patch)
tree86468bce9d615fa8d6407874ac9ebd13cf680bc8 /navit/bookmarks.c
parentecfbf9a951fefb7ce96c0a1801f9a69137c4b93c (diff)
downloadnavit-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
Diffstat (limited to 'navit/bookmarks.c')
-rw-r--r--navit/bookmarks.c41
1 files changed, 41 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"
*/