Due to the new icon struct, a lot of redundant functions have now been removed.

This commit is contained in:
Christian Hammond 2004-06-30 02:34:10 +00:00
parent f722bacff3
commit 5e153367b3
3 changed files with 54 additions and 206 deletions

View File

@ -1,3 +1,10 @@
Tue Jun 29 19:33:43 PDT 2004 Christian Hammond <chipx86@gnupdate.org>
* libnotify/notify.c:
* libnotify/notify.h:
- Due to the new icon struct, a lot of redundant functions have now
been removed.
Tue Jun 29 19:26:58 PDT 2004 Christian Hammond <chipx86@gnupdate.org>
* libnotify/notify.c:

View File

@ -454,10 +454,10 @@ notify_icon_destroy(NotifyIcon *icon)
/**************************************************************************
* Notifications API
**************************************************************************/
static NotifyHandle *
_notify_send_notification(NotifyUrgency urgency, const char *summary,
const char *detailed, const char *icon_uri,
size_t icon_len, guchar *icon_data, time_t timeout)
NotifyHandle *
notify_send_notification(NotifyUrgency urgency, const char *summary,
const char *detailed, const NotifyIcon *icon,
time_t timeout)
{
NotifyHandle *handle;
DBusMessage *message, *reply;
@ -474,10 +474,15 @@ _notify_send_notification(NotifyUrgency urgency, const char *summary,
dbus_message_iter_append_string(&iter, summary);
_notify_dbus_message_iter_append_string_or_nil(&iter, detailed);
if (icon_len > 0 && icon_data != NULL)
dbus_message_iter_append_byte_array(&iter, icon_data, icon_len);
if (icon == NULL)
dbus_message_iter_append_nil(&iter);
else if (icon->raw_len > 0 && icon->raw_data != NULL)
{
dbus_message_iter_append_byte_array(&iter, icon->raw_data,
icon->raw_len);
}
else
_notify_dbus_message_iter_append_string_or_nil(&iter, icon_uri);
dbus_message_iter_append_string(&iter, icon->uri);
dbus_message_iter_append_uint32(&iter, timeout);
@ -511,35 +516,32 @@ _notify_send_notification(NotifyUrgency urgency, const char *summary,
}
NotifyHandle *
notify_send_notification(NotifyUrgency urgency, const char *summary,
const char *detailed, const char *icon_uri,
time_t timeout)
notify_send_request(NotifyUrgency urgency, const char *summary,
const char *detailed, const NotifyIcon *icon,
time_t timeout, gpointer user_data,
size_t default_button, size_t button_count, ...)
{
g_return_val_if_fail(summary != NULL, 0);
va_list buttons;
NotifyHandle *handle;
return _notify_send_notification(urgency, summary, detailed, icon_uri,
0, NULL, timeout);
g_return_val_if_fail(summary != NULL, 0);
g_return_val_if_fail(button_count > 1, 0);
va_start(buttons, button_count);
handle = notify_send_request_varg(urgency, summary, detailed, icon,
timeout, user_data, default_button,
button_count, buttons);
va_end(buttons);
return handle;
}
NotifyHandle *
notify_send_notification_with_icon_data(NotifyUrgency urgency,
const char *summary,
const char *detailed,
size_t icon_len, guchar *icon_data,
time_t timeout)
{
g_return_val_if_fail(summary != NULL, 0);
return _notify_send_notification(urgency, summary, detailed, NULL,
icon_len, icon_data, timeout);
}
static NotifyHandle *
_notify_send_request(NotifyUrgency urgency, const char *summary,
const char *detailed, const char *icon_uri,
size_t icon_len, guchar *icon_data, time_t timeout,
gpointer user_data, guint32 default_button,
size_t button_count, va_list buttons)
notify_send_request_varg(NotifyUrgency urgency, const char *summary,
const char *detailed, const NotifyIcon *icon,
time_t timeout, gpointer user_data,
size_t default_button, size_t button_count,
va_list buttons)
{
DBusMessage *message, *reply;
DBusMessageIter iter;
@ -559,10 +561,15 @@ _notify_send_request(NotifyUrgency urgency, const char *summary,
dbus_message_iter_append_string(&iter, summary);
_notify_dbus_message_iter_append_string_or_nil(&iter, detailed);
if (icon_len > 0 && icon_data != NULL)
dbus_message_iter_append_byte_array(&iter, icon_data, icon_len);
if (icon == NULL)
dbus_message_iter_append_nil(&iter);
else if (icon->raw_len > 0 && icon->raw_data != NULL)
{
dbus_message_iter_append_byte_array(&iter, icon->raw_data,
icon->raw_len);
}
else
_notify_dbus_message_iter_append_string_or_nil(&iter, icon_uri);
dbus_message_iter_append_string(&iter, icon->uri);
dbus_message_iter_append_uint32(&iter, timeout);
dbus_message_iter_append_uint32(&iter, default_button);
@ -616,81 +623,3 @@ _notify_send_request(NotifyUrgency urgency, const char *summary,
return handle;
}
NotifyHandle *
notify_send_request(NotifyUrgency urgency, const char *summary,
const char *detailed, const char *icon_uri,
time_t timeout, gpointer user_data,
size_t default_button, size_t button_count, ...)
{
va_list buttons;
NotifyHandle *handle;
g_return_val_if_fail(summary != NULL, 0);
g_return_val_if_fail(button_count > 1, 0);
va_start(buttons, button_count);
handle = notify_send_request_varg(urgency, summary, detailed, icon_uri,
timeout, user_data, default_button,
button_count, buttons);
va_end(buttons);
return handle;
}
NotifyHandle *
notify_send_request_varg(NotifyUrgency urgency, const char *summary,
const char *detailed, const char *icon_uri,
time_t timeout, gpointer user_data,
size_t default_button, size_t button_count,
va_list buttons)
{
g_return_val_if_fail(summary != NULL, 0);
g_return_val_if_fail(button_count > 1, 0);
return _notify_send_request(urgency, summary, detailed, icon_uri,
0, NULL, timeout, user_data, default_button,
button_count, buttons);
}
NotifyHandle *
notify_send_request_with_icon_data(NotifyUrgency urgency,
const char *summary, const char *detailed,
size_t icon_len, guchar *icon_data,
time_t timeout, gpointer user_data,
gint32 default_button, size_t button_count,
...)
{
va_list buttons;
NotifyHandle *handle;
g_return_val_if_fail(summary != NULL, 0);
g_return_val_if_fail(button_count > 1, 0);
va_start(buttons, button_count);
handle = notify_send_request_with_icon_data_varg(urgency, summary,
detailed, icon_len,
icon_data, timeout,
user_data, default_button,
button_count, buttons);
va_end(buttons);
return handle;
}
NotifyHandle *
notify_send_request_with_icon_data_varg(NotifyUrgency urgency,
const char *summary,
const char *detailed,
size_t icon_len, guchar *icon_data,
time_t timeout, gpointer user_data,
gint32 default_button,
size_t button_count, va_list buttons)
{
g_return_val_if_fail(summary != NULL, 0);
g_return_val_if_fail(button_count > 1, 0);
return _notify_send_request(urgency, summary, detailed, NULL, icon_len,
icon_data, timeout, user_data, default_button,
button_count, buttons);
}

View File

@ -134,7 +134,7 @@ void notify_icon_destroy(NotifyIcon *icon);
* @param urgency The urgency level.
* @param summary The summary of the notification.
* @param detailed The optional detailed information.
* @param icon_uri The optional icon URI.
* @param icon The optional icon.
* @param timeout The optional time to automatically close the notification,
* or 0.
*
@ -143,27 +143,7 @@ void notify_icon_destroy(NotifyIcon *icon);
NotifyHandle *notify_send_notification(NotifyUrgency urgency,
const char *summary,
const char *detailed,
const char *icon_uri, time_t timeout);
/**
* Sends a standard notification with raw icon data.
*
* @param urgency The urgency level.
* @param summary The summary of the notification.
* @param detailed The optional detailed information.
* @param icon_len The icon data length.
* @param icon_data The icon data.
* @param timeout The optional time to automatically close the notification,
* or 0.
*
* @return A unique ID for the notification.
*/
NotifyHandle *notify_send_notification_with_icon_data(NotifyUrgency urgency,
const char *summary,
const char *detailed,
size_t icon_len,
guchar *icon_data,
time_t timeout);
const NotifyIcon *icon, time_t timeout);
/*@}*/
@ -184,7 +164,7 @@ NotifyHandle *notify_send_notification_with_icon_data(NotifyUrgency urgency,
* @param urgency The urgency level.
* @param summary The summary of the request.
* @param detailed The optional detailed information.
* @param icon_uri The optional icon URI.
* @param icon The optional icon.
* @param timeout The optional time to automatically close the request,
* or 0.
* @param user_data User-specified data to send to a callback.
@ -195,7 +175,7 @@ NotifyHandle *notify_send_notification_with_icon_data(NotifyUrgency urgency,
* @return A unique ID for the request.
*/
NotifyHandle *notify_send_request(NotifyUrgency urgency, const char *summary,
const char *detailed, const char *icon_uri,
const char *detailed, const NotifyIcon *icon,
time_t timeout, gpointer user_data,
size_t default_button,
size_t button_count, ...);
@ -212,7 +192,7 @@ NotifyHandle *notify_send_request(NotifyUrgency urgency, const char *summary,
* @param urgency The urgency level.
* @param summary The summary of the request.
* @param detailed The optional detailed information.
* @param icon_uri The optional icon URI.
* @param icon The optional icon.
* @param timeout The optional time to automatically close the request,
* or 0.
* @param user_data User-specified data to send to a callback.
@ -225,79 +205,11 @@ NotifyHandle *notify_send_request(NotifyUrgency urgency, const char *summary,
NotifyHandle *notify_send_request_varg(NotifyUrgency urgency,
const char *summary,
const char *detailed,
const char *icon_uri, time_t timeout,
const NotifyIcon *icon, time_t timeout,
gpointer user_data,
size_t default_button,
size_t button_count, va_list buttons);
/**
* Sends a standard request with raw icon data.
*
* A callback has the following prototype:
*
* @code
* void callback(NotifyHandle *handle, guint32 button, void *user_data);
* @endcode
*
* @param urgency The urgency level.
* @param summary The summary of the request.
* @param detailed The optional detailed information.
* @param icon_len The icon data length.
* @param icon_data The icon data.
* @param timeout The optional time to automatically close the request,
* or 0.
* @param user_data User-specified data to send to a callback.
* @param default_button The default button, or -1.
* @param button_count The number of buttons.
* @param ... The buttons in string/callback pairs.
*
* @return A unique ID for the request.
*/
NotifyHandle *notify_send_request_with_icon_data(NotifyUrgency urgency,
const char *summary,
const char *detailed,
size_t icon_len,
guchar *icon_data,
time_t timeout,
gpointer user_data,
gint32 default_button,
size_t button_count, ...);
/**
* Sends a standard request with raw icon data, taking a va_list for the
* buttons.
*
* A callback has the following prototype:
*
* @code
* void callback(NotifyHandle *handle, guint32 button, void *user_data);
* @endcode
*
* @param urgency The urgency level.
* @param summary The summary of the request.
* @param detailed The optional detailed information.
* @param icon_len The icon data length.
* @param icon_data The icon data.
* @param timeout The optional time to automatically close the request,
* or 0.
* @param user_data User-specified data to send to a callback.
* @param default_button The default button, or -1.
* @param button_count The number of buttons.
* @param buttons The buttons in string/callback pairs.
*
* @return A unique ID for the request.
*/
NotifyHandle *notify_send_request_with_icon_data_varg(NotifyUrgency urgency,
const char *summary,
const char *detailed,
size_t icon_len,
guchar *icon_data,
time_t timeout,
gpointer user_data,
gint32 default_button,
size_t button_count,
va_list buttons);
/*@}*/
#endif /* _LIBNOTIFY_NOTIFY_H_ */