1package glib
2
3// #include <gio/gio.h>
4// #include <glib.h>
5// #include <glib-object.h>
6// #include "glib.go.h"
7import "C"
8import "unsafe"
9
10// Notification is a representation of GNotification.
11type Notification struct {
12	*Object
13}
14
15// native() returns a pointer to the underlying GNotification.
16func (v *Notification) native() *C.GNotification {
17	if v == nil || v.GObject == nil {
18		return nil
19	}
20	return C.toGNotification(unsafe.Pointer(v.GObject))
21}
22
23func (v *Notification) Native() uintptr {
24	return uintptr(unsafe.Pointer(v.native()))
25}
26
27func marshalNotification(p uintptr) (interface{}, error) {
28	c := C.g_value_get_object((*C.GValue)(unsafe.Pointer(p)))
29	return wrapNotification(wrapObject(unsafe.Pointer(c))), nil
30}
31
32func wrapNotification(obj *Object) *Notification {
33	return &Notification{obj}
34}
35
36// NotificationNew is a wrapper around g_notification_new().
37func NotificationNew(title string) *Notification {
38	cstr1 := (*C.gchar)(C.CString(title))
39	defer C.free(unsafe.Pointer(cstr1))
40
41	c := C.g_notification_new(cstr1)
42	if c == nil {
43		return nil
44	}
45	return wrapNotification(wrapObject(unsafe.Pointer(c)))
46}
47
48// SetTitle is a wrapper around g_notification_set_title().
49func (v *Notification) SetTitle(title string) {
50	cstr1 := (*C.gchar)(C.CString(title))
51	defer C.free(unsafe.Pointer(cstr1))
52
53	C.g_notification_set_title(v.native(), cstr1)
54}
55
56// SetBody is a wrapper around g_notification_set_body().
57func (v *Notification) SetBody(body string) {
58	cstr1 := (*C.gchar)(C.CString(body))
59	defer C.free(unsafe.Pointer(cstr1))
60
61	C.g_notification_set_body(v.native(), cstr1)
62}
63
64// SetDefaultAction is a wrapper around g_notification_set_default_action().
65func (v *Notification) SetDefaultAction(detailedAction string) {
66	cstr1 := (*C.gchar)(C.CString(detailedAction))
67	defer C.free(unsafe.Pointer(cstr1))
68
69	C.g_notification_set_default_action(v.native(), cstr1)
70}
71
72// AddButton is a wrapper around g_notification_add_button().
73func (v *Notification) AddButton(label, detailedAction string) {
74	cstr1 := (*C.gchar)(C.CString(label))
75	defer C.free(unsafe.Pointer(cstr1))
76
77	cstr2 := (*C.gchar)(C.CString(detailedAction))
78	defer C.free(unsafe.Pointer(cstr2))
79
80	C.g_notification_add_button(v.native(), cstr1, cstr2)
81}
82
83// SetIcon is a wrapper around g_notification_set_icon().
84func (v *Notification) SetIcon(iconPath string) {
85	fileIcon := FileIconNew(iconPath)
86
87	C.g_notification_set_icon(v.native(), (*C.GIcon)(fileIcon.native()))
88}
89
90// void 	g_notification_set_default_action_and_target () // requires varargs
91// void 	g_notification_set_default_action_and_target_value () // requires variant
92// void 	g_notification_add_button_with_target () // requires varargs
93// void 	g_notification_add_button_with_target_value () //requires variant
94// void 	g_notification_set_urgent () // Deprecated, so not implemented
95