fix [#32564] Entries in recent list (file select dialog) don't get pushed to top...
authorCampbell Barton <ideasman42@gmail.com>
Mon, 17 Sep 2012 02:19:41 +0000 (02:19 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 17 Sep 2012 02:19:41 +0000 (02:19 +0000)
source/blender/editors/space_file/file_ops.c
source/blender/editors/space_file/fsmenu.c
source/blender/editors/space_file/fsmenu.h

index aa423448e45fb44c44982f6977513201a5daa77d..f0fdffadb12155f95cd24b0be72b5bc2d0683d40 100644 (file)
@@ -770,8 +770,9 @@ int file_exec(bContext *C, wmOperator *exec_op)
 
                file_sfile_to_operator(op, sfile, filepath);
 
-               if (BLI_exists(sfile->params->dir))
-                       fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, FS_INSERT_SAVE);
+               if (BLI_exists(sfile->params->dir)) {
+                       fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, FS_INSERT_SAVE | FS_INSERT_FIRST);
+               }
 
                BLI_make_file_string(G.main->name, filepath, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
                fsmenu_write_file(fsmenu_get(), filepath);
index 474ec81ad9347fb9a604fb93d1f1ebfa54e3ee16..3877534e1dc2009e8019f28164ac2a232ca9ec82 100644 (file)
@@ -164,14 +164,22 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const c
        FSMenuEntry *prev;
        FSMenuEntry *fsme;
        FSMenuEntry *fsms;
+       FSMenuEntry *fsms_first;
 
        fsms = fsmenu_get_category(fsmenu, category);
-       prev = fsme = fsms;
+       prev = fsme = fsms_first = fsms;
 
        for (; fsme; prev = fsme, fsme = fsme->next) {
                if (fsme->path) {
                        const int cmp_ret = BLI_path_cmp(path, fsme->path);
                        if (cmp_ret == 0) {
+                               if (FS_INSERT_FIRST) {
+                                       if (fsme != fsms_first) {
+                                               prev->next = fsme->next;
+                                               fsme->next = fsms_first;
+                                               fsmenu_set_category(fsmenu, category, fsme);
+                                       }
+                               }
                                return;
                        }
                        else if ((flag & FS_INSERT_SORTED) && cmp_ret < 0) {
index a16aab1984253454e6458ddc943176f024a09487..875f8de42bdedbbc6df5ba775f4bbeeaef7a5b2f 100644 (file)
@@ -45,7 +45,8 @@ typedef enum FSMenuCategory {
 
 typedef enum FSMenuInsert {
        FS_INSERT_SORTED = (1 << 0),
-       FS_INSERT_SAVE   = (1 << 1)
+       FS_INSERT_SAVE   = (1 << 1),
+       FS_INSERT_FIRST  = (1 << 2)   /* moves the item to the front of the list when its already there */
 } FSMenuInsert;
 
 struct FSMenu;