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 }
// 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)) }
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))) }
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 }
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 }
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 }
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)) } } } }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }
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 }