コード例 #1
0
ファイル: window_unix.go プロジェクト: NotBadPad/ui
func newWindow(title string, width int, height int, control Control) *window {
	widget := C.gtk_window_new(C.GTK_WINDOW_TOPLEVEL)
	ctitle := togstr(title)
	defer freegstr(ctitle)
	w := &window{
		widget:  widget,
		wc:      (*C.GtkContainer)(unsafe.Pointer(widget)),
		bin:     (*C.GtkBin)(unsafe.Pointer(widget)),
		window:  (*C.GtkWindow)(unsafe.Pointer(widget)),
		closing: newEvent(),
	}
	C.gtk_window_set_title(w.window, ctitle)
	g_signal_connect(
		C.gpointer(unsafe.Pointer(w.window)),
		"delete-event",
		C.GCallback(C.windowClosing),
		C.gpointer(unsafe.Pointer(w)))
	C.gtk_window_resize(w.window, C.gint(width), C.gint(height))
	w.container = newContainer(control)
	w.container.setParent(&controlParent{w.wc})
	// for dialogs; otherwise, they will be modal to all windows, not just this one
	w.group = C.gtk_window_group_new()
	C.gtk_window_group_add_window(w.group, w.window)
	return w
}
コード例 #2
0
ファイル: keyfile.go プロジェクト: sqp/godock
// HasKey is a wrapper around g_key_file_has_key().
func (kf *KeyFile) HasKey(group string, key string) bool {
	cGroup := (*C.gchar)(C.CString(group))
	defer C.g_free(C.gpointer(cGroup))
	cKey := (*C.gchar)(C.CString(key))
	defer C.g_free(C.gpointer(cKey))
	return goBool(C.g_key_file_has_key(kf.cKey, cGroup, cKey, nil))
}
コード例 #3
0
ファイル: internet_address.go プロジェクト: partkyle/go-gmime
func NewMailboxAddress(name string, email string) *MailboxAddress {
	var cName *C.char = C.CString(name)
	var cEmail *C.char = C.CString(email)
	defer C.free(unsafe.Pointer(cName))
	defer C.free(unsafe.Pointer(cEmail))
	ai := C.internet_address_mailbox_new(cName, cEmail)
	defer unref(C.gpointer(ai))
	return CastMailboxAddress((*C.InternetAddressMailbox)(C.gpointer(ai)))
}
コード例 #4
0
ファイル: gobject_class_types.go プロジェクト: reusee/ggir
func NewParamSpecFromCPointer(p unsafe.Pointer) *ParamSpec {
	ret := &ParamSpec{
		NewTraitParamSpec(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *ParamSpec) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #5
0
ファイル: gobject_class_types.go プロジェクト: reusee/ggir
func NewObjectFromCPointer(p unsafe.Pointer) *Object {
	ret := &Object{
		NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *Object) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #6
0
ファイル: gdk_class_types.go プロジェクト: reusee/ggir
func NewAppLaunchContextFromCPointer(p unsafe.Pointer) *AppLaunchContext {
	ret := &AppLaunchContext{
		NewTraitAppLaunchContext(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *AppLaunchContext) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #7
0
ファイル: glib.go プロジェクト: leif/go-gtk
func (v *GObject) Set(name string, value interface{}) {
	ptr := C.CString(name)
	defer C.free_string(ptr)

	if _, ok := value.(WrappedObject); ok {
		value = value.(WrappedObject).GetInternalValue()
	}
	if _, ok := value.(GObject); ok {
		value = value.(GObject).Object
	}
	if _, ok := value.(GValue); ok {
		value = value.(GValue).Value
	}

	switch value.(type) {
	case bool:
		bval := bool2gboolean(value.(bool))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&bval))
	case byte:
		bval := C.gchar(value.(byte))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&bval))
		//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.gchar(value.(byte))).UnsafeAddr()))
	case int:
		ival := C.int(value.(int))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&ival))
	case uint:
		uval := C.guint(value.(uint))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&uval))
		//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.guint(value.(uint))).UnsafeAddr()))
	case float32:
		f32val := C.gfloat(value.(float32))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&f32val))
		//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.gfloat(value.(float64))).UnsafeAddr()))
	case float64:
		f64val := C.gfloat(value.(float64))
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&f64val))
		//C._g_object_set(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(C.gfloat(value.(float64))).UnsafeAddr()))
	case string:
		pval := C.CString(value.(string))
		defer C.free_string(pval)
		C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(&pval))
	default:
		if pv, ok := value.(*[0]uint8); ok {
			C._g_object_set_ptr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(pv))
		} else {
			av := reflect.ValueOf(value)
			if av.CanAddr() {
				C._g_object_set_addr(C.gpointer(v.Object), C.to_gcharptr(ptr), unsafe.Pointer(reflect.ValueOf(value).UnsafeAddr()))
			} else {
				C._g_object_set_ptr(C.gpointer(v.Object), C.to_gcharptr(ptr), value.(unsafe.Pointer))
			}
		}
	}
}
コード例 #8
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewAppInfoMonitorFromCPointer(p unsafe.Pointer) *AppInfoMonitor {
	ret := &AppInfoMonitor{
		NewTraitAppInfoMonitor(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *AppInfoMonitor) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #9
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewDBusMethodInvocationFromCPointer(p unsafe.Pointer) *DBusMethodInvocation {
	ret := &DBusMethodInvocation{
		NewTraitDBusMethodInvocation(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *DBusMethodInvocation) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #10
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewSimpleProxyResolverFromCPointer(p unsafe.Pointer) *SimpleProxyResolver {
	ret := &SimpleProxyResolver{
		NewTraitSimpleProxyResolver(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *SimpleProxyResolver) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #11
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewCredentialsFromCPointer(p unsafe.Pointer) *Credentials {
	ret := &Credentials{
		NewTraitCredentials(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *Credentials) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #12
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewInetAddressMaskFromCPointer(p unsafe.Pointer) *InetAddressMask {
	ret := &InetAddressMask{
		NewTraitInetAddressMask(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *InetAddressMask) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #13
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewApplicationCommandLineFromCPointer(p unsafe.Pointer) *ApplicationCommandLine {
	ret := &ApplicationCommandLine{
		NewTraitApplicationCommandLine(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *ApplicationCommandLine) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #14
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewTlsPasswordFromCPointer(p unsafe.Pointer) *TlsPassword {
	ret := &TlsPassword{
		NewTraitTlsPassword(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *TlsPassword) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #15
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewEmblemedIconFromCPointer(p unsafe.Pointer) *EmblemedIcon {
	ret := &EmblemedIcon{
		NewTraitEmblemedIcon(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *EmblemedIcon) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #16
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewTlsCertificateFromCPointer(p unsafe.Pointer) *TlsCertificate {
	ret := &TlsCertificate{
		NewTraitTlsCertificate(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *TlsCertificate) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #17
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewCancellableFromCPointer(p unsafe.Pointer) *Cancellable {
	ret := &Cancellable{
		NewTraitCancellable(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *Cancellable) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #18
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewSubprocessLauncherFromCPointer(p unsafe.Pointer) *SubprocessLauncher {
	ret := &SubprocessLauncher{
		NewTraitSubprocessLauncher(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *SubprocessLauncher) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #19
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewSocketControlMessageFromCPointer(p unsafe.Pointer) *SocketControlMessage {
	ret := &SocketControlMessage{
		NewTraitSocketControlMessage(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *SocketControlMessage) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #20
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewSocketAddressEnumeratorFromCPointer(p unsafe.Pointer) *SocketAddressEnumerator {
	ret := &SocketAddressEnumerator{
		NewTraitSocketAddressEnumerator(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *SocketAddressEnumerator) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #21
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewDBusServerFromCPointer(p unsafe.Pointer) *DBusServer {
	ret := &DBusServer{
		NewTraitDBusServer(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *DBusServer) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #22
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewPropertyActionFromCPointer(p unsafe.Pointer) *PropertyAction {
	ret := &PropertyAction{
		NewTraitPropertyAction(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *PropertyAction) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #23
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewDesktopAppInfoFromCPointer(p unsafe.Pointer) *DesktopAppInfo {
	ret := &DesktopAppInfo{
		NewTraitDesktopAppInfo(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *DesktopAppInfo) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #24
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewCharsetConverterFromCPointer(p unsafe.Pointer) *CharsetConverter {
	ret := &CharsetConverter{
		NewTraitCharsetConverter(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *CharsetConverter) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #25
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewFilenameCompleterFromCPointer(p unsafe.Pointer) *FilenameCompleter {
	ret := &FilenameCompleter{
		NewTraitFilenameCompleter(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *FilenameCompleter) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #26
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewVfsFromCPointer(p unsafe.Pointer) *Vfs {
	ret := &Vfs{
		NewTraitVfs(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *Vfs) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #27
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewInputStreamFromCPointer(p unsafe.Pointer) *InputStream {
	ret := &InputStream{
		NewTraitInputStream(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *InputStream) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #28
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewZlibDecompressorFromCPointer(p unsafe.Pointer) *ZlibDecompressor {
	ret := &ZlibDecompressor{
		NewTraitZlibDecompressor(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *ZlibDecompressor) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #29
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewUnixFDListFromCPointer(p unsafe.Pointer) *UnixFDList {
	ret := &UnixFDList{
		NewTraitUnixFDList(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *UnixFDList) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}
コード例 #30
0
ファイル: gio_class_types.go プロジェクト: reusee/ggir
func NewSimpleActionGroupFromCPointer(p unsafe.Pointer) *SimpleActionGroup {
	ret := &SimpleActionGroup{
		NewTraitSimpleActionGroup(p),
		gobject.NewTraitObject(p),
		p,
	}
	C.g_object_ref_sink(C.gpointer(p))
	runtime.SetFinalizer(ret, func(p *SimpleActionGroup) {
		C.g_object_unref(C.gpointer(unsafe.Pointer(p.CPointer)))
	})
	return ret
}