summaryrefslogtreecommitdiff
path: root/dialog_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2015-12-11 20:37:59 -0500
committerPietro Gagliardi <[email protected]>2015-12-11 20:37:59 -0500
commitf8e3f12ab02b528f2a05a4f713d7af7ea8e44b42 (patch)
tree82dedf4d37f0f6d31e88ebb2ca1ce6499dead261 /dialog_unix.go
parente34c561ed5bedeb180437ec165882b98d70d38c1 (diff)
LET'S GET THIS FINAL REWRITE EVER STARTED
Diffstat (limited to 'dialog_unix.go')
-rw-r--r--dialog_unix.go59
1 files changed, 0 insertions, 59 deletions
diff --git a/dialog_unix.go b/dialog_unix.go
deleted file mode 100644
index c908910..0000000
--- a/dialog_unix.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// +build !windows,!darwin
-
-// 19 august 2014
-
-package ui
-
-import (
- "unsafe"
-)
-
-// #include "gtk_unix.h"
-// extern void our_openfile_response_callback(GtkDialog *, gint, gpointer);
-// /* because cgo doesn't like ... */
-// static inline GtkWidget *newOpenFileDialog(GtkWindow *parent)
-// {
-// return gtk_file_chooser_dialog_new(NULL, /* default title */
-// parent,
-// GTK_FILE_CHOOSER_ACTION_OPEN,
-// GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-// GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
-// NULL);
-// }
-import "C"
-
-func (w *window) openFile(f func(filename string)) {
- widget := C.newOpenFileDialog(w.window)
- window := (*C.GtkWindow)(unsafe.Pointer(widget))
- dialog := (*C.GtkDialog)(unsafe.Pointer(widget))
- fc := (*C.GtkFileChooser)(unsafe.Pointer(widget))
- // non-local filenames are relevant mainly to GIO where we can open *anything*, not to Go os.File; see https://twitter.com/braket/status/506142849654870016
- C.gtk_file_chooser_set_local_only(fc, C.TRUE)
- C.gtk_file_chooser_set_select_multiple(fc, C.FALSE)
- C.gtk_file_chooser_set_show_hidden(fc, C.TRUE)
- C.gtk_window_set_modal(window, C.TRUE)
- g_signal_connect(
- C.gpointer(unsafe.Pointer(dialog)),
- "response",
- C.GCallback(C.our_openfile_response_callback),
- C.gpointer(unsafe.Pointer(&f)))
- C.gtk_widget_show_all(widget)
-}
-
-//export our_openfile_response_callback
-func our_openfile_response_callback(dialog *C.GtkDialog, response C.gint, data C.gpointer) {
- f := (*func(string))(unsafe.Pointer(data))
- if response != C.GTK_RESPONSE_ACCEPT {
- (*f)("")
- C.gtk_widget_destroy((*C.GtkWidget)(unsafe.Pointer(dialog)))
- return
- }
- filename := C.gtk_file_chooser_get_filename((*C.GtkFileChooser)(unsafe.Pointer(dialog)))
- if filename == nil {
- panic("chosen filename NULL in OpenFile()")
- }
- realfilename := fromgstr(filename)
- C.g_free(C.gpointer(unsafe.Pointer(filename)))
- C.gtk_widget_destroy((*C.GtkWidget)(unsafe.Pointer(dialog)))
- (*f)(realfilename)
-}