Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-11-23 20:40:31 +0300
committerJulian Eisel <julian@blender.org>2021-11-23 20:57:25 +0300
commitea93e5df6c4cd42dc19073fd61e11ccd1a01c395 (patch)
tree226fc592d68effbacb2a8e68a5b6110e3fe497e5 /source/blender/editors/asset
parent60befc8f0284e70fda2ef1d704cb3f81ec406170 (diff)
Asset: Merge asset library/list refresh operators
In rBdcdbaf89bd11, I introduced a new operator (`file.asset_library_refresh()`) to handle Asset Browser refreshing more separate from File Browser refreshing. However, there already was `asset.asset_list_refresh()`, which at this point only works for asset view templates, but was intended to cover the Asset Browser case in future too. This would happen once the Asset Browser uses the asset list design of the asset view template. So rather than having two operators for refreshing asset library data, have one that just handles both cases, until they converge into one. This avoids changes to the Python API in future (deprecating/changing operators). Differential Revision: https://developer.blender.org/D13239
Diffstat (limited to 'source/blender/editors/asset')
-rw-r--r--source/blender/editors/asset/intern/asset_ops.cc46
1 files changed, 35 insertions, 11 deletions
diff --git a/source/blender/editors/asset/intern/asset_ops.cc b/source/blender/editors/asset/intern/asset_ops.cc
index a228b275558..3c4f6b8755f 100644
--- a/source/blender/editors/asset/intern/asset_ops.cc
+++ b/source/blender/editors/asset/intern/asset_ops.cc
@@ -30,7 +30,10 @@
#include "BLI_fileops.h"
#include "BLI_fnmatch.h"
#include "BLI_path_util.h"
+
#include "ED_asset.h"
+#include "ED_asset_catalog.hh"
+#include "ED_screen.h"
#include "ED_util.h"
/* XXX needs access to the file list, should all be done via the asset system in future. */
#include "ED_fileselect.h"
@@ -388,8 +391,14 @@ static void ASSET_OT_clear(wmOperatorType *ot)
/* -------------------------------------------------------------------- */
-static bool asset_list_refresh_poll(bContext *C)
+static bool asset_library_refresh_poll(bContext *C)
{
+ if (ED_operator_asset_browsing_active(C)) {
+ return true;
+ }
+
+ /* While not inside an Asset Browser, check if there's a asset list stored for the active asset
+ * library (stored in the workspace, obtained via context). */
const AssetLibraryReference *library = CTX_wm_asset_library_ref(C);
if (!library) {
return false;
@@ -398,23 +407,38 @@ static bool asset_list_refresh_poll(bContext *C)
return ED_assetlist_storage_has_list_for_library(library);
}
-static int asset_list_refresh_exec(bContext *C, wmOperator *UNUSED(unused))
+static int asset_library_refresh_exec(bContext *C, wmOperator *UNUSED(unused))
{
- const AssetLibraryReference *library = CTX_wm_asset_library_ref(C);
- ED_assetlist_clear(library, C);
+ /* Execution mode #1: Inside the Asset Browser. */
+ if (ED_operator_asset_browsing_active(C)) {
+ SpaceFile *sfile = CTX_wm_space_file(C);
+ ED_fileselect_clear(CTX_wm_manager(C), sfile);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
+ }
+ else {
+ /* Execution mode #2: Outside the Asset Browser, use the asset list. */
+ const AssetLibraryReference *library = CTX_wm_asset_library_ref(C);
+ ED_assetlist_clear(library, C);
+ }
+
return OPERATOR_FINISHED;
}
-static void ASSET_OT_list_refresh(struct wmOperatorType *ot)
+/**
+ * This operator currently covers both cases, the File/Asset Browser file list and the asset list
+ * used for the asset-view template. Once the asset list design is used by the Asset Browser, this
+ * can be simplified to just that case.
+ */
+static void ASSET_OT_library_refresh(struct wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Refresh Asset List";
- ot->description = "Trigger a reread of the assets";
- ot->idname = "ASSET_OT_list_refresh";
+ ot->name = "Refresh Asset Library";
+ ot->description = "Reread assets and asset catalogs from the asset library on disk";
+ ot->idname = "ASSET_OT_library_refresh";
/* api callbacks */
- ot->exec = asset_list_refresh_exec;
- ot->poll = asset_list_refresh_poll;
+ ot->exec = asset_library_refresh_exec;
+ ot->poll = asset_library_refresh_poll;
}
/* -------------------------------------------------------------------- */
@@ -901,5 +925,5 @@ void ED_operatortypes_asset(void)
WM_operatortype_append(ASSET_OT_catalog_undo_push);
WM_operatortype_append(ASSET_OT_bundle_install);
- WM_operatortype_append(ASSET_OT_list_refresh);
+ WM_operatortype_append(ASSET_OT_library_refresh);
}