diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-19 10:31:12 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-19 10:32:23 -0400 |
| commit | 24e5519a5baacc9263eb1e46cd915a068b1d8562 (patch) | |
| tree | 5e60197d3bafbf89da0c2944b8e9d0296465a464 /redo/dialog_unix.go | |
| parent | ea9907e62a7e47758b784979fa46308678433168 (diff) | |
Added the GTK+ implementation of OpenFile(). Also more TODOs.
Diffstat (limited to 'redo/dialog_unix.go')
| -rw-r--r-- | redo/dialog_unix.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/redo/dialog_unix.go b/redo/dialog_unix.go new file mode 100644 index 0000000..552f485 --- /dev/null +++ b/redo/dialog_unix.go @@ -0,0 +1,42 @@ +// 19 august 2014 + +package ui + +import ( + "unsafe" +) + +// #include "gtk_unix.h" +// /* because cgo doesn't like ... */ +// GtkWidget *newOpenFileDialog(void) +// { +// return gtk_file_chooser_dialog_new(NULL, /* default title */ +// NULL, /* no parent window */ +// GTK_FILE_CHOOSER_ACTION_OPEN, +// GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, +// GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, +// NULL); +// } +import "C" + +func openFile() string { + widget := C.newOpenFileDialog() + defer C.gtk_widget_destroy(widget) + dialog := (*C.GtkDialog)(unsafe.Pointer(widget)) + fc := (*C.GtkFileChooser)(unsafe.Pointer(widget)) + 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 + response := C.gtk_dialog_run(dialog) + inmodal = false + if response != C.GTK_RESPONSE_ACCEPT { + return "" + } + filename := C.gtk_file_chooser_get_filename(fc) + if filename == nil { + panic("[DEBUG TODO] chosen filename NULL") + } + defer C.g_free(C.gpointer(unsafe.Pointer(filename))) + return fromgstr(filename) +} |
