func (snoty Notification) Show() {

	var message *C.char = C.CString(snoty.Message)
	var title *C.char = C.CString(snoty.Title)
	var appname *C.char = C.CString(snoty.Appname)
	var n *C.NotifyNotification

	if C.strlen(appname) > 0 {
		if C.notify_is_initted() == C.FALSE {
			C.notify_init(appname)
		}
	} else {
		if C.notify_is_initted() == C.FALSE {
			C.notify_init(C.CString("Simple.Notification"))

		}
	}

	if snoty.Icon_path != "" {
		var tmpPath *C.char = C.CString(snoty.Icon_path)
		var buf *C.GdkPixbuf = C.gdk_pixbuf_new_from_file(tmpPath, nil)
		C.notify_notification_set_image_from_pixbuf(n, buf)
		//C.free(unsafe.Pointer(tmpPath))
	}

	n = C.notify_notification_new(title, message, nil)
	C.notify_notification_show(n, nil)
	C.my_own_unref(n)

	C.notify_uninit()
	C.free(unsafe.Pointer(appname))
	C.free(unsafe.Pointer(message))
	C.free(unsafe.Pointer(title))

}
Esempio n. 2
0
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
}
Esempio n. 3
0
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
}
Esempio n. 4
0
File: gdk.go Progetto: raichu/gotk3
// PixbufNewFromFile is a wrapper around gdk_pixbuf_new_from_file().
func PixbufNewFromFile(filename string) (*Pixbuf, error) {
	cstr := C.CString(filename)
	defer C.free(unsafe.Pointer(cstr))
	var err *C.GError
	res := C.gdk_pixbuf_new_from_file((*C.char)(cstr), &err)
	if res == nil {
		defer C.g_error_free(err)
		return nil, errors.New(C.GoString((*C.char)(err.message)))
	}
	obj := &glib.Object{glib.ToGObject(unsafe.Pointer(res))}
	p := &Pixbuf{obj}
	runtime.SetFinalizer(obj, (*glib.Object).Unref)
	return p, nil
}
Esempio n. 5
0
func NewFromFile(path string) (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(ptr, &error)
	pixbuf = &Pixbuf{
		GPixbuf: gpixbuf,
		GObject: glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
	}
	if err != nil && error != nil {
		*err = glib.ErrorFromNative(unsafe.Pointer(error))
	}
	return
}
Esempio n. 6
0
// PixbufNewFromFile() is a wrapper around gdk_pixbuf_new_from_file().
func PixbufNewFromFile(fileName string) (*Pixbuf, error) {
	var cerr *C.GError
	cstr := C.CString(fileName)
	defer C.free(unsafe.Pointer(cstr))
	c := C.gdk_pixbuf_new_from_file(cstr, &cerr)
	if c == nil {
		defer C.g_error_free(cerr)
		return nil, errors.New(C.GoString((*C.char)(C.error_get_message(cerr))))
	}
	obj := &glib.Object{glib.ToGObject(unsafe.Pointer(c))}
	p := wrapPixbuf(obj)
	runtime.SetFinalizer(obj, (*glib.Object).Unref)
	return p, nil
}
/*
Creates a new pixbuf by loading an image from a file.  The file format is
detected automatically. If %NULL is returned, then @error will be set.
Possible errors are in the #GDK_PIXBUF_ERROR and #G_FILE_ERROR domains.
*/
func PixbufNewFromFile(filename string) (return__ *Pixbuf, __err__ error) {
	__cgo__filename := C.CString(filename)
	var __cgo_error__ *C.GError
	var __cgo__return__ interface{}
	__cgo__return__ = C.gdk_pixbuf_new_from_file(__cgo__filename, &__cgo_error__)
	C.free(unsafe.Pointer(__cgo__filename))
	if __cgo__return__ != nil {
		return__ = NewPixbufFromCPointer(unsafe.Pointer(reflect.ValueOf(__cgo__return__).Pointer()))
	}
	if __cgo_error__ != nil {
		__err__ = errors.New(C.GoString((*C.char)(unsafe.Pointer(__cgo_error__.message))))
	}
	return
}
Esempio n. 8
0
func NewFromFile(filename string) (*Pixbuf, *glib.Error) {
	var error *C.GError
	ptr := C.CString(filename)
	defer cfree(ptr)
	gpixbuf := C.gdk_pixbuf_new_from_file(ptr, &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
}