diff options
author | Andrea Weikert <elubie@gmx.net> | 2012-09-18 01:29:30 +0400 |
---|---|---|
committer | Andrea Weikert <elubie@gmx.net> | 2012-09-18 01:29:30 +0400 |
commit | dd3636a6d4fbbddc700f5b2fc8a083a7416b445b (patch) | |
tree | dafe1a222a5b653632945f4434a7d8cf78c893df /source/blender/editors/space_file/fsmenu.c | |
parent | f5395107cc36ed3ffebf57a4f17f90db15fccbd1 (diff) |
== filebrowser ==
further fixes for 'RECENT' files panel in filebrowser:
* Also add the recent folder at the head if it is not yet in the list
* since we now insert at the head, we need to remove the skipping of the first entries if there are too many. Now correctly leaving the last elements unwritten.
* Another consequence of inserting at the head is that we don't want to reverse the list in the recent panel anymore - got rid of the corresponding code.
Diffstat (limited to 'source/blender/editors/space_file/fsmenu.c')
-rw-r--r-- | source/blender/editors/space_file/fsmenu.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 3b204befec6..f7701e79016 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -203,8 +203,13 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const c fsm_iter->save = (flag & FS_INSERT_SAVE) != 0; if (fsm_prev) { - fsm_iter->next = fsm_prev->next; - fsm_prev->next = fsm_iter; + if (flag & FS_INSERT_FIRST) { + fsm_iter->next = fsm_head; + fsmenu_set_category(fsmenu, category, fsm_iter); + } else { + fsm_iter->next = fsm_prev->next; + fsm_prev->next = fsm_iter; + } } else { fsm_iter->next = fsm_head; @@ -247,7 +252,7 @@ void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename) { FSMenuEntry *fsm_iter = NULL; - int nskip = 0; + int nwritten = 0; FILE *fp = BLI_fopen(filename, "w"); if (!fp) return; @@ -259,12 +264,7 @@ void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename) } } fprintf(fp, "[Recent]\n"); - nskip = fsmenu_get_nentries(fsmenu, FS_CATEGORY_RECENT) - FSMENU_RECENT_MAX; - /* skip first entries if list too long */ - for (fsm_iter = fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsm_iter && (nskip > 0); fsm_iter = fsm_iter->next, --nskip) { - /* pass */ - } - for (; fsm_iter; fsm_iter = fsm_iter->next) { + for (fsm_iter = fsmenu_get_category(fsmenu, FS_CATEGORY_RECENT); fsm_iter && (nwritten < FSMENU_RECENT_MAX); fsm_iter = fsm_iter->next, ++nwritten) { if (fsm_iter->path && fsm_iter->save) { fprintf(fp, "%s\n", fsm_iter->path); } |