[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50679] trunk/blender/source/blender/ editors/space_file: code cleanup: replace fsmenu_insert_entry args with flags.

Campbell Barton ideasman42 at gmail.com
Mon Sep 17 04:01:11 CEST 2012


Revision: 50679
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50679
Author:   campbellbarton
Date:     2012-09-17 02:01:09 +0000 (Mon, 17 Sep 2012)
Log Message:
-----------
code cleanup: replace fsmenu_insert_entry args with flags.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_file/file_ops.c
    trunk/blender/source/blender/editors/space_file/fsmenu.c
    trunk/blender/source/blender/editors/space_file/fsmenu.h

Modified: trunk/blender/source/blender/editors/space_file/file_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/file_ops.c	2012-09-17 01:48:59 UTC (rev 50678)
+++ trunk/blender/source/blender/editors/space_file/file_ops.c	2012-09-17 02:01:09 UTC (rev 50679)
@@ -459,7 +459,7 @@
 	if (params->dir[0] != '\0') {
 		char name[FILE_MAX];
 	
-		fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, 0, 1);
+		fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, FS_INSERT_SAVE);
 		BLI_make_file_string("/", name, BLI_get_folder_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE);
 		fsmenu_write_file(fsmenu, name);
 	}
@@ -771,7 +771,7 @@
 		file_sfile_to_operator(op, sfile, filepath);
 
 		if (BLI_exists(sfile->params->dir))
-			fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, 0, 1);
+			fsmenu_insert_entry(fsmenu_get(), FS_CATEGORY_RECENT, sfile->params->dir, FS_INSERT_SAVE);
 
 		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);

Modified: trunk/blender/source/blender/editors/space_file/fsmenu.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/fsmenu.c	2012-09-17 01:48:59 UTC (rev 50678)
+++ trunk/blender/source/blender/editors/space_file/fsmenu.c	2012-09-17 02:01:09 UTC (rev 50679)
@@ -159,7 +159,7 @@
 	return fsme ? fsme->save : 0;
 }
 
-void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, int sorted, short save)
+void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, FSMenuInsert flag)
 {
 	FSMenuEntry *prev;
 	FSMenuEntry *fsme;
@@ -174,7 +174,7 @@
 			if (cmp_ret == 0) {
 				return;
 			}
-			else if (sorted && cmp_ret < 0) {
+			else if ((flag & FS_INSERT_SORTED) && cmp_ret < 0) {
 				break;
 			}
 		}
@@ -182,7 +182,7 @@
 			/* if we're bookmarking this, file should come
 			 * before the last separator, only automatically added
 			 * current dir go after the last sep. */
-			if (save) {
+			if (flag & FS_INSERT_SAVE) {
 				break;
 			}
 		}
@@ -190,7 +190,7 @@
 
 	fsme = MEM_mallocN(sizeof(*fsme), "fsme");
 	fsme->path = BLI_strdup(path);
-	fsme->save = save;
+	fsme->save = (flag & FS_INSERT_SAVE) != 0;
 
 	if (prev) {
 		fsme->next = prev->next;
@@ -288,7 +288,7 @@
 				if (BLI_exists(line))
 #endif
 				{
-					fsmenu_insert_entry(fsmenu, category, line, 0, 1);
+					fsmenu_insert_entry(fsmenu, category, line, FS_INSERT_SAVE);
 				}
 			}
 		}
@@ -477,10 +477,10 @@
 
 		if (read_bookmarks && home) {
 			BLI_snprintf(line, FILE_MAXDIR, "%s/", home);
-			fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+			fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
 			BLI_snprintf(line, FILE_MAXDIR, "%s/Desktop/", home);
 			if (BLI_exists(line)) {
-				fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+				fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
 			}
 		}
 
@@ -505,10 +505,11 @@
 					len = strlen(mnt->mnt_dir);
 					if (len && mnt->mnt_dir[len - 1] != '/') {
 						BLI_snprintf(line, FILE_MAXDIR, "%s/", mnt->mnt_dir);
-						fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, 1, 0);
+						fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED);
 					}
-					else
-						fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, mnt->mnt_dir, 1, 0);
+					else {
+						fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, mnt->mnt_dir, FS_INSERT_SORTED);
+					}
 
 					found = 1;
 				}
@@ -520,7 +521,7 @@
 
 			/* fallback */
 			if (!found)
-				fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", 1, 0);
+				fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, "/", FS_INSERT_SORTED);
 		}
 	}
 #endif

Modified: trunk/blender/source/blender/editors/space_file/fsmenu.h
===================================================================
--- trunk/blender/source/blender/editors/space_file/fsmenu.h	2012-09-17 01:48:59 UTC (rev 50678)
+++ trunk/blender/source/blender/editors/space_file/fsmenu.h	2012-09-17 02:01:09 UTC (rev 50679)
@@ -43,6 +43,11 @@
 	FS_CATEGORY_RECENT
 } FSMenuCategory;
 
+typedef enum FSMenuInsert {
+	FS_INSERT_SORTED,
+	FS_INSERT_SAVE
+} FSMenuInsert;
+
 struct FSMenu;
 
 struct FSMenu *fsmenu_get(void);
@@ -59,7 +64,7 @@
  * Duplicate entries are not added.
  * \param sorted Should entry be inserted in sorted order?
  */
-void    fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, int sorted, short save);
+void    fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const char *path, const FSMenuInsert flag);
 
 /** Return whether the entry was created by the user and can be saved and deleted */
 short   fsmenu_can_save(struct FSMenu *fsmenu, FSMenuCategory category, int index);




More information about the Bf-blender-cvs mailing list