1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- |
2 | * |
3 | * Copyright (C) 2006 Christian Hammond |
4 | * Copyright (C) 2006 John Palmieri |
5 | * Copyright (C) 2010 Red Hat, Inc. |
6 | * |
7 | * This library is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Lesser General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2.1 of the License, or (at your option) any later version. |
11 | * |
12 | * This library is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Lesser General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Lesser General Public |
18 | * License along with this library; if not, write to the |
19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 | * Boston, MA 02111-1307, USA. |
21 | */ |
22 | |
23 | #ifndef _NOTIFY_NOTIFICATION_H_ |
24 | #define _NOTIFY_NOTIFICATION_H_ |
25 | |
26 | #include <glib.h> |
27 | #include <glib-object.h> |
28 | #include <gdk-pixbuf/gdk-pixbuf.h> |
29 | |
30 | G_BEGIN_DECLS |
31 | |
32 | /** |
33 | * NOTIFY_EXPIRES_DEFAULT: |
34 | * |
35 | * The default expiration time on a notification. |
36 | */ |
37 | #define NOTIFY_EXPIRES_DEFAULT -1 |
38 | |
39 | /** |
40 | * NOTIFY_EXPIRES_NEVER: |
41 | * |
42 | * The notification never expires. |
43 | * |
44 | * It stays open until closed by the calling API or the user. |
45 | */ |
46 | #define NOTIFY_EXPIRES_NEVER 0 |
47 | |
48 | #define NOTIFY_TYPE_NOTIFICATION (notify_notification_get_type ()) |
49 | #define NOTIFY_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NOTIFY_TYPE_NOTIFICATION, NotifyNotification)) |
50 | #define NOTIFY_NOTIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NOTIFY_TYPE_NOTIFICATION, NotifyNotificationClass)) |
51 | #define NOTIFY_IS_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NOTIFY_TYPE_NOTIFICATION)) |
52 | #define NOTIFY_IS_NOTIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NOTIFY_TYPE_NOTIFICATION)) |
53 | #define NOTIFY_NOTIFICATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NOTIFY_TYPE_NOTIFICATION, NotifyNotificationClass)) |
54 | |
55 | typedef struct _NotifyNotification NotifyNotification; |
56 | typedef struct _NotifyNotificationClass NotifyNotificationClass; |
57 | typedef struct _NotifyNotificationPrivate NotifyNotificationPrivate; |
58 | |
59 | /** |
60 | * NotifyNotification: |
61 | * |
62 | * A passive pop-up notification. |
63 | * |
64 | * #NotifyNotification represents a passive pop-up notification. It can |
65 | * contain summary text, body text, and an icon, as well as hints specifying |
66 | * how the notification should be presented. The notification is rendered |
67 | * by a notification daemon, and may present the notification in any number |
68 | * of ways. As such, there is a clear separation of content and presentation, |
69 | * and this API enforces that. |
70 | */ |
71 | struct _NotifyNotification |
72 | { |
73 | /*< private >*/ |
74 | GObject parent_object; |
75 | |
76 | NotifyNotificationPrivate *priv; |
77 | }; |
78 | |
79 | struct _NotifyNotificationClass |
80 | { |
81 | GObjectClass parent_class; |
82 | |
83 | /* Signals */ |
84 | void (*closed) (NotifyNotification *notification); |
85 | }; |
86 | |
87 | |
88 | /** |
89 | * NotifyUrgency: |
90 | * @NOTIFY_URGENCY_LOW: Low urgency. Used for unimportant notifications. |
91 | * @NOTIFY_URGENCY_NORMAL: Normal urgency. Used for most standard notifications. |
92 | * @NOTIFY_URGENCY_CRITICAL: Critical urgency. Used for very important notifications. |
93 | * |
94 | * The urgency level of the notification. |
95 | */ |
96 | typedef enum |
97 | { |
98 | NOTIFY_URGENCY_LOW, |
99 | NOTIFY_URGENCY_NORMAL, |
100 | NOTIFY_URGENCY_CRITICAL, |
101 | |
102 | } NotifyUrgency; |
103 | |
104 | |
105 | /** |
106 | * NotifyClosedReason: |
107 | * @NOTIFY_CLOSED_REASON_UNSET: Notification not closed. |
108 | * @NOTIFY_CLOSED_REASON_EXPIRED: Timeout has expired. |
109 | * @NOTIFY_CLOSED_REASON_DISMISSED: It has been dismissed by the user. |
110 | * @NOTIFY_CLOSED_REASON_API_REQUEST: It has been closed by a call to |
111 | * [method@NotifyNotification.close]. |
112 | * @NOTIFY_CLOSED_REASON_UNDEFIEND: Closed by undefined/reserved reasons. |
113 | * |
114 | * The reason for which the notification has been closed. |
115 | * |
116 | * Since: 0.8.0 |
117 | */ |
118 | typedef enum |
119 | { |
120 | NOTIFY_CLOSED_REASON_UNSET = -1, |
121 | NOTIFY_CLOSED_REASON_EXPIRED = 1, |
122 | NOTIFY_CLOSED_REASON_DISMISSED = 2, |
123 | NOTIFY_CLOSED_REASON_API_REQUEST = 3, |
124 | NOTIFY_CLOSED_REASON_UNDEFIEND = 4, |
125 | } NotifyClosedReason; |
126 | |
127 | /** |
128 | * NotifyActionCallback: |
129 | * @notification: a #NotifyActionCallback notification |
130 | * @action: (transfer none): The activated action name |
131 | * @user_data: (nullable) (transfer none): User provided data |
132 | * |
133 | * An action callback function. |
134 | */ |
135 | typedef void (*NotifyActionCallback) (NotifyNotification *notification, |
136 | char *action, |
137 | gpointer user_data); |
138 | |
139 | /** |
140 | * NOTIFY_ACTION_CALLBACK: |
141 | * @func: The function to cast. |
142 | * |
143 | * A convenience macro for casting a function to a [callback@ActionCallback]. |
144 | * |
145 | * This is much like [func@GObject.CALLBACK]. |
146 | */ |
147 | #define NOTIFY_ACTION_CALLBACK(func) ((NotifyActionCallback)(func)) |
148 | |
149 | GType notify_notification_get_type (void); |
150 | |
151 | NotifyNotification *notify_notification_new (const char *summary, |
152 | const char *body, |
153 | const char *icon); |
154 | |
155 | gboolean notify_notification_update (NotifyNotification *notification, |
156 | const char *summary, |
157 | const char *body, |
158 | const char *icon); |
159 | |
160 | gboolean notify_notification_show (NotifyNotification *notification, |
161 | GError **error); |
162 | |
163 | void notify_notification_set_timeout (NotifyNotification *notification, |
164 | gint timeout); |
165 | |
166 | void notify_notification_set_category (NotifyNotification *notification, |
167 | const char *category); |
168 | |
169 | void notify_notification_set_urgency (NotifyNotification *notification, |
170 | NotifyUrgency urgency); |
171 | |
172 | void notify_notification_set_image_from_pixbuf (NotifyNotification *notification, |
173 | GdkPixbuf *pixbuf); |
174 | |
175 | #ifndef LIBNOTIFY_DISABLE_DEPRECATED |
176 | void notify_notification_set_icon_from_pixbuf (NotifyNotification *notification, |
177 | GdkPixbuf *icon); |
178 | |
179 | void notify_notification_set_hint_int32 (NotifyNotification *notification, |
180 | const char *key, |
181 | gint value); |
182 | void notify_notification_set_hint_uint32 (NotifyNotification *notification, |
183 | const char *key, |
184 | guint value); |
185 | |
186 | void notify_notification_set_hint_double (NotifyNotification *notification, |
187 | const char *key, |
188 | gdouble value); |
189 | |
190 | void notify_notification_set_hint_string (NotifyNotification *notification, |
191 | const char *key, |
192 | const char *value); |
193 | |
194 | void notify_notification_set_hint_byte (NotifyNotification *notification, |
195 | const char *key, |
196 | guchar value); |
197 | |
198 | void notify_notification_set_hint_byte_array (NotifyNotification *notification, |
199 | const char *key, |
200 | const guchar *value, |
201 | gsize len); |
202 | #endif |
203 | |
204 | void notify_notification_set_hint (NotifyNotification *notification, |
205 | const char *key, |
206 | GVariant *value); |
207 | |
208 | void notify_notification_set_app_name (NotifyNotification *notification, |
209 | const char *app_name); |
210 | |
211 | void notify_notification_clear_hints (NotifyNotification *notification); |
212 | |
213 | void notify_notification_add_action (NotifyNotification *notification, |
214 | const char *action, |
215 | const char *label, |
216 | NotifyActionCallback callback, |
217 | gpointer user_data, |
218 | GFreeFunc free_func); |
219 | |
220 | const char *notify_notification_get_activation_token (NotifyNotification *notification); |
221 | |
222 | void notify_notification_clear_actions (NotifyNotification *notification); |
223 | gboolean notify_notification_close (NotifyNotification *notification, |
224 | GError **error); |
225 | |
226 | gint notify_notification_get_closed_reason (const NotifyNotification *notification); |
227 | |
228 | G_END_DECLS |
229 | #endif /* NOTIFY_NOTIFICATION_H */ |
230 | |