Blender V5.3
userpref_ops.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstring>
10#include <fmt/format.h>
11
12#include "AS_remote_library.hh"
13
14#include "DNA_screen_types.h"
15#include "DNA_space_types.h"
16
17#include "BLI_listbase.hh"
18#ifdef WIN32
19# include "BLI_winstuff.hh"
20#endif
21#include "BLI_fileops.hh"
22#include "BLI_path_utils.hh"
23#include "BLI_string.hh"
24#include "BLI_string_utf8.hh"
25
26#include "BKE_callbacks.hh"
27#include "BKE_context.hh"
28#include "BKE_global.hh"
29#include "BKE_main.hh"
30#include "BKE_preferences.h"
31#include "BKE_screen.hh"
32
33#include "BKE_report.hh"
34
35#include "BLT_translation.hh"
36
37#include "RNA_access.hh"
38#include "RNA_define.hh"
39#include "RNA_prototypes.hh"
40#include "RNA_types.hh"
41
42#include "UI_interface.hh"
44
45#include "WM_api.hh"
46#include "WM_types.hh"
47
48#include "ED_asset.hh"
49#include "ED_screen.hh"
50#include "ED_userpref.hh"
51
52#include "MEM_guardedalloc.h"
53
54#include "userpref_intern.hh"
55
56namespace blender {
57
58/* -------------------------------------------------------------------- */
61
73
75{
76 /* identifiers */
77 ot->name = "Reset to Default Theme";
78 ot->idname = "PREFERENCES_OT_reset_default_theme";
79 ot->description = "Reset to the default theme colors";
80
81 /* callbacks */
83
84 /* flags */
86}
87
89
90/* -------------------------------------------------------------------- */
93
95{
96 bPathCompare *path_cmp = MEM_new<bPathCompare>("bPathCompare");
97 BLI_addtail(&U.autoexec_paths, path_cmp);
98 U.runtime.is_dirty = true;
99 return OPERATOR_FINISHED;
100}
101
103{
104 ot->name = "Add Auto-Execution Path";
105 ot->idname = "PREFERENCES_OT_autoexec_path_add";
106 ot->description = "Add path to exclude from auto-execution";
107
109
110 ot->flag = OPTYPE_INTERNAL;
111}
112
114
115/* -------------------------------------------------------------------- */
118
120{
121 const int index = RNA_int_get(op->ptr, "index");
122 bPathCompare *path_cmp = static_cast<bPathCompare *>(BLI_findlink(&U.autoexec_paths, index));
123 if (path_cmp) {
124 BLI_freelinkN(&U.autoexec_paths, path_cmp);
125 U.runtime.is_dirty = true;
126 }
127 return OPERATOR_FINISHED;
128}
129
131{
132 ot->name = "Remove Auto-Execution Path";
133 ot->idname = "PREFERENCES_OT_autoexec_path_remove";
134 ot->description = "Remove path to exclude from auto-execution";
135
137
138 ot->flag = OPTYPE_INTERNAL;
139
140 RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
141}
142
144
145/* -------------------------------------------------------------------- */
148
150{
152 RNA_enum_get(op->ptr, "type"));
153
154 char name[sizeof(bUserAssetLibrary::name)] = "";
155 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "name");
156 if (RNA_property_is_set(op->ptr, prop)) {
157 RNA_property_string_get(op->ptr, prop, name);
158 }
159
160 switch (library_type) {
162 char *dirpath = RNA_string_get_alloc(op->ptr, "directory", nullptr, 0, nullptr);
163 ED_userpref_asset_library_new(C, name, dirpath, library_type, false, {}, {});
164 MEM_delete(dirpath);
165 break;
166 }
168 char *remote_url = RNA_string_get_alloc(op->ptr, "remote_url", nullptr, 0, nullptr);
169 char *auth_token_str = RNA_string_get_alloc(op->ptr, "auth_token", nullptr, 0, nullptr);
170 const bool use_auth_token = RNA_boolean_get(op->ptr, "use_auth_token");
171 std::optional<char *> auth_token = {};
172 if (use_auth_token) {
173 auth_token = auth_token_str;
174 }
175 ED_userpref_asset_library_new(C, name, remote_url, library_type, false, {}, auth_token);
176 MEM_delete(remote_url);
177 MEM_delete(auth_token_str);
178 break;
179 }
180 }
181
182 U.runtime.is_dirty = true;
183 return OPERATOR_FINISHED;
184}
185
187 wmOperator *op,
188 const wmEvent *event)
189{
191 RNA_enum_get(op->ptr, "type"));
192
193 if ((library_type == bUserAssetLibraryAddType::Local) &&
194 !RNA_struct_property_is_set(op->ptr, "directory"))
195 {
198 }
199
201 C, op, event, IFACE_("Add Asset Library"), IFACE_("Create"));
202}
203
205{
206 blender::ui::Layout *layout = op->layout;
207 layout->use_property_split_set(true);
208 layout->use_property_decorate_set(false);
209
210 PointerRNA *ptr = op->ptr;
212 RNA_enum_get(ptr, "type"));
213 switch (library_type) {
215 layout->prop(op->ptr, "remote_url", ui::ITEM_R_IMMEDIATE, std::nullopt, ICON_NONE);
216
217 const bool use_auth_token = RNA_boolean_get(ptr, "use_auth_token");
218 const int token_icon = (use_auth_token && RNA_string_length(ptr, "auth_token")) ?
219 ICON_LOCKED :
220 ICON_UNLOCKED;
221
222 ui::Layout &col = layout->column(true, IFACE_("Authentication"));
223 col.prop(ptr, "use_auth_token", UI_ITEM_NONE, std::nullopt, ICON_NONE);
224 if (use_auth_token) {
225 ui::Layout &row = col.row(false);
226 /* Use "immediate" flag to refresh the icon. */
227 row.prop(ptr, "auth_token", ui::ITEM_R_IMMEDIATE, IFACE_("Secret"), token_icon);
228 }
229 break;
230 }
232 layout->prop(op->ptr, "name", ui::ITEM_R_IMMEDIATE, std::nullopt, ICON_NONE);
233 break;
234 }
235 }
236}
237
239 PointerRNA * /*ptr*/,
240 PropertyRNA * /*prop*/,
241 bool *r_free)
242{
243 *r_free = false;
244
245 if (USER_EXPERIMENTAL_TEST(&U, use_remote_asset_libraries)) {
246 /* Experimental flag is enabled, just return all items. */
248 }
249
250 /* Since the Remote item is the first in the list, we can just return a pointer to
251 * the 2nd item in the list, when remote asset libraries should be hidden. */
253 return custom_library_type_items + 1;
254}
255
257{
258 ot->name = "Add Asset Library";
259 ot->idname = "PREFERENCES_OT_asset_library_add";
260 ot->description = "Add a directory to be used by the Asset Browser as source of assets";
261
265
267
275
276 /* Copy the RNA values are copied into the operator to avoid repetition. */
277 StructRNA *type_ref = RNA_UserAssetLibrary;
278
279 { /* Name. */
280 const char *prop_id = "name";
281 const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
282 PropertyRNA *prop = RNA_def_string(ot->srna,
283 prop_id,
284 nullptr,
286 RNA_property_ui_name_raw(prop_ref),
289 }
290
291 { /* Remote Path. */
292 const char *prop_id = "remote_url";
293 const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
294 PropertyRNA *prop = RNA_def_string(ot->srna,
295 prop_id,
296 nullptr,
298 RNA_property_ui_name_raw(prop_ref),
301 }
302 { /* Use Authentication Token. */
303 const char *prop_id = "use_auth_token";
304 const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
305 PropertyRNA *prop = RNA_def_boolean(ot->srna,
306 prop_id,
307 false,
308 RNA_property_ui_name_raw(prop_ref),
311 }
312 { /* Authentication Token (dynamic length). */
313 const char *prop_id = "auth_token";
314 const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
315 PropertyRNA *prop = RNA_def_string(ot->srna,
316 prop_id,
317 nullptr,
318 0,
319 RNA_property_ui_name_raw(prop_ref),
323 }
324
325 ot->prop = RNA_def_enum(ot->srna,
326 "type",
329 "Type",
330 "The kind of asset library to add");
333}
334
336
337/* -------------------------------------------------------------------- */
340
342{
343 if (U.asset_libraries.is_empty()) {
344 CTX_wm_operator_poll_msg_set(C, "There is no asset library to remove");
345 return false;
346 }
347 return true;
348}
349
351{
352 const int index = RNA_int_get(op->ptr, "index");
354 BLI_findlink(&U.asset_libraries, index));
355 if (!library) {
356 return OPERATOR_CANCELLED;
357 }
358 if (library->extension_id[0]) {
360 op->reports,
361 RPT_ERROR,
362 "Asset libraries defined by an extension are removed by uninstalling the extension");
363 return OPERATOR_CANCELLED;
364 }
365
367 U.runtime.is_dirty = true;
368
369 return OPERATOR_FINISHED;
370}
371
373{
374 ot->name = "Remove Asset Library";
375 ot->idname = "PREFERENCES_OT_asset_library_remove";
376 ot->description =
377 "Remove a path to a .blend file, so the Asset Browser will not attempt to show it anymore";
378
381
382 ot->flag = OPTYPE_INTERNAL;
383
384 RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
385}
386
388
389/* -------------------------------------------------------------------- */
392
395 Local = 1,
396};
397
399 const bUserExtensionRepoAddType repo_type)
400{
401 switch (repo_type) {
403 return "Remote Repository";
404 }
406 return "User Repository";
407 }
408 }
410 return "";
411}
412
414{
416 RNA_enum_get(op->ptr, "type"));
417
418 Main *bmain = CTX_data_main(C);
420
421 char name[sizeof(bUserExtensionRepo::name)] = "";
422 char remote_url[sizeof(bUserExtensionRepo::remote_url)] = "";
423 char *access_token = nullptr;
424 char custom_directory[sizeof(bUserExtensionRepo::custom_dirpath)] = "";
425
426 const bool use_custom_directory = RNA_boolean_get(op->ptr, "use_custom_directory");
427 const bool use_access_token = RNA_boolean_get(op->ptr, "use_access_token");
428 const bool use_sync_on_startup = RNA_boolean_get(op->ptr, "use_sync_on_startup");
429 if (use_custom_directory) {
430 RNA_string_get(op->ptr, "custom_directory", custom_directory);
431 BLI_path_slash_rstrip(custom_directory);
432 }
433
434 if (repo_type == bUserExtensionRepoAddType::Remote) {
435 RNA_string_get(op->ptr, "remote_url", remote_url);
436
437 if (use_access_token) {
438 if (RNA_string_length(op->ptr, "access_token")) {
439 access_token = RNA_string_get_alloc(op->ptr, "access_token", nullptr, 0, nullptr);
440 }
441 }
442 }
443
444 /* Setup the name using the following logic:
445 * - It has been set so leave as-is.
446 * - Initialize it based on the URL (default for remote repositories).
447 * - Use a default name as a fallback.
448 */
449 {
450 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "name");
451 if (RNA_property_is_set(op->ptr, prop)) {
452 RNA_property_string_get(op->ptr, prop, name);
453 }
454
455 /* Unset or empty, auto-name based on remote URL or local directory. */
456 if (name[0] == '\0') {
457 switch (repo_type) {
459 BKE_preferences_remote_to_name(remote_url, name);
460 break;
461 }
463 if (use_custom_directory) {
464 const char *custom_directory_basename = BLI_path_basename(custom_directory);
465 STRNCPY_UTF8(name, custom_directory_basename);
467 }
468 break;
469 }
470 }
471 }
472 if (name[0] == '\0') {
474 }
475 }
476
477 const char *module = custom_directory[0] ? BLI_path_basename(custom_directory) : name;
478 /* Not essential but results in more readable module names.
479 * Otherwise URL's have their '.' removed, making for quite unreadable module names. */
480 char module_buf[FILE_MAX];
481 {
482 STRNCPY_UTF8(module_buf, module);
483 int i;
484 for (i = 0; module_buf[i]; i++) {
485 if (ELEM(module_buf[i], '.', '-', '/', '\\')) {
486 module_buf[i] = '_';
487 }
488 }
489 /* Strip any trailing underscores. */
490 while ((i > 0) && (module_buf[--i] == '_')) {
491 module_buf[i] = '\0';
492 }
493 module = module_buf;
494 }
495
497 &U, name, module, custom_directory);
498
499 if (use_sync_on_startup) {
501 }
502 if (use_custom_directory) {
504 }
505
506 if (repo_type == bUserExtensionRepoAddType::Remote) {
507 STRNCPY_UTF8(new_repo->remote_url, remote_url);
509
510 if (use_access_token) {
512 }
513 if (access_token) {
514 new_repo->access_token = access_token;
515 }
516 }
517
518 /* Activate new repository in the UI for further setup. */
519 U.active_extension_repo = BLI_findindex(&U.extension_repos, new_repo);
520 U.runtime.is_dirty = true;
521
522 {
524 nullptr, RNA_UserExtensionRepo, new_repo);
525 PointerRNA *pointers[] = {&new_repo_ptr};
526
529 }
530
531 /* There's no dedicated notifier for the Preferences. */
533
534 /* Mainly useful when adding a repository from a popup since it's not as obvious
535 * the repository was added compared to the repository popover. */
537 RPT_INFO,
538 "Added %s \"%s\"",
540 new_repo->name);
541
542 return OPERATOR_FINISHED;
543}
544
546 wmOperator *op,
547 const wmEvent *event)
548{
550 RNA_enum_get(op->ptr, "type"));
551 PropertyRNA *prop_name = RNA_struct_find_property(op->ptr, "name");
552 if (!RNA_property_is_set(op->ptr, prop_name)) {
553 const char *name_default = preferences_extension_repo_default_name_from_type(repo_type);
554 /* Leave unset, let this be set by the URL. */
555 if (repo_type == bUserExtensionRepoAddType::Remote) {
556 name_default = nullptr;
557 }
558 RNA_property_string_set(op->ptr, prop_name, name_default);
559 }
560
562 C, op, event, IFACE_("Add New Extension Repository"), IFACE_("Create"));
563}
564
566{
567
568 ui::Layout &layout = *op->layout;
569 layout.use_property_split_set(true);
570 layout.use_property_decorate_set(false);
571
572 PointerRNA *ptr = op->ptr;
574
575 switch (repo_type) {
577 layout.prop(op->ptr, "remote_url", ui::ITEM_R_IMMEDIATE, std::nullopt, ICON_NONE);
578 layout.prop(op->ptr, "use_sync_on_startup", UI_ITEM_NONE, std::nullopt, ICON_NONE);
579
581
582 const bool use_access_token = RNA_boolean_get(ptr, "use_access_token");
583 const int token_icon = (use_access_token && RNA_string_length(op->ptr, "access_token")) ?
584 ICON_LOCKED :
585 ICON_UNLOCKED;
586
587 ui::Layout &row = layout.row(true, IFACE_("Authentication"));
588 row.prop(op->ptr, "use_access_token", UI_ITEM_NONE, std::nullopt, ICON_NONE);
589 if (use_access_token) {
590 ui::Layout &col = layout.row(false);
591 col.active_set(use_access_token);
592 /* Use "immediate" flag to refresh the icon. */
593 col.prop(op->ptr, "access_token", ui::ITEM_R_IMMEDIATE, std::nullopt, token_icon);
594 }
596
597 break;
598 }
600 layout.prop(op->ptr, "name", ui::ITEM_R_IMMEDIATE, std::nullopt, ICON_NONE);
601 break;
602 }
603 }
604
605 layout.prop(op->ptr, "use_custom_directory", UI_ITEM_NONE, std::nullopt, ICON_NONE);
606 ui::Layout &col = layout.row(false);
607 col.active_set(RNA_boolean_get(ptr, "use_custom_directory"));
608 col.prop(op->ptr, "custom_directory", UI_ITEM_NONE, std::nullopt, ICON_NONE);
609}
610
612{
613 ot->name = "Add Extension Repository";
614 ot->idname = "PREFERENCES_OT_extension_repo_add";
615 ot->description = "Add a new repository used to store extensions";
616
620
622
623 static const EnumPropertyItem repo_type_items[] = {
625 "REMOTE",
626 ICON_INTERNET,
627 "Add Remote Repository",
628 "Add a repository referencing a remote repository "
629 "with support for listing and updating extensions"},
631 "LOCAL",
632 ICON_DISK_DRIVE,
633 "Add Local Repository",
634 "Add a repository managed manually without referencing an external repository"},
635 {0, nullptr, 0, nullptr, nullptr},
636 };
637
638 /* After creating a new repository some settings can't be easily changed
639 * (especially the custom directory). To avoid showing a partially initialized repository,
640 * set these values upon creation instead of having the user create the repository and change
641 * them afterwards.
642 *
643 * An alternative solution could be implemented by creating an "uninitialized" repository,
644 * setting up all it's properties then running an "initialize" operator however this seems
645 * unnecessarily confusing as in most cases a user can do this in one step by naming and
646 * setting the repositories URL (optionally the custom-directory). */
647
648 /* Copy the RNA values are copied into the operator to avoid repetition. */
649 StructRNA *type_ref = RNA_UserExtensionRepo;
650
651 { /* Name. */
652 const char *prop_id = "name";
653 const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
654 PropertyRNA *prop = RNA_def_string(ot->srna,
655 prop_id,
656 nullptr,
658 RNA_property_ui_name_raw(prop_ref),
661 }
662
663 { /* Remote Path. */
664 const char *prop_id = "remote_url";
665 const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
666 PropertyRNA *prop = RNA_def_string(ot->srna,
667 prop_id,
668 nullptr,
670 RNA_property_ui_name_raw(prop_ref),
673 }
674
675 { /* Use Access Token. */
676 const char *prop_id = "use_access_token";
677 const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
678 PropertyRNA *prop = RNA_def_boolean(ot->srna,
679 prop_id,
680 false,
681 RNA_property_ui_name_raw(prop_ref),
684 }
685
686 { /* Access Token (dynamic length). */
687 const char *prop_id = "access_token";
688 const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
689 PropertyRNA *prop = RNA_def_string(ot->srna,
690 prop_id,
691 nullptr,
692 0,
693 RNA_property_ui_name_raw(prop_ref),
697 }
698
699 { /* Check for Updated on Startup. */
700 const char *prop_id = "use_sync_on_startup";
701 const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
702 PropertyRNA *prop = RNA_def_boolean(ot->srna,
703 prop_id,
704 false,
705 RNA_property_ui_name_raw(prop_ref),
708 }
709
710 { /* Use Custom Directory. */
711 const char *prop_id = "use_custom_directory";
712 const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
713 PropertyRNA *prop = RNA_def_boolean(ot->srna,
714 prop_id,
715 false,
716 RNA_property_ui_name_raw(prop_ref),
719 }
720
721 { /* Custom Directory. */
722 const char *prop_id = "custom_directory";
723 const PropertyRNA *prop_ref = RNA_struct_type_find_property(type_ref, prop_id);
725 prop_id,
726 nullptr,
728 RNA_property_ui_name_raw(prop_ref),
731 }
732
733 ot->prop = RNA_def_enum(
734 ot->srna, "type", repo_type_items, 0, "Type", "The kind of repository to add");
736}
737
739
740/* -------------------------------------------------------------------- */
743
745{
746 if (U.extension_repos.is_empty()) {
747 CTX_wm_operator_poll_msg_set(C, "There is no extension repository to remove");
748 return false;
749 }
750 return true;
751}
752
754 wmOperator *op,
755 const wmEvent * /*event*/)
756{
757 const int index = RNA_int_get(op->ptr, "index");
758 bool remove_files = RNA_boolean_get(op->ptr, "remove_files");
759 const bUserExtensionRepo *repo = static_cast<bUserExtensionRepo *>(
760 BLI_findlink(&U.extension_repos, index));
761
762 if (!repo) {
763 return OPERATOR_CANCELLED;
764 }
765
766 if (remove_files) {
769 remove_files = false;
770 }
771 }
772 }
773
774 std::string message;
775 if (remove_files) {
776 char dirpath[FILE_MAX];
777 char user_dirpath[FILE_MAX];
778 BKE_preferences_extension_repo_dirpath_get(repo, dirpath, sizeof(dirpath));
779 BKE_preferences_extension_repo_user_dirpath_get(repo, user_dirpath, sizeof(user_dirpath));
780
781 if (dirpath[0] || user_dirpath[0]) {
782 message = IFACE_("Remove all files in:");
783 const char *paths[] = {dirpath, user_dirpath};
784 for (int i = 0; i < ARRAY_SIZE(paths); i++) {
785 if (paths[i][0] == '\0') {
786 continue;
787 }
788 message.append(fmt::format("\n\"{}\"", paths[i]));
789 }
790 }
791 else {
792 message = IFACE_("Remove, local files not found.");
793 remove_files = false;
794 }
795 }
796 else {
797 message = IFACE_("Remove, keeping local files.");
798 }
799
800 const char *confirm_text = remove_files ? IFACE_("Remove Repository & Files") :
801 IFACE_("Remove Repository");
802
804 C, op, nullptr, message.c_str(), confirm_text, ui::AlertIcon::Warning, true);
805}
806
808{
809 const int index = RNA_int_get(op->ptr, "index");
810 bool remove_files = RNA_boolean_get(op->ptr, "remove_files");
811 bUserExtensionRepo *repo = static_cast<bUserExtensionRepo *>(
812 BLI_findlink(&U.extension_repos, index));
813 if (!repo) {
814 return OPERATOR_CANCELLED;
815 }
816
817 Main *bmain = CTX_data_main(C);
819
820 if (remove_files) {
823 /* The UI doesn't show this option, if it's accessed disallow it. */
824 BKE_report(op->reports, RPT_WARNING, "Unable to remove files for \"System\" repositories");
825 remove_files = false;
826 }
827 }
828 }
829
830 if (remove_files) {
834 /* Account for it not being null terminated. */
835 "Unable to remove files, the module name \"%.*s\" is invalid and "
836 "could remove non-repository files",
837 int(sizeof(repo->module)),
838 repo->module);
839 remove_files = false;
840 }
841 }
842
843 if (remove_files) {
844 char dirpath[FILE_MAX];
845 BKE_preferences_extension_repo_dirpath_get(repo, dirpath, sizeof(dirpath));
846 if (dirpath[0] && BLI_is_dir(dirpath)) {
847
848 /* Removing custom directories has the potential to remove user data
849 * if users accidentally point this to their home directory or similar.
850 * Even though the UI shows a warning, we better prevent any accidents
851 * caused by recursive removal, see #119481.
852 * Only check custom directories because the non-custom directory is always
853 * a specific location under Blender's local extensions directory. */
854 const bool recursive = (repo->flag & USER_EXTENSION_REPO_FLAG_USE_CUSTOM_DIRECTORY) == 0;
855
856 /* Perform package manager specific clear operations,
857 * needed when `recursive` is false so the empty directory can be removed.
858 * If it's not empty there will be a warning that the directory couldn't be removed.
859 * The user will have to do this manually which is good since unknown files
860 * could be user data. */
862
863 if (BLI_delete(dirpath, true, recursive) != 0) {
866 "Unable to remove directory: %s",
867 errno ? strerror(errno) : "unknown");
868 }
869 }
870
871 BKE_preferences_extension_repo_user_dirpath_get(repo, dirpath, sizeof(dirpath));
872 if (dirpath[0] && BLI_is_dir(dirpath)) {
873 if (BLI_delete(dirpath, true, true) != 0) {
876 "Unable to remove directory: %s",
877 errno ? strerror(errno) : "unknown");
878 }
879 }
880 }
881
883 const int count_remaining = U.extension_repos.count();
884 /* Update active repo index to be in range. */
885 CLAMP(U.active_extension_repo, 0, count_remaining - 1);
886 U.runtime.is_dirty = true;
887
889
890 /* There's no dedicated notifier for the Preferences. */
892
893 return OPERATOR_FINISHED;
894}
895
897{
898 ot->name = "Remove Extension Repository";
899 ot->idname = "PREFERENCES_OT_extension_repo_remove";
900 ot->description = "Remove an extension repository";
901
905
906 ot->flag = OPTYPE_INTERNAL;
907
908 PropertyRNA *prop;
909 prop = RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
911 prop = RNA_def_boolean(ot->srna,
912 "remove_files",
913 false,
914 "Remove Files",
915 "Remove extension files when removing the repository");
917}
918
920
921/* -------------------------------------------------------------------- */
924
926 wmOperator *op,
927 const wmEvent *event)
928{
929 std::string url = RNA_string_get(op->ptr, "url");
930 const bool url_is_file = STRPREFIX(url.c_str(), "file://");
931 const bool url_is_online = STRPREFIX(url.c_str(), "http://") ||
932 STRPREFIX(url.c_str(), "https://");
933 const bool url_is_remote = url_is_file | url_is_online;
934
935 /* NOTE: searching for hard-coded add-on name isn't great.
936 * Needed since #WM_dropbox_add expects the operator to exist on startup. */
937 const char *idname_external = url_is_remote ? "extensions.package_install" :
938 "extensions.package_install_files";
939 bool use_url = true;
940
941 if (url_is_online && (G.f & G_FLAG_INTERNET_ALLOW) == 0) {
942 idname_external = "extensions.userpref_allow_online_popup";
943 use_url = false;
944 }
945
946 wmOperatorType *ot = WM_operatortype_find(idname_external, true);
947 wmOperatorStatus retval;
948 if (ot) {
950 if (use_url) {
951 RNA_string_set(&props_ptr, "url", url.c_str());
952 }
954 WM_operator_properties_free(&props_ptr);
955 retval = OPERATOR_FINISHED;
956 }
957 else {
958 BKE_reportf(op->reports, RPT_ERROR, "Extension operator not found \"%s\"", idname_external);
959 retval = OPERATOR_CANCELLED;
960 }
961 return retval;
962}
963
965{
966 /* identifiers */
967 ot->name = "Drop Extension URL";
968 ot->description = "Handle dropping an extension URL";
969 ot->idname = "PREFERENCES_OT_extension_url_drop";
970
971 /* API callbacks. */
973
974 RNA_def_string(ot->srna, "url", nullptr, 0, "URL", "Location of the extension to install");
975}
976
978
979/* -------------------------------------------------------------------- */
982
984{
985#ifdef WIN32
987 CTX_wm_operator_poll_msg_set(C, "Not available for Microsoft Store installations");
988 return false;
989 }
990 return true;
991#elif defined(__APPLE__)
992 CTX_wm_operator_poll_msg_set(C, "Windows & Linux only operator");
993 return false;
994#else
995 UNUSED_VARS(C);
996 return true;
997#endif
998}
999
1000#if !defined(__APPLE__)
1001static bool associate_blend(bool do_register, bool all_users, char **r_error_msg)
1002{
1003 const bool result = WM_platform_associate_set(do_register, all_users, r_error_msg);
1004# ifdef WIN32
1005 if ((result == false) &&
1006 /* For some reason the message box isn't shown in this case. */
1007 (all_users == false))
1008 {
1009 const char *msg = do_register ? "Unable to register file association" :
1010 "Unable to unregister file association";
1011 MessageBox(0, msg, "Blender", MB_OK | MB_ICONERROR);
1012 }
1013# endif /* !WIN32 */
1014 return result;
1015}
1016#endif
1017
1019{
1020#ifdef __APPLE__
1021 UNUSED_VARS(op);
1023 return OPERATOR_CANCELLED;
1024#else
1025
1026# ifdef WIN32
1028 BKE_report(
1029 op->reports, RPT_ERROR, "Registration not possible from Microsoft Store installations");
1030 return OPERATOR_CANCELLED;
1031 }
1032# endif
1033
1034 const bool all_users = (U.uiflag & USER_REGISTER_ALL_USERS);
1035 char *error_msg = nullptr;
1036
1037 WM_cursor_wait(true);
1038 const bool success = associate_blend(true, all_users, &error_msg);
1039 WM_cursor_wait(false);
1040
1041 if (!success) {
1042 BKE_report(
1043 op->reports, RPT_ERROR, error_msg ? error_msg : "Unable to register file association");
1044 if (error_msg) {
1045 MEM_delete(error_msg);
1046 }
1047 return OPERATOR_CANCELLED;
1048 }
1049 BLI_assert(error_msg == nullptr);
1050 BKE_report(op->reports, RPT_INFO, "File association registered");
1051 return OPERATOR_FINISHED;
1052#endif /* !__APPLE__ */
1053}
1054
1056{
1057 /* identifiers */
1058 ot->name = "Register File Association";
1059 ot->description = "Use this installation for .blend files and to display thumbnails";
1060 ot->idname = "PREFERENCES_OT_associate_blend";
1061
1062 /* API callbacks. */
1065}
1066
1068{
1069#ifdef __APPLE__
1070 UNUSED_VARS(op);
1072 return OPERATOR_CANCELLED;
1073#else
1074# ifdef WIN32
1076 BKE_report(
1077 op->reports, RPT_ERROR, "Unregistration not possible from Microsoft Store installations");
1078 return OPERATOR_CANCELLED;
1079 }
1080# endif
1081
1082 const bool all_users = (U.uiflag & USER_REGISTER_ALL_USERS);
1083 char *error_msg = nullptr;
1084
1085 WM_cursor_wait(true);
1086 bool success = associate_blend(false, all_users, &error_msg);
1087 WM_cursor_wait(false);
1088
1089 if (!success) {
1090 BKE_report(
1091 op->reports, RPT_ERROR, error_msg ? error_msg : "Unable to unregister file association");
1092 if (error_msg) {
1093 MEM_delete(error_msg);
1094 }
1095 return OPERATOR_CANCELLED;
1096 }
1097 BLI_assert(error_msg == nullptr);
1098 BKE_report(op->reports, RPT_INFO, "File association unregistered");
1099 return OPERATOR_FINISHED;
1100#endif /* !__APPLE__ */
1101}
1102
1104{
1105 /* identifiers */
1106 ot->name = "Remove File Association";
1107 ot->description = "Remove this installation's associations with .blend files";
1108 ot->idname = "PREFERENCES_OT_unassociate_blend";
1109
1110 /* API callbacks. */
1113}
1114
1116
1117/* -------------------------------------------------------------------- */
1120
1121static bool drop_extension_url_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/)
1122{
1123 if (drag->type != WM_DRAG_STRING) {
1124 return false;
1125 }
1126
1127 /* NOTE(@ideasman42): it should be possible to drag a URL into the text editor or Python console.
1128 * In the future we may support dragging images into Blender by URL, so treating any single-line
1129 * URL as an extension could back-fire. Avoid problems in the future by limiting the text which
1130 * is accepted as an extension to ZIP's or URL's that reference known repositories. */
1131
1132 const std::string &str = WM_drag_get_string(drag);
1133
1134 /* Only URL formatted text. */
1135 const char *cstr = str.c_str();
1136 if (BKE_preferences_remote_scheme_end(cstr) == 0) {
1137 return false;
1138 }
1139
1140 /* Only single line strings. */
1141 if (str.find('\n') != std::string::npos) {
1142 return false;
1143 }
1144
1145 bool has_known_extension = false;
1146 {
1147 /* Strip parameters from the URL (if they exist) before the file extension is checked.
1148 * This allows for `https://example.org/api/v1/file.zip?repository=/api/v1/`.
1149 * This allows draggable links to specify their repository, see: #120665. */
1150 std::string str_strip;
1151 const char *cstr_maybe_copy = cstr;
1152 size_t param_char = str.find('?');
1153 if (param_char != std::string::npos) {
1154 str_strip = str.substr(0, param_char);
1155 cstr_maybe_copy = str_strip.c_str();
1156 }
1157
1158 const char *cstr_ext = BLI_path_extension(cstr_maybe_copy);
1159 if (cstr_ext && STRCASEEQ(cstr_ext, ".zip")) {
1160 has_known_extension = true;
1161 }
1162 }
1163
1164 /* Check the URL has a `.zip` suffix OR has a known repository as a prefix.
1165 * This is needed to support redirects which don't contain an extension. */
1166 if (!has_known_extension &&
1168 {
1169 return false;
1170 }
1171
1172 return true;
1173}
1174
1175static void drop_extension_url_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
1176{
1177 /* Copy drag URL to properties. */
1178 const std::string &str = WM_drag_get_string(drag);
1179 RNA_string_set(drop->ptr, "url", str.c_str());
1180}
1181
1183
1184/* -------------------------------------------------------------------- */
1187
1188static bool drop_extension_path_poll(bContext * /*C*/, wmDrag *drag, const wmEvent * /*event*/)
1189{
1190 if (drag->type != WM_DRAG_PATH) {
1191 return false;
1192 }
1193
1194 const char *cstr = WM_drag_get_single_path(drag);
1195 const char *cstr_ext = BLI_path_extension(cstr);
1196 if (!(cstr_ext && STRCASEEQ(cstr_ext, ".zip"))) {
1197 return false;
1198 }
1199
1200 return true;
1201}
1202
1203static void drop_extension_path_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
1204{
1205 /* Copy drag URL to properties. */
1206 const char *cstr = WM_drag_get_single_path(drag);
1207 RNA_string_set(drop->ptr, "url", cstr);
1208}
1209
1211
1213{
1214 ListBaseT<wmDropBox> *lb = WM_dropboxmap_find("Window", SPACE_EMPTY, RGN_TYPE_WINDOW);
1215 WM_dropbox_add(lb,
1216 "PREFERENCES_OT_extension_url_drop",
1219 nullptr,
1220 nullptr);
1221 WM_dropbox_add(lb,
1222 "PREFERENCES_OT_extension_url_drop",
1225 nullptr,
1226 nullptr);
1227}
1228
1229/* -------------------------------------------------------------------- */
1234
1236{
1238 ScrArea *area = CTX_wm_area(C);
1240 ED_region_activate_rna_prop(C, region, space, "search_filter");
1241 return OPERATOR_FINISHED;
1242}
1243
1245{
1246 ot->name = "Filter";
1247 ot->description = "Start entering filter text";
1248 ot->idname = "PREFERENCES_OT_start_filter";
1251}
1252
1254{
1256 space->runtime->search_string[0] = '\0';
1257 ScrArea *area = CTX_wm_area(C);
1259 ED_region_search_filter_update(area, main_region);
1260 ED_area_tag_redraw(area);
1261 return OPERATOR_FINISHED;
1262}
1263
1265{
1266 ot->name = "Clear Filter";
1267 ot->description = "Clear the search filter";
1268 ot->idname = "PREFERENCES_OT_clear_filter";
1271}
1272
1274
1297
1298} // namespace blender
File and directory operations.
#define FILE_MAX
#define STRNCPY_UTF8(dst, src)
Compatibility-like things for windows.
#define IFACE_(msgid)
#define USER_EXPERIMENTAL_TEST(userdef, member)
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_ITEM_NONE
#define ND_UI_FONT
Definition WM_types.hh:602
#define NC_WINDOW
Definition WM_types.hh:388
#define NC_UI
Definition WM_types.hh:422
#define CLAMP(a, b, c)
#define STRPREFIX(a, b)
#define BLI_assert_unreachable()
#define UNUSED_VARS(...)
#define ELEM(...)
#define STRCASEEQ(a, b)
#define str(s)
#define INT_MAX
void style_init_default()
Definition resources.cc:67
BMesh Iterators.
UserDef U
Definition blender.cc:58
bool BKE_preferences_extension_repo_module_is_valid(const bUserExtensionRepo *repo)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
bUserAssetLibraryAddType
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
const EnumPropertyItem custom_library_type_items[]
const char * WM_drag_get_single_path(const wmDrag *drag)
static bool preferences_asset_library_remove_poll(bContext *C)
static wmOperatorStatus preferences_extension_repo_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
size_t BKE_preferences_extension_repo_user_dirpath_get(const bUserExtensionRepo *repo, char *dirpath, const int dirpath_maxncpy)
ScrArea * CTX_wm_area(const bContext *C)
void BKE_callback_exec_string(Main *bmain, const char *str, eCbEvent evt)
Definition callbacks.cc:76
wmDropBox * WM_dropbox_add(ListBaseT< wmDropBox > *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)
int RNA_enum_get(PointerRNA *ptr, const char *name)
bUserExtensionRepo * BKE_preferences_extension_repo_find_by_remote_url_prefix(const UserDef *userdef, const char *remote_url_full, const bool only_enabled)
static void PREFERENCES_OT_reset_default_theme(wmOperatorType *ot)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ RPT_WARNING
Definition BKE_report.hh:40
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
static void PREFERENCES_OT_associate_blend(wmOperatorType *ot)
static wmOperatorStatus preferences_extension_repo_remove_exec(bContext *C, wmOperator *op)
const char * RNA_property_ui_name_raw(const PropertyRNA *prop, const PointerRNA *ptr)
bool WM_platform_associate_set(bool do_register, bool all_users, char **r_error_msg)
@ BKE_CB_EVT_EXTENSION_REPOS_UPDATE_PRE
@ BKE_CB_EVT_EXTENSION_REPOS_UPDATE_POST
@ BKE_CB_EVT_EXTENSION_REPOS_FILES_CLEAR
@ BKE_CB_EVT_EXTENSION_REPOS_SYNC
void BKE_callback_exec_null(Main *bmain, eCbEvent evt)
Definition callbacks.cc:40
static void PREFERENCES_OT_extension_url_drop(wmOperatorType *ot)
bUserExtensionRepoAddType
static wmOperatorStatus preferences_autoexec_remove_exec(bContext *, wmOperator *op)
void WM_operator_properties_free(PointerRNA *ptr)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
int BKE_preferences_remote_scheme_end(const char *url)
void PREFERENCES_OT_clear_filter(wmOperatorType *ot)
const char * BLI_path_extension(const char *filepath) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
SpaceUserPref * CTX_wm_space_userpref(const bContext *C)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PointerRNA WM_operator_properties_create_ptr(wmOperatorType *ot)
@ WM_DRAG_STRING
Definition WM_types.hh:1311
@ WM_DRAG_PATH
Definition WM_types.hh:1302
static bool drop_extension_path_poll(bContext *, wmDrag *drag, const wmEvent *)
std::string RNA_property_string_get(PointerRNA *ptr, PropertyRNA *prop)
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)
int RNA_int_get(PointerRNA *ptr, const char *name)
void ED_region_search_filter_update(const ScrArea *area, ARegion *region)
Definition area.cc:957
const std::string & WM_drag_get_string(const wmDrag *drag)
static bool associate_blend(bool do_register, bool all_users, char **r_error_msg)
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)
static wmOperatorStatus associate_blend_exec(bContext *, wmOperator *op)
char * RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen, int *r_len)
void WM_reinit_gizmomap_all(Main *bmain)
static wmOperatorStatus preferences_extension_repo_add_exec(bContext *C, wmOperator *op)
static const char * preferences_extension_repo_default_name_from_type(const bUserExtensionRepoAddType repo_type)
Global G
Definition blender.cc:57
static bool associate_blend_poll(bContext *C)
static wmOperatorStatus preferences_extension_repo_remove_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void PREFERENCES_OT_asset_library_add(wmOperatorType *ot)
static void drop_extension_path_copy(bContext *, wmDrag *drag, wmDropBox *drop)
static const EnumPropertyItem * custom_library_type_itemf(bContext *, PointerRNA *, PropertyRNA *, bool *r_free)
void void void const char * BLI_path_basename(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
void * BLI_findlink(const ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:541
static wmOperatorStatus preferences_asset_library_remove_exec(bContext *C, wmOperator *op)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
void BKE_preferences_remote_to_name(const char *remote_url, char name[64])
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
void BLI_path_slash_rstrip(char *path) ATTR_NONNULL(1)
void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *value)
void ED_operatortypes_userpref()
static void ED_dropbox_drop_extension()
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
bool ED_operator_preferences_active(bContext *C)
@ WM_FILESEL_DIRECTORY
Definition WM_api.hh:1330
static wmOperatorStatus preferences_autoexec_add_exec(bContext *, wmOperator *)
void ED_userpref_asset_library_remove(bContext *C, struct bUserAssetLibrary *asset_library)
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
struct bUserAssetLibrary * ED_userpref_asset_library_new(const struct bContext *C, const char *name, const char *dirpath, bUserAssetLibraryAddType library_type, bool is_project_defined, std::optional< UUID > uuid, std::optional< char * > auth_token)
bool BLI_windows_is_store_install(void)
@ USER_EXTENSION_REPO_SOURCE_SYSTEM
static wmOperatorStatus preferences_start_filter_exec(bContext *C, wmOperator *)
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:277
void RNA_def_property_subtype(PropertyRNA *prop, PropertySubType subtype)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
const char * RNA_property_ui_description_raw(const PropertyRNA *prop, const PointerRNA *ptr)
static wmOperatorStatus unassociate_blend_exec(bContext *, wmOperator *op)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
static wmOperatorStatus preferences_asset_library_add_exec(bContext *C, wmOperator *op)
static bool drop_extension_url_poll(bContext *, wmDrag *drag, const wmEvent *)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, ui::AlertIcon icon, bool cancel_default)
void BKE_preferences_extension_repo_remove(UserDef *userdef, bUserExtensionRepo *repo)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
int RNA_string_length(PointerRNA *ptr, const char *name)
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:457
static void PREFERENCES_OT_extension_repo_add(wmOperatorType *ot)
static void PREFERENCES_OT_autoexec_path_remove(wmOperatorType *ot)
@ USER_EXTENSION_REPO_FLAG_USE_REMOTE_URL
@ USER_EXTENSION_REPO_FLAG_SYNC_ON_STARTUP
@ USER_EXTENSION_REPO_FLAG_USE_ACCESS_TOKEN
@ USER_EXTENSION_REPO_FLAG_USE_CUSTOM_DIRECTORY
static bool preferences_extension_repo_remove_poll(bContext *C)
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)
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
Definition screen.cc:1024
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
static wmOperatorStatus preferences_extension_url_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void PREFERENCES_OT_asset_library_remove(wmOperatorType *ot)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
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)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
@ FILE_OPENFILE
Definition WM_api.hh:1341
void PREFERENCES_OT_start_filter(wmOperatorType *ot)
static void drop_extension_url_copy(bContext *, wmDrag *drag, wmDropBox *drop)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
@ G_FLAG_INTERNET_ALLOW
Main * CTX_data_main(const bContext *C)
bUserExtensionRepo * BKE_preferences_extension_repo_add(UserDef *userdef, const char *name, const char *module, const char *custom_dirpath)
static void PREFERENCES_OT_extension_repo_remove(wmOperatorType *ot)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
@ PROP_HIDDEN
Definition RNA_types.hh:408
static void preferences_asset_library_add_ui(bContext *, wmOperator *op)
static void preferences_extension_repo_add_ui(bContext *, wmOperator *op)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_INTERNAL
Definition WM_types.hh:210
std::string RNA_string_get(PointerRNA *ptr, const char *name)
static void PREFERENCES_OT_unassociate_blend(wmOperatorType *ot)
static wmOperatorStatus preferences_reset_default_theme_exec(bContext *C, wmOperator *)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
ListBaseT< wmDropBox > * WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
@ PROP_PASSWORD
Definition RNA_types.hh:298
void ED_region_activate_rna_prop(bContext *C, ARegion *region, const void *data, StringRefNull prop_name)
Definition area.cc:696
static wmOperatorStatus preferences_asset_library_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void WM_cursor_wait(bool val)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
static void PREFERENCES_OT_autoexec_path_add(wmOperatorType *ot)
void ED_area_tag_redraw(ScrArea *area)
Definition area.cc:784
static wmOperatorStatus preferences_clear_filter_exec(bContext *C, wmOperator *)
size_t BKE_preferences_extension_repo_dirpath_get(const bUserExtensionRepo *repo, char *dirpath, int dirpath_maxncpy)
void BKE_callback_exec(Main *bmain, PointerRNA **pointers, int pointers_num, eCbEvent evt)
Definition callbacks.cc:29
SpaceUserPref_Runtime * runtime
eUserExtensionRepo_Flag flag
eUserExtensionRepo_Source source
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)
void active_set(bool active)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
Layout & row(bool align)
eWM_DragDataType type
Definition WM_types.hh:1424
PointerRNA * ptr
Definition WM_types.hh:1524
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
void(*) ui(bContext *C, wmOperator *op)
Definition WM_types.hh:1176
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
struct ReportList * reports