Resolved TODO about OpenFile() on GTK+ returning NULL.

This commit is contained in:
Pietro Gagliardi 2014-08-31 19:07:55 -04:00
parent 29a764199f
commit c91cbf12b8
2 changed files with 4 additions and 2 deletions

View File

@ -27,7 +27,8 @@ func (w *window) openFile(f func(filename string)) {
window := (*C.GtkWindow)(unsafe.Pointer(widget))
dialog := (*C.GtkDialog)(unsafe.Pointer(widget))
fc := (*C.GtkFileChooser)(unsafe.Pointer(widget))
C.gtk_file_chooser_set_local_only(fc, C.FALSE)
// 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)
@ -49,7 +50,7 @@ func our_openfile_response_callback(dialog *C.GtkDialog, response C.gint, data C
}
filename := C.gtk_file_chooser_get_filename((*C.GtkFileChooser)(unsafe.Pointer(dialog)))
if filename == nil {
panic("[DEBUG TODO] chosen filename NULL")
panic("chosen filename NULL in OpenFile()")
}
realfilename := fromgstr(filename)
C.g_free(C.gpointer(unsafe.Pointer(filename)))

View File

@ -29,6 +29,7 @@ static DWORD WINAPI doOpenFile(LPVOID data)
ofn.lpstrInitialDir = NULL; // let system decide
ofn.lpstrTitle = NULL; // let system decide
// TODO OFN_SHAREAWARE?
// better question: TODO keep networking?
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_FORCESHOWHIDDEN | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_NOCHANGEDIR | OFN_NODEREFERENCELINKS | OFN_NOTESTFILECREATE | OFN_PATHMUSTEXIST;
if (GetOpenFileNameW(&ofn) == FALSE) {
err = CommDlgExtendedError();