Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarley Acheson <harley.acheson@gmail.com>2021-06-14 20:15:37 +0300
committerHarley Acheson <harley.acheson@gmail.com>2021-06-14 20:22:03 +0300
commitbcff0ef9cabc37c4b89a1e2c7972a09ac80d4555 (patch)
tree06c0f6e881018b578197ddbcfe671c70318cf852 /source/blender/editors/space_file
parent2e5671a959182dadcdd55117732082ab7893f3d1 (diff)
UI: Windows Blend File Association
This patch allows Windows users to specify that their current blender installation should be used to create thumbnails and be associated with ".blend" files. This is done from Preferences / System. The only way to do this currently is from the command-line and this is sometimes inconvenient. Differential Revision: https://developer.blender.org/D10887 Reviewed by Brecht Van Lommel
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/file_intern.h1
-rw-r--r--source/blender/editors/space_file/file_ops.c37
-rw-r--r--source/blender/editors/space_file/space_file.c1
3 files changed, 39 insertions, 0 deletions
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index f1d0197b9ae..a7c57459729 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -62,6 +62,7 @@ void FILE_OT_bookmark_cleanup(struct wmOperatorType *ot);
void FILE_OT_bookmark_move(struct wmOperatorType *ot);
void FILE_OT_reset_recent(wmOperatorType *ot);
void FILE_OT_hidedot(struct wmOperatorType *ot);
+void FILE_OT_associate_blend(struct wmOperatorType *ot);
void FILE_OT_execute(struct wmOperatorType *ot);
void FILE_OT_mouse_execute(struct wmOperatorType *ot);
void FILE_OT_cancel(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 7c14f4659eb..4bbdbb0d97c 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -2633,6 +2633,43 @@ void FILE_OT_hidedot(struct wmOperatorType *ot)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Associate File Type Operator (Windows only)
+ * \{ */
+
+static int associate_blend_exec(bContext *C, wmOperator *op)
+{
+#ifdef WIN32
+ WM_cursor_wait(true);
+ if (BLI_windows_register_blend_extension(true)) {
+ BKE_report(op->reports, RPT_INFO, "File association registered");
+ WM_cursor_wait(false);
+ return OPERATOR_FINISHED;
+ }
+ else {
+ BKE_report(op->reports, RPT_ERROR, "Unable to register file association");
+ WM_cursor_wait(false);
+ return OPERATOR_CANCELLED;
+ }
+#else
+ BKE_report(op->reports, RPT_WARNING, "Operator Not supported");
+ return OPERATOR_CANCELLED;
+#endif
+}
+
+void FILE_OT_associate_blend(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Register File Association";
+ ot->description = "Use this installation for .blend files and to display thumbnails";
+ ot->idname = "FILE_OT_associate_blend";
+
+ /* api callbacks */
+ ot->exec = associate_blend_exec;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Increment Filename Operator
* \{ */
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 12bc0a68ca6..0418bb87768 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -675,6 +675,7 @@ static void file_operatortypes(void)
WM_operatortype_append(FILE_OT_bookmark_move);
WM_operatortype_append(FILE_OT_reset_recent);
WM_operatortype_append(FILE_OT_hidedot);
+ WM_operatortype_append(FILE_OT_associate_blend);
WM_operatortype_append(FILE_OT_filenum);
WM_operatortype_append(FILE_OT_directory_new);
WM_operatortype_append(FILE_OT_delete);