[Bf-blender-cvs] [3316e28418a] master: Preferences: Move "Register File Association" to preferences level

Julian Eisel noreply at git.blender.org
Fri Jul 30 16:25:49 CEST 2021


Commit: 3316e28418a2ce624c61324d8d3fd284afabf71b
Author: Julian Eisel
Date:   Fri Jul 30 16:23:17 2021 +0200
Branches: master
https://developer.blender.org/rB3316e28418a2ce624c61324d8d3fd284afabf71b

Preferences: Move "Register File Association" to preferences level

The operator was register as a "file" operator, which are by convention
used for File Browser operators only. Move it to the "preferences"
operators, where it's displayed in the UI too.

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

M	release/scripts/startup/bl_ui/space_userpref.py
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
M	source/blender/editors/space_userpref/userpref_ops.c

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

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 7e6fde1ebaf..91bd5f04b9d 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -619,7 +619,7 @@ class USERPREF_PT_system_os_settings(SystemPanel, CenterAlignMixIn, Panel):
         split = layout.split(factor=0.4)
         split.alignment = 'RIGHT'
         split.label(text="")
-        split.operator("file.associate_blend", text="Make Default")
+        split.operator("preferences.associate_blend", text="Make Default")
 
 
 class USERPREF_PT_system_memory(SystemPanel, CenterAlignMixIn, Panel):
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index 0bbed65671c..17749d36418 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -62,7 +62,6 @@ 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 4d25524cd19..e65156167a9 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -2623,43 +2623,6 @@ void FILE_OT_hidedot(struct wmOperatorType *ot)
 
 /** \} */
 
-/* -------------------------------------------------------------------- */
-/** \name Associate File Type Operator (Windows only)
- * \{ */
-
-static int associate_blend_exec(bContext *UNUSED(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 274b21f7043..46cc96ba0d4 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -685,7 +685,6 @@ 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);
diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c
index 7c799f0d97b..79f5d1818cb 100644
--- a/source/blender/editors/space_userpref/userpref_ops.c
+++ b/source/blender/editors/space_userpref/userpref_ops.c
@@ -26,11 +26,16 @@
 #include "DNA_screen_types.h"
 
 #include "BLI_listbase.h"
+#ifdef WIN32
+#  include "BLI_winstuff.h"
+#endif
 
 #include "BKE_context.h"
 #include "BKE_main.h"
 #include "BKE_preferences.h"
 
+#include "BKE_report.h"
+
 #include "RNA_access.h"
 #include "RNA_define.h"
 #include "RNA_types.h"
@@ -188,6 +193,43 @@ static void PREFERENCES_OT_asset_library_remove(wmOperatorType *ot)
 
 /** \} */
 
+/* -------------------------------------------------------------------- */
+/** \name Associate File Type Operator (Windows only)
+ * \{ */
+
+static int associate_blend_exec(bContext *UNUSED(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
+}
+
+static void PREFERENCES_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 = "PREFERENCES_OT_associate_blend";
+
+  /* api callbacks */
+  ot->exec = associate_blend_exec;
+}
+
+/** \} */
+
 void ED_operatortypes_userpref(void)
 {
   WM_operatortype_append(PREFERENCES_OT_reset_default_theme);
@@ -197,4 +239,6 @@ void ED_operatortypes_userpref(void)
 
   WM_operatortype_append(PREFERENCES_OT_asset_library_add);
   WM_operatortype_append(PREFERENCES_OT_asset_library_remove);
+
+  WM_operatortype_append(PREFERENCES_OT_associate_blend);
 }



More information about the Bf-blender-cvs mailing list