From 8666935caf8d6596255bc495691224e50b6d5a6c Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sun, 27 Sep 2020 14:49:38 +1000 Subject: [PATCH] Support multiple files in dialog --- v2/internal/ffenestri/ffenestri_darwin.c | 3 ++- v2/pkg/options/dialog.go | 1 + v2/test/runtime/runtime.go | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/v2/internal/ffenestri/ffenestri_darwin.c b/v2/internal/ffenestri/ffenestri_darwin.c index 5e40d8b9f..348bc9636 100644 --- a/v2/internal/ffenestri/ffenestri_darwin.c +++ b/v2/internal/ffenestri/ffenestri_darwin.c @@ -416,7 +416,7 @@ char* OpenFileDialog(struct Application *app, char *title, char *filter) { // OpenDialog opens a dialog to select files/directories // NOTE: The result is a string that will need to be freed! -void OpenDialog(struct Application *app, char* callbackID, char *title, char *filter, int allowFiles, int allowDirs) { +void OpenDialog(struct Application *app, char* callbackID, char *title, char *filter, int allowFiles, int allowDirs, int allowMultiple) { Debug("OpenDialog Called with callback id: %s", callbackID); // Create an open panel @@ -430,6 +430,7 @@ void OpenDialog(struct Application *app, char* callbackID, char *title, char *fi // TODO: Other options msg(dialog, s("setCanChooseFiles:"), allowFiles); msg(dialog, s("setCanChooseDirectories:"), allowDirs); + msg(dialog, s("setAllowsMultipleSelection:"), allowMultiple); msg(dialog, s("beginSheetModalForWindow:completionHandler:"), app->mainWindow, ^(id result) { diff --git a/v2/pkg/options/dialog.go b/v2/pkg/options/dialog.go index 609f67e50..a58f23b70 100644 --- a/v2/pkg/options/dialog.go +++ b/v2/pkg/options/dialog.go @@ -6,4 +6,5 @@ type OpenDialog struct { Filter string AllowFiles bool AllowDirectories bool + AllowMultiple bool } diff --git a/v2/test/runtime/runtime.go b/v2/test/runtime/runtime.go index faf7edfec..1e37a82bd 100644 --- a/v2/test/runtime/runtime.go +++ b/v2/test/runtime/runtime.go @@ -98,6 +98,18 @@ func (r *RuntimeTest) OpenDialog(title string, filter string) []string { return r.runtime.Dialog.Open(dialogOptions) } +// OpenDialogMultiple will call the Runtime.Dialog.OpenDialog method allowing multiple selection +func (r *RuntimeTest) OpenDialogMultiple(title string, filter string) []string { + dialogOptions := &options.OpenDialog{ + Title: title, + Filter: filter, + AllowDirectories: true, + AllowFiles: true, + AllowMultiple: true, + } + return r.runtime.Dialog.Open(dialogOptions) +} + // HideWindow will call the Runtime.Window.Hide method and then call // Runtime.Window.Show 3 seconds later. func (r *RuntimeTest) HideWindow() {