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

}
Exemplo n.º 2
0
// NotificationChannel builds and returns a channel for Notifications.
func NotificationChannel(cache *FileCache) chan *Notification {
	c := make(chan *Notification)

	go func() {
		// libnotify needs a default app name when initialized. This will be
		// changed later.
		appName := C.CString("gntp_notify")
		defer C.free(unsafe.Pointer(appName))
		if inited := bool(C.notify_init(appName) != 0); !inited {
			log.Fatalf("gntp: Could not initialize libnotify")
		}
		defer C.notify_uninit()

		for {
			processNotification(<-c, cache)
		}
	}()

	return c
}
Exemplo n.º 3
0
// Pure Functions
func Init(app_name string) bool {
	papp_name := C.CString(app_name)
	defer C.free(unsafe.Pointer(papp_name))

	return bool(C.notify_init(papp_name) != 0)
}