2 * Copyright (C) 2004-2006 Christian Hammond
3 * Copyright (C) 2010 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 module iv
.libnotify
/*is aliced*/;
21 pragma(lib
, "notify");
24 //version = libnotify_new;
28 import core
.sys
.posix
.unistd
: dup2
;
29 import core
.sys
.posix
.fcntl
/*: open*/;
30 auto xfd
= open("/dev/null", O_WRONLY
, 0x1b6/*0o600*/);
32 dup2(xfd
, 2); // fuck stderr
38 auto n
= notify_notification_new("summary", "body", "none");
40 notify_notification_show(n
, &ge
);
41 scope(success
) notify_uninit();
45 extern(C
) nothrow @nogc:
49 version(libnotify_new
)
62 static enum check(int major
, int minor
, int micro
) =
64 (Major
== major
&& Minor
> minor
) ||
65 (Major
== major
&& Minor
== minor
&& Micro
>= micro
);
70 alias void function (void*) GFreeFunc
;
87 struct GObjectClass
{}
92 GType
notify_urgency_get_type ();
95 /// special timeout values
97 Default
= -1, /// The default expiration time on a notification.
98 Never
= 0, /// The notification never expires. It stays open until closed by the calling API or the user.
102 // #define NOTIFY_TYPE_NOTIFICATION (notify_notification_get_type ())
103 // #define NOTIFY_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NOTIFY_TYPE_NOTIFICATION, NotifyNotification))
104 // #define NOTIFY_NOTIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NOTIFY_TYPE_NOTIFICATION, NotifyNotificationClass))
105 // #define NOTIFY_IS_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NOTIFY_TYPE_NOTIFICATION))
106 // #define NOTIFY_IS_NOTIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NOTIFY_TYPE_NOTIFICATION))
107 // #define NOTIFY_NOTIFICATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NOTIFY_TYPE_NOTIFICATION, NotifyNotificationClass))
110 //struct NotifyNotificationPrivate;
111 struct NotifyNotification
{
113 GObject parent_object
;
114 /*NotifyNotificationPrivate*/void *priv
;
118 struct NotifyNotificationClass
{
119 GObjectClass parent_class
;
121 void function (NotifyNotification
* notification
) closed
;
125 /// The urgency level of the notification.
127 Low
, /// Low urgency. Used for unimportant notifications.
128 Normal
, /// Normal urgency. Used for most standard notifications.
129 Critical
, /// Critical urgency. Used for very important notifications.
133 * NotifyActionCallback:
138 * An action callback function.
140 alias NotifyActionCallback
= void function (NotifyNotification
* notification
, char* action
, void* user_data
);
143 GType
notify_notification_get_type ();
144 // there is no `attach` in newver versions
145 version(libnotify_new
)
146 NotifyNotification
* notify_notification_new (const(char)* summary
, const(char)* body_
, const(char)* icon
);
148 NotifyNotification
* notify_notification_new (const(char)* summary
, const(char)* body_
, const(char)* icon
, GtkWidget
* attach
=null);
149 bool notify_notification_update (NotifyNotification
* notification
, const(char)* summary
, const(char)* body_
, const(char)* icon
);
150 bool notify_notification_show (NotifyNotification
* notification
, GError
** error
);
151 void notify_notification_set_timeout (NotifyNotification
* notification
, int timeout
);
152 void notify_notification_set_category (NotifyNotification
* notification
, const(char)* category
);
153 void notify_notification_set_urgency (NotifyNotification
* notification
, NotifyUrgency urgency
);
154 void notify_notification_set_image_from_pixbuf (NotifyNotification
* notification
, GdkPixbuf
* pixbuf
);
155 void notify_notification_set_icon_from_pixbuf (NotifyNotification
* notification
, GdkPixbuf
* icon
);
156 void notify_notification_set_hint_int32 (NotifyNotification
* notification
, const(char)* key
, int value
);
157 void notify_notification_set_hint_uint32 (NotifyNotification
* notification
, const(char)* key
, uint value
);
158 void notify_notification_set_hint_double (NotifyNotification
* notification
, const(char)* key
, double value
);
159 void notify_notification_set_hint_string (NotifyNotification
* notification
, const(char)* key
, const(char)* value
);
160 void notify_notification_set_hint_byte (NotifyNotification
* notification
, const(char)* key
, ubyte value
);
161 void notify_notification_set_hint_byte_array (NotifyNotification
* notification
, const(char)* key
, const(ubyte)* value
, ulong len
);
162 //void notify_notification_set_hint (NotifyNotification* notification, const(char)* key, GVariant* value);
163 void notify_notification_set_app_name (NotifyNotification
* notification
, const(char)* app_name
);
164 void notify_notification_clear_hints (NotifyNotification
* notification
);
165 void notify_notification_add_action (NotifyNotification
* notification
, const(char)* action
, const(char)* label
,
166 NotifyActionCallback callback
, void* user_data
, GFreeFunc free_func
);
167 void notify_notification_clear_actions (NotifyNotification
* notification
);
168 bool notify_notification_close (NotifyNotification
* notification
, GError
** error
);
169 int notify_notification_get_closed_reason (const NotifyNotification
* notification
);
172 bool notify_init (const(char)* app_name
);
173 void notify_uninit ();
174 bool notify_is_initted ();
176 const(char)* notify_get_app_name ();
177 void notify_set_app_name (const(char)* app_name
);
179 GList
*notify_get_server_caps ();
181 bool notify_get_server_info (char** ret_name
, char** ret_vendor
, char** ret_version
, char** ret_spec_version
);