[Bf-blender-cvs] [d8ad4f9] temp_file-dropper: removed obsolete blank line

Gaia Clary noreply at git.blender.org
Wed Nov 4 14:28:54 CET 2015


Commit: d8ad4f90eacee23aabd2bea48c3ca433c29f962a
Author: Gaia Clary
Date:   Wed Nov 4 14:24:46 2015 +0100
Branches: temp_file-dropper
https://developer.blender.org/rBd8ad4f90eacee23aabd2bea48c3ca433c29f962a

removed obsolete blank line

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

M	release/datafiles/locale
M	release/scripts/addons
M	release/scripts/addons_contrib
M	source/blender/editors/space_file/file_intern.h
M	source/blender/editors/space_file/file_ops.c
M	source/blender/editors/space_file/space_file.c

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

diff --git a/release/datafiles/locale b/release/datafiles/locale
index e4d4a56..9628dc1 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit e4d4a560cafb21d74dd4db13473a2d1d7ee73161
+Subproject commit 9628dc1922be2fb6281bc66f5f7512c2a57c294a
diff --git a/release/scripts/addons b/release/scripts/addons
index ecdc7c0..407d0ea 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit ecdc7c03ec14e6ed70dea808b61049017f46ad97
+Subproject commit 407d0ea752b3af73d3f13ba072671bd09eefecb1
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index c63ada6..9f29e18 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit c63ada6ae2569864be891ff308cda6b39d8368f1
+Subproject commit 9f29e18707917ec5be262431d2e09dbb85332f41
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index baafefa..e7f62a6 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -93,6 +93,7 @@ void FILE_OT_filenum(struct wmOperatorType *ot);
 void FILE_OT_delete(struct wmOperatorType *ot);
 void FILE_OT_rename(struct wmOperatorType *ot);
 void FILE_OT_smoothscroll(struct wmOperatorType *ot);
+void FILE_OT_filepath_drop(struct wmOperatorType *ot);
 
 int file_exec(bContext *C, struct wmOperator *exec_op);
 int file_cancel_exec(bContext *C, struct wmOperator *unused);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 36572d6..48ab318 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1259,6 +1259,40 @@ void file_sfile_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
 	}
 }
 
+void file_sfilepath_to_operator(wmOperator *op, SpaceFile *sfile, char *filepath)
+{
+	PropertyRNA *filename_prop  = RNA_struct_find_property(op->ptr, "filename");
+	PropertyRNA *filepath_prop  = RNA_struct_find_property(op->ptr, "filepath");
+	PropertyRNA *directory_prop = RNA_struct_find_property(op->ptr, "directory");
+
+	if (BLI_is_dir(filepath)) {
+		BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir));
+		sfile->params->file[0] = '\0';
+	}
+	else {
+		if (filename_prop || filepath_prop) {
+			BLI_split_dirfile(filepath, sfile->params->dir, sfile->params->file,
+				sizeof(sfile->params->dir), sizeof(sfile->params->file));
+		}
+		else{
+			BLI_split_dir_part(filepath, sfile->params->dir, sizeof(sfile->params->dir));
+		}
+	}
+
+	if (filepath_prop) {
+		RNA_property_string_set(op->ptr, filepath_prop, filepath);
+	}
+
+	if (filename_prop) {
+		RNA_property_string_set(op->ptr, filename_prop, sfile->params->file);
+	}
+
+	if (directory_prop) {
+		RNA_property_string_set(op->ptr, directory_prop, sfile->params->dir);
+	}
+
+}
+
 void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op)
 {
 	PropertyRNA *prop;
@@ -1652,6 +1686,47 @@ void FILE_OT_smoothscroll(wmOperatorType *ot)
 }
 
 
+/* *************** File drag&drop to 3DView ******** */
+static int filepath_drop_exec(bContext *C, wmOperator *op)
+{
+	char filepath[FILE_MAX];
+	SpaceFile *sfile = CTX_wm_space_file(C);
+
+	if (sfile) {
+		wmOperator *target_op = sfile->op;
+		if (target_op) {
+
+			RNA_string_get(op->ptr, "filepath", filepath);
+			if (!BLI_exists(filepath)) {
+				BKE_report(op->reports, RPT_ERROR, "File does not exist");
+				return OPERATOR_CANCELLED;
+			}
+
+			file_sfilepath_to_operator(target_op, sfile, filepath);
+
+			WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+			return OPERATOR_FINISHED;
+		}
+	}
+	return OPERATOR_CANCELLED;
+}
+
+void FILE_OT_filepath_drop(wmOperatorType *ot)
+{
+	short sort = false; /* not sure with this one*/
+	ot->name = "DND File to Viewport";
+	ot->description = "Import a File by Dragging from external File browser and Drop to File selector";
+	ot->idname = "FILE_OT_filepath_drop";
+
+	ot->invoke = WM_operator_filesel;
+	ot->exec = filepath_drop_exec;
+	ot->poll = WM_operator_winactive;
+
+	WM_operator_properties_filesel(ot, FILE_TYPE_FOLDER, FILE_BLENDER, FILE_OPENFILE,
+		WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, sort);
+}
+
+
 /* create a new, non-existing folder name, returns 1 if successful, 0 if name couldn't be created.
  * The actual name is returned in 'name', 'folder' contains the complete path, including the new folder name.
  */
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 97c2d75..03889bb 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -441,6 +441,7 @@ static void file_operatortypes(void)
 	WM_operatortype_append(FILE_OT_delete);
 	WM_operatortype_append(FILE_OT_rename);
 	WM_operatortype_append(FILE_OT_smoothscroll);
+	WM_operatortype_append(FILE_OT_filepath_drop);
 }
 
 /* NOTE: do not add .blend file reading on this level */
@@ -661,6 +662,33 @@ static void file_ui_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), AReg
 	}
 }
 
+static int filepath_drop_poll(bContext *C, wmDrag *drag, const wmEvent *UNUSED(event))
+{
+	if (drag->type == WM_DRAG_PATH) {
+		SpaceFile *sfile = CTX_wm_space_file(C);
+		if (sfile) {
+			wmOperator *op = sfile->op;
+			if (op) {
+				return 1;
+			}
+		}
+	}
+	return 0;
+}
+
+static void filepath_drop_copy(wmDrag *drag, wmDropBox *drop)
+{
+	RNA_string_set(drop->ptr, "filepath", drag->path);
+}
+
+/* region dropbox definition */
+static void file_dropboxes(void)
+{
+	ListBase *lb = WM_dropboxmap_find("Window", SPACE_EMPTY, RGN_TYPE_WINDOW);
+
+	WM_dropbox_add(lb, "FILE_OT_filepath_drop", filepath_drop_poll, filepath_drop_copy);
+}
+
 /* only called once, from space/spacetypes.c */
 void ED_spacetype_file(void)
 {
@@ -679,7 +707,8 @@ void ED_spacetype_file(void)
 	st->listener = file_listener;
 	st->operatortypes = file_operatortypes;
 	st->keymap = file_keymap;
-	
+	st->dropboxes = file_dropboxes;
+
 	/* regions: main window */
 	art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
 	art->regionid = RGN_TYPE_WINDOW;




More information about the Bf-blender-cvs mailing list