[Bf-blender-cvs] [a4ee50f] gooseberry: Disable file collapse when user cancels after an operator.

Antony Riakiotakis noreply at git.blender.org
Tue Jun 9 12:29:26 CEST 2015


Commit: a4ee50f52e4dd5aa1664a65eafd289e79110cf15
Author: Antony Riakiotakis
Date:   Tue Jun 9 12:29:16 2015 +0200
Branches: gooseberry
https://developer.blender.org/rBa4ee50f52e4dd5aa1664a65eafd289e79110cf15

Disable file collapse when user cancels after an operator.

Now file open operator also sets a temporary flag for collapse. This
allows the user to configure the option to always collapse files and the
editor will remember the setting and not reset it back after finishing a
collapsed file open.

===================================================================

M	source/blender/editors/space_file/file_ops.c
M	source/blender/editors/space_file/filesel.c
M	source/blender/makesdna/DNA_space_types.h

===================================================================

diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 9177899..0eab155 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -804,6 +804,17 @@ int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused))
 	SpaceFile *sfile = CTX_wm_space_file(C);
 	wmOperator *op = sfile->op;
 	
+	if (op) {
+		PropertyRNA *prop;
+		if ((prop = RNA_struct_find_property(op->ptr, "collapse_images")) &&
+		    (sfile->params->flag & FILE_COLLAPSE_IMAGES_TMP))
+		{
+			/* turn off collapsed flag if evoked from operator */
+			sfile->params->flag &= ~FILE_COLLAPSE_IMAGES_TMP;
+			sfile->params->flag &= ~FILE_COLLAPSE_IMAGES;
+		}
+	}
+
 	sfile->op = NULL;
 
 	WM_event_fileselect_event(wm, op, EVT_FILESELECT_CANCEL);
@@ -918,8 +929,11 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
 			}
 		}
 
-		if ((prop = RNA_struct_find_property(op->ptr, "collapse_images"))) {
+		if ((prop = RNA_struct_find_property(op->ptr, "collapse_images")) &&
+		    (sfile->params->flag & FILE_COLLAPSE_IMAGES_TMP))
+		{
 			/* turn off collapsed flag if evoked from operator */
+			sfile->params->flag &= ~FILE_COLLAPSE_IMAGES_TMP;
 			sfile->params->flag &= ~FILE_COLLAPSE_IMAGES;
 		}
 	}
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index 6778daa..231712b 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -232,7 +232,10 @@ short ED_fileselect_set_params(SpaceFile *sfile)
 
 		if (params->filter & FILE_TYPE_IMAGE) {
 			if ((prop = RNA_struct_find_property(op->ptr, "collapse_images"))) {
-				params->flag |= FILE_COLLAPSE_IMAGES;
+				if (!(params->flag & FILE_COLLAPSE_IMAGES)) {
+					params->flag |= FILE_COLLAPSE_IMAGES_TMP;
+					params->flag |= FILE_COLLAPSE_IMAGES;
+				}
 			}
 		}
 
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 9682d4e..b352686 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -702,18 +702,19 @@ typedef enum eFileSel_Action {
 
 /* sfile->params->flag and simasel->flag */
 typedef enum eFileSel_Params_Flag {
-	FILE_SHOWSHORT       = (1 << 0),
-	FILE_RELPATH         = (1 << 1), /* was FILE_STRINGCODE */
-	FILE_LINK            = (1 << 2),
-	FILE_HIDE_DOT        = (1 << 3),
-	FILE_AUTOSELECT      = (1 << 4),
-	FILE_ACTIVELAY       = (1 << 5),
-/*  FILE_ATCURSOR        = (1 << 6), */ /* deprecated */
-	FILE_DIRSEL_ONLY     = (1 << 7),
-	FILE_FILTER          = (1 << 8),
-	FILE_BOOKMARKS       = (1 << 9),
-	FILE_GROUP_INSTANCE  = (1 << 10),
-	FILE_COLLAPSE_IMAGES = (1 << 11),
+	FILE_SHOWSHORT           = (1 << 0),
+	FILE_RELPATH             = (1 << 1), /* was FILE_STRINGCODE */
+	FILE_LINK                = (1 << 2),
+	FILE_HIDE_DOT            = (1 << 3),
+	FILE_AUTOSELECT          = (1 << 4),
+	FILE_ACTIVELAY           = (1 << 5),
+/*  FILE_ATCURSOR            = (1 << 6), */ /* deprecated */
+	FILE_DIRSEL_ONLY         = (1 << 7),
+	FILE_FILTER              = (1 << 8),
+	FILE_BOOKMARKS           = (1 << 9),
+	FILE_GROUP_INSTANCE      = (1 << 10),
+	FILE_COLLAPSE_IMAGES     = (1 << 11),
+	FILE_COLLAPSE_IMAGES_TMP = (1 << 12),
 } eFileSel_Params_Flag;




More information about the Bf-blender-cvs mailing list