mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
file chooser (WIP).
This commit is contained in:
parent
b49ed65a5c
commit
22d31e871c
@ -1,9 +1,52 @@
|
|||||||
package desktop
|
package desktop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
file_chooser_dialog_open = false
|
||||||
|
)
|
||||||
|
|
||||||
|
func (manager *DesktopManagerCtx) fileChooserDialogStart() {
|
||||||
|
if manager.IsFileChooserDialogOpen() {
|
||||||
|
manager.CloseFileChooserDialog()
|
||||||
|
}
|
||||||
|
|
||||||
|
manager.OnWindowCreated(func(window uint32, name string, role string) {
|
||||||
|
if role != "GtkFileChooserDialog" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement, call event.
|
||||||
|
file_chooser_dialog_open = true
|
||||||
|
|
||||||
|
manager.logger.Debug().
|
||||||
|
Uint32("window", window).
|
||||||
|
Msg("GtkFileChooserDialog has been opened")
|
||||||
|
})
|
||||||
|
|
||||||
|
manager.OnWindowConfigured(func(window uint32, name string, role string) {
|
||||||
|
if role != "GtkFileChooserDialog" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
go func(){
|
||||||
|
// TOOD: Refactor.
|
||||||
|
manager.PutWindowBelow(window)
|
||||||
|
|
||||||
|
// Because first dialog is not put properly to background
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
manager.PutWindowBelow(window)
|
||||||
|
}()
|
||||||
|
|
||||||
|
manager.logger.Debug().
|
||||||
|
Uint32("window", window).
|
||||||
|
Msg("GtkFileChooserDialog has been put below main window")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
|
func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
@ -23,6 +66,9 @@ func (manager *DesktopManagerCtx) HandleFileChooserDialog(uri string) error {
|
|||||||
"sleep", "0.3",
|
"sleep", "0.3",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO: Implement, call event.
|
||||||
|
file_chooser_dialog_open = false
|
||||||
|
|
||||||
_, err := cmd.Output()
|
_, err := cmd.Output()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -40,6 +86,8 @@ func (manager *DesktopManagerCtx) CloseFileChooserDialog() bool {
|
|||||||
mu.Unlock()
|
mu.Unlock()
|
||||||
|
|
||||||
if !manager.IsFileChooserDialogOpen() {
|
if !manager.IsFileChooserDialogOpen() {
|
||||||
|
// TODO: Implement, call event.
|
||||||
|
file_chooser_dialog_open = false
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,17 @@ func (manager *DesktopManagerCtx) Start() {
|
|||||||
|
|
||||||
go xevent.EventLoop(manager.display)
|
go xevent.EventLoop(manager.display)
|
||||||
|
|
||||||
|
go manager.fileChooserDialogStart()
|
||||||
|
|
||||||
|
manager.OnEventError(func(error_code uint8, message string, request_code uint8, minor_code uint8) {
|
||||||
|
manager.logger.Warn().
|
||||||
|
Uint8("error_code", error_code).
|
||||||
|
Str("message", message).
|
||||||
|
Uint8("request_code", request_code).
|
||||||
|
Uint8("minor_code", minor_code).
|
||||||
|
Msg("X event error occured")
|
||||||
|
})
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
xorg.DisplayClose()
|
xorg.DisplayClose()
|
||||||
|
Loading…
Reference in New Issue
Block a user