mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 22:55:48 +01:00
Support default directory
This commit is contained in:
parent
ac27137e5a
commit
8cd39f6a9a
5 changed files with 19 additions and 3 deletions
|
|
@ -29,5 +29,5 @@ extern void Fullscreen(void *app);
|
|||
extern void UnFullscreen(void *app);
|
||||
extern void ToggleFullscreen(void *app);
|
||||
extern void DisableFrame(void *app);
|
||||
extern void OpenDialog(void *appPointer, char *callbackID, char *title, char *filter, int allowFiles, int allowDirs, int allowMultiple, int showHiddenFiles, int canCreateDirectories, int resolveAliases, int treatPackagesAsDirectories);
|
||||
extern void OpenDialog(void *appPointer, char *callbackID, char *title, char *filter, char *defaultDir, int allowFiles, int allowDirs, int allowMultiple, int showHiddenFiles, int canCreateDirectories, int resolveAliases, int treatPackagesAsDirectories);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@ func (c *Client) OpenDialog(dialogOptions *options.OpenDialog, callbackID string
|
|||
c.app.string2CString(callbackID),
|
||||
c.app.string2CString(dialogOptions.Title),
|
||||
c.app.string2CString(dialogOptions.Filter),
|
||||
c.app.string2CString(dialogOptions.DefaultDirectory),
|
||||
c.app.bool2Cint(dialogOptions.AllowFiles),
|
||||
c.app.bool2Cint(dialogOptions.AllowDirectories),
|
||||
c.app.bool2Cint(dialogOptions.AllowMultiple),
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#define s(str) sel_registerName(str)
|
||||
#define u(str) sel_getUid(str)
|
||||
#define str(input) msg(c("NSString"), s("stringWithUTF8String:"), input)
|
||||
#define url(input) msg(c("NSURL"), s("fileURLWithPath:"), str(input))
|
||||
|
||||
#define GET_FRAME(receiver) ((CGRect(*)(id, SEL))objc_msgSend_stret)(receiver, s("frame"));
|
||||
|
||||
|
|
@ -416,7 +417,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, int allowMultiple, int showHiddenFiles, int canCreateDirectories, int resolveAliases, int treatPackagesAsDirectories) {
|
||||
void OpenDialog(struct Application *app, char *callbackID, char *title, char *filter, char *defaultDir, int allowFiles, int allowDirs, int allowMultiple, int showHiddenFiles, int canCreateDirectories, int resolveAliases, int treatPackagesAsDirectories) {
|
||||
Debug("OpenDialog Called with callback id: %s", callbackID);
|
||||
|
||||
// Create an open panel
|
||||
|
|
@ -439,6 +440,16 @@ void OpenDialog(struct Application *app, char *callbackID, char *title, char *fi
|
|||
msg(dialog, s("setAllowsOtherFileTypes:"), YES);
|
||||
}
|
||||
|
||||
// Default Directory
|
||||
if( defaultDir != NULL && strlen(defaultDir) > 0 ) {
|
||||
msg(dialog, s("setDirectoryURL:"), url(defaultDir));
|
||||
}
|
||||
|
||||
// Default Filename
|
||||
// if( defaultFilename != NULL && strlen(defaultFilename) > 0 ) {
|
||||
// msg(dialog, s("setNameFieldStringValue:"), str(defaultFilename));
|
||||
// }
|
||||
|
||||
// Setup Options
|
||||
msg(dialog, s("setCanChooseFiles:"), allowFiles);
|
||||
msg(dialog, s("setCanChooseDirectories:"), allowDirs);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package options
|
|||
|
||||
// OpenDialog contains the options for the OpenDialog runtime method
|
||||
type OpenDialog struct {
|
||||
DefaultDirectory string
|
||||
DefaultFilename string
|
||||
Title string
|
||||
Filter string
|
||||
AllowFiles bool
|
||||
|
|
|
|||
|
|
@ -111,8 +111,10 @@ func (r *RuntimeTest) OpenDialogMultiple(title string, filter string) []string {
|
|||
}
|
||||
|
||||
// OpenDialogAllOptions will call the Runtime.Dialog.OpenDialog method allowing multiple selection
|
||||
func (r *RuntimeTest) OpenDialogAllOptions(filter string) []string {
|
||||
func (r *RuntimeTest) OpenDialogAllOptions(filter string, defaultDir string, defaultFilename string) []string {
|
||||
dialogOptions := &options.OpenDialog{
|
||||
DefaultDirectory: defaultDir,
|
||||
DefaultFilename: defaultFilename,
|
||||
Filter: filter,
|
||||
AllowFiles: true,
|
||||
AllowDirectories: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue