diff --git a/ChangeLog b/ChangeLog index 54d6a38..c2ef563 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Jun 29 19:26:58 PDT 2004 Christian Hammond + + * libnotify/notify.c: + * libnotify/notify.h: + - Added a NotifyIcon struct and the beginnings of the API. + Tue Jun 29 18:49:38 PDT 2004 Christian Hammond * libnotify/notify.c: diff --git a/libnotify/notify.c b/libnotify/notify.c index 92e9987..e4c0671 100644 --- a/libnotify/notify.c +++ b/libnotify/notify.c @@ -63,6 +63,14 @@ struct _NotifyHandle } data; }; +struct _NotifyIcon +{ + char *uri; + + size_t raw_len; + guchar *raw_data; +}; + static DBusConnection *_dbus_conn = NULL; static gboolean _initted = FALSE; static gboolean _filters_added = FALSE; @@ -395,6 +403,57 @@ notify_close(NotifyHandle *handle) dbus_message_unref(message); } +/************************************************************************** + * Icon API + **************************************************************************/ +NotifyIcon * +notify_icon_new(const char *icon_uri) +{ + NotifyIcon *icon; + + g_return_val_if_fail(icon_uri != NULL, NULL); + g_return_val_if_fail(*icon_uri != '\0', NULL); + + icon = g_new0(NotifyIcon, 1); + + icon->uri = g_strdup(icon_uri); + + return icon; +} + +NotifyIcon * +notify_icon_new_with_data(size_t icon_len, const guchar *icon_data) +{ + NotifyIcon *icon; + + g_return_val_if_fail(icon_len > 0, NULL); + g_return_val_if_fail(icon_data != NULL, NULL); + + icon = g_new0(NotifyIcon, 1); + + icon->raw_len = icon_len; + icon->raw_data = g_memdup(icon_data, icon_len); + + return icon; +} + +void +notify_icon_destroy(NotifyIcon *icon) +{ + g_return_if_fail(icon != NULL); + + if (icon->uri != NULL) + g_free(icon->uri); + + if (icon->raw_data != NULL) + g_free(icon->raw_data); + + g_free(icon); +} + +/************************************************************************** + * Notifications API + **************************************************************************/ static NotifyHandle * _notify_send_notification(NotifyUrgency urgency, const char *summary, const char *detailed, const char *icon_uri, diff --git a/libnotify/notify.h b/libnotify/notify.h index 5b65685..ba2d67a 100644 --- a/libnotify/notify.h +++ b/libnotify/notify.h @@ -47,6 +47,7 @@ typedef enum } NotifyUrgency; typedef struct _NotifyHandle NotifyHandle; +typedef struct _NotifyIcon NotifyIcon; typedef void (*NotifyCallback)(NotifyHandle *, guint32, gpointer); @@ -88,6 +89,40 @@ void notify_close(NotifyHandle *handle); /*@}*/ +/**************************************************************************/ +/** @name NotifyIcon API */ +/**************************************************************************/ +/*@{*/ + +/** + * Creates an icon with the specified icon URI. + * + * @param icon_uri The icon URI. + * + * @return The icon. + */ +NotifyIcon *notify_icon_new(const char *icon_uri); + +/** + * Creates an icon with the specified icon data. + * + * @param icon_len The icon data length. + * @param icon_data The icon data. + * + * @return The icon. + */ +NotifyIcon *notify_icon_new_with_data(size_t icon_len, + const guchar *icon_data); + +/** + * Destroys an icon. + * + * @param icon The icon to destroy. + */ +void notify_icon_destroy(NotifyIcon *icon); + +/*@}*/ + /**************************************************************************/ /** @name Notifications API */ /**************************************************************************/