/[zanavi_public1]/navit/navit/bookmarks.c
ZANavi

Diff of /navit/navit/bookmarks.c

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

Revision 30 Revision 31
218 } 218 }
219 bookmarks_move_root(this_); 219 bookmarks_move_root(this_);
220} 220}
221 221
222struct bookmarks * 222struct bookmarks *
223bookmarks_new(struct attr *parent, struct attr **attrs, struct transformation *trans) { 223bookmarks_new(struct attr *parent, struct attr **attrs, struct transformation *trans)
224{
224 struct bookmarks *this_; 225 struct bookmarks *this_;
225 226
226 if (parent->type!=attr_navit) { 227 if (parent->type!=attr_navit)
228 {
227 return NULL; 229 return NULL;
228 } 230 }
231
232 dbg(0,"bb 001\n");
229 233
230 this_ = g_new0(struct bookmarks,1); 234 this_ = g_new0(struct bookmarks,1);
231 this_->attr_cbl=callback_list_new(); 235 this_->attr_cbl=callback_list_new();
232 this_->parent=parent; 236 this_->parent=parent;
233 //this_->attrs=attr_list_dup(attrs); 237 //this_->attrs=attr_list_dup(attrs);
234 this_->trans=trans; 238 this_->trans=trans;
235 239
240
241 return this_;
242
243#if 0
244 dbg(0,"bb 002\n");
245
236 this_->bookmark_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/bookmark.txt", NULL); 246 this_->bookmark_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/bookmark.txt", NULL);
237 this_->working_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/bookmark.txt.tmp", NULL); 247 this_->working_file=g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/bookmark.txt.tmp", NULL);
238 248
249 dbg(0,"bb 003\n");
250
239 this_->clipboard=g_new0(struct bookmark_item_priv,1); 251 this_->clipboard=g_new0(struct bookmark_item_priv,1);
252
253 dbg(0,"bb 004\n");
240 254
241 { 255 {
242 //Load map now 256 //Load map now
243 struct attr type={attr_type, {"textfile"}}, data={attr_data, {this_->bookmark_file}}; 257 struct attr type={attr_type, {"textfile"}}, data={attr_data, {this_->bookmark_file}};
244 struct attr *attrs[]={&type, &data, NULL}; 258 struct attr *attrs[]={&type, &data, NULL};
245 this_->bookmark=map_new(this_->parent, attrs); 259 this_->bookmark=map_new(this_->parent, attrs);
246 if (!this_->bookmark) 260 if (!this_->bookmark)
261 {
247 return NULL; 262 return NULL;
263 }
264 dbg(0,"bb 005\n");
248 bookmarks_load_hash(this_); 265 bookmarks_load_hash(this_);
249 } 266 }
250 267
268 dbg(0,"bb 006\n");
269
251 return this_; 270 return this_;
271#endif
252} 272}
253 273
254void 274void
255bookmarks_destroy(struct bookmarks *this_) { 275bookmarks_destroy(struct bookmarks *this_) {
256 276
285 FILE *f; 305 FILE *f;
286 struct bookmark_item_priv *item,*parent_item; 306 struct bookmark_item_priv *item,*parent_item;
287 char *fullname; 307 char *fullname;
288 const char *prostr; 308 const char *prostr;
289 int result; 309 int result;
290 GHashTable *dedup=g_hash_table_new_full(g_str_hash,g_str_equal,g_free,NULL); 310 GHashTable *dedup=g_hash_table_new_full(g_str_hash,g_str_equal,g_free_func,NULL);
291 311
292 f=fopen(this_->working_file, replace ? "w+" : "a+"); 312 f=fopen(this_->working_file, replace ? "w+" : "a+");
293 if (f==NULL) { 313 if (f==NULL) {
294 navit_add_message(this_->parent->u.navit,"Failed to write bookmarks file"); 314 navit_add_message(this_->parent->u.navit,"Failed to write bookmarks file");
295 return FALSE; 315 return FALSE;
412 f = fopen(file, "r"); 432 f = fopen(file, "r");
413 if (! f) 433 if (! f)
414 return; 434 return;
415 getline(&line, &line_size, f); 435 getline(&line, &line_size, f);
416 fclose(f); 436 fclose(f);
417 if (line) { 437 if (line)
438 {
418 center = transform_center(this_->trans); 439 center = transform_center(this_->trans);
419 pro = transform_get_projection(this_->trans); 440 pro = transform_get_projection(this_->trans);
420 coord_parse(g_strchomp(line), pro, center); 441 coord_parse(g_strchomp(line), pro, center);
421 dbg(0,"******** load center from file *********\n"); 442 dbg(0,"******** load center from file *********\n");
422 free(line); 443 free(line);

Legend:
Removed from v.30  
changed lines
  Added in v.31

   
Visit the ZANavi Wiki