Blender V5.3
file_banner_remote_assets.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "AS_asset_library.hh"
10
11#include "BKE_global.hh"
12
13#include "BLT_translation.hh"
14
15#include "RNA_access.hh"
16
17#include "UI_interface.hh"
19
20#include "file_banner.hh"
21#include "file_intern.hh"
22#include "filelist.hh"
23
24namespace blender {
25
27{
28 const bool is_online_allowed = G.f & G_FLAG_INTERNET_ALLOW;
29 const bool was_choice_made = U.extension_flag & USER_EXTENSION_FLAG_ONLINE_ACCESS_HANDLED;
30 if (is_online_allowed || was_choice_made) {
31 return false;
32 }
33
34 /* Only show this banner when there are assets being displayed. If there are no assets, the asset
35 * browser draws a larger "Internet Access Required" box instead. */
36 if (filelist_files_num_entries(sfile.files) < 1) {
37 return false;
38 }
39
40 const FileAssetSelectParams *asset_params = ED_fileselect_get_asset_params(&sfile);
41 if (!asset_params) {
42 return false;
43 }
45 return false;
46 }
47
48 return true;
49}
50
52 ui::Layout &layout)
53{
54 layout.label(IFACE_("Internet access disabled, only showing assets that are available offline."),
55 ICON_INTERNET_OFFLINE);
56
57 ui::Layout &right_row = layout.row(false);
59
60 PointerRNA props = right_row.op("WM_OT_context_set_boolean", IFACE_("Continue Offline"), ICON_X);
61 RNA_string_set(&props, "data_path", "preferences.extensions.use_online_access_handled");
62 RNA_boolean_set(&props, "value", true);
63
64 right_row.op("extensions.userpref_allow_online", IFACE_("Allow Online Access"), ICON_CHECKMARK);
65}
66
71
72} // namespace blender
#define IFACE_(msgid)
bool is_or_contains_remote_libraries(const AssetLibraryReference &reference)
BMesh Iterators.
UserDef U
Definition blender.cc:58
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
@ USER_EXTENSION_FLAG_ONLINE_ACCESS_HANDLED
Global G
Definition blender.cc:57
BannerType remote_libraries_online_access_required_banner
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
static void file_banner_remote_asset_libraries_layout(const SpaceFile &, ui::Layout &layout)
FileAssetSelectParams * ED_fileselect_get_asset_params(const SpaceFile *sfile)
Definition filesel.cc:416
@ G_FLAG_INTERNET_ALLOW
int filelist_files_num_entries(FileList *filelist)
Definition filelist.cc:1068
static bool file_banner_remote_asset_libraries_poll(const SpaceFile &sfile)
AssetLibraryReference asset_library_ref
struct FileList * files
void alignment_set(LayoutAlign alignment)
void label(StringRef name, int icon)
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
Layout & row(bool align)