• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang glib.ErrorFromNative函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/mattn/go-gtk/glib.ErrorFromNative函数的典型用法代码示例。如果您正苦于以下问题:Golang ErrorFromNative函数的具体用法?Golang ErrorFromNative怎么用?Golang ErrorFromNative使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ErrorFromNative函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Save

func (p *Pixbuf) Save(filename, savetype string, options ...string) *glib.Error {
	if len(options)%2 != 0 {
		argumentPanic("Save options must be even (key and value)")
	}

	pfilename := C.CString(filename)
	defer cfree(pfilename)
	psavetype := C.CString(savetype)
	defer cfree(psavetype)

	klen := len(options) / 2
	keys := C.makeCstrv(C.int(klen + 1))
	vals := C.makeCstrv(C.int(klen + 1))
	for i := 0; i < klen; i++ {
		C.setCstr(keys, C.int(i), C.CString(options[2*i]))
		C.setCstr(vals, C.int(i), C.CString(options[2*i+1]))
	}
	C.setCstr(keys, C.int(klen), nil)
	C.setCstr(vals, C.int(klen), nil)
	defer func() {
		for i := 0; i < klen; i++ {
			cfree(C.getCstr(keys, C.int(i)))
			cfree(C.getCstr(vals, C.int(i)))
		}
		C.freeCstrv(keys)
		C.freeCstrv(vals)
	}()

	var err *C.GError
	C.gdk_pixbuf_savev(p.GPixbuf, pfilename, psavetype, keys, vals, &err)
	if err != nil {
		return glib.ErrorFromNative(unsafe.Pointer(err))
	}
	return nil
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:35,代码来源:gdkpixbuf.go


示例2: NotificationClose

func NotificationClose(notif *NotifyNotification) *glib.Error {
	var err *C.GError

	C.notify_notification_close(notif._notification, &err)

	return glib.ErrorFromNative(unsafe.Pointer(err))
}
开发者ID:oblank,项目名称:go-notify,代码行数:7,代码来源:notify.go


示例3: Close

func (v Loader) Close() (bool, *glib.Error) {
	var err *C.GError
	ret := gobool(C.gdk_pixbuf_loader_close(v.GPixbufLoader, &err))
	if err != nil {
		return ret, glib.ErrorFromNative(unsafe.Pointer(err))
	}
	return ret, nil
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:8,代码来源:gdkpixbuf.go


示例4: NewLoaderWithMimeType

func NewLoaderWithMimeType(mime_type string) (loader *Loader, err *glib.Error) {
	var error *C.GError
	ptr := C.CString(mime_type)
	defer cfree(ptr)
	loader = &Loader{
		C.gdk_pixbuf_loader_new_with_mime_type(ptr, &error)}
	err = glib.ErrorFromNative(unsafe.Pointer(error))
	return
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:9,代码来源:gdkpixbuf.go


示例5: Write

func (v Loader) Write(buf []byte) (bool, *glib.Error) {
	var err *C.GError
	var pbuf *byte
	pbuf = &buf[0]
	ret := gobool(C.gdk_pixbuf_loader_write(v.GPixbufLoader, C.to_gucharptr(unsafe.Pointer(pbuf)), C.gsize(len(buf)), &err))
	if err != nil {
		return ret, glib.ErrorFromNative(unsafe.Pointer(err))
	}
	return ret, nil
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:10,代码来源:gdkpixbuf.go


示例6: PixbufFromFileAtSize

func PixbufFromFileAtSize(path string, imgW int, imgH int) (pixbuf *GdkPixbuf, err **glib.Error) {
	var error *C.GError
	ptr := C.CString(path)
	defer C.free_string(ptr)
	pixbuf = &GdkPixbuf{C.gdk_pixbuf_new_from_file_at_size(ptr, C.int(imgW), C.int(imgH), &error)}
	if err != nil && error != nil {
		*err = glib.ErrorFromNative(unsafe.Pointer(error))
	}
	return
}
开发者ID:arip33,项目名称:go-gtk,代码行数:10,代码来源:gdkpixbuf.go


示例7: PixbufFromFile

func PixbufFromFile(path string) (pixbuf *GdkPixbuf, err **glib.Error) {
	var error *C.GError
	ptr := C.CString(path)
	defer C.free_string(ptr)
	pixbuf = &GdkPixbuf{C.gdk_pixbuf_new_from_file(ptr, &error)}
	if err != nil && error != nil {
		*err = glib.ErrorFromNative(unsafe.Pointer(error))
	}
	return
}
开发者ID:arip33,项目名称:go-gtk,代码行数:10,代码来源:gdkpixbuf.go


示例8: NewLoaderWithType

func NewLoaderWithType(image_type string) (loader *Loader, err *glib.Error) {
	var gerr *C.GError
	ptr := C.CString(image_type)
	defer cfree(ptr)
	loader = &Loader{
		C.gdk_pixbuf_loader_new_with_type(ptr, &gerr)}
	if gerr != nil {
		err = glib.ErrorFromNative(unsafe.Pointer(gerr))
	}
	return
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:11,代码来源:gdkpixbuf.go


示例9: SetLanguage

func (spell *GtkSpell) SetLanguage(language string) *glib.Error {
	lang := C.CString(language)
	defer C.free(unsafe.Pointer(lang))

	var gerror *C.GError
	C.gtkspell_set_language(spell.Spell, C.to_gcharptr(lang), &gerror)
	if gerror != nil {
		return glib.ErrorFromNative(unsafe.Pointer(gerror))
	}
	return nil
}
开发者ID:mattn,项目名称:go-gtk,代码行数:11,代码来源:gtkspell.go


示例10: NewPixbufFromXpmData

func NewPixbufFromXpmData(data **byte) (*Pixbuf, *glib.Error) {
	var err *C.GError
	gpixbuf := C.gdk_pixbuf_new_from_xpm_data(
		(**C.char)(unsafe.Pointer(data)),
	)
	if err != nil {
		return nil, glib.ErrorFromNative(unsafe.Pointer(err))
	}
	return &Pixbuf{
		GdkPixbuf: &GdkPixbuf{gpixbuf},
		GObject:   glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
	}, nil
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:13,代码来源:gdkpixbuf.go


示例11: NewPixbufFromFileAtScale

func NewPixbufFromFileAtScale(filename string, width, height int, preserve_aspect_ratio bool) (*Pixbuf, *glib.Error) {
	var err *C.GError
	ptr := C.CString(filename)
	defer cfree(ptr)
	gpixbuf := C.gdk_pixbuf_new_from_file_at_scale(ptr, C.int(width), C.int(height), gbool(preserve_aspect_ratio), &err)
	if err != nil {
		return nil, glib.ErrorFromNative(unsafe.Pointer(err))
	}
	return &Pixbuf{
		GdkPixbuf: &GdkPixbuf{gpixbuf},
		GObject:   glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
	}, nil
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:13,代码来源:gdkpixbuf.go


示例12: NewPixbufFromFile

func NewPixbufFromFile(filename string) (*Pixbuf, *glib.Error) {
	var err *C.GError
	ptr := C.CString(filename)
	defer cfree(ptr)
	gpixbuf := C.gdk_pixbuf_new_from_file(ptr, &err)
	if err != nil {
		return nil, glib.ErrorFromNative(unsafe.Pointer(err))
	}
	return &Pixbuf{
		GdkPixbuf: &GdkPixbuf{gpixbuf},
		GObject:   glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
	}, nil
}
开发者ID:hauke96,项目名称:go-gtk,代码行数:13,代码来源:gdkpixbuf.go


示例13: New

func New(textview *gtk.TextView, language string) (*GtkSpell, *glib.Error) {
	var lang *C.char
	if len(language) > 0 {
		lang = C.CString(language)
		defer C.free(unsafe.Pointer(lang))
	}

	var gerror *C.GError
	v := C.gtkspell_new_attach(C.to_GtkTextView(unsafe.Pointer(&textview.Widget)), C.to_gcharptr(lang), &gerror)
	if gerror != nil {
		return nil, glib.ErrorFromNative(unsafe.Pointer(gerror))
	}
	return &GtkSpell{v}, nil
}
开发者ID:mattn,项目名称:go-gtk,代码行数:14,代码来源:gtkspell.go


示例14: NewFromFileAtSize

func NewFromFileAtSize(path string, imgW int, imgH int) (pixbuf *Pixbuf, err **glib.Error) {
	var error *C.GError
	ptr := C.CString(path)
	defer C.free_string(ptr)
	gpixbuf := C.gdk_pixbuf_new_from_file_at_size(ptr, C.int(imgW), C.int(imgH), &error)
	pixbuf = &Pixbuf{
		GPixbuf: gpixbuf,
		GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
	}
	if err != nil && error != nil {
		*err = glib.ErrorFromNative(unsafe.Pointer(error))
	}
	return
}
开发者ID:kissthink,项目名称:go-gtk,代码行数:14,代码来源:gdkpixbuf.go


示例15: NewFromFileAtSize

func NewFromFileAtSize(filename string, width, heigth int) (*Pixbuf, *glib.Error) {
	var error *C.GError
	ptr := C.CString(filename)
	defer cfree(ptr)
	gpixbuf := C.gdk_pixbuf_new_from_file_at_size(ptr, C.int(width), C.int(heigth), &error)
	if error != nil {
		err := glib.ErrorFromNative(unsafe.Pointer(error))
		return nil, err
	}
	pixbuf := &Pixbuf{
		GPixbuf: gpixbuf,
		GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
	}
	return pixbuf, nil
}
开发者ID:nieware,项目名称:go-gtk,代码行数:15,代码来源:gdkpixbuf.go



注:本文中的github.com/mattn/go-gtk/glib.ErrorFromNative函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang glib.ObjectFromNative函数代码示例发布时间:2022-05-23
下一篇:
Golang gdkpixbuf.GdkPixbufLoader类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap