diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-02-11 19:07:52 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-02-11 19:13:16 +0300 |
commit | b9ffd70960c5047a003fadf2363bfed50095d79b (patch) | |
tree | cbf45b057f0104fe00948ef2c14a40c63ab98ac9 /source/blender/editors/space_file/file_ops.c | |
parent | f60b4228b929ce4d77187a5bbe52f74df2c3315e (diff) |
FileBrowser Bookmarks: fix issue with invalid bookmarks.
Reported by maxon through IRC, thanks.
Invalid (inexistant) bookmarks would not be selectable, hence not removable.
First, made invalid bookmarks grayed out in lists, so that user knows when there are some.
Then, added a new 'cleanup' operator that removes all invalid bookmarks.
This solution may not be completely satisfaying, but should do the work for now.
I do not want to add back those ugly 'X' delete buttons for each entry in list,
so better solution would be to make UIList able to select several items at once...
Diffstat (limited to 'source/blender/editors/space_file/file_ops.c')
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index a0e312e72ef..ddf9545289e 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -573,6 +573,52 @@ void FILE_OT_bookmark_delete(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); } +static int bookmark_cleanup_exec(bContext *C, wmOperator *UNUSED(op)) +{ + ScrArea *sa = CTX_wm_area(C); + struct FSMenu *fsmenu = ED_fsmenu_get(); + struct FSMenuEntry *fsme_next, *fsme = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_BOOKMARKS); + int index; + bool changed = false; + + for (index = 0; fsme; fsme = fsme_next) { + fsme_next = fsme->next; + + if (!BLI_is_dir(fsme->path)) { + fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index); + changed = true; + } + else { + index++; + } + } + + if (changed) { + char name[FILE_MAX]; + + BLI_make_file_string("/", name, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); + fsmenu_write_file(fsmenu, name); + ED_area_tag_refresh(sa); + ED_area_tag_redraw(sa); + } + + return OPERATOR_FINISHED; +} + +void FILE_OT_bookmark_cleanup(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Cleanup Bookmarks"; + ot->description = "Delete all invalid bookmarks"; + ot->idname = "FILE_OT_bookmark_cleanup"; + + /* api callbacks */ + ot->exec = bookmark_cleanup_exec; + ot->poll = ED_operator_file_active; + + /* properties */ +} + enum { FILE_BOOKMARK_MOVE_TOP = -2, FILE_BOOKMARK_MOVE_UP = -1, |