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";
89 U.runtime.is_dirty =
true;
95 ot->
name =
"Add Auto-Execution Path";
96 ot->
idname =
"PREFERENCES_OT_autoexec_path_add";
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";
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";
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';
356 &
U, name,
module, custom_directory);
358 if (use_sync_on_startup) {
361 if (use_custom_directory) {
369 if (use_access_token) {
379 U.runtime.is_dirty =
true;
412 name_default =
nullptr;
418 C, op, event,
IFACE_(
"Add New Extension Repository"),
IFACE_(
"Create"));
468 ot->
name =
"Add Extension Repository";
469 ot->
idname =
"PREFERENCES_OT_extension_repo_add";
470 ot->
description =
"Add a new repository used to store extensions";
482 "Add Remote Repository",
483 "Add a repository referencing an remote repository "
484 "with support for listing and updating extensions"},
488 "Add Local Repository",
489 "Add a repository managed manually without referencing an external repository"},
490 {0,
nullptr, 0,
nullptr,
nullptr},
504 StructRNA *type_ref = &RNA_UserExtensionRepo;
507 const char *prop_id =
"name";
519 const char *prop_id =
"remote_url";
531 const char *prop_id =
"use_access_token";
542 const char *prop_id =
"access_token";
555 const char *prop_id =
"use_sync_on_startup";
566 const char *prop_id =
"use_custom_directory";
577 const char *prop_id =
"custom_directory";
589 ot->
srna,
"type", repo_type_items, 0,
"Type",
"The kind of repository to add");
624 remove_files =
false;
636 if (dirpath[0] || user_dirpath[0]) {
637 message =
IFACE_(
"Remove all files in:");
638 const char *paths[] = {dirpath, user_dirpath};
640 if (paths[i][0] ==
'\0') {
643 message.append(fmt::format(
"\n\"{}\"", paths[i]));
647 message =
IFACE_(
"Remove, local files not found.");
648 remove_files =
false;
652 message =
IFACE_(
"Remove, keeping local files.");
655 const char *confirm_text = remove_files ?
IFACE_(
"Remove Repository & Files") :
656 IFACE_(
"Remove Repository");
680 remove_files =
false;
690 "Unable to remove files, the module name \"%.*s\" is invalid and "
691 "could remove non-repository files",
692 int(
sizeof(repo->
module)),
694 remove_files =
false;
718 if (
BLI_delete(dirpath,
true, recursive) != 0) {
721 "Unable to remove directory: %s",
722 errno ? strerror(errno) :
"unknown");
731 "Unable to remove directory: %s",
732 errno ? strerror(errno) :
"unknown");
740 CLAMP(
U.active_extension_repo, 0, count_remaining - 1);
741 U.runtime.is_dirty =
true;
753 ot->
name =
"Remove Extension Repository";
754 ot->
idname =
"PREFERENCES_OT_extension_repo_remove";
770 "Remove extension files when removing the repository");
783 const bool url_is_file =
STRPREFIX(url,
"file://");
785 const bool url_is_remote = url_is_file | url_is_online;
789 const char *idname_external = url_is_remote ?
"extensions.package_install" :
790 "extensions.package_install_files";
794 idname_external =
"extensions.userpref_allow_online_popup";
821 ot->
name =
"Drop Extension URL";
823 ot->
idname =
"PREFERENCES_OT_extension_url_drop";
845#elif defined(__APPLE__)
854#if !defined(__APPLE__)
859 if ((result ==
false) &&
861 (all_users ==
false))
863 const char *msg = do_register ?
"Unable to register file association" :
864 "Unable to unregister file association";
865 MessageBox(0, msg,
"Blender", MB_OK | MB_ICONERROR);
883 op->
reports,
RPT_ERROR,
"Registration not possible from Microsoft Store installations");
889 char *error_msg =
nullptr;
897 op->
reports,
RPT_ERROR, error_msg ? error_msg :
"Unable to register file association");
912 ot->
name =
"Register File Association";
913 ot->
description =
"Use this installation for .blend files and to display thumbnails";
914 ot->
idname =
"PREFERENCES_OT_associate_blend";
931 op->
reports,
RPT_ERROR,
"Unregistration not possible from Microsoft Store installations");
937 char *error_msg =
nullptr;
945 op->
reports,
RPT_ERROR, error_msg ? error_msg :
"Unable to unregister file association");
960 ot->
name =
"Remove File Association";
961 ot->
description =
"Remove this installation's associations with .blend files";
962 ot->
idname =
"PREFERENCES_OT_unassociate_blend";
989 const char *cstr =
str.c_str();
995 if (
str.find(
'\n') != std::string::npos) {
999 bool has_known_extension =
false;
1004 std::string str_strip;
1005 const char *cstr_maybe_copy = cstr;
1006 size_t param_char =
str.find(
'?');
1007 if (param_char != std::string::npos) {
1008 str_strip =
str.substr(0, param_char);
1009 cstr_maybe_copy = str_strip.c_str();
1013 if (cstr_ext &&
STRCASEEQ(cstr_ext,
".zip")) {
1014 has_known_extension =
true;
1020 if (!has_known_extension &&
1050 if (!(cstr_ext &&
STRCASEEQ(cstr_ext,
".zip"))) {
1070 "PREFERENCES_OT_extension_url_drop",
1076 "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()
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct 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(dst, 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 uiLayoutSetActive(uiLayout *layout, bool active)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
uiLayout * uiLayoutRowWithHeading(uiLayout *layout, bool align, const char *heading)
void uiItemS_ex(uiLayout *layout, float factor, LayoutSeparatorType type=LayoutSeparatorType::Auto)
void UI_style_init_default()
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
void UI_theme_init_default()
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
#define ND_SPACE_ASSET_PARAMS
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
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(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]
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* ui)(bContext *C, wmOperator *op)
struct ReportList * reports
static bool associate_blend_poll(bContext *C)
static bool preferences_asset_library_remove_poll(bContext *C)
static int associate_blend_exec(bContext *, wmOperator *op)
static bool preferences_extension_repo_remove_poll(bContext *C)
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 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 int preferences_asset_library_add_exec(bContext *C, wmOperator *op)
bUserExtensionRepoAddType
static void PREFERENCES_OT_unassociate_blend(wmOperatorType *ot)
static int preferences_asset_library_remove_exec(bContext *C, wmOperator *op)
void ED_operatortypes_userpref()
static int preferences_autoexec_remove_exec(bContext *, wmOperator *op)
static int preferences_reset_default_theme_exec(bContext *C, wmOperator *)
static int preferences_extension_repo_remove_invoke(bContext *C, wmOperator *op, const wmEvent *)
static int unassociate_blend_exec(bContext *, 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 int preferences_extension_repo_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void ED_dropbox_drop_extension()
static int preferences_extension_url_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool associate_blend(bool do_register, bool all_users, char **r_error_msg)
static void PREFERENCES_OT_asset_library_remove(wmOperatorType *ot)
static int preferences_autoexec_add_exec(bContext *, wmOperator *)
static int preferences_asset_library_add_invoke(bContext *C, wmOperator *op, const wmEvent *)
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 int preferences_extension_repo_add_exec(bContext *C, wmOperator *op)
static void PREFERENCES_OT_asset_library_add(wmOperatorType *ot)
static void PREFERENCES_OT_extension_repo_add(wmOperatorType *ot)
static int 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)
int 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)
int WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, int icon, bool cancel_default)
int 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)
void WM_operator_properties_free(PointerRNA *ptr)