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