diff options
-rw-r--r-- | release/scripts/startup/bl_ui/space_userpref.py | 20 | ||||
-rw-r--r-- | source/blender/blenlib/BLI_winstuff.h | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/winstuff.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 37 | ||||
-rw-r--r-- | source/blender/editors/space_file/space_file.c | 1 | ||||
-rw-r--r-- | source/creator/creator_args.c | 1 |
7 files changed, 68 insertions, 4 deletions
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 26ad22d3ac2..b3a456ee2fe 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -605,6 +605,25 @@ class USERPREF_PT_system_cycles_devices(SystemPanel, CenterAlignMixIn, Panel): # col.row().prop(system, "opensubdiv_compute_type", text="") +class USERPREF_PT_system_os_settings(SystemPanel, CenterAlignMixIn, Panel): + bl_label = "Operating System Settings" + + @classmethod + def poll(cls, _context): + # Only for Windows so far + import sys + return sys.platform[:3] == "win" + + def draw_centered(self, context, layout): + prefs = context.preferences + + layout.label(text="Make this installation your default Blender") + split = layout.split(factor=0.4) + split.alignment = 'RIGHT' + split.label(text="") + split.operator("file.associate_blend", text="Make Default") + + class USERPREF_PT_system_memory(SystemPanel, CenterAlignMixIn, Panel): bl_label = "Memory & Limits" @@ -2324,6 +2343,7 @@ classes = ( USERPREF_PT_animation_fcurves, USERPREF_PT_system_cycles_devices, + USERPREF_PT_system_os_settings, USERPREF_PT_system_memory, USERPREF_PT_system_video_sequencer, USERPREF_PT_system_sound, diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h index f771d26baab..0953e3f1946 100644 --- a/source/blender/blenlib/BLI_winstuff.h +++ b/source/blender/blenlib/BLI_winstuff.h @@ -105,7 +105,7 @@ int closedir(DIR *dp); const char *dirname(char *path); /* Windows utility functions. */ -void BLI_windows_register_blend_extension(const bool background); +bool BLI_windows_register_blend_extension(const bool background); void BLI_windows_get_default_root_dir(char *root_dir); int BLI_windows_get_executable_dir(char *str); diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 3aa61d1fec5..d40f665ba0d 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -67,10 +67,9 @@ static void register_blend_extension_failed(HKEY root, const bool background) if (!background) { MessageBox(0, "Could not register file extension.", "Blender error", MB_OK | MB_ICONERROR); } - TerminateProcess(GetCurrentProcess(), 1); } -void BLI_windows_register_blend_extension(const bool background) +bool BLI_windows_register_blend_extension(const bool background) { LONG lresult; HKEY hkey = 0; @@ -107,6 +106,7 @@ void BLI_windows_register_blend_extension(const bool background) lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); if (lresult != ERROR_SUCCESS) { register_blend_extension_failed(0, background); + return false; } } @@ -119,6 +119,7 @@ void BLI_windows_register_blend_extension(const bool background) } if (lresult != ERROR_SUCCESS) { register_blend_extension_failed(root, background); + return false; } lresult = RegCreateKeyEx(root, @@ -137,6 +138,7 @@ void BLI_windows_register_blend_extension(const bool background) } if (lresult != ERROR_SUCCESS) { register_blend_extension_failed(root, background); + return false; } lresult = RegCreateKeyEx(root, @@ -155,6 +157,7 @@ void BLI_windows_register_blend_extension(const bool background) } if (lresult != ERROR_SUCCESS) { register_blend_extension_failed(root, background); + return false; } lresult = RegCreateKeyEx( @@ -166,6 +169,7 @@ void BLI_windows_register_blend_extension(const bool background) } if (lresult != ERROR_SUCCESS) { register_blend_extension_failed(root, background); + return false; } BLI_windows_get_executable_dir(InstallDir); @@ -184,7 +188,7 @@ void BLI_windows_register_blend_extension(const bool background) "all users"); MessageBox(0, MBox, "Blender", MB_OK | MB_ICONINFORMATION); } - TerminateProcess(GetCurrentProcess(), 0); + return true; } void BLI_windows_get_default_root_dir(char *root) 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); diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index 43f23510927..3f5ca84fbef 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -1317,6 +1317,7 @@ static int arg_handle_register_extension(int UNUSED(argc), const char **UNUSED(a G.background = 1; } BLI_windows_register_blend_extension(G.background); + TerminateProcess(GetCurrentProcess(), 0); # else (void)data; /* unused */ # endif |