Fix indentation

This commit is contained in:
William Jon McCann 2010-01-09 12:57:51 -05:00
parent 9607cf459f
commit 8374438dcf
6 changed files with 255 additions and 225 deletions

View File

@ -1,4 +1,5 @@
/** /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file libnotify/internal.h Internal definitions * @file libnotify/internal.h Internal definitions
* *
* @Copyright (C) 2006 Christian Hammond * @Copyright (C) 2006 Christian Hammond
@ -44,8 +45,7 @@ DBusGProxy *_notify_get_g_proxy(void);
void _notify_cache_add_notification(NotifyNotification *n); void _notify_cache_add_notification(NotifyNotification *n);
void _notify_cache_remove_notification(NotifyNotification *n); void _notify_cache_remove_notification(NotifyNotification *n);
gint _notify_notification_get_timeout(const NotifyNotification *n); gint _notify_notification_get_timeout(const NotifyNotification *n);
gboolean _notify_notification_has_nondefault_actions( gboolean _notify_notification_has_nondefault_actions(const NotifyNotification *n);
const NotifyNotification *n);
G_END_DECLS G_END_DECLS

View File

@ -48,11 +48,11 @@ static void notify_notification_class_init(NotifyNotificationClass *klass);
static void notify_notification_init(NotifyNotification *sp); static void notify_notification_init(NotifyNotification *sp);
static void notify_notification_finalize(GObject *object); static void notify_notification_finalize(GObject *object);
static void _close_signal_handler(DBusGProxy *proxy, guint32 id, guint32 reason, static void _close_signal_handler(DBusGProxy *proxy, guint32 id, guint32 reason,
NotifyNotification *notification); NotifyNotification *notification);
static void _action_signal_handler(DBusGProxy *proxy, guint32 id, static void _action_signal_handler(DBusGProxy *proxy, guint32 id,
gchar *action, gchar *action,
NotifyNotification *notification); NotifyNotification *notification);
typedef struct typedef struct
{ {
@ -113,10 +113,10 @@ enum
}; };
static void notify_notification_set_property(GObject *object, guint prop_id, static void notify_notification_set_property(GObject *object, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void notify_notification_get_property(GObject *object, guint prop_id, static void notify_notification_get_property(GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec); GValue *value, GParamSpec *pspec);
static guint signals[LAST_SIGNAL] = { 0 }; static guint signals[LAST_SIGNAL] = { 0 };
static GObjectClass *parent_class = NULL; static GObjectClass *parent_class = NULL;
@ -124,11 +124,11 @@ G_DEFINE_TYPE(NotifyNotification, notify_notification, G_TYPE_OBJECT)
static GObject * static GObject *
notify_notification_constructor(GType type, notify_notification_constructor(GType type,
guint n_construct_properties, guint n_construct_properties,
GObjectConstructParam *construct_params) GObjectConstructParam *construct_params)
{ {
GObject *object = parent_class->constructor(type, n_construct_properties, GObject *object = parent_class->constructor(type, n_construct_properties,
construct_params); construct_params);
_notify_cache_add_notification(NOTIFY_NOTIFICATION(object)); _notify_cache_add_notification(NOTIFY_NOTIFICATION(object));
@ -155,11 +155,11 @@ notify_notification_class_init(NotifyNotificationClass *klass)
*/ */
signals[SIGNAL_CLOSED] = signals[SIGNAL_CLOSED] =
g_signal_new("closed", g_signal_new("closed",
G_TYPE_FROM_CLASS(object_class), G_TYPE_FROM_CLASS(object_class),
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET(NotifyNotificationClass, closed), G_STRUCT_OFFSET(NotifyNotificationClass, closed),
NULL, NULL, NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
g_object_class_install_property(object_class, PROP_ID, g_object_class_install_property(object_class, PROP_ID,
g_param_spec_int("id", "ID", g_param_spec_int("id", "ID",
@ -175,57 +175,57 @@ notify_notification_class_init(NotifyNotificationClass *klass)
g_object_class_install_property(object_class, PROP_SUMMARY, g_object_class_install_property(object_class, PROP_SUMMARY,
g_param_spec_string("summary", "Summary", g_param_spec_string("summary", "Summary",
"The summary text", "The summary text",
NULL, NULL,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT |
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB)); G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class, PROP_BODY, g_object_class_install_property(object_class, PROP_BODY,
g_param_spec_string("body", "Message Body", g_param_spec_string("body", "Message Body",
"The message body text", "The message body text",
NULL, NULL,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT |
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB)); G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class, PROP_ICON_NAME, g_object_class_install_property(object_class, PROP_ICON_NAME,
g_param_spec_string("icon-name", g_param_spec_string("icon-name",
"Icon Name", "Icon Name",
"The icon filename or icon theme-compliant name", "The icon filename or icon theme-compliant name",
NULL, NULL,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT |
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB)); G_PARAM_STATIC_BLURB));
g_object_class_install_property(object_class, PROP_ATTACH_WIDGET, g_object_class_install_property(object_class, PROP_ATTACH_WIDGET,
g_param_spec_object("attach-widget", g_param_spec_object("attach-widget",
"Attach Widget", "Attach Widget",
"The widget to attach the notification to", "The widget to attach the notification to",
GTK_TYPE_WIDGET, GTK_TYPE_WIDGET,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT |
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB)); G_PARAM_STATIC_BLURB));
#ifdef HAVE_STATUS_ICON #ifdef HAVE_STATUS_ICON
g_object_class_install_property(object_class, PROP_STATUS_ICON, g_object_class_install_property(object_class, PROP_STATUS_ICON,
g_param_spec_object("status-icon", g_param_spec_object("status-icon",
"Status Icon", "Status Icon",
"The status icon to attach the notification to", "The status icon to attach the notification to",
GTK_TYPE_STATUS_ICON, GTK_TYPE_STATUS_ICON,
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT |
G_PARAM_STATIC_NAME | G_PARAM_STATIC_NAME |
G_PARAM_STATIC_NICK | G_PARAM_STATIC_NICK |
G_PARAM_STATIC_BLURB)); G_PARAM_STATIC_BLURB));
#endif /* HAVE_STATUS_ICON */ #endif /* HAVE_STATUS_ICON */
g_object_class_install_property(object_class, PROP_CLOSED_REASON, g_object_class_install_property(object_class, PROP_CLOSED_REASON,
@ -257,18 +257,18 @@ notify_notification_set_property(GObject *object,
case PROP_SUMMARY: case PROP_SUMMARY:
notify_notification_update(notification, g_value_get_string(value), notify_notification_update(notification, g_value_get_string(value),
priv->body, priv->icon_name); priv->body, priv->icon_name);
break; break;
case PROP_BODY: case PROP_BODY:
notify_notification_update(notification, priv->summary, notify_notification_update(notification, priv->summary,
g_value_get_string(value), g_value_get_string(value),
priv->icon_name); priv->icon_name);
break; break;
case PROP_ICON_NAME: case PROP_ICON_NAME:
notify_notification_update(notification, priv->summary, notify_notification_update(notification, priv->summary,
priv->body, g_value_get_string(value)); priv->body, g_value_get_string(value));
break; break;
case PROP_ATTACH_WIDGET: case PROP_ATTACH_WIDGET:
@ -359,12 +359,12 @@ notify_notification_init(NotifyNotification *obj)
obj->priv->timeout = NOTIFY_EXPIRES_DEFAULT; obj->priv->timeout = NOTIFY_EXPIRES_DEFAULT;
obj->priv->closed_reason = -1; obj->priv->closed_reason = -1;
obj->priv->hints = g_hash_table_new_full(g_str_hash, g_str_equal, obj->priv->hints = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free,
(GFreeFunc)_g_value_free); (GFreeFunc)_g_value_free);
obj->priv->action_map = g_hash_table_new_full(g_str_hash, g_str_equal, obj->priv->action_map = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, g_free,
(GFreeFunc)destroy_pair); (GFreeFunc)destroy_pair);
} }
static void static void
@ -398,17 +398,17 @@ notify_notification_finalize(GObject *object)
#ifdef HAVE_STATUS_ICON #ifdef HAVE_STATUS_ICON
if (priv->status_icon != NULL) if (priv->status_icon != NULL)
g_object_remove_weak_pointer(G_OBJECT(priv->status_icon), g_object_remove_weak_pointer(G_OBJECT(priv->status_icon),
(gpointer)&priv->status_icon); (gpointer)&priv->status_icon);
#endif #endif
if (priv->signals_registered) if (priv->signals_registered)
{ {
dbus_g_proxy_disconnect_signal(proxy, "NotificationClosed", dbus_g_proxy_disconnect_signal(proxy, "NotificationClosed",
G_CALLBACK(_close_signal_handler), G_CALLBACK(_close_signal_handler),
object); object);
dbus_g_proxy_disconnect_signal(proxy, "ActionInvoked", dbus_g_proxy_disconnect_signal(proxy, "ActionInvoked",
G_CALLBACK(_action_signal_handler), G_CALLBACK(_action_signal_handler),
object); object);
} }
g_free(obj->priv); g_free(obj->priv);
@ -417,10 +417,10 @@ notify_notification_finalize(GObject *object)
} }
static GtkWidget * static GtkWidget *
get_internal_tray_icon (GtkStatusIcon *status) get_internal_tray_icon (GtkStatusIcon *status)
{ {
/* This function is a temporary hack */ /* This function is a temporary hack */
return GTK_WIDGET (*((GtkWidget**)(status->priv))); return GTK_WIDGET (*((GtkWidget**)(status->priv)));
} }
static void static void
@ -448,7 +448,7 @@ _notify_notification_update_applet_hints(NotifyNotification *n)
} }
if (!gtk_status_icon_get_geometry(priv->status_icon, &screen, if (!gtk_status_icon_get_geometry(priv->status_icon, &screen,
&rect, NULL)) &rect, NULL))
{ {
return; return;
} }
@ -527,17 +527,19 @@ _idle_check_updates(void *user_data)
* Returns: The new #NotifyNotification. * Returns: The new #NotifyNotification.
*/ */
NotifyNotification * NotifyNotification *
notify_notification_new(const gchar *summary, const gchar *body, notify_notification_new(const gchar *summary,
const gchar *icon, GtkWidget *attach) const gchar *body,
const gchar *icon,
GtkWidget *attach)
{ {
g_return_val_if_fail(attach == NULL || GTK_IS_WIDGET(attach), NULL); g_return_val_if_fail(attach == NULL || GTK_IS_WIDGET(attach), NULL);
return g_object_new(NOTIFY_TYPE_NOTIFICATION, return g_object_new(NOTIFY_TYPE_NOTIFICATION,
"summary", summary, "summary", summary,
"body", body, "body", body,
"icon-name", icon, "icon-name", icon,
"attach-widget", attach, "attach-widget", attach,
NULL); NULL);
} }
#ifdef HAVE_STATUS_ICON #ifdef HAVE_STATUS_ICON
@ -566,11 +568,11 @@ notify_notification_new_with_status_icon(const gchar *summary,
g_return_val_if_fail(GTK_IS_STATUS_ICON(status_icon), NULL); g_return_val_if_fail(GTK_IS_STATUS_ICON(status_icon), NULL);
return g_object_new(NOTIFY_TYPE_NOTIFICATION, return g_object_new(NOTIFY_TYPE_NOTIFICATION,
"summary", summary, "summary", summary,
"body", message, "body", message,
"icon-name", icon, "icon-name", icon,
"status-icon", status_icon, "status-icon", status_icon,
NULL); NULL);
} }
#endif /* HAVE_STATUS_ICON */ #endif /* HAVE_STATUS_ICON */
@ -589,8 +591,9 @@ notify_notification_new_with_status_icon(const gchar *summary,
*/ */
gboolean gboolean
notify_notification_update(NotifyNotification *notification, notify_notification_update(NotifyNotification *notification,
const gchar *summary, const gchar *body, const gchar *summary,
const gchar *icon) const gchar *body,
const gchar *icon)
{ {
g_return_val_if_fail(notification != NULL, FALSE); g_return_val_if_fail(notification != NULL, FALSE);
g_return_val_if_fail(NOTIFY_IS_NOTIFICATION(notification), FALSE); g_return_val_if_fail(NOTIFY_IS_NOTIFICATION(notification), FALSE);
@ -635,7 +638,7 @@ notify_notification_update(NotifyNotification *notification,
*/ */
void void
notify_notification_attach_to_widget(NotifyNotification *notification, notify_notification_attach_to_widget(NotifyNotification *notification,
GtkWidget *attach) GtkWidget *attach)
{ {
g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification)); g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification));
@ -665,7 +668,7 @@ notify_notification_attach_to_widget(NotifyNotification *notification,
*/ */
void void
notify_notification_attach_to_status_icon(NotifyNotification *notification, notify_notification_attach_to_status_icon(NotifyNotification *notification,
GtkStatusIcon *status_icon) GtkStatusIcon *status_icon)
{ {
NotifyNotificationPrivate *priv; NotifyNotificationPrivate *priv;
@ -680,7 +683,7 @@ notify_notification_attach_to_status_icon(NotifyNotification *notification,
if (priv->status_icon != NULL) if (priv->status_icon != NULL)
{ {
g_object_remove_weak_pointer(G_OBJECT(priv->status_icon), g_object_remove_weak_pointer(G_OBJECT(priv->status_icon),
(gpointer)&priv->status_icon); (gpointer)&priv->status_icon);
} }
priv->status_icon = status_icon; priv->status_icon = status_icon;
@ -688,7 +691,7 @@ notify_notification_attach_to_status_icon(NotifyNotification *notification,
if (priv->status_icon != NULL) if (priv->status_icon != NULL)
{ {
g_object_add_weak_pointer(G_OBJECT(priv->status_icon), g_object_add_weak_pointer(G_OBJECT(priv->status_icon),
(gpointer)&priv->status_icon); (gpointer)&priv->status_icon);
} }
g_object_notify(G_OBJECT(notification), "status-icon"); g_object_notify(G_OBJECT(notification), "status-icon");
@ -710,9 +713,9 @@ notify_notification_attach_to_status_icon(NotifyNotification *notification,
*/ */
void void
notify_notification_set_geometry_hints(NotifyNotification *notification, notify_notification_set_geometry_hints(NotifyNotification *notification,
GdkScreen *screen, GdkScreen *screen,
gint x, gint x,
gint y) gint y)
{ {
char *display_name; char *display_name;
@ -730,8 +733,10 @@ notify_notification_set_geometry_hints(NotifyNotification *notification,
} }
static void static void
_close_signal_handler(DBusGProxy *proxy, guint32 id, guint32 reason, _close_signal_handler(DBusGProxy *proxy,
NotifyNotification *notification) guint32 id,
guint32 reason,
NotifyNotification *notification)
{ {
if (id == notification->priv->id) if (id == notification->priv->id)
{ {
@ -744,8 +749,10 @@ _close_signal_handler(DBusGProxy *proxy, guint32 id, guint32 reason,
} }
static void static void
_action_signal_handler(DBusGProxy *proxy, guint32 id, gchar *action, _action_signal_handler(DBusGProxy *proxy,
NotifyNotification *notification) guint32 id,
gchar *action,
NotifyNotification *notification)
{ {
CallbackPair *pair; CallbackPair *pair;
@ -774,7 +781,7 @@ _gslist_to_string_array(GSList *list)
{ {
GSList *l; GSList *l;
GArray *a = g_array_sized_new(TRUE, FALSE, sizeof(gchar *), GArray *a = g_array_sized_new(TRUE, FALSE, sizeof(gchar *),
g_slist_length(list)); g_slist_length(list));
for (l = list; l != NULL; l = l->next) for (l = list; l != NULL; l = l->next)
g_array_append_val(a, l->data); g_array_append_val(a, l->data);
@ -793,7 +800,8 @@ _gslist_to_string_array(GSList *list)
* @error. * @error.
*/ */
gboolean gboolean
notify_notification_show(NotifyNotification *notification, GError **error) notify_notification_show(NotifyNotification *notification,
GError **error)
{ {
NotifyNotificationPrivate *priv; NotifyNotificationPrivate *priv;
GError *tmp_error = NULL; GError *tmp_error = NULL;
@ -810,12 +818,12 @@ notify_notification_show(NotifyNotification *notification, GError **error)
if (!priv->signals_registered) if (!priv->signals_registered)
{ {
dbus_g_proxy_connect_signal(proxy, "NotificationClosed", dbus_g_proxy_connect_signal(proxy, "NotificationClosed",
G_CALLBACK(_close_signal_handler), G_CALLBACK(_close_signal_handler),
notification, NULL); notification, NULL);
dbus_g_proxy_connect_signal(proxy, "ActionInvoked", dbus_g_proxy_connect_signal(proxy, "ActionInvoked",
G_CALLBACK(_action_signal_handler), G_CALLBACK(_action_signal_handler),
notification, NULL); notification, NULL);
priv->signals_registered = TRUE; priv->signals_registered = TRUE;
} }
@ -827,18 +835,18 @@ notify_notification_show(NotifyNotification *notification, GError **error)
/* TODO: make this nonblocking */ /* TODO: make this nonblocking */
dbus_g_proxy_call(proxy, "Notify", &tmp_error, dbus_g_proxy_call(proxy, "Notify", &tmp_error,
G_TYPE_STRING, notify_get_app_name(), G_TYPE_STRING, notify_get_app_name(),
G_TYPE_UINT, priv->id, G_TYPE_UINT, priv->id,
G_TYPE_STRING, priv->icon_name, G_TYPE_STRING, priv->icon_name,
G_TYPE_STRING, priv->summary, G_TYPE_STRING, priv->summary,
G_TYPE_STRING, priv->body, G_TYPE_STRING, priv->body,
G_TYPE_STRV, action_array, G_TYPE_STRV, action_array,
dbus_g_type_get_map("GHashTable", G_TYPE_STRING, dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
G_TYPE_VALUE), priv->hints, G_TYPE_VALUE), priv->hints,
G_TYPE_INT, priv->timeout, G_TYPE_INT, priv->timeout,
G_TYPE_INVALID, G_TYPE_INVALID,
G_TYPE_UINT, &priv->id, G_TYPE_UINT, &priv->id,
G_TYPE_INVALID); G_TYPE_INVALID);
/* Don't free the elements because they are owned by priv->actions */ /* Don't free the elements because they are owned by priv->actions */
g_free(action_array); g_free(action_array);
@ -863,7 +871,7 @@ notify_notification_show(NotifyNotification *notification, GError **error)
*/ */
void void
notify_notification_set_timeout(NotifyNotification *notification, notify_notification_set_timeout(NotifyNotification *notification,
gint timeout) gint timeout)
{ {
g_return_if_fail(notification != NULL); g_return_if_fail(notification != NULL);
g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification)); g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification));
@ -890,7 +898,7 @@ _notify_notification_get_timeout(const NotifyNotification *notification)
*/ */
void void
notify_notification_set_category(NotifyNotification *notification, notify_notification_set_category(NotifyNotification *notification,
const char *category) const char *category)
{ {
g_return_if_fail(notification != NULL); g_return_if_fail(notification != NULL);
g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification)); g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification));
@ -909,7 +917,7 @@ notify_notification_set_category(NotifyNotification *notification,
*/ */
void void
notify_notification_set_urgency(NotifyNotification *notification, notify_notification_set_urgency(NotifyNotification *notification,
NotifyUrgency urgency) NotifyUrgency urgency)
{ {
g_return_if_fail(notification != NULL); g_return_if_fail(notification != NULL);
g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification)); g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification));
@ -969,7 +977,7 @@ _gvalue_array_append_byte_array(GValueArray *array, guchar *bytes, gsize len)
*/ */
void void
notify_notification_set_icon_from_pixbuf(NotifyNotification *notification, notify_notification_set_icon_from_pixbuf(NotifyNotification *notification,
GdkPixbuf *icon) GdkPixbuf *icon)
{ {
#if CHECK_DBUS_VERSION(0, 60) #if CHECK_DBUS_VERSION(0, 60)
gint width; gint width;
@ -1012,7 +1020,7 @@ notify_notification_set_icon_from_pixbuf(NotifyNotification *notification,
g_value_take_boxed(value, image_struct); g_value_take_boxed(value, image_struct);
g_hash_table_insert(notification->priv->hints, g_hash_table_insert(notification->priv->hints,
g_strdup("icon_data"), value); g_strdup("icon_data"), value);
#else /* D-BUS < 0.60 */ #else /* D-BUS < 0.60 */
g_warning("Raw images and pixbufs require D-BUS >= 0.60"); g_warning("Raw images and pixbufs require D-BUS >= 0.60");
#endif #endif
@ -1028,7 +1036,8 @@ notify_notification_set_icon_from_pixbuf(NotifyNotification *notification,
*/ */
void void
notify_notification_set_hint_int32(NotifyNotification *notification, notify_notification_set_hint_int32(NotifyNotification *notification,
const gchar *key, gint value) const gchar *key,
gint value)
{ {
GValue *hint_value; GValue *hint_value;
@ -1040,7 +1049,7 @@ notify_notification_set_hint_int32(NotifyNotification *notification,
g_value_init(hint_value, G_TYPE_INT); g_value_init(hint_value, G_TYPE_INT);
g_value_set_int(hint_value, value); g_value_set_int(hint_value, value);
g_hash_table_insert(notification->priv->hints, g_hash_table_insert(notification->priv->hints,
g_strdup(key), hint_value); g_strdup(key), hint_value);
} }
@ -1054,7 +1063,8 @@ notify_notification_set_hint_int32(NotifyNotification *notification,
*/ */
void void
notify_notification_set_hint_uint32(NotifyNotification *notification, notify_notification_set_hint_uint32(NotifyNotification *notification,
const gchar *key, guint value) const gchar *key,
guint value)
{ {
GValue *hint_value; GValue *hint_value;
@ -1066,7 +1076,7 @@ notify_notification_set_hint_uint32(NotifyNotification *notification,
g_value_init(hint_value, G_TYPE_UINT); g_value_init(hint_value, G_TYPE_UINT);
g_value_set_uint(hint_value, value); g_value_set_uint(hint_value, value);
g_hash_table_insert(notification->priv->hints, g_hash_table_insert(notification->priv->hints,
g_strdup(key), hint_value); g_strdup(key), hint_value);
} }
/** /**
@ -1079,7 +1089,8 @@ notify_notification_set_hint_uint32(NotifyNotification *notification,
*/ */
void void
notify_notification_set_hint_double(NotifyNotification *notification, notify_notification_set_hint_double(NotifyNotification *notification,
const gchar *key, gdouble value) const gchar *key,
gdouble value)
{ {
GValue *hint_value; GValue *hint_value;
@ -1091,7 +1102,7 @@ notify_notification_set_hint_double(NotifyNotification *notification,
g_value_init(hint_value, G_TYPE_FLOAT); g_value_init(hint_value, G_TYPE_FLOAT);
g_value_set_float(hint_value, value); g_value_set_float(hint_value, value);
g_hash_table_insert(notification->priv->hints, g_hash_table_insert(notification->priv->hints,
g_strdup(key), hint_value); g_strdup(key), hint_value);
} }
/** /**
@ -1104,7 +1115,8 @@ notify_notification_set_hint_double(NotifyNotification *notification,
*/ */
void void
notify_notification_set_hint_byte(NotifyNotification *notification, notify_notification_set_hint_byte(NotifyNotification *notification,
const gchar *key, guchar value) const gchar *key,
guchar value)
{ {
GValue *hint_value; GValue *hint_value;
@ -1131,8 +1143,9 @@ notify_notification_set_hint_byte(NotifyNotification *notification,
*/ */
void void
notify_notification_set_hint_byte_array(NotifyNotification *notification, notify_notification_set_hint_byte_array(NotifyNotification *notification,
const gchar *key, const gchar *key,
const guchar *value, gsize len) const guchar *value,
gsize len)
{ {
GValue *hint_value; GValue *hint_value;
GArray *byte_array; GArray *byte_array;
@ -1148,11 +1161,11 @@ notify_notification_set_hint_byte_array(NotifyNotification *notification,
hint_value = g_new0(GValue, 1); hint_value = g_new0(GValue, 1);
g_value_init(hint_value, dbus_g_type_get_collection("GArray", g_value_init(hint_value, dbus_g_type_get_collection("GArray",
G_TYPE_UCHAR)); G_TYPE_UCHAR));
g_value_take_boxed(hint_value, byte_array); g_value_take_boxed(hint_value, byte_array);
g_hash_table_insert(notification->priv->hints, g_hash_table_insert(notification->priv->hints,
g_strdup(key), hint_value); g_strdup(key), hint_value);
} }
/** /**
@ -1165,7 +1178,8 @@ notify_notification_set_hint_byte_array(NotifyNotification *notification,
*/ */
void void
notify_notification_set_hint_string(NotifyNotification *notification, notify_notification_set_hint_string(NotifyNotification *notification,
const gchar *key, const gchar *value) const gchar *key,
const gchar *value)
{ {
GValue *hint_value; GValue *hint_value;
@ -1177,7 +1191,7 @@ notify_notification_set_hint_string(NotifyNotification *notification,
g_value_init(hint_value, G_TYPE_STRING); g_value_init(hint_value, G_TYPE_STRING);
g_value_set_string(hint_value, value); g_value_set_string(hint_value, value);
g_hash_table_insert(notification->priv->hints, g_hash_table_insert(notification->priv->hints,
g_strdup(key), hint_value); g_strdup(key), hint_value);
} }
static gboolean static gboolean
@ -1199,7 +1213,7 @@ notify_notification_clear_hints(NotifyNotification *notification)
g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification)); g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification));
g_hash_table_foreach_remove(notification->priv->hints, g_hash_table_foreach_remove(notification->priv->hints,
(GHRFunc)_remove_all, NULL); (GHRFunc)_remove_all, NULL);
} }
/** /**
@ -1215,7 +1229,7 @@ notify_notification_clear_actions(NotifyNotification *notification)
g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification)); g_return_if_fail(NOTIFY_IS_NOTIFICATION(notification));
g_hash_table_foreach_remove(notification->priv->action_map, g_hash_table_foreach_remove(notification->priv->action_map,
(GHRFunc)_remove_all, NULL); (GHRFunc)_remove_all, NULL);
if (notification->priv->actions != NULL) if (notification->priv->actions != NULL)
{ {
@ -1243,10 +1257,11 @@ notify_notification_clear_actions(NotifyNotification *notification)
*/ */
void void
notify_notification_add_action(NotifyNotification *notification, notify_notification_add_action(NotifyNotification *notification,
const char *action, const char *action,
const char *label, const char *label,
NotifyActionCallback callback, NotifyActionCallback callback,
gpointer user_data, GFreeFunc free_func) gpointer user_data,
GFreeFunc free_func)
{ {
NotifyNotificationPrivate *priv; NotifyNotificationPrivate *priv;
CallbackPair *pair; CallbackPair *pair;
@ -1296,7 +1311,7 @@ _notify_notification_has_nondefault_actions(const NotifyNotification *n)
*/ */
gboolean gboolean
notify_notification_close(NotifyNotification *notification, notify_notification_close(NotifyNotification *notification,
GError **error) GError **error)
{ {
NotifyNotificationPrivate *priv; NotifyNotificationPrivate *priv;
GError *tmp_error = NULL; GError *tmp_error = NULL;
@ -1308,8 +1323,8 @@ notify_notification_close(NotifyNotification *notification,
priv = notification->priv; priv = notification->priv;
dbus_g_proxy_call(_notify_get_g_proxy(), "CloseNotification", &tmp_error, dbus_g_proxy_call(_notify_get_g_proxy(), "CloseNotification", &tmp_error,
G_TYPE_UINT, priv->id, G_TYPE_INVALID, G_TYPE_UINT, priv->id, G_TYPE_INVALID,
G_TYPE_INVALID); G_TYPE_INVALID);
if (tmp_error != NULL) if (tmp_error != NULL)
{ {

View File

@ -1,4 +1,5 @@
/** /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file libnotify/notification.h Notification object * @file libnotify/notification.h Notification object
* *
* @Copyright (C) 2006 Christian Hammond * @Copyright (C) 2006 Christian Hammond
@ -77,17 +78,17 @@ typedef enum
} NotifyUrgency; } NotifyUrgency;
typedef void (*NotifyActionCallback)(NotifyNotification *notification, typedef void (*NotifyActionCallback)(NotifyNotification *notification,
gchar *action, gchar *action,
gpointer user_data); gpointer user_data);
#define NOTIFY_ACTION_CALLBACK(func) ((NotifyActionCallback)(func)) #define NOTIFY_ACTION_CALLBACK(func) ((NotifyActionCallback)(func))
GType notify_notification_get_type(); GType notify_notification_get_type();
NotifyNotification *notify_notification_new(const gchar *summary, NotifyNotification *notify_notification_new(const gchar *summary,
const gchar *body, const gchar *body,
const gchar *icon, const gchar *icon,
GtkWidget *attach); GtkWidget *attach);
#if GTK_CHECK_VERSION(2, 9, 2) #if GTK_CHECK_VERSION(2, 9, 2)
NotifyNotification *notify_notification_new_with_status_icon( NotifyNotification *notify_notification_new_with_status_icon(
const gchar *summary, const gchar *body, const gchar *summary, const gchar *body,
@ -95,12 +96,12 @@ NotifyNotification *notify_notification_new_with_status_icon(
#endif #endif
gboolean notify_notification_update(NotifyNotification *notification, gboolean notify_notification_update(NotifyNotification *notification,
const gchar *summary, const gchar *summary,
const gchar *body, const gchar *body,
const gchar *icon); const gchar *icon);
void notify_notification_attach_to_widget(NotifyNotification* notification, void notify_notification_attach_to_widget(NotifyNotification* notification,
GtkWidget *attach); GtkWidget *attach);
#if GTK_CHECK_VERSION(2, 9, 2) #if GTK_CHECK_VERSION(2, 9, 2)
void notify_notification_attach_to_status_icon(NotifyNotification *notification, void notify_notification_attach_to_status_icon(NotifyNotification *notification,
@ -108,57 +109,63 @@ void notify_notification_attach_to_status_icon(NotifyNotification *notification,
#endif #endif
void notify_notification_set_geometry_hints(NotifyNotification *notification, void notify_notification_set_geometry_hints(NotifyNotification *notification,
GdkScreen *screen, GdkScreen *screen,
gint x, gint x,
gint y); gint y);
gboolean notify_notification_show(NotifyNotification *notification, gboolean notify_notification_show(NotifyNotification *notification,
GError **error); GError **error);
void notify_notification_set_timeout(NotifyNotification *notification, void notify_notification_set_timeout(NotifyNotification *notification,
gint timeout); gint timeout);
void notify_notification_set_category(NotifyNotification *notification, void notify_notification_set_category(NotifyNotification *notification,
const char *category); const char *category);
void notify_notification_set_urgency(NotifyNotification *notification, void notify_notification_set_urgency(NotifyNotification *notification,
NotifyUrgency urgency); NotifyUrgency urgency);
void notify_notification_set_icon_from_pixbuf(NotifyNotification *notification, void notify_notification_set_icon_from_pixbuf(NotifyNotification *notification,
GdkPixbuf *icon); GdkPixbuf *icon);
void notify_notification_set_hint_int32(NotifyNotification *notification, void notify_notification_set_hint_int32(NotifyNotification *notification,
const gchar *key, gint value); const gchar *key,
gint value);
void notify_notification_set_hint_uint32(NotifyNotification *notification, void notify_notification_set_hint_uint32(NotifyNotification *notification,
const gchar *key, guint value); const gchar *key,
guint value);
void notify_notification_set_hint_double(NotifyNotification *notification, void notify_notification_set_hint_double(NotifyNotification *notification,
const gchar *key, gdouble value); const gchar *key,
gdouble value);
void notify_notification_set_hint_string(NotifyNotification *notification, void notify_notification_set_hint_string(NotifyNotification *notification,
const gchar *key, const gchar *key,
const gchar *value); const gchar *value);
void notify_notification_set_hint_byte(NotifyNotification *notification, void notify_notification_set_hint_byte(NotifyNotification *notification,
const gchar *key, guchar value); const gchar *key,
guchar value);
void notify_notification_set_hint_byte_array(NotifyNotification *notification, void notify_notification_set_hint_byte_array(NotifyNotification *notification,
const gchar *key, const gchar *key,
const guchar *value, gsize len); const guchar *value,
gsize len);
void notify_notification_clear_hints(NotifyNotification *notification); void notify_notification_clear_hints(NotifyNotification *notification);
void notify_notification_add_action(NotifyNotification *notification, void notify_notification_add_action(NotifyNotification *notification,
const char *action, const char *label, const char *action,
NotifyActionCallback callback, const char *label,
gpointer user_data, GFreeFunc free_func); NotifyActionCallback callback,
gpointer user_data,
GFreeFunc free_func);
void notify_notification_clear_actions(NotifyNotification *notification); void notify_notification_clear_actions(NotifyNotification *notification);
gboolean notify_notification_close(NotifyNotification *notification, gboolean notify_notification_close(NotifyNotification *notification,
GError **error); GError **error);
gint notify_notification_get_closed_reason( gint notify_notification_get_closed_reason(const NotifyNotification *notification);
const NotifyNotification *notification);
G_END_DECLS G_END_DECLS

View File

@ -1,4 +1,5 @@
/** /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file libnotify/notify.c Notifications library * @file libnotify/notify.c Notifications library
* *
* @Copyright (C) 2004-2006 Christian Hammond <chipx86@chipx86.com> * @Copyright (C) 2004-2006 Christian Hammond <chipx86@chipx86.com>
@ -67,27 +68,27 @@ notify_init(const char *app_name)
} }
_proxy = dbus_g_proxy_new_for_name(bus, _proxy = dbus_g_proxy_new_for_name(bus,
NOTIFY_DBUS_NAME, NOTIFY_DBUS_NAME,
NOTIFY_DBUS_CORE_OBJECT, NOTIFY_DBUS_CORE_OBJECT,
NOTIFY_DBUS_CORE_INTERFACE); NOTIFY_DBUS_CORE_INTERFACE);
dbus_g_connection_unref(bus); dbus_g_connection_unref(bus);
dbus_g_object_register_marshaller(notify_marshal_VOID__UINT_UINT, dbus_g_object_register_marshaller(notify_marshal_VOID__UINT_UINT,
G_TYPE_NONE, G_TYPE_NONE,
G_TYPE_UINT, G_TYPE_UINT,
G_TYPE_UINT, G_TYPE_INVALID); G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_object_register_marshaller(notify_marshal_VOID__UINT_STRING, dbus_g_object_register_marshaller(notify_marshal_VOID__UINT_STRING,
G_TYPE_NONE, G_TYPE_NONE,
G_TYPE_UINT, G_TYPE_UINT,
G_TYPE_STRING, G_TYPE_INVALID); G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_add_signal(_proxy, "NotificationClosed", dbus_g_proxy_add_signal(_proxy, "NotificationClosed",
G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT,
G_TYPE_INVALID); G_TYPE_INVALID);
dbus_g_proxy_add_signal(_proxy, "ActionInvoked", dbus_g_proxy_add_signal(_proxy, "ActionInvoked",
G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING,
G_TYPE_INVALID); G_TYPE_INVALID);
_initted = TRUE; _initted = TRUE;
@ -188,8 +189,8 @@ notify_get_server_caps(void)
g_return_val_if_fail(proxy != NULL, NULL); g_return_val_if_fail(proxy != NULL, NULL);
if (!dbus_g_proxy_call(proxy, "GetCapabilities", &error, if (!dbus_g_proxy_call(proxy, "GetCapabilities", &error,
G_TYPE_INVALID, G_TYPE_INVALID,
G_TYPE_STRV, &caps, G_TYPE_INVALID)) G_TYPE_STRV, &caps, G_TYPE_INVALID))
{ {
g_message("GetCapabilities call failed: %s", error->message); g_message("GetCapabilities call failed: %s", error->message);
g_error_free(error); g_error_free(error);
@ -222,8 +223,10 @@ notify_get_server_caps(void)
* on failure. * on failure.
*/ */
gboolean gboolean
notify_get_server_info(char **ret_name, char **ret_vendor, notify_get_server_info(char **ret_name,
char **ret_version, char **ret_spec_version) char **ret_vendor,
char **ret_version,
char **ret_spec_version)
{ {
GError *error = NULL; GError *error = NULL;
DBusGProxy *proxy = _notify_get_g_proxy(); DBusGProxy *proxy = _notify_get_g_proxy();
@ -232,12 +235,12 @@ notify_get_server_info(char **ret_name, char **ret_vendor,
g_return_val_if_fail(proxy != NULL, FALSE); g_return_val_if_fail(proxy != NULL, FALSE);
if (!dbus_g_proxy_call(proxy, "GetServerInformation", &error, if (!dbus_g_proxy_call(proxy, "GetServerInformation", &error,
G_TYPE_INVALID, G_TYPE_INVALID,
G_TYPE_STRING, &name, G_TYPE_STRING, &name,
G_TYPE_STRING, &vendor, G_TYPE_STRING, &vendor,
G_TYPE_STRING, &version, G_TYPE_STRING, &version,
G_TYPE_STRING, &spec_version, G_TYPE_STRING, &spec_version,
G_TYPE_INVALID)) G_TYPE_INVALID))
{ {
g_message("GetServerInformation call failed: %s", error->message); g_message("GetServerInformation call failed: %s", error->message);
return FALSE; return FALSE;

View File

@ -1,4 +1,5 @@
/** /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file libnotify/notify.h Notifications library * @file libnotify/notify.h Notifications library
* *
* @Copyright (C) 2004-2006 Christian Hammond * @Copyright (C) 2004-2006 Christian Hammond
@ -80,9 +81,9 @@ GList *notify_get_server_caps(void);
* @return TRUE if the call succeeded, or FALSE if there were errors. * @return TRUE if the call succeeded, or FALSE if there were errors.
*/ */
gboolean notify_get_server_info(char **ret_name, gboolean notify_get_server_info(char **ret_name,
char **ret_vendor, char **ret_vendor,
char **ret_version, char **ret_version,
char **ret_spec_version); char **ret_spec_version);
G_END_DECLS G_END_DECLS

View File

@ -1,4 +1,5 @@
/** /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* @file notify-send.c A tool for sending notifications. * @file notify-send.c A tool for sending notifications.
* *
* Copyright (C) 2004 Christian Hammond. * Copyright (C) 2004 Christian Hammond.
@ -34,9 +35,9 @@ static NotifyUrgency urgency = NOTIFY_URGENCY_NORMAL;
static gboolean static gboolean
g_option_arg_urgency_cb(const gchar *option_name, g_option_arg_urgency_cb(const gchar *option_name,
const gchar *value, const gchar *value,
gpointer data, gpointer data,
GError **error) GError **error)
{ {
if (value != NULL) if (value != NULL)
{ {
@ -49,10 +50,10 @@ g_option_arg_urgency_cb(const gchar *option_name,
else else
{ {
*error = g_error_new(G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, *error = g_error_new(G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
N_("Unknown urgency %s specified. " N_("Unknown urgency %s specified. "
"Known urgency levels: low, " "Known urgency levels: low, "
"normal, critical."), "normal, critical."),
value); value);
return FALSE; return FALSE;
} }
@ -63,8 +64,10 @@ g_option_arg_urgency_cb(const gchar *option_name,
static gboolean static gboolean
notify_notification_set_hint_variant(NotifyNotification *notification, notify_notification_set_hint_variant(NotifyNotification *notification,
const gchar *type, const gchar *key, const gchar *type,
const gchar *value, GError **error) const gchar *key,
const gchar *value,
GError **error)
{ {
static gboolean conv_error = FALSE; static gboolean conv_error = FALSE;
if (!strcasecmp(type, "string")) if (!strcasecmp(type, "string"))
@ -100,24 +103,26 @@ notify_notification_set_hint_variant(NotifyNotification *notification,
else else
{ {
notify_notification_set_hint_byte(notification, key, notify_notification_set_hint_byte(notification, key,
(guchar)h_byte); (guchar)h_byte);
} }
} }
else else
{ {
*error = g_error_new(G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, *error = g_error_new(G_OPTION_ERROR,
N_("Invalid hint type \"%s\". Valid types " G_OPTION_ERROR_BAD_VALUE,
"are int, double, string and byte."), N_("Invalid hint type \"%s\". Valid types "
type); "are int, double, string and byte."),
type);
return FALSE; return FALSE;
} }
if (conv_error) if (conv_error)
{ {
*error = g_error_new(G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, *error = g_error_new(G_OPTION_ERROR,
N_("Value \"%s\" of hint \"%s\" could not be " G_OPTION_ERROR_BAD_VALUE,
"parsed as type \"%s\"."), N_("Value \"%s\" of hint \"%s\" could not be "
value, key, type); "parsed as type \"%s\"."),
value, key, type);
return FALSE; return FALSE;
} }
@ -172,7 +177,7 @@ main(int argc, char *argv[])
g_set_prgname(argv[0]); g_set_prgname(argv[0]);
opt_ctx = g_option_context_new(N_("<SUMMARY> [BODY] - " opt_ctx = g_option_context_new(N_("<SUMMARY> [BODY] - "
"create a notification")); "create a notification"));
g_option_context_add_main_entries(opt_ctx, entries, GETTEXT_PACKAGE); g_option_context_add_main_entries(opt_ctx, entries, GETTEXT_PACKAGE);
retval = g_option_context_parse(opt_ctx, &argc, &argv, &error); retval = g_option_context_parse(opt_ctx, &argc, &argv, &error);
g_option_context_free(opt_ctx); g_option_context_free(opt_ctx);
@ -245,14 +250,13 @@ main(int argc, char *argv[])
if (l != 3) if (l != 3)
{ {
fprintf(stderr, "%s\n", fprintf(stderr, "%s\n",
N_("Invalid hint syntax specified. " N_("Invalid hint syntax specified. "
"Use TYPE:NAME:VALUE.")); "Use TYPE:NAME:VALUE."));
hint_error = TRUE; hint_error = TRUE;
} }
else else
{ {
retval = notify_notification_set_hint_variant( retval = notify_notification_set_hint_variant(notify, tokens[0], tokens[1], tokens[2], &error);
notify, tokens[0], tokens[1], tokens[2], &error);
if (!retval) if (!retval)
{ {