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. It stays open until closed by the calling API |
43 | * or the user. |
44 | */ |
45 | #define NOTIFY_EXPIRES_NEVER 0 |
46 | |
47 | #define NOTIFY_TYPE_NOTIFICATION (notify_notification_get_type ()) |
48 | #define NOTIFY_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NOTIFY_TYPE_NOTIFICATION, NotifyNotification)) |
49 | #define NOTIFY_NOTIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NOTIFY_TYPE_NOTIFICATION, NotifyNotificationClass)) |
50 | #define NOTIFY_IS_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NOTIFY_TYPE_NOTIFICATION)) |
51 | #define NOTIFY_IS_NOTIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NOTIFY_TYPE_NOTIFICATION)) |
52 | #define NOTIFY_NOTIFICATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NOTIFY_TYPE_NOTIFICATION, NotifyNotificationClass)) |
53 | |
54 | typedef struct _NotifyNotification NotifyNotification; |
55 | typedef struct _NotifyNotificationClass NotifyNotificationClass; |
56 | typedef struct _NotifyNotificationPrivate NotifyNotificationPrivate; |
57 | |
58 | struct _NotifyNotification |
59 | { |
60 | /*< private >*/ |
61 | GObject parent_object; |
62 | |
63 | NotifyNotificationPrivate *priv; |
64 | }; |
65 | |
66 | struct _NotifyNotificationClass |
67 | { |
68 | GObjectClass parent_class; |
69 | |
70 | /* Signals */ |
71 | void (*closed) (NotifyNotification *notification); |
72 | }; |
73 | |
74 | |
75 | /** |
76 | * NotifyUrgency: |
77 | * @NOTIFY_URGENCY_LOW: Low urgency. Used for unimportant notifications. |
78 | * @NOTIFY_URGENCY_NORMAL: Normal urgency. Used for most standard notifications. |
79 | * @NOTIFY_URGENCY_CRITICAL: Critical urgency. Used for very important notifications. |
80 | * |
81 | * The urgency level of the notification. |
82 | */ |
83 | typedef enum |
84 | { |
85 | NOTIFY_URGENCY_LOW, |
86 | NOTIFY_URGENCY_NORMAL, |
87 | NOTIFY_URGENCY_CRITICAL, |
88 | |
89 | } NotifyUrgency; |
90 | |
91 | /** |
92 | * NotifyActionCallback: |
93 | * @notification: |
94 | * @action: |
95 | * @user_data: |
96 | * |
97 | * An action callback function. |
98 | */ |
99 | typedef void (*NotifyActionCallback) (NotifyNotification *notification, |
100 | char *action, |
101 | gpointer user_data); |
102 | |
103 | /** |
104 | * NOTIFY_ACTION_CALLBACK: |
105 | * @func: The function to cast. |
106 | * |
107 | * A convenience macro for casting a function to a #NotifyActionCallback. This |
108 | * is much like G_CALLBACK(). |
109 | */ |
110 | #define NOTIFY_ACTION_CALLBACK(func) ((NotifyActionCallback)(func)) |
111 | |
112 | GType notify_notification_get_type (void); |
113 | |
114 | NotifyNotification *notify_notification_new (const char *summary, |
115 | const char *body, |
116 | const char *icon); |
117 | |
118 | gboolean notify_notification_update (NotifyNotification *notification, |
119 | const char *summary, |
120 | const char *body, |
121 | const char *icon); |
122 | |
123 | gboolean notify_notification_show (NotifyNotification *notification, |
124 | GError **error); |
125 | |
126 | void notify_notification_set_timeout (NotifyNotification *notification, |
127 | gint timeout); |
128 | |
129 | void notify_notification_set_category (NotifyNotification *notification, |
130 | const char *category); |
131 | |
132 | void notify_notification_set_urgency (NotifyNotification *notification, |
133 | NotifyUrgency urgency); |
134 | |
135 | void notify_notification_set_image_from_pixbuf (NotifyNotification *notification, |
136 | GdkPixbuf *pixbuf); |
137 | |
138 | #ifndef LIBNOTIFY_DISABLE_DEPRECATED |
139 | void notify_notification_set_icon_from_pixbuf (NotifyNotification *notification, |
140 | GdkPixbuf *icon); |
141 | |
142 | void notify_notification_set_hint_int32 (NotifyNotification *notification, |
143 | const char *key, |
144 | gint value); |
145 | void notify_notification_set_hint_uint32 (NotifyNotification *notification, |
146 | const char *key, |
147 | guint value); |
148 | |
149 | void notify_notification_set_hint_double (NotifyNotification *notification, |
150 | const char *key, |
151 | gdouble value); |
152 | |
153 | void notify_notification_set_hint_string (NotifyNotification *notification, |
154 | const char *key, |
155 | const char *value); |
156 | |
157 | void notify_notification_set_hint_byte (NotifyNotification *notification, |
158 | const char *key, |
159 | guchar value); |
160 | |
161 | void notify_notification_set_hint_byte_array (NotifyNotification *notification, |
162 | const char *key, |
163 | const guchar *value, |
164 | gsize len); |
165 | #endif |
166 | |
167 | void notify_notification_set_hint (NotifyNotification *notification, |
168 | const char *key, |
169 | GVariant *value); |
170 | |
171 | void notify_notification_set_app_name (NotifyNotification *notification, |
172 | const char *app_name); |
173 | |
174 | void notify_notification_clear_hints (NotifyNotification *notification); |
175 | |
176 | void notify_notification_add_action (NotifyNotification *notification, |
177 | const char *action, |
178 | const char *label, |
179 | NotifyActionCallback callback, |
180 | gpointer user_data, |
181 | GFreeFunc free_func); |
182 | |
183 | void notify_notification_clear_actions (NotifyNotification *notification); |
184 | gboolean notify_notification_close (NotifyNotification *notification, |
185 | GError **error); |
186 | |
187 | gint notify_notification_get_closed_reason (const NotifyNotification *notification); |
188 | |
189 | G_END_DECLS |
190 | #endif /* NOTIFY_NOTIFICATION_H */ |
191 | |