MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / OpenFileDialogKey

Function OpenFileDialogKey

src/osdep/file_dialog.cpp:338–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336}
337
338void OpenFileDialogKey(const char* key, const char* title, const char* filters, const std::string& initialPath, bool saveMode)
339{
340 key = dialog_key_or_default(key);
341 title = title ? title : "Choose File";
342 filters = filters ? filters : ".*";
343 const auto dialogPath = resolve_dialog_initial_directory(initialPath);
344
345 if (can_use_native_dialog())
346 {
347#ifdef HAS_NFD
348 ensure_wayland_display();
349 ParsedNFDFilters parsed = parse_igfd_filters(filters);
350
351 nfdu8char_t* outPath = nullptr;
352 nfdresult_t result = NFD_ERROR;
353
354 AmigaMonitor* mon = &AMonitors[0];
355 nfdwindowhandle_t parentWindow{};
356 if (mon->gui_window)
357 NFD_GetNativeWindowFromSDL3Window(mon->gui_window, &parentWindow);
358
359 if (saveMode)
360 {
361 nfdsavedialogu8args_t args{};
362 if (!parsed.items.empty())
363 {
364 args.filterList = parsed.items.data();
365 args.filterCount = static_cast<nfdfiltersize_t>(parsed.items.size());
366 }
367 args.defaultPath = dialogPath.empty() ? nullptr : dialogPath.c_str();
368 args.parentWindow = parentWindow;
369 result = NFD_SaveDialogU8_With(&outPath, &args);
370 }
371 else
372 {
373 nfdopendialogu8args_t args{};
374 if (!parsed.items.empty())
375 {
376 args.filterList = parsed.items.data();
377 args.filterCount = static_cast<nfdfiltersize_t>(parsed.items.size());
378 }
379 args.defaultPath = dialogPath.empty() ? nullptr : dialogPath.c_str();
380 args.parentWindow = parentWindow;
381 result = NFD_OpenDialogU8_With(&outPath, &args);
382 }
383
384 if (result == NFD_OKAY)
385 {
386 std::string path = outPath ? outPath : "";
387 if (outPath)
388 NFD_FreePathU8(outPath);
389 s_results[key] = path;
390 if (!path.empty())
391 macos_bookmark_store(path);
392 return;
393 }
394
395 if (result == NFD_CANCEL)

Callers 15

OpenFileDialogFunction · 0.85
render_panel_expansionsFunction · 0.85
render_panel_diskswapperFunction · 0.85
RenderDriveSlotFunction · 0.85
render_panel_floppyFunction · 0.85
RenderCDSectionFunction · 0.85
ShowCreateHardfileModalFunction · 0.85
ShowEditCDDriveModalFunction · 0.85
ShowEditTapeDriveModalFunction · 0.85
render_panel_themesFunction · 0.85

Calls 13

dialog_key_or_defaultFunction · 0.85
can_use_native_dialogFunction · 0.85
ensure_wayland_displayFunction · 0.85
parse_igfd_filtersFunction · 0.85
macos_bookmark_storeFunction · 0.85
open_igfd_file_dialogFunction · 0.85
c_strMethod · 0.80
write_logFunction · 0.70
emptyMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected