mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-21 03:19:31 +08:00
Merge remote-tracking branch 'origin/v3-alpha-linux-dialogs' into v3-alpha
This commit is contained in:
commit
724ca386e7
@ -272,6 +272,7 @@ func (d *OpenFileDialogStruct) PromptForSingleSelection() (string, error) {
|
||||
if err == nil {
|
||||
result = <-selections
|
||||
}
|
||||
close(selections)
|
||||
|
||||
return result, err
|
||||
}
|
||||
|
@ -10,10 +10,12 @@ func (a *linuxApp) showAboutDialog(title string, message string, icon []byte) {
|
||||
about.SetTitle(title).
|
||||
SetMessage(message).
|
||||
SetIcon(icon)
|
||||
runQuestionDialog(
|
||||
pointer(parent),
|
||||
about,
|
||||
)
|
||||
InvokeAsync(func() {
|
||||
runQuestionDialog(
|
||||
pointer(parent),
|
||||
about,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
type linuxDialog struct {
|
||||
@ -28,13 +30,15 @@ func (m *linuxDialog) show() {
|
||||
parent, _ = window.(*WebviewWindow).NativeWindowHandle()
|
||||
}
|
||||
|
||||
response := runQuestionDialog(pointer(parent), m.dialog)
|
||||
if response >= 0 && response < len(m.dialog.Buttons) {
|
||||
button := m.dialog.Buttons[response]
|
||||
if button.Callback != nil {
|
||||
go button.Callback()
|
||||
InvokeAsync(func() {
|
||||
response := runQuestionDialog(pointer(parent), m.dialog)
|
||||
if response >= 0 && response < len(m.dialog.Buttons) {
|
||||
button := m.dialog.Buttons[response]
|
||||
if button.Callback != nil {
|
||||
go button.Callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func newDialogImpl(d *MessageDialog) *linuxDialog {
|
||||
|
@ -1556,8 +1556,8 @@ func runChooserDialog(window pointer, allowMultiple, createFolders, showHidden b
|
||||
selections := make(chan string)
|
||||
// run this on the gtk thread
|
||||
InvokeAsync(func() {
|
||||
response := C.gtk_dialog_run((*C.GtkDialog)(fc))
|
||||
go func() {
|
||||
response := C.gtk_dialog_run((*C.GtkDialog)(fc))
|
||||
if response == C.GTK_RESPONSE_ACCEPT {
|
||||
filenames := C.gtk_file_chooser_get_filenames((*C.GtkFileChooser)(fc))
|
||||
iter := filenames
|
||||
@ -1570,16 +1570,21 @@ func runChooserDialog(window pointer, allowMultiple, createFolders, showHidden b
|
||||
}
|
||||
count++
|
||||
}
|
||||
close(selections)
|
||||
C.gtk_widget_destroy((*C.GtkWidget)(unsafe.Pointer(fc)))
|
||||
}
|
||||
}()
|
||||
})
|
||||
C.gtk_widget_destroy((*C.GtkWidget)(unsafe.Pointer(fc)))
|
||||
return selections, nil
|
||||
}
|
||||
|
||||
func runOpenFileDialog(dialog *OpenFileDialogStruct) (chan string, error) {
|
||||
const GtkFileChooserActionOpen = C.GTK_FILE_CHOOSER_ACTION_OPEN
|
||||
var action int
|
||||
|
||||
if dialog.canChooseDirectories {
|
||||
action = C.GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
|
||||
} else {
|
||||
action = C.GTK_FILE_CHOOSER_ACTION_OPEN
|
||||
}
|
||||
|
||||
window := nilPointer
|
||||
if dialog.window != nil {
|
||||
@ -1598,7 +1603,7 @@ func runOpenFileDialog(dialog *OpenFileDialogStruct) (chan string, error) {
|
||||
dialog.showHiddenFiles,
|
||||
dialog.directory,
|
||||
dialog.title,
|
||||
GtkFileChooserActionOpen,
|
||||
action,
|
||||
buttonText,
|
||||
dialog.filters)
|
||||
}
|
||||
|
@ -1084,6 +1084,15 @@ func runChooserDialog(window pointer, allowMultiple, createFolders, showHidden b
|
||||
// dialog related
|
||||
func runOpenFileDialog(dialog *OpenFileDialogStruct) ([]string, error) {
|
||||
const GtkFileChooserActionOpen = 0
|
||||
const GtkFileChooserActionSelectFolder = 2
|
||||
|
||||
var action int
|
||||
|
||||
if dialog.canChooseDirectories {
|
||||
action = GtkFileChooserActionSelectFolder
|
||||
} else {
|
||||
action = GtkFileChooserActionOpen
|
||||
}
|
||||
|
||||
window := pointer(0)
|
||||
if dialog.window != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user