10#include <fmt/format.h>
36#include "RNA_prototypes.hh"
60 U.runtime.is_dirty =
true;
67 ot->name =
"Reset to Default Theme";
68 ot->idname =
"PREFERENCES_OT_reset_default_theme";
69 ot->description =
"Reset to the default theme colors";
88 U.runtime.is_dirty =
true;
94 ot->name =
"Add Auto-Execution Path";
95 ot->idname =
"PREFERENCES_OT_autoexec_path_add";
96 ot->description =
"Add path to exclude from auto-execution";
115 U.runtime.is_dirty =
true;
122 ot->name =
"Remove Auto-Execution Path";
123 ot->idname =
"PREFERENCES_OT_autoexec_path_remove";
124 ot->description =
"Remove path to exclude from auto-execution";
130 RNA_def_int(
ot->srna,
"index", 0, 0, INT_MAX,
"Index",
"", 0, 1000);
150 U.active_asset_library =
BLI_findindex(&
U.asset_libraries, new_library);
151 U.runtime.is_dirty =
true;
175 ot->name =
"Add Asset Library";
176 ot->idname =
"PREFERENCES_OT_asset_library_add";
177 ot->description =
"Add a directory to be used by the Asset Browser as source of assets";
220 CLAMP(
U.active_asset_library, 0, count_remaining - 1);
221 U.runtime.is_dirty =
true;
232 ot->name =
"Remove Asset Library";
233 ot->idname =
"PREFERENCES_OT_asset_library_remove";
235 "Remove a path to a .blend file, so the Asset Browser will not attempt to show it anymore";
242 RNA_def_int(
ot->srna,
"index", 0, 0, INT_MAX,
"Index",
"", 0, 1000);
261 return "Remote Repository";
264 return "User Repository";
281 char *access_token =
nullptr;
287 if (use_custom_directory) {
295 if (use_access_token) {
314 if (name[0] ==
'\0') {
321 if (use_custom_directory) {
330 if (name[0] ==
'\0') {
342 for (
i = 0; module_buf[
i];
i++) {
343 if (
ELEM(module_buf[
i],
'.',
'-',
'/',
'\\')) {
348 while ((
i > 0) && (module_buf[--
i] ==
'_')) {
349 module_buf[
i] =
'\0';
355 &
U, name,
module, custom_directory);
357 if (use_sync_on_startup) {
360 if (use_custom_directory) {
368 if (use_access_token) {
378 U.runtime.is_dirty =
true;
382 nullptr, &RNA_UserExtensionRepo, new_repo);
414 name_default =
nullptr;
420 C, op, event,
IFACE_(
"Add New Extension Repository"),
IFACE_(
"Create"));
470 ot->name =
"Add Extension Repository";
471 ot->idname =
"PREFERENCES_OT_extension_repo_add";
472 ot->description =
"Add a new repository used to store extensions";
484 "Add Remote Repository",
485 "Add a repository referencing a remote repository "
486 "with support for listing and updating extensions"},
490 "Add Local Repository",
491 "Add a repository managed manually without referencing an external repository"},
492 {0,
nullptr, 0,
nullptr,
nullptr},
506 StructRNA *type_ref = &RNA_UserExtensionRepo;
509 const char *prop_id =
"name";
521 const char *prop_id =
"remote_url";
533 const char *prop_id =
"use_access_token";
544 const char *prop_id =
"access_token";
557 const char *prop_id =
"use_sync_on_startup";
568 const char *prop_id =
"use_custom_directory";
579 const char *prop_id =
"custom_directory";
591 ot->srna,
"type", repo_type_items, 0,
"Type",
"The kind of repository to add");
626 remove_files =
false;
638 if (dirpath[0] || user_dirpath[0]) {
639 message =
IFACE_(
"Remove all files in:");
640 const char *paths[] = {dirpath, user_dirpath};
642 if (paths[
i][0] ==
'\0') {
645 message.append(fmt::format(
"\n\"{}\"", paths[
i]));
649 message =
IFACE_(
"Remove, local files not found.");
650 remove_files =
false;
654 message =
IFACE_(
"Remove, keeping local files.");
657 const char *confirm_text = remove_files ?
IFACE_(
"Remove Repository & Files") :
658 IFACE_(
"Remove Repository");
682 remove_files =
false;
692 "Unable to remove files, the module name \"%.*s\" is invalid and "
693 "could remove non-repository files",
694 int(
sizeof(repo->
module)),
696 remove_files =
false;
720 if (
BLI_delete(dirpath,
true, recursive) != 0) {
723 "Unable to remove directory: %s",
724 errno ? strerror(errno) :
"unknown");
733 "Unable to remove directory: %s",
734 errno ? strerror(errno) :
"unknown");
742 CLAMP(
U.active_extension_repo, 0, count_remaining - 1);
743 U.runtime.is_dirty =
true;
755 ot->name =
"Remove Extension Repository";
756 ot->idname =
"PREFERENCES_OT_extension_repo_remove";
757 ot->description =
"Remove an extension repository";
766 prop =
RNA_def_int(
ot->srna,
"index", 0, 0, INT_MAX,
"Index",
"", 0, 1000);
772 "Remove extension files when removing the repository");
787 const bool url_is_file =
STRPREFIX(url,
"file://");
789 const bool url_is_remote = url_is_file | url_is_online;
793 const char *idname_external = url_is_remote ?
"extensions.package_install" :
794 "extensions.package_install_files";
798 idname_external =
"extensions.userpref_allow_online_popup";
825 ot->name =
"Drop Extension URL";
826 ot->description =
"Handle dropping an extension URL";
827 ot->idname =
"PREFERENCES_OT_extension_url_drop";
832 RNA_def_string(
ot->srna,
"url",
nullptr, 0,
"URL",
"Location of the extension to install");
849#elif defined(__APPLE__)
858#if !defined(__APPLE__)
865 (all_users ==
false))
867 const char *msg = do_register ?
"Unable to register file association" :
868 "Unable to unregister file association";
869 MessageBox(0, msg,
"Blender", MB_OK | MB_ICONERROR);
887 op->
reports,
RPT_ERROR,
"Registration not possible from Microsoft Store installations");
893 char *error_msg =
nullptr;
901 op->
reports,
RPT_ERROR, error_msg ? error_msg :
"Unable to register file association");
916 ot->name =
"Register File Association";
917 ot->description =
"Use this installation for .blend files and to display thumbnails";
918 ot->idname =
"PREFERENCES_OT_associate_blend";
935 op->
reports,
RPT_ERROR,
"Unregistration not possible from Microsoft Store installations");
941 char *error_msg =
nullptr;
949 op->
reports,
RPT_ERROR, error_msg ? error_msg :
"Unable to unregister file association");
964 ot->name =
"Remove File Association";
965 ot->description =
"Remove this installation's associations with .blend files";
966 ot->idname =
"PREFERENCES_OT_unassociate_blend";
993 const char *cstr =
str.c_str();
999 if (
str.find(
'\n') != std::string::npos) {
1003 bool has_known_extension =
false;
1008 std::string str_strip;
1009 const char *cstr_maybe_copy = cstr;
1010 size_t param_char =
str.find(
'?');
1011 if (param_char != std::string::npos) {
1012 str_strip =
str.substr(0, param_char);
1013 cstr_maybe_copy = str_strip.c_str();
1017 if (cstr_ext &&
STRCASEEQ(cstr_ext,
".zip")) {
1018 has_known_extension =
true;
1024 if (!has_known_extension &&
1054 if (!(cstr_ext &&
STRCASEEQ(cstr_ext,
".zip"))) {
1074 "PREFERENCES_OT_extension_url_drop",
1080 "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
char * STRNCPY(char(&dst)[N], const char *src)
#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()
void uiLayoutSetActive(uiLayout *layout, bool active)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
#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
const char * RNA_property_ui_name_raw(const PropertyRNA *prop)
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)
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
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)
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)
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 separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
uiLayout & row(bool align)
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)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
void WM_main_add_notifier(uint type, void *reference)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
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)
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)
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)