al_create_native_file_dialog(3alleg5)
π al_create_native_file_dialog β Allegro 5 API π
okay bestie, welcome to the Allegro reference manual, and today we're doing al_create_native_file_dialog β the function that literally pops up a real, native, operating-system-blessed file picker for you. iconic behaviour, no cap. β¨
πΈ NAME πΈ
al_create_native_file_dialog β Allegro 5 API
π¦ SYNOPSIS π¦
#include <allegro5/allegro_native_dialog.h>
ALLEGRO_FILECHOOSER *al_create_native_file_dialog(
char const *initial_path,
char const *title,
char const *patterns,
int mode)
β¨ DESCRIPTION β¨
It makes you a brand new native file dialog, bestie. and listen β you should only have one such dialog opened at a time. one. single. dialog. don't be greedy, it's not the vibe. π
Parameters β the group chat lineup:
initial_pathβ the starting search path and filename. this one can beNULL. π«Ά if you want it to start with a blank file name, your string should end with a directory separator β and that's actually the common case, so don't overthink it.titleβ the title of the dialog. the little name tag. the main character energy on the window bar. πpatternsβ a string of newline-separated sets of patterns to match. a pattern is either a shell-style glob pattern (like"*.txt") or a MIME type (like"image/png"). and here's the tea: not all platforms support both, and some don't even support globs at all π, so the portable move is to give a MIME type and simple-style globs, and let Allegro pick whichever one the platform actually supports (so like, do"image/png;*.png"). multiple patterns get separated with a semicolon. if the platform doesn't support patterns at all, this parameter is just ignored. shrug, we move on. π
here's some example patterns so you can see the vision:
"*.txt"β defines a single filter, matching*.txtfiles."*.txt;*.md"β like above, but matching two types of files."Text files (*.txt, *.md) *.txt;*.md"β like above, but with a custom description (separated from the patterns using a space)."Text files *.txt\nPNG images image/png;*.png"β defines two filters, with the second filter using a MIME type and extension at the same time.
π¨ note time, and this one matters: Windows does not support MIME types. Android supports only MIME types. and MacOS supports extensions instead of file patterns, so matching based on filename beyond file type does not work there β Allegro will parse your file pattern to try to extract the file extension. MacOS also supports MIME types though, which behave more predictably. also MacOS does not support detailed descriptions or multiple pattern sets, so Allegro will strip the detailed descriptions and concatenate all patterns into one list. it's giving chaos but it's fine, Allegro handles it. π§
modeβ0, or a combination of the following flags:ALLEGRO_FILECHOOSER_FILE_MUST_EXISTβ if the native dialog supports it, it won't let you enter new names, it'll just let existing files be selected. else it is ignored.ALLEGRO_FILECHOOSER_SAVEβ if the native dialog system has a different dialog for saving (for example one which allows creating new directories), it gets used. else it is ignored.ALLEGRO_FILECHOOSER_FOLDERβ if there's support for a separate dialog to select a folder instead of a file, it will be used.ALLEGRO_FILECHOOSER_PICTURESβ if a different dialog is available for selecting pictures, it gets used. else it is ignored.ALLEGRO_FILECHOOSER_SHOW_HIDDENβ if the platform supports it, hidden files will be shown too. peek behind the curtain π«£ALLEGRO_FILECHOOSER_MULTIPLEβ if supported, it lets you select multiple files. slay. π₯
Returns:
a handle to the dialog π β you pass it to al_show_native_file_dialog(3alleg5) to actually display it, and then you can query the results using al_get_native_file_dialog_count(3alleg5) and al_get_native_file_dialog_path(3alleg5). and when you're done? call al_destroy_native_file_dialog(3alleg5) on it. clean up after yourself, bestie, it's the respectful thing. π
and if a dialog window could not be created, this function returns NULL. π it happens. it's not your fault.
and that's the whole page, fr fr. this has been the Allegro reference manual serving you al_create_native_file_dialog(3alleg5) β go forth, open a file picker, be the main character of your own desktop app ππ¦β¨
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms