10#include <fmt/format.h>
36#include "RNA_prototypes.hh"
61 U.runtime.is_dirty =
true;
68 ot->name =
"Reset to Default Theme";
69 ot->idname =
"PREFERENCES_OT_reset_default_theme";
70 ot->description =
"Reset to the default theme colors";
89 U.runtime.is_dirty =
true;
95 ot->name =
"Add Auto-Execution Path";
96 ot->idname =
"PREFERENCES_OT_autoexec_path_add";
97 ot->description =
"Add path to exclude from auto-execution";
116 U.runtime.is_dirty =
true;
123 ot->name =
"Remove Auto-Execution Path";
124 ot->idname =
"PREFERENCES_OT_autoexec_path_remove";
125 ot->description =
"Remove path to exclude from auto-execution";
131 RNA_def_int(
ot->srna,
"index", 0, 0, INT_MAX,
"Index",
"", 0, 1000);
151 U.active_asset_library =
BLI_findindex(&
U.asset_libraries, new_library);
152 U.runtime.is_dirty =
true;
176 ot->name =
"Add Asset Library";
177 ot->idname =
"PREFERENCES_OT_asset_library_add";
178 ot->description =
"Add a directory to be used by the Asset Browser as source of assets";
221 CLAMP(
U.active_asset_library, 0, count_remaining - 1);
222 U.runtime.is_dirty =
true;
233 ot->name =
"Remove Asset Library";
234 ot->idname =
"PREFERENCES_OT_asset_library_remove";
236 "Remove a path to a .blend file, so the Asset Browser will not attempt to show it anymore";
243 RNA_def_int(
ot->srna,
"index", 0, 0, INT_MAX,
"Index",
"", 0, 1000);
262 return "Remote Repository";
265 return "User Repository";
282 char *access_token =
nullptr;
288 if (use_custom_directory) {
296 if (use_access_token) {
315 if (
name[0] ==
'\0') {
322 if (use_custom_directory) {
331 if (
name[0] ==
'\0') {
343 for (
i = 0; module_buf[
i];
i++) {
344 if (
ELEM(module_buf[
i],
'.',
'-',
'/',
'\\')) {
349 while ((
i > 0) && (module_buf[--
i] ==
'_')) {
350 module_buf[
i] =
'\0';
358 if (use_sync_on_startup) {
361 if (use_custom_directory) {
369 if (use_access_token) {
379 U.runtime.is_dirty =
true;
383 nullptr, &RNA_UserExtensionRepo, new_repo);
415 name_default =
nullptr;
421 C, op, event,
IFACE_(
"Add New Extension Repository"),
IFACE_(
"Create"));
449 col->active_set(use_access_token);
471 ot->name =
"Add Extension Repository";
472 ot->idname =
"PREFERENCES_OT_extension_repo_add";
473 ot->description =
"Add a new repository used to store extensions";
485 "Add Remote Repository",
486 "Add a repository referencing a remote repository "
487 "with support for listing and updating extensions"},
491 "Add Local Repository",
492 "Add a repository managed manually without referencing an external repository"},
493 {0,
nullptr, 0,
nullptr,
nullptr},
507 StructRNA *type_ref = &RNA_UserExtensionRepo;
510 const char *prop_id =
"name";
522 const char *prop_id =
"remote_url";
534 const char *prop_id =
"use_access_token";
545 const char *prop_id =
"access_token";
558 const char *prop_id =
"use_sync_on_startup";
569 const char *prop_id =
"use_custom_directory";
580 const char *prop_id =
"custom_directory";
592 ot->srna,
"type", repo_type_items, 0,
"Type",
"The kind of repository to add");
627 remove_files =
false;
639 if (dirpath[0] || user_dirpath[0]) {
640 message =
IFACE_(
"Remove all files in:");
641 const char *paths[] = {dirpath, user_dirpath};
643 if (paths[
i][0] ==
'\0') {
646 message.append(fmt::format(
"\n\"{}\"", paths[
i]));
650 message =
IFACE_(
"Remove, local files not found.");
651 remove_files =
false;
655 message =
IFACE_(
"Remove, keeping local files.");
658 const char *confirm_text = remove_files ?
IFACE_(
"Remove Repository & Files") :
659 IFACE_(
"Remove Repository");
683 remove_files =
false;
693 "Unable to remove files, the module name \"%.*s\" is invalid and "
694 "could remove non-repository files",
695 int(
sizeof(repo->
module)),
697 remove_files =
false;
721 if (
BLI_delete(dirpath,
true, recursive) != 0) {
724 "Unable to remove directory: %s",
725 errno ? strerror(errno) :
"unknown");
734 "Unable to remove directory: %s",
735 errno ? strerror(errno) :
"unknown");
743 CLAMP(
U.active_extension_repo, 0, count_remaining - 1);
744 U.runtime.is_dirty =
true;
756 ot->name =
"Remove Extension Repository";
757 ot->idname =
"PREFERENCES_OT_extension_repo_remove";
758 ot->description =
"Remove an extension repository";
767 prop =
RNA_def_int(
ot->srna,
"index", 0, 0, INT_MAX,
"Index",
"", 0, 1000);
773 "Remove extension files when removing the repository");
788 const bool url_is_file =
STRPREFIX(url.c_str(),
"file://");
789 const bool url_is_online =
STRPREFIX(url.c_str(),
"http://") ||
791 const bool url_is_remote = url_is_file | url_is_online;
795 const char *idname_external = url_is_remote ?
"extensions.package_install" :
796 "extensions.package_install_files";
800 idname_external =
"extensions.userpref_allow_online_popup";
826 ot->name =
"Drop Extension URL";
827 ot->description =
"Handle dropping an extension URL";
828 ot->idname =
"PREFERENCES_OT_extension_url_drop";
833 RNA_def_string(
ot->srna,
"url",
nullptr, 0,
"URL",
"Location of the extension to install");
850#elif defined(__APPLE__)
859#if !defined(__APPLE__)
866 (all_users ==
false))
868 const char *msg = do_register ?
"Unable to register file association" :
869 "Unable to unregister file association";
870 MessageBox(0, msg,
"Blender", MB_OK | MB_ICONERROR);
888 op->
reports,
RPT_ERROR,
"Registration not possible from Microsoft Store installations");
894 char *error_msg =
nullptr;
902 op->
reports,
RPT_ERROR, error_msg ? error_msg :
"Unable to register file association");
917 ot->name =
"Register File Association";
918 ot->description =
"Use this installation for .blend files and to display thumbnails";
919 ot->idname =
"PREFERENCES_OT_associate_blend";
936 op->
reports,
RPT_ERROR,
"Unregistration not possible from Microsoft Store installations");
942 char *error_msg =
nullptr;
950 op->
reports,
RPT_ERROR, error_msg ? error_msg :
"Unable to unregister file association");
965 ot->name =
"Remove File Association";
966 ot->description =
"Remove this installation's associations with .blend files";
967 ot->idname =
"PREFERENCES_OT_unassociate_blend";
994 const char *cstr =
str.c_str();
1000 if (
str.find(
'\n') != std::string::npos) {
1004 bool has_known_extension =
false;
1009 std::string str_strip;
1010 const char *cstr_maybe_copy = cstr;
1011 size_t param_char =
str.find(
'?');
1012 if (param_char != std::string::npos) {
1013 str_strip =
str.substr(0, param_char);
1014 cstr_maybe_copy = str_strip.c_str();
1018 if (cstr_ext &&
STRCASEEQ(cstr_ext,
".zip")) {
1019 has_known_extension =
true;
1025 if (!has_known_extension &&
1055 if (!(cstr_ext &&
STRCASEEQ(cstr_ext,
".zip"))) {
1075 "PREFERENCES_OT_extension_url_drop",
1081 "PREFERENCES_OT_extension_url_drop",
void BKE_callback_exec(Main *bmain, PointerRNA **pointers, int num_pointers, eCbEvent evt)
void BKE_callback_exec_string(Main *bmain, eCbEvent evt, const char *str)
void BKE_callback_exec_null(Main *bmain, eCbEvent evt)
@ BKE_CB_EVT_EXTENSION_REPOS_FILES_CLEAR
@ BKE_CB_EVT_EXTENSION_REPOS_UPDATE_PRE
@ BKE_CB_EVT_EXTENSION_REPOS_UPDATE_POST
@ BKE_CB_EVT_EXTENSION_REPOS_SYNC
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
Main * CTX_data_main(const bContext *C)
bUserExtensionRepo * BKE_preferences_extension_repo_find_by_remote_url_prefix(const UserDef *userdef, const char *remote_url_full, const bool only_enabled)
bool BKE_preferences_extension_repo_module_is_valid(const bUserExtensionRepo *repo)
size_t BKE_preferences_extension_repo_dirpath_get(const bUserExtensionRepo *repo, char *dirpath, int dirpath_maxncpy)
size_t BKE_preferences_extension_repo_user_dirpath_get(const bUserExtensionRepo *repo, char *dirpath, const int dirpath_maxncpy)
int BKE_preferences_extension_repo_remote_scheme_end(const char *url)
bUserExtensionRepo * BKE_preferences_extension_repo_add(UserDef *userdef, const char *name, const char *module, const char *custom_dirpath)
struct bUserAssetLibrary * BKE_preferences_asset_library_add(struct UserDef *userdef, const char *name, const char *dirpath) ATTR_NONNULL(1)
void BKE_preferences_extension_repo_remove(UserDef *userdef, bUserExtensionRepo *repo)
void BKE_preferences_asset_library_remove(struct UserDef *userdef, struct bUserAssetLibrary *library) ATTR_NONNULL()
void BKE_preferences_extension_remote_to_name(const char *remote_url, char name[64])
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
#define BLI_assert_unreachable()
File and directory operations.
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_listbase_count(const ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void void void BLI_path_split_file_part(const char *filepath, char *file, size_t file_maxncpy) ATTR_NONNULL(1
void BLI_path_slash_rstrip(char *path) ATTR_NONNULL(1)
const char * BLI_path_extension(const char *filepath) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
#define STRNCPY_UTF8(dst, src)
Compatibility-like things for windows.
const char * dirname(char *path)
bool BLI_windows_is_store_install(void)
@ USER_REGISTER_ALL_USERS
@ USER_EXTENSION_REPO_SOURCE_SYSTEM
@ USER_EXTENSION_REPO_FLAG_USE_ACCESS_TOKEN
@ USER_EXTENSION_REPO_FLAG_USE_CUSTOM_DIRECTORY
@ USER_EXTENSION_REPO_FLAG_SYNC_ON_STARTUP
@ USER_EXTENSION_REPO_FLAG_USE_REMOTE_URL
Read Guarded memory(de)allocation.
void UI_style_init_default()
void UI_theme_init_default()
#define ND_SPACE_ASSET_PARAMS
void * MEM_callocN(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void clear_all_library(const bContext *C)
static struct PyModuleDef module
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
const char * RNA_property_ui_description_raw(const PropertyRNA *prop)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
int RNA_int_get(PointerRNA *ptr, const char *name)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
int RNA_string_length(PointerRNA *ptr, const char *name)
std::string RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
const char * RNA_property_ui_name_raw(const PropertyRNA *prop, const PointerRNA *ptr)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
PropertyRNA * RNA_def_string_dir_path(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
char custom_dirpath[1024]
void use_property_decorate_set(bool is_sep)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
uiLayout & row(bool align)
void use_property_split_set(bool value)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
struct ReportList * reports
static bool associate_blend_poll(bContext *C)
static bool preferences_asset_library_remove_poll(bContext *C)
static bool preferences_extension_repo_remove_poll(bContext *C)
static wmOperatorStatus unassociate_blend_exec(bContext *, wmOperator *op)
static bool drop_extension_path_poll(bContext *, wmDrag *drag, const wmEvent *)
static void PREFERENCES_OT_associate_blend(wmOperatorType *ot)
static void PREFERENCES_OT_extension_repo_remove(wmOperatorType *ot)
static wmOperatorStatus preferences_extension_repo_remove_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus preferences_extension_url_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void drop_extension_url_copy(bContext *, wmDrag *drag, wmDropBox *drop)
static void PREFERENCES_OT_extension_url_drop(wmOperatorType *ot)
static void PREFERENCES_OT_reset_default_theme(wmOperatorType *ot)
static void drop_extension_path_copy(bContext *, wmDrag *drag, wmDropBox *drop)
static wmOperatorStatus associate_blend_exec(bContext *, wmOperator *op)
static wmOperatorStatus preferences_asset_library_add_invoke(bContext *C, wmOperator *op, const wmEvent *)
bUserExtensionRepoAddType
static wmOperatorStatus preferences_autoexec_remove_exec(bContext *, wmOperator *op)
static void PREFERENCES_OT_unassociate_blend(wmOperatorType *ot)
void ED_operatortypes_userpref()
static wmOperatorStatus preferences_autoexec_add_exec(bContext *, wmOperator *)
static wmOperatorStatus preferences_reset_default_theme_exec(bContext *C, wmOperator *)
static wmOperatorStatus preferences_extension_repo_add_exec(bContext *C, wmOperator *op)
static void preferences_extension_repo_add_ui(bContext *, wmOperator *op)
static const char * preferences_extension_repo_default_name_from_type(const bUserExtensionRepoAddType repo_type)
static wmOperatorStatus preferences_asset_library_remove_exec(bContext *C, wmOperator *op)
static void ED_dropbox_drop_extension()
static bool associate_blend(bool do_register, bool all_users, char **r_error_msg)
static void PREFERENCES_OT_asset_library_remove(wmOperatorType *ot)
static wmOperatorStatus preferences_extension_repo_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus preferences_asset_library_add_exec(bContext *C, wmOperator *op)
static void PREFERENCES_OT_autoexec_path_remove(wmOperatorType *ot)
static void PREFERENCES_OT_autoexec_path_add(wmOperatorType *ot)
static bool drop_extension_url_poll(bContext *, wmDrag *drag, const wmEvent *)
static void PREFERENCES_OT_asset_library_add(wmOperatorType *ot)
static void PREFERENCES_OT_extension_repo_add(wmOperatorType *ot)
static wmOperatorStatus preferences_extension_repo_remove_exec(bContext *C, wmOperator *op)
void WM_cursor_wait(bool val)
wmDropBox * WM_dropbox_add(ListBase *lb, const char *idname, bool(*poll)(bContext *C, wmDrag *drag, const wmEvent *event), void(*copy)(bContext *C, wmDrag *drag, wmDropBox *drop), void(*cancel)(Main *bmain, wmDrag *drag, wmDropBox *drop), WMDropboxTooltipFunc tooltip)
const std::string & WM_drag_get_string(const wmDrag *drag)
const char * WM_drag_get_single_path(const wmDrag *drag)
ListBase * WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, blender::wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_reinit_gizmomap_all(Main *bmain)
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, int icon, bool cancel_default)
void WM_operator_properties_free(PointerRNA *ptr)
wmOperatorStatus WM_operator_props_popup_confirm_ex(bContext *C, wmOperator *op, const wmEvent *, std::optional< std::string > title, std::optional< std::string > confirm_text, const bool cancel_default, std::optional< std::string > message)