// Code generated by cmd/cgo; DO NOT EDIT. //line /home/josie/.cache/paru/clone/wiiudownloader/src/pkg/mod/github.com/!xpl0it!u/dialog@v0.0.0-20230805114139-ec888310aded/dlgs_linux.go:1:1 package dialog // #cgo pkg-config: gtk+-3.0 // #cgo LDFLAGS: -lX11 // #include // #include // #include // static GtkWidget* msgdlg(GtkWindow *parent, GtkDialogFlags flags, GtkMessageType type, GtkButtonsType buttons, char *msg) { // return gtk_message_dialog_new(parent, flags, type, buttons, "%s", msg); // } // static GtkWidget* filedlg(char *title, GtkWindow *parent, GtkFileChooserAction action, char* acceptText) { // return gtk_file_chooser_dialog_new(title, parent, action, "Cancel", GTK_RESPONSE_CANCEL, acceptText, GTK_RESPONSE_ACCEPT, NULL); // } import _ "unsafe" import "unsafe" var initSuccess bool func init() { ( /*line :20:2*/_Cfunc_XInitThreads /*line :20:15*/)() initSuccess = (( /*line :21:17*/_Cfunc_gtk_init_check /*line :21:32*/)(nil, nil) == ( /*line :21:47*/_Ciconst_TRUE /*line :21:52*/)) } func checkStatus() { if !initSuccess { panic("gtk initialisation failed; presumably no X server is available") } } func closeDialog(dlg * /*line :30:23*/_Ctype_GtkWidget /*line :30:34*/) { func() { _cgo0 := /*line :31:23*/dlg; _cgoCheckPointer(_cgo0, nil); /*line :31:27*/_Cfunc_gtk_widget_destroy(_cgo0); }() /* The Destroy call itself isn't enough to remove the dialog from the screen; apparently ** that happens once the GTK main loop processes some further events. But if we're ** in a non-GTK app the main loop isn't running, so we empty the event queue before ** returning from the dialog functions. ** Not sure how this interacts with an actual GTK app... */ for ( /*line :37:6*/_Cfunc_gtk_events_pending /*line :37:25*/)() != 0 { ( /*line :38:3*/_Cfunc_gtk_main_iteration /*line :38:22*/)() } } func runMsgDlg(defaultTitle string, flags /*line :42:43*/_Ctype_GtkDialogFlags /*line :42:59*/, msgtype /*line :42:69*/_Ctype_GtkMessageType /*line :42:85*/, buttons /*line :42:95*/_Ctype_GtkButtonsType /*line :42:111*/, b *MsgBuilder) /*line :42:128*/_Ctype_gint /*line :42:134*/ { checkStatus() cmsg := ( /*line :44:10*/_Cfunc_CString /*line :44:18*/)(b.Msg) defer func() func() { _cgo0 := /*line :45:15*/unsafe.Pointer(cmsg); return func() { _cgoCheckPointer(_cgo0, nil); /*line :45:36*/_Cfunc_free(_cgo0); }}()() dlg := ( /*line :46:9*/_Cfunc_msgdlg /*line :46:16*/)(nil, flags, msgtype, buttons, cmsg) ctitle := ( /*line :47:12*/_Cfunc_CString /*line :47:20*/)(firstOf(b.Dlg.Title, defaultTitle)) defer func() func() { _cgo0 := /*line :48:15*/unsafe.Pointer(ctitle); return func() { _cgoCheckPointer(_cgo0, nil); /*line :48:38*/_Cfunc_free(_cgo0); }}()() func() { _cgo0 := /*line :49:25*/(*_Ctype_GtkWindow /*line :49:38*/)(unsafe.Pointer(dlg)); var _cgo1 *_Ctype_gchar = /*line :49:62*/ctitle; _cgoCheckPointer(_cgo0, nil); /*line :49:69*/_Cfunc_gtk_window_set_title(_cgo0, _cgo1); }() defer closeDialog(dlg) return func() _Ctype_gint{ _cgo0 := /*line :51:26*/(*_Ctype_GtkDialog /*line :51:39*/)(unsafe.Pointer(dlg)); _cgoCheckPointer(_cgo0, nil); return /*line :51:62*/_Cfunc_gtk_dialog_run(_cgo0); }() } func (b *MsgBuilder) yesNo() bool { return runMsgDlg("Confirm?", 0, ( /*line :55:34*/_Ciconst_GTK_MESSAGE_QUESTION /*line :55:55*/), ( /*line :55:58*/_Ciconst_GTK_BUTTONS_YES_NO /*line :55:77*/), b) == ( /*line :55:86*/_Ciconst_GTK_RESPONSE_YES /*line :55:103*/) } func (b *MsgBuilder) info() { runMsgDlg("Information", 0, ( /*line :59:30*/_Ciconst_GTK_MESSAGE_INFO /*line :59:47*/), ( /*line :59:50*/_Ciconst_GTK_BUTTONS_OK /*line :59:65*/), b) } func (b *MsgBuilder) error() { runMsgDlg("Error", 0, ( /*line :63:24*/_Ciconst_GTK_MESSAGE_ERROR /*line :63:42*/), ( /*line :63:45*/_Ciconst_GTK_BUTTONS_OK /*line :63:60*/), b) } func (b *FileBuilder) load() (string, error) { return chooseFile("Open File", "Open", ( /*line :67:41*/_Ciconst_GTK_FILE_CHOOSER_ACTION_OPEN /*line :67:70*/), b) } func (b *FileBuilder) save() (string, error) { f, err := chooseFile("Save File", "Save", ( /*line :71:44*/_Ciconst_GTK_FILE_CHOOSER_ACTION_SAVE /*line :71:73*/), b) if err != nil { return "", err } return f, nil } func chooseFile(title string, buttonText string, action /*line :78:57*/_Ctype_GtkFileChooserAction /*line :78:79*/, b *FileBuilder) (string, error) { checkStatus() ctitle := ( /*line :80:12*/_Cfunc_CString /*line :80:20*/)(title) defer func() func() { _cgo0 := /*line :81:15*/unsafe.Pointer(ctitle); return func() { _cgoCheckPointer(_cgo0, nil); /*line :81:38*/_Cfunc_free(_cgo0); }}()() cbuttonText := ( /*line :82:17*/_Cfunc_CString /*line :82:25*/)(buttonText) defer func() func() { _cgo0 := /*line :83:15*/unsafe.Pointer(cbuttonText); return func() { _cgoCheckPointer(_cgo0, nil); /*line :83:43*/_Cfunc_free(_cgo0); }}()() dlg := ( /*line :84:9*/_Cfunc_filedlg /*line :84:17*/)(ctitle, nil, action, cbuttonText) fdlg := (* /*line :85:12*/_Ctype_GtkFileChooser /*line :85:28*/)(unsafe.Pointer(dlg)) for _, filt := range b.Filters { filter := ( /*line :88:13*/_Cfunc_gtk_file_filter_new /*line :88:33*/)() cdesc := ( /*line :89:12*/_Cfunc_CString /*line :89:20*/)(filt.Desc) defer func() func() { _cgo0 := /*line :90:16*/unsafe.Pointer(cdesc); return func() { _cgoCheckPointer(_cgo0, nil); /*line :90:38*/_Cfunc_free(_cgo0); }}()() func() { _cgo0 := /*line :91:30*/filter; var _cgo1 *_Ctype_gchar = /*line :91:38*/cdesc; _cgoCheckPointer(_cgo0, nil); /*line :91:44*/_Cfunc_gtk_file_filter_set_name(_cgo0, _cgo1); }() for _, ext := range filt.Extensions { cpattern := ( /*line :94:16*/_Cfunc_CString /*line :94:24*/)("*." + ext) defer func() func() { _cgo0 := /*line :95:17*/unsafe.Pointer(cpattern); return func() { _cgoCheckPointer(_cgo0, nil); /*line :95:42*/_Cfunc_free(_cgo0); }}()() func() { _cgo0 := /*line :96:34*/filter; var _cgo1 *_Ctype_gchar = /*line :96:42*/cpattern; _cgoCheckPointer(_cgo0, nil); /*line :96:51*/_Cfunc_gtk_file_filter_add_pattern(_cgo0, _cgo1); }() } func() { _cgo0 := /*line :98:33*/fdlg; _cgo1 := /*line :98:39*/filter; _cgoCheckPointer(_cgo0, nil); _cgoCheckPointer(_cgo1, nil); /*line :98:46*/_Cfunc_gtk_file_chooser_add_filter(_cgo0, _cgo1); }() } if b.StartDir != "" { cdir := ( /*line :101:11*/_Cfunc_CString /*line :101:19*/)(b.StartDir) defer func() func() { _cgo0 := /*line :102:16*/unsafe.Pointer(cdir); return func() { _cgoCheckPointer(_cgo0, nil); /*line :102:37*/_Cfunc_free(_cgo0); }}()() func() _Ctype_gboolean{ _cgo0 := /*line :103:41*/fdlg; var _cgo1 *_Ctype_gchar = /*line :103:47*/cdir; _cgoCheckPointer(_cgo0, nil); return /*line :103:52*/_Cfunc_gtk_file_chooser_set_current_folder(_cgo0, _cgo1); }() } if b.StartFile != "" { cfile := ( /*line :106:12*/_Cfunc_CString /*line :106:20*/)(b.StartFile) defer func() func() { _cgo0 := /*line :107:16*/unsafe.Pointer(cfile); return func() { _cgoCheckPointer(_cgo0, nil); /*line :107:38*/_Cfunc_free(_cgo0); }}()() func() { _cgo0 := /*line :108:39*/fdlg; var _cgo1 *_Ctype_gchar = /*line :108:45*/cfile; _cgoCheckPointer(_cgo0, nil); /*line :108:51*/_Cfunc_gtk_file_chooser_set_current_name(_cgo0, _cgo1); }() } func() { _cgo0 := /*line :110:51*/fdlg; var _cgo1 _Ctype_gboolean = /*line :110:57*/_Ciconst_TRUE /*line :110:63*/; _cgoCheckPointer(_cgo0, nil); /*line :110:64*/_Cfunc_gtk_file_chooser_set_do_overwrite_confirmation(_cgo0, _cgo1); }() r := func() _Ctype_gint{ _cgo0 := /*line :111:24*/(*_Ctype_GtkDialog /*line :111:37*/)(unsafe.Pointer(dlg)); _cgoCheckPointer(_cgo0, nil); return /*line :111:60*/_Cfunc_gtk_dialog_run(_cgo0); }() defer closeDialog(dlg) if r == ( /*line :113:10*/_Ciconst_GTK_RESPONSE_ACCEPT /*line :113:30*/) { return ( /*line :114:10*/_Cfunc_GoString /*line :114:19*/)(func() *_Ctype_gchar{ _cgo0 := /*line :114:53*/fdlg; _cgoCheckPointer(_cgo0, nil); return /*line :114:58*/_Cfunc_gtk_file_chooser_get_filename(_cgo0); }()), nil } return "", ErrCancelled } func (b *DirectoryBuilder) browse() (string, error) { return chooseFile("Open Folder", "Open", ( /*line :120:43*/_Ciconst_GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER /*line :120:81*/), &FileBuilder{Dlg: b.Dlg}) }