-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_chooser.go
62 lines (47 loc) · 1.49 KB
/
file_chooser.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package gtk
/*
#include <stdlib.h>
#include <gtk/gtkfilechooser.h>
GtkFileChooser* _gtk_file_chooser_cast(GtkWidget* w) {
return GTK_FILE_CHOOSER(w);
}
char* _gtk_file_chooser_get_filename(GtkFileChooser* f) {
return gtk_file_chooser_get_filename(f);
}
*/
import "C"
import (
"unsafe"
"github.com/ziutek/glib"
)
type FileChooserAction C.GtkFileChooserAction
const (
FILE_CHOOSER_ACTION_OPEN = FileChooserAction(C.GTK_FILE_CHOOSER_ACTION_OPEN)
FILE_CHOOSER_ACTION_SAVE = FileChooserAction(C.GTK_FILE_CHOOSER_ACTION_SAVE)
FILE_CHOOSER_ACTION_SELECT_FOLDER = FileChooserAction(C.GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
FILE_CHOOSER_ACTION_CREATE_FOLDER = FileChooserAction(C.GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
)
func (f FileChooserAction) g() C.GtkFileChooserAction {
return C.GtkFileChooserAction(f)
}
type FileChooser C.GtkFileChooser
func (f *FileChooser) g() *C.GtkFileChooser {
return (*C.GtkFileChooser)(f)
}
func (f *FileChooser) Type() glib.Type {
return glib.TypeFromName("GtkFileChooser")
}
func (f *FileChooser) SetAction(action FileChooserAction) {
C.gtk_file_chooser_set_action(f.g(), action.g())
}
func (f *FileChooser) GetAction() FileChooserAction {
return FileChooserAction(C.gtk_file_chooser_get_action(f.g()))
}
func (f *FileChooser) GetFilename() string {
n := C._gtk_file_chooser_get_filename(f.g())
defer C.free(unsafe.Pointer(n))
return C.GoString(n)
}
func FileChooserCast(w *Widget) *FileChooser {
return (*FileChooser)(C._gtk_file_chooser_cast(w.g()))
}