summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redo/dialog_unix.go5
-rw-r--r--redo/uitask_unix.go23
2 files changed, 16 insertions, 12 deletions
diff --git a/redo/dialog_unix.go b/redo/dialog_unix.go
index 6a16ac6..a4020aa 100644
--- a/redo/dialog_unix.go
+++ b/redo/dialog_unix.go
@@ -9,6 +9,7 @@ import (
)
// #include "gtk_unix.h"
+// #include "modalqueue.h"
// /* because cgo doesn't like ... */
// GtkWidget *newOpenFileDialog(void)
// {
@@ -29,9 +30,9 @@ func openFile() string {
C.gtk_file_chooser_set_local_only(fc, C.FALSE)
C.gtk_file_chooser_set_select_multiple(fc, C.FALSE)
C.gtk_file_chooser_set_show_hidden(fc, C.TRUE)
- inmodal = true
+ C.beginModal()
response := C.gtk_dialog_run(dialog)
- inmodal = false
+ C.endModal()
if response != C.GTK_RESPONSE_ACCEPT {
return ""
}
diff --git a/redo/uitask_unix.go b/redo/uitask_unix.go
index d330e4b..86628dd 100644
--- a/redo/uitask_unix.go
+++ b/redo/uitask_unix.go
@@ -12,7 +12,8 @@ import (
// #cgo pkg-config: gtk+-3.0
// #cgo CFLAGS: --std=c99
// #include "gtk_unix.h"
-// extern gboolean doissue(gpointer data);
+// #include "modalqueue.h"
+// extern gboolean xdoissue(gpointer data);
import "C"
func uiinit() error {
@@ -36,17 +37,19 @@ func uistop() {
}
func issue(f *func()) {
- C.gdk_threads_add_idle(C.GSourceFunc(C.doissue), C.gpointer(unsafe.Pointer(f)))
+ if C.queueIfModal(unsafe.Pointer(f)) == 0 {
+ C.gdk_threads_add_idle(C.GSourceFunc(C.xdoissue), C.gpointer(unsafe.Pointer(f)))
+ }
}
-// TODO this is not order-safe!
-var inmodal = false
-
-//export doissue
-func doissue(data C.gpointer) C.gboolean {
- if inmodal {
- return C.TRUE // wait for modal dialog to finish
- }
+//export xdoissue
+func xdoissue(data C.gpointer) C.gboolean {
perform(unsafe.Pointer(data))
return C.FALSE // don't repeat
}
+
+//export doissue
+func doissue(data unsafe.Pointer) {
+ // for the modal queue functions
+ perform(data)
+}