mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-15 07:05:50 +01:00
This commit includes the addition of common events for the Linux platform. Refactored and standardized the method receivers for the application from 'm' to 'l'. Also, the application startup events in the window example have been updated according to the new naming scheme.
72 lines
1.6 KiB
Go
72 lines
1.6 KiB
Go
package application
|
|
|
|
func (l *linuxApp) showAboutDialog(title string, message string, icon []byte) {
|
|
window := globalApplication.getWindowForID(l.getCurrentWindowID())
|
|
var parent uintptr
|
|
if window != nil {
|
|
parent, _ = window.(*WebviewWindow).NativeWindowHandle()
|
|
}
|
|
about := newMessageDialog(InfoDialogType)
|
|
about.SetTitle(title).
|
|
SetMessage(message).
|
|
SetIcon(icon)
|
|
runQuestionDialog(
|
|
pointer(parent),
|
|
about,
|
|
)
|
|
}
|
|
|
|
type linuxDialog struct {
|
|
dialog *MessageDialog
|
|
}
|
|
|
|
func (m *linuxDialog) show() {
|
|
windowId := getNativeApplication().getCurrentWindowID()
|
|
window := globalApplication.getWindowForID(windowId)
|
|
var parent uintptr
|
|
if window != nil {
|
|
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()
|
|
}
|
|
}
|
|
}
|
|
|
|
func newDialogImpl(d *MessageDialog) *linuxDialog {
|
|
return &linuxDialog{
|
|
dialog: d,
|
|
}
|
|
}
|
|
|
|
type linuxOpenFileDialog struct {
|
|
dialog *OpenFileDialogStruct
|
|
}
|
|
|
|
func newOpenFileDialogImpl(d *OpenFileDialogStruct) *linuxOpenFileDialog {
|
|
return &linuxOpenFileDialog{
|
|
dialog: d,
|
|
}
|
|
}
|
|
|
|
func (m *linuxOpenFileDialog) show() (chan string, error) {
|
|
return runOpenFileDialog(m.dialog)
|
|
}
|
|
|
|
type linuxSaveFileDialog struct {
|
|
dialog *SaveFileDialogStruct
|
|
}
|
|
|
|
func newSaveFileDialogImpl(d *SaveFileDialogStruct) *linuxSaveFileDialog {
|
|
return &linuxSaveFileDialog{
|
|
dialog: d,
|
|
}
|
|
}
|
|
|
|
func (m *linuxSaveFileDialog) show() (chan string, error) {
|
|
return runSaveFileDialog(m.dialog)
|
|
}
|