Skip to content
Snippets Groups Projects
Select Git revision
  • f61f61e37be5358a9869de6644dc63a67327f005
  • master default protected
  • fix/dont_save_partition_table_of_mapper_devices
  • fix_11285
  • debian
  • pristine-tar
  • upstream
  • backupninja_debian/1.0.2-1
  • backupninja_upstream/1.0.2
  • backupninja-1.0.2
  • backupninja_debian/1.0.1-2
  • backupninja_debian/1.0.1-1
  • backupninja_upstream/1.0.1
  • backupninja-1.0.1
  • backupninja_debian/1.0-1
  • backupninja_upstream/1.0
  • backupninja-1.0
  • backupninja_debian/1.0_rc1-1
  • backupninja_upstream/1.0_rc1
  • backupninja-1.0-rc1
  • backupninja_debian/0.9.10-2
  • backupninja_debian/0.9.10-1
  • backupninja_upstream/0.9.10
  • backupninja-0.9.10
  • backupninja_debian/0.9.9-1
  • backupninja-0.9.9
  • backupninja-0.9.8.1
27 results

example.sh

Blame
  • Forked from Liberate / backupninja
    Source project has a limited visibility.
    dlg.go 2.24 KiB
    package cocoa
    
    // #cgo darwin LDFLAGS: -framework Cocoa
    // #include <stdlib.h>
    // #include <sys/syslimits.h>
    // #include "dlg.h"
    import "C"
    
    import (
    	"bytes"
    	"errors"
    	"unsafe"
    )
    
    type AlertParams struct {
    	p C.AlertDlgParams
    }
    
    func mkAlertParams(msg, title string, style C.AlertStyle) *AlertParams {
    	a := AlertParams{C.AlertDlgParams{msg: C.CString(msg), style: style}}
    	if title != "" {
    		a.p.title = C.CString(title)
    	}
    	return &a
    }
    
    func (a *AlertParams) run() C.DlgResult {
    	return C.alertDlg(&a.p)
    }
    
    func (a *AlertParams) free() {
    	C.free(unsafe.Pointer(a.p.msg))
    	if a.p.title != nil {
    		C.free(unsafe.Pointer(a.p.title))
    	}
    }
    
    func nsStr(s string) unsafe.Pointer {
    	return C.NSStr(unsafe.Pointer(&[]byte(s)[0]), C.int(len(s)))
    }
    
    func YesNoDlg(msg, title string) bool {
    	a := mkAlertParams(msg, title, C.MSG_YESNO)
    	defer a.free()
    	return a.run() == C.DLG_OK
    }
    
    func InfoDlg(msg, title string) {
    	a := mkAlertParams(msg, title, C.MSG_INFO)
    	defer a.free()
    	a.run()
    }
    
    func ErrorDlg(msg, title string) {
    	a := mkAlertParams(msg, title, C.MSG_ERROR)
    	defer a.free()
    	a.run()
    }
    
    const BUFSIZE = C.PATH_MAX
    
    func FileDlg(save int, title string, exts []string, relaxExt bool) (string, error) {
    	p := C.FileDlgParams{
    		save: C.int(save),
    		nbuf: BUFSIZE,
    	}
    	p.buf = (*C.char)(C.malloc(BUFSIZE))
    	defer C.free(unsafe.Pointer(p.buf))
    	buf := (*(*[BUFSIZE]byte)(unsafe.Pointer(p.buf)))[:]
    	if title != "" {