diff --git a/addons/native_dialog/android_dialog.c b/addons/native_dialog/android_dialog.c index 4a10ab1cc..10939bc3f 100644 --- a/addons/native_dialog/android_dialog.c +++ b/addons/native_dialog/android_dialog.c @@ -92,10 +92,15 @@ bool _al_show_native_file_dialog(ALLEGRO_DISPLAY *display, ALLEGRO_NATIVE_DIALOG ALLEGRO_DEBUG("waiting for the file chooser"); ALLEGRO_USTR *mime_patterns = al_ustr_new(""); bool first = true; + bool any_catchalls = false; for (size_t i = 0; i < _al_vector_size(&fd->fc_patterns); i++) { _AL_PATTERNS_AND_DESC *patterns_and_desc = _al_vector_ref(&fd->fc_patterns, (int)i); for (size_t j = 0; j < _al_vector_size(&patterns_and_desc->patterns_vec); j++) { _AL_PATTERN *pattern = _al_vector_ref(&patterns_and_desc->patterns_vec, (int)j); + if (pattern->is_catchall) { + any_catchalls = true; + break; + } if (pattern->is_mime) { if (!first) @@ -105,6 +110,8 @@ bool _al_show_native_file_dialog(ALLEGRO_DISPLAY *display, ALLEGRO_NATIVE_DIALOG } } } + if (any_catchalls) + al_ustr_truncate(mime_patterns, 0); bool ret = open_file_chooser(fd->flags, al_cstr(mime_patterns), initial_path, &fd->fc_paths, &fd->fc_path_count); al_ustr_free(mime_patterns); ALLEGRO_DEBUG("done waiting for the file chooser"); diff --git a/addons/native_dialog/osx_dialog.m b/addons/native_dialog/osx_dialog.m index e5be9ca84..0e326ed33 100644 --- a/addons/native_dialog/osx_dialog.m +++ b/addons/native_dialog/osx_dialog.m @@ -24,12 +24,14 @@ void _al_shutdown_native_dialog_addon(void) { NSMutableArray *filter_array = [[NSMutableArray alloc] init]; + bool any_catchalls = false; for (size_t i = 0; i < _al_vector_size(patterns); i++) { _AL_PATTERNS_AND_DESC *patterns_and_desc = _al_vector_ref(patterns, (int)i); for (size_t j = 0; j < _al_vector_size(&patterns_and_desc->patterns_vec); j++) { _AL_PATTERN *pattern = _al_vector_ref(&patterns_and_desc->patterns_vec, (int)j); if (pattern->is_catchall) { - continue; + any_catchalls = true; + break; } char *cstr = al_cstr_dup(al_ref_info(&pattern->info)); NSString *filter_text = [NSString stringWithUTF8String: cstr]; @@ -61,6 +63,10 @@ void _al_shutdown_native_dialog_addon(void) } } + if (any_catchalls) { + filter_array = [[NSMutableArray alloc] init]; + } + return filter_array; } diff --git a/addons/native_dialog/win_dialog.c b/addons/native_dialog/win_dialog.c index bccce8636..57c38c72e 100644 --- a/addons/native_dialog/win_dialog.c +++ b/addons/native_dialog/win_dialog.c @@ -201,7 +201,10 @@ static ALLEGRO_USTR *create_filter_string(const _AL_VECTOR *patterns) al_ustr_append_chr(filter, ';'); } first = false; - al_ustr_append(filter, al_ref_info(&pattern->info)); + if (pattern->is_catchall) + al_ustr_append_cstr(filter, "*.*"); + else + al_ustr_append(filter, al_ref_info(&pattern->info)); } } al_ustr_append_chr(filter, '\0'); diff --git a/examples/ex_native_filechooser.c b/examples/ex_native_filechooser.c index a59d58c27..054503538 100644 --- a/examples/ex_native_filechooser.c +++ b/examples/ex_native_filechooser.c @@ -103,7 +103,7 @@ static AsyncDialog *spawn_async_file_dialog(ALLEGRO_DISPLAY *display, int flags = save ? ALLEGRO_FILECHOOSER_SAVE : ALLEGRO_FILECHOOSER_MULTIPLE; const char* title = save ? "Save (no files will be changed)" : "Choose files"; data->file_dialog = al_create_native_file_dialog( - initial_path, title, NULL, + initial_path, title, "image/jpeg;*", flags); al_init_user_event_source(&data->event_source); data->display = display; @@ -200,13 +200,13 @@ int main(int argc, char **argv) al_install_mouse(); touch = al_install_touch_input(); al_install_keyboard(); - + if (touch) { al_set_mouse_emulation_mode(ALLEGRO_MOUSE_EMULATION_5_0_x); } message("Creating window..."); - + #ifdef ALLEGRO_IPHONE al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW); #endif @@ -250,7 +250,7 @@ int main(int argc, char **argv) while (1) { float h = al_get_display_height(display); - + ALLEGRO_EVENT event; al_wait_for_event(queue, &event); @@ -264,7 +264,7 @@ int main(int argc, char **argv) break; } } - + /* When a mouse button is pressed, and no native dialog is * shown already, we show a new one. */