[Galago-commits] r2440 - in trunk/libnotify: . libnotify

galago-commits at freedesktop.org galago-commits at freedesktop.org
Thu Jan 19 22:09:08 PST 2006


Author: chipx86
Date: 2006-01-19 22:08:58 -0800 (Thu, 19 Jan 2006)
New Revision: 2440

Added:
   trunk/libnotify/libnotify/internal.h
   trunk/libnotify/libnotify/notification.c
   trunk/libnotify/libnotify/notification.h
Removed:
   trunk/libnotify/libnotify/notifycommon.h
   trunk/libnotify/libnotify/notifynotification.c
   trunk/libnotify/libnotify/notifynotification.h
Modified:
   trunk/libnotify/ChangeLog
   trunk/libnotify/libnotify/Makefile.am
   trunk/libnotify/libnotify/notify.c
   trunk/libnotify/libnotify/notify.h
Log:
Do some rearranging of the files in libnotify, and include things properly so people can actually use the library without fudging with include paths.


Modified: trunk/libnotify/ChangeLog
===================================================================
--- trunk/libnotify/ChangeLog	2006-01-20 05:56:49 UTC (rev 2439)
+++ trunk/libnotify/ChangeLog	2006-01-20 06:08:58 UTC (rev 2440)
@@ -1,3 +1,18 @@
+Thu Jan 19 22:07:41 PST 2006  Christian Hammond <chipx86 at chipx86.com>
+
+	A libnotify/internal.h:
+	A libnotify/notification.c:
+	A libnotify/notification.h:
+	D libnotify/notifycommon.h:
+	D libnotify/notifynotification.c:
+	D libnotify/notifynotification.h:
+	* libnotify/Makefile.am:
+	* libnotify/notify.c:
+	* libnotify/notify.h:
+	  - Do some rearranging of the files in libnotify, and include things
+	    properly so people can actually use the library without fudging with
+	    include paths.
+
 Thu Jan 19 21:56:29 PST 2006  Christian Hammond <chipx86 at chipx86.com>
 
 	* libnotify/Makefile.am:

Modified: trunk/libnotify/libnotify/Makefile.am
===================================================================
--- trunk/libnotify/libnotify/Makefile.am	2006-01-20 05:56:49 UTC (rev 2439)
+++ trunk/libnotify/libnotify/Makefile.am	2006-01-20 06:08:58 UTC (rev 2440)
@@ -7,15 +7,14 @@
 
 notifyinc_HEADERS = 		\
 	notify.h		\
-	notifynotification.h	\
-	notifycommon.h
+	notification.h
 
 noinst_HEADERS = \
 	notify-marshal.h
 
 libnotify_la_SOURCES = 		\
 	notify.c		\
-	notifynotification.c	\
+	notification.c	\
 	notify-marshal.c
 
 libnotify_la_LIBADD = \

Added: trunk/libnotify/libnotify/internal.h
===================================================================
--- trunk/libnotify/libnotify/internal.h	2006-01-20 05:56:49 UTC (rev 2439)
+++ trunk/libnotify/libnotify/internal.h	2006-01-20 06:08:58 UTC (rev 2440)
@@ -0,0 +1,28 @@
+/**
+ * @file libnotify/internal.h Internal definitions
+ *
+ * @Copyright (C) 2006 Christian Hammond
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA  02111-1307, USA.
+ */
+#ifndef _LIBNOTIFY_INTERNAL_H_
+#define _LIBNOTIFY_INTERNAL_H_
+
+#define NOTIFY_DBUS_NAME           "org.freedesktop.Notifications"
+#define NOTIFY_DBUS_CORE_INTERFACE "org.freedesktop.Notifications"
+#define NOTIFY_DBUS_CORE_OBJECT    "/org/freedesktop/Notifications"
+
+#endif /* _LIBNOTIFY_INTERNAL_H_ */

Copied: trunk/libnotify/libnotify/notification.c (from rev 2438, trunk/libnotify/libnotify/notifynotification.c)
===================================================================
--- trunk/libnotify/libnotify/notifynotification.c	2006-01-20 05:55:30 UTC (rev 2438)
+++ trunk/libnotify/libnotify/notification.c	2006-01-20 06:08:58 UTC (rev 2440)
@@ -0,0 +1,877 @@
+/**
+ * @file libnotify/notifynotification.c Notification object
+ *
+ * @Copyright (C) 2006 Christian Hammond
+ * @Copyright (C) 2006 John Palmieri
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA  02111-1307, USA.
+ */
+#include "config.h"
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib.h>
+
+#include <libnotify/notify.h>
+#include <libnotify/notify-marshal.h>
+#include <libnotify/internal.h>
+
+static void notify_notification_class_init(NotifyNotificationClass *klass);
+static void notify_notification_init(NotifyNotification *sp);
+static void notify_notification_finalize(GObject *object);
+static void _close_signal_handler(DBusGProxy *proxy, guint32 id,
+								  NotifyNotification *notification);
+
+static void _action_signal_handler(DBusGProxy *proxy, guint32 id,
+								   gchar *action,
+								   NotifyNotification *notification);
+
+struct _NotifyNotificationPrivate
+{
+	guint32 id;
+	gchar *summary;
+	gchar *message;
+
+	/* NULL to use icon data anything else to have server lookup icon */
+	gchar *icon_name;
+
+	/*
+	 * -1   = use server default
+	 *  0   = never timeout
+	 *  > 0 = Number of milliseconds before we timeout
+    */
+	gint timeout;
+
+	GSList *actions;
+	GHashTable *action_map;
+	GHashTable *hints;
+
+	GtkWidget *attached_widget;
+	gint widget_old_x;
+	gint widget_old_y;
+
+	gpointer user_data;
+	GDestroyNotify user_data_free_func;
+
+	gboolean updates_pending;
+
+	DBusGProxy *proxy;
+};
+
+typedef enum
+{
+	SIGNAL_TYPE_CLOSED,
+	LAST_SIGNAL
+
+} NotifyNotificationSignalType;
+
+typedef struct
+{
+	NotifyNotification *object;
+
+} NotifyNotificationSignal;
+
+static guint notify_notification_signals[LAST_SIGNAL] = { 0 };
+static GObjectClass *parent_class = NULL;
+
+GType
+notify_notification_get_type()
+{
+	static GType type = 0;
+
+	if (type == 0)
+	{
+		static const GTypeInfo our_info = {
+			sizeof(NotifyNotificationClass),
+			NULL,
+			NULL,
+			(GClassInitFunc) notify_notification_class_init,
+			NULL,
+			NULL,
+			sizeof(NotifyNotification),
+			0,
+			(GInstanceInitFunc) notify_notification_init,
+		};
+
+		type = g_type_register_static(G_TYPE_OBJECT,
+									  "NotifyNotification", &our_info, 0);
+	}
+
+	return type;
+}
+
+static void
+notify_notification_class_init(NotifyNotificationClass * klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+	parent_class = g_type_class_peek_parent(klass);
+	object_class->finalize = notify_notification_finalize;
+
+	/* Create signals here: */
+	notify_notification_signals[SIGNAL_TYPE_CLOSED] =
+		g_signal_new("closed",
+					 G_TYPE_FROM_CLASS(object_class),
+					 G_SIGNAL_RUN_FIRST,
+					 G_STRUCT_OFFSET(NotifyNotificationClass, closed),
+					 NULL, NULL,
+					 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+	dbus_g_object_register_marshaller(notify_marshal_VOID__UINT_STRING,
+									  G_TYPE_NONE,
+									  G_TYPE_UINT,
+									  G_TYPE_STRING, G_TYPE_INVALID);
+}
+
+static void
+_g_value_free(GValue *value)
+{
+	g_value_unset(value);
+	g_free(value);
+}
+
+static void
+notify_notification_init(NotifyNotification *obj)
+{
+	obj->priv = g_new0(NotifyNotificationPrivate, 1);
+
+	obj->priv->id = 0;
+	obj->priv->summary = NULL;
+	obj->priv->message = NULL;
+	obj->priv->icon_name = NULL;
+	obj->priv->timeout = NOTIFY_TIMEOUT_DEFAULT;
+	obj->priv->actions = NULL;
+	obj->priv->hints = g_hash_table_new_full(g_str_hash, g_str_equal,
+											 g_free,
+											 (GFreeFunc)_g_value_free);
+
+	obj->priv->action_map = g_hash_table_new_full(g_str_hash, g_str_equal,
+												  g_free, NULL);
+
+	obj->priv->attached_widget = NULL;
+	obj->priv->user_data = NULL;
+	obj->priv->user_data_free_func = NULL;
+
+	obj->priv->updates_pending = FALSE;
+
+	obj->priv->widget_old_x = 0;
+	obj->priv->widget_old_y = 0;
+
+	obj->priv->proxy = NULL;
+}
+
+static void
+notify_notification_finalize(GObject *object)
+{
+	NotifyNotification *obj = NOTIFY_NOTIFICATION(object);
+	NotifyNotificationPrivate *priv = obj->priv;
+
+	g_free(priv->summary);
+	g_free(priv->message);
+	g_free(priv->icon_name);
+
+	if (priv->actions != NULL)
+	{
+		g_slist_foreach(priv->actions, (GFunc)g_free, NULL);
+		g_slist_free(priv->actions);
+	}
+
+	if (priv->action_map != NULL)
+		g_hash_table_destroy(priv->action_map);
+
+	if (priv->hints != NULL)
+		g_hash_table_destroy(priv->hints);
+
+	if (priv->attached_widget != NULL)
+		g_object_unref(G_OBJECT(priv->attached_widget));
+
+	if (priv->user_data_free_func != NULL)
+		priv->user_data_free_func(priv->user_data);
+
+	dbus_g_proxy_disconnect_signal(priv->proxy, "NotificationClosed",
+								   G_CALLBACK(_close_signal_handler),
+								   object);
+
+	dbus_g_proxy_disconnect_signal(priv->proxy, "ActionInvoked",
+								   G_CALLBACK(_action_signal_handler),
+								   object);
+
+	g_free(obj->priv);
+	G_OBJECT_CLASS(parent_class)->finalize(object);
+}
+
+static gboolean
+_notify_notification_update_applet_hints(NotifyNotification *n)
+{
+	NotifyNotificationPrivate *priv = n->priv;
+	gboolean update_pending = FALSE;
+
+	if (priv->attached_widget != NULL)
+	{
+		gint x, y, h, w;
+		GtkWidget *widget = priv->attached_widget;
+		GtkRequisition requisition;
+
+		gtk_widget_size_request(widget, &requisition);
+		w = requisition.width;
+		h = requisition.height;
+
+		gdk_window_get_origin(widget->window, &x, &y);
+
+		if (GTK_WIDGET_NO_WINDOW(widget))
+		{
+			x += widget->allocation.x;
+			y += widget->allocation.y;
+		}
+
+		x += widget->allocation.width / 2;
+		y += widget->allocation.height / 2;
+
+		if (x != priv->widget_old_x)
+		{
+			notify_notification_set_hint_int32(n, "x", x);
+			priv->widget_old_x = x;
+
+			update_pending = TRUE;
+		}
+
+		if (y != priv->widget_old_y)
+		{
+			notify_notification_set_hint_int32(n, "y", y);
+			priv->widget_old_y = y;
+
+			update_pending = TRUE;
+		}
+	}
+
+	return update_pending;
+}
+
+#if 0
+
+/* This is left here just incase we revisit autoupdating
+   One thought would be to check for updates every time the icon
+   is redrawn but we still have to deal with the race conditions
+   that could occure between the server and the client so we will
+   leave this alone for now.
+*/
+static gboolean
+_idle_check_updates(void *user_data)
+{
+	NotifyNotification *n = NOTIFY_NOTIFICATION(user_data);
+	NotifyNotificationPrivate *priv = n->priv;
+
+	if (priv->is_visible)
+	{
+		priv->updates_pending = _notify_notification_update_applet_hints(n);
+
+		if (priv->updates_pending)
+		{
+			/* Try again if we fail on next idle */
+			priv->updates_pending = !notify_notification_show(n, NULL);
+		}
+	}
+	else
+	{
+		priv->updates_pending = FALSE;
+	}
+
+	return TRUE;
+}
+#endif
+
+GdkFilterReturn
+_catch(GdkXEvent *xevent, GdkEvent *event, gpointer data)
+{
+	static int i = 1;
+
+	printf("here, %i\n", i);
+	i++;
+	return GDK_FILTER_CONTINUE;
+}
+
+NotifyNotification *
+notify_notification_new(const gchar *summary, const gchar *message,
+						const gchar *icon, GtkWidget *attach)
+{
+	NotifyNotification *obj;
+
+	g_assert(summary != NULL);
+	g_assert(message != NULL);
+
+	obj = NOTIFY_NOTIFICATION(g_object_new(NOTIFY_TYPE_NOTIFICATION, NULL));
+
+	obj->priv->summary = g_strdup(summary);
+	obj->priv->message = g_strdup(message);
+	obj->priv->icon_name = g_strdup(icon);
+
+	if (attach != NULL)
+	{
+		g_object_ref(G_OBJECT(attach));
+		obj->priv->attached_widget = attach;
+	}
+
+	return obj;
+}
+
+gboolean
+notify_notification_update(NotifyNotification *notification,
+						   const gchar *summary,
+						   const gchar *message, const gchar *icon)
+{
+	NotifyNotificationPrivate *priv = notification->priv;
+
+	g_free(priv->summary);
+	g_free(priv->message);
+	g_free(priv->icon_name);
+
+	priv->summary = g_strdup(summary);
+	priv->message = g_strdup(message);
+	priv->icon_name = g_strdup(icon);
+
+	priv->updates_pending = TRUE;
+
+	/*TODO: return false on OOM */
+	return TRUE;
+}
+
+void
+notify_notification_attach_to_widget(NotifyNotification *notification,
+									 GtkWidget *attach)
+{
+	NotifyNotificationPrivate *priv = notification->priv;
+
+	if (priv->attached_widget != NULL)
+		g_object_unref(priv->attached_widget);
+
+	priv->attached_widget = (attach != NULL ? g_object_ref(attach) : NULL);
+}
+
+gboolean
+notify_notification_set_user_data(NotifyNotification *notification,
+								  void *user_data, GFreeFunc free_func)
+{
+	NotifyNotificationPrivate *priv = notification->priv;
+
+	if (priv->user_data)
+	{
+		if (priv->user_data_free_func)
+			priv->user_data_free_func(priv->user_data);
+	}
+
+	priv->user_data = user_data;
+	priv->user_data_free_func = free_func;
+
+	/* TODO: return FALSE on OOM */
+	return TRUE;
+}
+
+gpointer
+notify_notification_get_user_data(NotifyNotification *notification)
+{
+	return notification->priv->user_data;
+}
+
+static void
+_close_signal_handler(DBusGProxy *proxy, guint32 id,
+					  NotifyNotification *notification)
+{
+	printf("Got the NotificationClosed signal (id = %i, "
+		   "notification->id = %i)\n",
+		   id, notification->priv->id);
+
+	if (id == notification->priv->id)
+	{
+		g_signal_emit(notification,
+					  notify_notification_signals[SIGNAL_TYPE_CLOSED], 0);
+	}
+}
+
+static void
+_action_signal_handler(DBusGProxy *proxy,
+					   guint32 id,
+					   gchar *action, NotifyNotification *notification)
+{
+	g_assert(NOTIFY_IS_NOTIFICATION(notification));
+
+	if (id == notification->priv->id)
+	{
+		NotifyActionCallback callback;
+
+		callback = (NotifyActionCallback)g_hash_table_lookup(
+			notification->priv->action_map, action);
+
+		if (callback == NULL)
+			g_warning("Recieved unknown action %s", action);
+		else
+			callback(notification, action);
+	}
+}
+
+static gchar **
+_gslist_to_string_array(GSList *list)
+{
+	GSList *l;
+	GArray *a;
+
+	a = g_array_sized_new(TRUE, FALSE, sizeof(gchar *),
+						  g_slist_length(list));
+
+	for (l = list; l != NULL; l = l->next)
+		g_array_append_val(a, l->data);
+
+	return (gchar **)g_array_free(a, FALSE);
+}
+
+static gboolean
+_notify_notification_show_internal(NotifyNotification *notification,
+								   GError **error, gboolean ignore_reply)
+{
+	NotifyNotificationPrivate *priv = notification->priv;
+	GError *tmp_error = NULL;
+	gchar **action_array;
+
+	g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
+
+	if (priv->proxy == NULL)
+	{
+		DBusGConnection *bus;
+
+		bus = dbus_g_bus_get(DBUS_BUS_SESSION, &tmp_error);
+
+		if (tmp_error != NULL)
+		{
+			g_propagate_error(error, tmp_error);
+			return FALSE;
+		}
+
+		priv->proxy = dbus_g_proxy_new_for_name(bus,
+												NOTIFY_DBUS_NAME,
+												NOTIFY_DBUS_CORE_OBJECT,
+												NOTIFY_DBUS_CORE_INTERFACE);
+
+		dbus_g_proxy_add_signal(priv->proxy, "NotificationClosed",
+								G_TYPE_UINT, G_TYPE_INVALID);
+		dbus_g_proxy_connect_signal(priv->proxy, "NotificationClosed",
+									G_CALLBACK(_close_signal_handler),
+									notification, NULL);
+
+		dbus_g_proxy_add_signal(priv->proxy, "ActionInvoked",
+								G_TYPE_UINT, G_TYPE_STRING,
+								G_TYPE_INVALID);
+		dbus_g_proxy_connect_signal(priv->proxy, "ActionInvoked",
+									G_CALLBACK(_action_signal_handler),
+									notification, NULL);
+
+		dbus_g_connection_unref(bus);
+	}
+
+	/* If attached to a widget, modify x and y in hints */
+	_notify_notification_update_applet_hints(notification);
+
+	action_array = _gslist_to_string_array(priv->actions);
+
+	/* TODO: make this nonblocking */
+
+	if (!ignore_reply)
+	{
+		dbus_g_proxy_call(priv->proxy, "Notify", &tmp_error,
+						  G_TYPE_STRING, notify_get_app_name(),
+						  G_TYPE_STRING,
+						  (priv->icon_name != NULL) ? priv->icon_name : "",
+						  G_TYPE_UINT, priv->id, G_TYPE_STRING,
+						  priv->summary, G_TYPE_STRING, priv->message,
+						  G_TYPE_STRV, action_array,
+						  dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
+											  G_TYPE_VALUE), priv->hints,
+						  G_TYPE_INT, priv->timeout, G_TYPE_INVALID,
+						  G_TYPE_UINT, &priv->id, G_TYPE_INVALID);
+	}
+	else
+	{
+		dbus_g_proxy_call_no_reply(priv->proxy, "Notify",
+								   G_TYPE_STRING, notify_get_app_name(),
+								   G_TYPE_STRING,
+								   (priv->icon_name !=
+									NULL) ? priv->icon_name : "",
+								   G_TYPE_UINT, priv->id, G_TYPE_STRING,
+								   priv->summary, G_TYPE_STRING,
+								   priv->message, G_TYPE_STRV,
+								   action_array,
+								   dbus_g_type_get_map("GHashTable",
+													   G_TYPE_STRING,
+													   G_TYPE_VALUE),
+								   priv->hints, G_TYPE_INT, priv->timeout,
+								   G_TYPE_INVALID);
+	}
+
+	/* Don't free the elements because they are owned by priv->actions */
+	g_free(action_array);
+
+	if (tmp_error != NULL)
+	{
+		g_propagate_error(error, tmp_error);
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+gboolean
+notify_notification_show(NotifyNotification *notification, GError **error)
+{
+	return _notify_notification_show_internal(notification, error, FALSE);
+}
+
+gboolean
+notify_notification_show_and_forget(NotifyNotification *notification,
+									GError **error)
+{
+	gboolean result =
+		_notify_notification_show_internal(notification, error, TRUE);
+
+	g_object_unref(G_OBJECT(notification));
+
+	return result;
+}
+
+void
+notify_notification_set_timeout(NotifyNotification *notification,
+								gint timeout)
+{
+	notification->priv->timeout = timeout;
+}
+
+gboolean
+notify_notification_set_category(NotifyNotification *notification,
+								 const char *category)
+{
+	return notify_notification_set_hint_string(notification,
+											   "category", category);
+}
+
+gboolean
+notify_notification_set_urgency(NotifyNotification *notification,
+								NotifyUrgency l)
+{
+	return notify_notification_set_hint_byte(notification,
+											 "urgency", (guchar)l);
+}
+
+static gboolean
+_gvalue_array_append_int(GValueArray *array, gint i)
+{
+	GValue *value = g_new0(GValue, 1);
+
+	if (value == NULL)
+		return FALSE;
+
+	g_value_init(value, G_TYPE_INT);
+	g_value_set_int(value, i);
+	g_value_array_append(array, value);
+
+	return TRUE;
+}
+
+static gboolean
+_gvalue_array_append_bool(GValueArray *array, gboolean b)
+{
+	GValue *value = g_new0(GValue, 1);
+
+	if (value == NULL)
+		return FALSE;
+
+	g_value_init(value, G_TYPE_BOOLEAN);
+	g_value_set_boolean(value, b);
+	g_value_array_append(array, value);
+
+	return TRUE;
+}
+
+static gboolean
+_gvalue_array_append_byte_array(GValueArray *array, guchar *bytes, gsize len)
+{
+	GArray *byte_array;
+	GValue *value;
+
+	byte_array = g_array_sized_new(FALSE, FALSE, sizeof(guchar), len);
+
+	if (byte_array == NULL)
+		return FALSE;
+
+	byte_array = g_array_append_vals(byte_array, bytes, len);
+
+	if ((value = g_new0(GValue, 1)) == NULL)
+	{
+		g_array_free(byte_array, TRUE);
+		return FALSE;
+	}
+
+	g_value_init(value, dbus_g_type_get_collection("GArray", G_TYPE_UCHAR));
+	g_value_set_boxed_take_ownership(value, byte_array);
+	g_value_array_append(array, value);
+
+	return TRUE;
+}
+
+gboolean
+notify_notification_set_icon_data_from_pixbuf(
+	NotifyNotification *notification, GdkPixbuf *icon)
+{
+	gint width;
+	gint height;
+	gint rowstride;
+	gboolean alpha;
+	gint bits_per_sample;
+	gint n_channels;
+	guchar *image;
+	gsize image_len;
+	GValueArray *image_struct;
+	GValue *value;
+	NotifyNotificationPrivate *priv;
+
+	priv = notification->priv;
+
+	width           = gdk_pixbuf_get_width(icon);
+	height          = gdk_pixbuf_get_height(icon);
+	rowstride       = gdk_pixbuf_get_rowstride(icon);
+	n_channels      = gdk_pixbuf_get_n_channels(icon);
+	bits_per_sample = gdk_pixbuf_get_bits_per_sample(icon);
+	alpha           = gdk_pixbuf_get_has_alpha(icon);
+	image_len       = (height - 1) * rowstride + width *
+	                  ((n_channels * bits_per_sample + 7) / 8);
+
+	image = gdk_pixbuf_get_pixels(icon);
+
+	image_struct = g_value_array_new(8);
+
+	if (image_struct == NULL)
+		goto fail;
+
+	_gvalue_array_append_int(image_struct, width);
+	_gvalue_array_append_int(image_struct, height);
+	_gvalue_array_append_int(image_struct, rowstride);
+	_gvalue_array_append_bool(image_struct, alpha);
+	_gvalue_array_append_int(image_struct, bits_per_sample);
+	_gvalue_array_append_int(image_struct, n_channels);
+	_gvalue_array_append_byte_array(image_struct, image, image_len);
+
+	value = g_new0(GValue, 1);
+
+	if (value == NULL)
+		goto fail;
+
+	g_value_init(value, G_TYPE_VALUE_ARRAY);
+	g_value_set_boxed(value, image_struct);
+
+	g_hash_table_insert(priv->hints, g_strdup("icon_data"), value);
+
+	return TRUE;
+
+fail:
+	if (image_struct != NULL)
+		g_value_array_free(image_struct);
+
+	return FALSE;
+}
+
+gboolean
+notify_notification_set_hint_int32(NotifyNotification *notification,
+								   const gchar *key, gint value)
+{
+	NotifyNotificationPrivate *priv;
+	GValue *hint_value;
+
+	priv = notification->priv;
+
+	hint_value = g_new0(GValue, 1);
+	g_value_init(hint_value, G_TYPE_INT);
+	g_value_set_int(hint_value, value);
+
+	g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
+
+	/* TODO: return FALSE on OOM */
+	return TRUE;
+}
+
+gboolean
+notify_notification_set_hint_double(NotifyNotification *notification,
+									const gchar *key, gdouble value)
+{
+	NotifyNotificationPrivate *priv;
+	GValue *hint_value;
+
+	priv = notification->priv;
+
+	hint_value = g_new0(GValue, 1);
+	g_value_init(hint_value, G_TYPE_FLOAT);
+	g_value_set_float(hint_value, value);
+
+	g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
+
+	/* TODO: return FALSE on OOM */
+	return TRUE;
+}
+
+gboolean
+notify_notification_set_hint_byte(NotifyNotification *notification,
+								  const gchar *key, guchar value)
+{
+	NotifyNotificationPrivate *priv;
+	GValue *hint_value;
+
+	priv = notification->priv;
+
+	hint_value = g_new0(GValue, 1);
+	g_value_init(hint_value, G_TYPE_UCHAR);
+	g_value_set_uchar(hint_value, value);
+
+	g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
+
+	/* TODO: return FALSE on OOM */
+	return TRUE;
+}
+
+gboolean
+notify_notification_set_hint_byte_array(NotifyNotification *notification,
+										const gchar *key,
+										const guchar *value, gsize len)
+{
+	NotifyNotificationPrivate *priv;
+	GValue *hint_value;
+	GArray *byte_array;
+
+	priv = notification->priv;
+
+	byte_array = g_array_sized_new(FALSE, FALSE, sizeof(guchar), len);
+	byte_array = g_array_append_vals(byte_array, value, len);
+
+	hint_value = g_new0(GValue, 1);
+	g_value_init(hint_value, dbus_g_type_get_collection("GArray",
+														G_TYPE_UCHAR));
+	g_value_set_boxed_take_ownership(hint_value, byte_array);
+
+	g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
+
+	/* TODO: return FALSE on OOM */
+	return TRUE;
+}
+
+gboolean
+notify_notification_set_hint_string(NotifyNotification *notification,
+									const gchar *key, const gchar *value)
+{
+	NotifyNotificationPrivate *priv;
+	GValue *hint_value;
+
+	priv = notification->priv;
+
+	hint_value = g_new0(GValue, 1);
+	g_value_init(hint_value, G_TYPE_STRING);
+	g_value_set_string(hint_value, value);
+
+	g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
+
+	/* TODO: return FALSE on OOM */
+	return TRUE;
+}
+
+static gboolean
+_remove_all(void)
+{
+	return TRUE;
+}
+
+void
+notify_notification_clear_hints(NotifyNotification *notification)
+{
+	g_hash_table_foreach_remove(notification->priv->hints,
+								(GHRFunc)_remove_all, NULL);
+}
+
+void
+notify_notification_clear_actions(NotifyNotification *notification)
+{
+	g_hash_table_foreach_remove(notification->priv->action_map,
+								(GHRFunc)_remove_all, NULL);
+
+	if (notification->priv->actions != NULL)
+	{
+		g_slist_foreach(notification->priv->actions, (GFunc)g_free, NULL);
+		g_slist_free(notification->priv->actions);
+	}
+
+	notification->priv->actions = NULL;
+}
+
+gboolean
+notify_notification_add_action(NotifyNotification *notification,
+							   const char *action,
+							   const char *label,
+							   NotifyActionCallback callback)
+{
+	NotifyNotificationPrivate *priv;
+
+	priv = notification->priv;
+
+	priv->actions = g_slist_append(priv->actions, g_strdup(action));
+	priv->actions = g_slist_append(priv->actions, g_strdup(label));
+
+	g_hash_table_insert(priv->action_map, g_strdup(action), callback);
+
+	return FALSE;
+}
+
+gboolean
+notify_notification_close(NotifyNotification *notification,
+						  GError **error)
+{
+	NotifyNotificationPrivate *priv;
+	GError *tmp_error;
+
+	g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
+
+	priv = notification->priv;
+
+	tmp_error = NULL;
+
+	if (priv->proxy == NULL)
+	{
+		DBusGConnection *bus = dbus_g_bus_get(DBUS_BUS_SESSION, &tmp_error);
+
+		if (tmp_error != NULL)
+		{
+			g_propagate_error(error, tmp_error);
+			return FALSE;
+		}
+
+		priv->proxy = dbus_g_proxy_new_for_name(bus,
+												NOTIFY_DBUS_NAME,
+												NOTIFY_DBUS_CORE_OBJECT,
+												NOTIFY_DBUS_CORE_INTERFACE);
+		dbus_g_connection_unref(bus);
+	}
+
+	dbus_g_proxy_call(priv->proxy, "CloseNotification", &tmp_error,
+					  G_TYPE_UINT, priv->id, G_TYPE_INVALID,
+					  G_TYPE_INVALID);
+
+	if (tmp_error != NULL)
+	{
+		g_propagate_error(error, tmp_error);
+		return FALSE;
+	}
+
+	return TRUE;
+}

Copied: trunk/libnotify/libnotify/notification.h (from rev 2438, trunk/libnotify/libnotify/notifynotification.h)
===================================================================
--- trunk/libnotify/libnotify/notifynotification.h	2006-01-20 05:55:30 UTC (rev 2438)
+++ trunk/libnotify/libnotify/notification.h	2006-01-20 06:08:58 UTC (rev 2440)
@@ -0,0 +1,153 @@
+/**
+ * @file libnotify/notifynotification.h Notification object
+ *
+ * @Copyright (C) 2006 Christian Hammond
+ * @Copyright (C) 2006 John Palmieri
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA  02111-1307, USA.
+ */
+#ifndef _NOTIFY_NOTIFICATION_H_
+#define _NOTIFY_NOTIFICATION_H_
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define NOTIFY_TIMEOUT_DEFAULT -1
+#define NOTIFY_TIMEOUT_NEVER    0
+
+#define NOTIFY_TYPE_NOTIFICATION (notify_notification_get_type ())
+#define NOTIFY_NOTIFICATION(o) \
+	(G_TYPE_CHECK_INSTANCE_CAST ((o), NOTIFY_TYPE_NOTIFICATION, \
+								 NotifyNotification))
+#define NOTIFY_NOTIFICATION_CLASS(k) \
+	(G_TYPE_CHECK_CLASS_CAST((k), NOTIFY_TYPE_NOTIFICATION, \
+							 NotifyNotificationClass))
+#define NOTIFY_IS_NOTIFICATION(o) \
+	(G_TYPE_CHECK_INSTANCE_TYPE ((o), NOTIFY_TYPE_NOTIFICATION))
+#define NOTIFY_IS_NOTIFICATION_CLASS(k) \
+	(G_TYPE_CHECK_CLASS_TYPE ((k), NOTIFY_TYPE_NOTIFICATION))
+#define NOTIFY_NOTIFICATION_GET_CLASS(o) \
+	(G_TYPE_INSTANCE_GET_CLASS ((o), NOTIFY_TYPE_NOTIFICATION, \
+								NotifyNotificationClass))
+
+
+typedef struct _NotifyNotification        NotifyNotification;
+typedef struct _NotifyNotificationClass   NotifyNotificationClass;
+typedef struct _NotifyNotificationPrivate NotifyNotificationPrivate;
+
+struct _NotifyNotification
+{
+	GObject parent;
+	NotifyNotificationPrivate *priv;
+};
+
+struct _NotifyNotificationClass
+{
+	GObjectClass parent_class;
+
+	/* Signals */
+	void (*closed)(NotifyNotification *notification);
+};
+
+/**
+ * Notification urgency levels.
+ */
+typedef enum
+{
+	NOTIFY_URGENCY_LOW,		  /**< Low urgency.      */
+	NOTIFY_URGENCY_NORMAL,	  /**< Normal urgency.   */
+	NOTIFY_URGENCY_CRITICAL,  /**< Critical urgency. */
+
+} NotifyUrgency;
+
+typedef void (*NotifyActionCallback)(NotifyNotification *, gchar *);
+
+GType notify_notification_get_type();
+
+NotifyNotification *notify_notification_new(const gchar *summary,
+											const gchar *message,
+											const gchar *icon,
+											GtkWidget *attach);
+
+gboolean notify_notification_update(NotifyNotification *notification,
+									const gchar *summary,
+									const gchar *message,
+									const gchar *icon);
+
+void notify_notification_attach_to_widget(NotifyNotification* notification,
+										  GtkWidget *attach);
+
+gboolean notify_notification_set_user_data(NotifyNotification *notification,
+										   void *user_data,
+										   GFreeFunc free_func);
+
+gpointer notify_notification_get_user_data(NotifyNotification *notification);
+
+gboolean notify_notification_show(NotifyNotification *notification,
+								  GError **error);
+
+gboolean notify_notification_show_and_forget(NotifyNotification *notification,
+											 GError **error);
+
+void notify_notification_set_timeout(NotifyNotification *notification,
+									 gint timeout);
+
+gboolean notify_notification_set_category(NotifyNotification *notification,
+										  const char *category);
+
+gboolean notify_notification_set_urgency(NotifyNotification *notification,
+										 NotifyUrgency l);
+
+gboolean notify_notification_set_icon_data_from_pixbuf(
+	NotifyNotification *notification, GdkPixbuf *icon);
+
+gboolean notify_notification_set_hint_int32(NotifyNotification *notification,
+											const gchar *key, gint value);
+
+gboolean notify_notification_set_hint_double(NotifyNotification *notification,
+											 const gchar *key,
+											 gdouble value);
+
+gboolean notify_notification_set_hint_string(NotifyNotification *notification,
+											 const gchar *key,
+											 const gchar *value);
+
+gboolean notify_notification_set_hint_byte(NotifyNotification *notification,
+										   const gchar *key,
+										   guchar value);
+
+gboolean notify_notification_set_hint_byte_array(
+	NotifyNotification *notification, const gchar *key,
+	const guchar *value, gsize len);
+
+void notify_notification_clear_hints(NotifyNotification *notification);
+
+gboolean notify_notification_add_action(NotifyNotification *notification,
+										const char *action,
+										const char *label,
+										NotifyActionCallback callback);
+
+void notify_notification_clear_actions(NotifyNotification *notification);
+gboolean notify_notification_close(NotifyNotification *notification,
+								   GError **error);
+
+NotifyNotification *notify_notification_ref(NotifyNotification *notification);
+void notify_notification_unref(NotifyNotification *notification);
+
+#endif /* NOTIFY_NOTIFICATION_H */

Modified: trunk/libnotify/libnotify/notify.c
===================================================================
--- trunk/libnotify/libnotify/notify.c	2006-01-20 05:56:49 UTC (rev 2439)
+++ trunk/libnotify/libnotify/notify.c	2006-01-20 06:08:58 UTC (rev 2440)
@@ -28,13 +28,14 @@
 # define DBUS_API_SUBJECT_TO_CHANGE 1
 #endif
 
-#include "notify.h"
 #include <dbus/dbus.h>
 #include <dbus/dbus-glib.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <unistd.h>
+#include <libnotify/notify.h>
+#include <libnotify/internal.h>
 
 static gboolean _initted = FALSE;
 static gchar *_app_name = NULL;

Modified: trunk/libnotify/libnotify/notify.h
===================================================================
--- trunk/libnotify/libnotify/notify.h	2006-01-20 05:56:49 UTC (rev 2439)
+++ trunk/libnotify/libnotify/notify.h	2006-01-20 06:08:58 UTC (rev 2440)
@@ -24,8 +24,7 @@
 #include <glib.h>
 #include <time.h>
 
-#include "notifycommon.h"
-#include "notifynotification.h"
+#include <libnotify/notification.h>
 
 /**************************************************************************/
 /** @name libnotify Base API                                              */

Deleted: trunk/libnotify/libnotify/notifycommon.h
===================================================================
--- trunk/libnotify/libnotify/notifycommon.h	2006-01-20 05:56:49 UTC (rev 2439)
+++ trunk/libnotify/libnotify/notifycommon.h	2006-01-20 06:08:58 UTC (rev 2440)
@@ -1,23 +0,0 @@
-#ifndef _LIBNOTIFY_NOTIFY_COMMON_H_
-#define _LIBNOTIFY_NOTIFY_COMMON_H_
-#include <glib.h>
-
-#define NOTIFY_TIMEOUT_DEFAULT -1
-#define NOTIFY_TIMEOUT_NEVER    0
-
-#define NOTIFY_DBUS_NAME           "org.freedesktop.Notifications"
-#define NOTIFY_DBUS_CORE_INTERFACE "org.freedesktop.Notifications"
-#define NOTIFY_DBUS_CORE_OBJECT    "/org/freedesktop/Notifications"
-
-/**
- * Notification urgency levels.
- */
-typedef enum
-{
-	NOTIFY_URGENCY_LOW,		  /**< Low urgency.      */
-	NOTIFY_URGENCY_NORMAL,	  /**< Normal urgency.   */
-	NOTIFY_URGENCY_CRITICAL,  /**< Critical urgency. */
-
-} NotifyUrgency;
-
-#endif /* _LIBNOTIFY_NOTIFY_H_ */

Deleted: trunk/libnotify/libnotify/notifynotification.c
===================================================================
--- trunk/libnotify/libnotify/notifynotification.c	2006-01-20 05:56:49 UTC (rev 2439)
+++ trunk/libnotify/libnotify/notifynotification.c	2006-01-20 06:08:58 UTC (rev 2440)
@@ -1,877 +0,0 @@
-/**
- * @file libnotify/notifynotification.c Notification object
- *
- * @Copyright (C) 2006 Christian Hammond
- * @Copyright (C) 2006 John Palmieri
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA  02111-1307, USA.
- */
-#include "config.h"
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-
-#include "notify.h"
-#include "notifynotification.h"
-#include "notify-marshal.h"
-
-static void notify_notification_class_init(NotifyNotificationClass *klass);
-static void notify_notification_init(NotifyNotification *sp);
-static void notify_notification_finalize(GObject *object);
-static void _close_signal_handler(DBusGProxy *proxy, guint32 id,
-								  NotifyNotification *notification);
-
-static void _action_signal_handler(DBusGProxy *proxy, guint32 id,
-								   gchar *action,
-								   NotifyNotification *notification);
-
-struct _NotifyNotificationPrivate
-{
-	guint32 id;
-	gchar *summary;
-	gchar *message;
-
-	/* NULL to use icon data anything else to have server lookup icon */
-	gchar *icon_name;
-
-	/*
-	 * -1   = use server default
-	 *  0   = never timeout
-	 *  > 0 = Number of milliseconds before we timeout
-    */
-	gint timeout;
-
-	GSList *actions;
-	GHashTable *action_map;
-	GHashTable *hints;
-
-	GtkWidget *attached_widget;
-	gint widget_old_x;
-	gint widget_old_y;
-
-	gpointer user_data;
-	GDestroyNotify user_data_free_func;
-
-	gboolean updates_pending;
-
-	DBusGProxy *proxy;
-};
-
-typedef enum
-{
-	SIGNAL_TYPE_CLOSED,
-	LAST_SIGNAL
-
-} NotifyNotificationSignalType;
-
-typedef struct
-{
-	NotifyNotification *object;
-
-} NotifyNotificationSignal;
-
-static guint notify_notification_signals[LAST_SIGNAL] = { 0 };
-static GObjectClass *parent_class = NULL;
-
-GType
-notify_notification_get_type()
-{
-	static GType type = 0;
-
-	if (type == 0)
-	{
-		static const GTypeInfo our_info = {
-			sizeof(NotifyNotificationClass),
-			NULL,
-			NULL,
-			(GClassInitFunc) notify_notification_class_init,
-			NULL,
-			NULL,
-			sizeof(NotifyNotification),
-			0,
-			(GInstanceInitFunc) notify_notification_init,
-		};
-
-		type = g_type_register_static(G_TYPE_OBJECT,
-									  "NotifyNotification", &our_info, 0);
-	}
-
-	return type;
-}
-
-static void
-notify_notification_class_init(NotifyNotificationClass * klass)
-{
-	GObjectClass *object_class = G_OBJECT_CLASS(klass);
-
-	parent_class = g_type_class_peek_parent(klass);
-	object_class->finalize = notify_notification_finalize;
-
-	/* Create signals here: */
-	notify_notification_signals[SIGNAL_TYPE_CLOSED] =
-		g_signal_new("closed",
-					 G_TYPE_FROM_CLASS(object_class),
-					 G_SIGNAL_RUN_FIRST,
-					 G_STRUCT_OFFSET(NotifyNotificationClass, closed),
-					 NULL, NULL,
-					 g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-
-	dbus_g_object_register_marshaller(notify_marshal_VOID__UINT_STRING,
-									  G_TYPE_NONE,
-									  G_TYPE_UINT,
-									  G_TYPE_STRING, G_TYPE_INVALID);
-}
-
-static void
-_g_value_free(GValue *value)
-{
-	g_value_unset(value);
-	g_free(value);
-}
-
-static void
-notify_notification_init(NotifyNotification *obj)
-{
-	obj->priv = g_new0(NotifyNotificationPrivate, 1);
-
-	obj->priv->id = 0;
-	obj->priv->summary = NULL;
-	obj->priv->message = NULL;
-	obj->priv->icon_name = NULL;
-	obj->priv->timeout = NOTIFY_TIMEOUT_DEFAULT;
-	obj->priv->actions = NULL;
-	obj->priv->hints = g_hash_table_new_full(g_str_hash, g_str_equal,
-											 g_free,
-											 (GFreeFunc)_g_value_free);
-
-	obj->priv->action_map = g_hash_table_new_full(g_str_hash, g_str_equal,
-												  g_free, NULL);
-
-	obj->priv->attached_widget = NULL;
-	obj->priv->user_data = NULL;
-	obj->priv->user_data_free_func = NULL;
-
-	obj->priv->updates_pending = FALSE;
-
-	obj->priv->widget_old_x = 0;
-	obj->priv->widget_old_y = 0;
-
-	obj->priv->proxy = NULL;
-}
-
-static void
-notify_notification_finalize(GObject *object)
-{
-	NotifyNotification *obj = NOTIFY_NOTIFICATION(object);
-	NotifyNotificationPrivate *priv = obj->priv;
-
-	g_free(priv->summary);
-	g_free(priv->message);
-	g_free(priv->icon_name);
-
-	if (priv->actions != NULL)
-	{
-		g_slist_foreach(priv->actions, (GFunc)g_free, NULL);
-		g_slist_free(priv->actions);
-	}
-
-	if (priv->action_map != NULL)
-		g_hash_table_destroy(priv->action_map);
-
-	if (priv->hints != NULL)
-		g_hash_table_destroy(priv->hints);
-
-	if (priv->attached_widget != NULL)
-		g_object_unref(G_OBJECT(priv->attached_widget));
-
-	if (priv->user_data_free_func != NULL)
-		priv->user_data_free_func(priv->user_data);
-
-	dbus_g_proxy_disconnect_signal(priv->proxy, "NotificationClosed",
-								   G_CALLBACK(_close_signal_handler),
-								   object);
-
-	dbus_g_proxy_disconnect_signal(priv->proxy, "ActionInvoked",
-								   G_CALLBACK(_action_signal_handler),
-								   object);
-
-	g_free(obj->priv);
-	G_OBJECT_CLASS(parent_class)->finalize(object);
-}
-
-static gboolean
-_notify_notification_update_applet_hints(NotifyNotification *n)
-{
-	NotifyNotificationPrivate *priv = n->priv;
-	gboolean update_pending = FALSE;
-
-	if (priv->attached_widget != NULL)
-	{
-		gint x, y, h, w;
-		GtkWidget *widget = priv->attached_widget;
-		GtkRequisition requisition;
-
-		gtk_widget_size_request(widget, &requisition);
-		w = requisition.width;
-		h = requisition.height;
-
-		gdk_window_get_origin(widget->window, &x, &y);
-
-		if (GTK_WIDGET_NO_WINDOW(widget))
-		{
-			x += widget->allocation.x;
-			y += widget->allocation.y;
-		}
-
-		x += widget->allocation.width / 2;
-		y += widget->allocation.height / 2;
-
-		if (x != priv->widget_old_x)
-		{
-			notify_notification_set_hint_int32(n, "x", x);
-			priv->widget_old_x = x;
-
-			update_pending = TRUE;
-		}
-
-		if (y != priv->widget_old_y)
-		{
-			notify_notification_set_hint_int32(n, "y", y);
-			priv->widget_old_y = y;
-
-			update_pending = TRUE;
-		}
-	}
-
-	return update_pending;
-}
-
-#if 0
-
-/* This is left here just incase we revisit autoupdating
-   One thought would be to check for updates every time the icon
-   is redrawn but we still have to deal with the race conditions
-   that could occure between the server and the client so we will
-   leave this alone for now.
-*/
-static gboolean
-_idle_check_updates(void *user_data)
-{
-	NotifyNotification *n = NOTIFY_NOTIFICATION(user_data);
-	NotifyNotificationPrivate *priv = n->priv;
-
-	if (priv->is_visible)
-	{
-		priv->updates_pending = _notify_notification_update_applet_hints(n);
-
-		if (priv->updates_pending)
-		{
-			/* Try again if we fail on next idle */
-			priv->updates_pending = !notify_notification_show(n, NULL);
-		}
-	}
-	else
-	{
-		priv->updates_pending = FALSE;
-	}
-
-	return TRUE;
-}
-#endif
-
-GdkFilterReturn
-_catch(GdkXEvent *xevent, GdkEvent *event, gpointer data)
-{
-	static int i = 1;
-
-	printf("here, %i\n", i);
-	i++;
-	return GDK_FILTER_CONTINUE;
-}
-
-NotifyNotification *
-notify_notification_new(const gchar *summary, const gchar *message,
-						const gchar *icon, GtkWidget *attach)
-{
-	NotifyNotification *obj;
-
-	g_assert(summary != NULL);
-	g_assert(message != NULL);
-
-	obj = NOTIFY_NOTIFICATION(g_object_new(NOTIFY_TYPE_NOTIFICATION, NULL));
-
-	obj->priv->summary = g_strdup(summary);
-	obj->priv->message = g_strdup(message);
-	obj->priv->icon_name = g_strdup(icon);
-
-	if (attach != NULL)
-	{
-		g_object_ref(G_OBJECT(attach));
-		obj->priv->attached_widget = attach;
-	}
-
-	return obj;
-}
-
-gboolean
-notify_notification_update(NotifyNotification *notification,
-						   const gchar *summary,
-						   const gchar *message, const gchar *icon)
-{
-	NotifyNotificationPrivate *priv = notification->priv;
-
-	g_free(priv->summary);
-	g_free(priv->message);
-	g_free(priv->icon_name);
-
-	priv->summary = g_strdup(summary);
-	priv->message = g_strdup(message);
-	priv->icon_name = g_strdup(icon);
-
-	priv->updates_pending = TRUE;
-
-	/*TODO: return false on OOM */
-	return TRUE;
-}
-
-void
-notify_notification_attach_to_widget(NotifyNotification *notification,
-									 GtkWidget *attach)
-{
-	NotifyNotificationPrivate *priv = notification->priv;
-
-	if (priv->attached_widget != NULL)
-		g_object_unref(priv->attached_widget);
-
-	priv->attached_widget = (attach != NULL ? g_object_ref(attach) : NULL);
-}
-
-gboolean
-notify_notification_set_user_data(NotifyNotification *notification,
-								  void *user_data, GFreeFunc free_func)
-{
-	NotifyNotificationPrivate *priv = notification->priv;
-
-	if (priv->user_data)
-	{
-		if (priv->user_data_free_func)
-			priv->user_data_free_func(priv->user_data);
-	}
-
-	priv->user_data = user_data;
-	priv->user_data_free_func = free_func;
-
-	/* TODO: return FALSE on OOM */
-	return TRUE;
-}
-
-gpointer
-notify_notification_get_user_data(NotifyNotification *notification)
-{
-	return notification->priv->user_data;
-}
-
-static void
-_close_signal_handler(DBusGProxy *proxy, guint32 id,
-					  NotifyNotification *notification)
-{
-	printf("Got the NotificationClosed signal (id = %i, "
-		   "notification->id = %i)\n",
-		   id, notification->priv->id);
-
-	if (id == notification->priv->id)
-	{
-		g_signal_emit(notification,
-					  notify_notification_signals[SIGNAL_TYPE_CLOSED], 0);
-	}
-}
-
-static void
-_action_signal_handler(DBusGProxy *proxy,
-					   guint32 id,
-					   gchar *action, NotifyNotification *notification)
-{
-	g_assert(NOTIFY_IS_NOTIFICATION(notification));
-
-	if (id == notification->priv->id)
-	{
-		NotifyActionCallback callback;
-
-		callback = (NotifyActionCallback)g_hash_table_lookup(
-			notification->priv->action_map, action);
-
-		if (callback == NULL)
-			g_warning("Recieved unknown action %s", action);
-		else
-			callback(notification, action);
-	}
-}
-
-static gchar **
-_gslist_to_string_array(GSList *list)
-{
-	GSList *l;
-	GArray *a;
-
-	a = g_array_sized_new(TRUE, FALSE, sizeof(gchar *),
-						  g_slist_length(list));
-
-	for (l = list; l != NULL; l = l->next)
-		g_array_append_val(a, l->data);
-
-	return (gchar **)g_array_free(a, FALSE);
-}
-
-static gboolean
-_notify_notification_show_internal(NotifyNotification *notification,
-								   GError **error, gboolean ignore_reply)
-{
-	NotifyNotificationPrivate *priv = notification->priv;
-	GError *tmp_error = NULL;
-	gchar **action_array;
-
-	g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
-
-	if (priv->proxy == NULL)
-	{
-		DBusGConnection *bus;
-
-		bus = dbus_g_bus_get(DBUS_BUS_SESSION, &tmp_error);
-
-		if (tmp_error != NULL)
-		{
-			g_propagate_error(error, tmp_error);
-			return FALSE;
-		}
-
-		priv->proxy = dbus_g_proxy_new_for_name(bus,
-												NOTIFY_DBUS_NAME,
-												NOTIFY_DBUS_CORE_OBJECT,
-												NOTIFY_DBUS_CORE_INTERFACE);
-
-		dbus_g_proxy_add_signal(priv->proxy, "NotificationClosed",
-								G_TYPE_UINT, G_TYPE_INVALID);
-		dbus_g_proxy_connect_signal(priv->proxy, "NotificationClosed",
-									G_CALLBACK(_close_signal_handler),
-									notification, NULL);
-
-		dbus_g_proxy_add_signal(priv->proxy, "ActionInvoked",
-								G_TYPE_UINT, G_TYPE_STRING,
-								G_TYPE_INVALID);
-		dbus_g_proxy_connect_signal(priv->proxy, "ActionInvoked",
-									G_CALLBACK(_action_signal_handler),
-									notification, NULL);
-
-		dbus_g_connection_unref(bus);
-	}
-
-	/* If attached to a widget, modify x and y in hints */
-	_notify_notification_update_applet_hints(notification);
-
-	action_array = _gslist_to_string_array(priv->actions);
-
-	/* TODO: make this nonblocking */
-
-	if (!ignore_reply)
-	{
-		dbus_g_proxy_call(priv->proxy, "Notify", &tmp_error,
-						  G_TYPE_STRING, notify_get_app_name(),
-						  G_TYPE_STRING,
-						  (priv->icon_name != NULL) ? priv->icon_name : "",
-						  G_TYPE_UINT, priv->id, G_TYPE_STRING,
-						  priv->summary, G_TYPE_STRING, priv->message,
-						  G_TYPE_STRV, action_array,
-						  dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
-											  G_TYPE_VALUE), priv->hints,
-						  G_TYPE_INT, priv->timeout, G_TYPE_INVALID,
-						  G_TYPE_UINT, &priv->id, G_TYPE_INVALID);
-	}
-	else
-	{
-		dbus_g_proxy_call_no_reply(priv->proxy, "Notify",
-								   G_TYPE_STRING, notify_get_app_name(),
-								   G_TYPE_STRING,
-								   (priv->icon_name !=
-									NULL) ? priv->icon_name : "",
-								   G_TYPE_UINT, priv->id, G_TYPE_STRING,
-								   priv->summary, G_TYPE_STRING,
-								   priv->message, G_TYPE_STRV,
-								   action_array,
-								   dbus_g_type_get_map("GHashTable",
-													   G_TYPE_STRING,
-													   G_TYPE_VALUE),
-								   priv->hints, G_TYPE_INT, priv->timeout,
-								   G_TYPE_INVALID);
-	}
-
-	/* Don't free the elements because they are owned by priv->actions */
-	g_free(action_array);
-
-	if (tmp_error != NULL)
-	{
-		g_propagate_error(error, tmp_error);
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-gboolean
-notify_notification_show(NotifyNotification *notification, GError **error)
-{
-	return _notify_notification_show_internal(notification, error, FALSE);
-}
-
-gboolean
-notify_notification_show_and_forget(NotifyNotification *notification,
-									GError **error)
-{
-	gboolean result =
-		_notify_notification_show_internal(notification, error, TRUE);
-
-	g_object_unref(G_OBJECT(notification));
-
-	return result;
-}
-
-void
-notify_notification_set_timeout(NotifyNotification *notification,
-								gint timeout)
-{
-	notification->priv->timeout = timeout;
-}
-
-gboolean
-notify_notification_set_category(NotifyNotification *notification,
-								 const char *category)
-{
-	return notify_notification_set_hint_string(notification,
-											   "category", category);
-}
-
-gboolean
-notify_notification_set_urgency(NotifyNotification *notification,
-								NotifyUrgency l)
-{
-	return notify_notification_set_hint_byte(notification,
-											 "urgency", (guchar)l);
-}
-
-static gboolean
-_gvalue_array_append_int(GValueArray *array, gint i)
-{
-	GValue *value = g_new0(GValue, 1);
-
-	if (value == NULL)
-		return FALSE;
-
-	g_value_init(value, G_TYPE_INT);
-	g_value_set_int(value, i);
-	g_value_array_append(array, value);
-
-	return TRUE;
-}
-
-static gboolean
-_gvalue_array_append_bool(GValueArray *array, gboolean b)
-{
-	GValue *value = g_new0(GValue, 1);
-
-	if (value == NULL)
-		return FALSE;
-
-	g_value_init(value, G_TYPE_BOOLEAN);
-	g_value_set_boolean(value, b);
-	g_value_array_append(array, value);
-
-	return TRUE;
-}
-
-static gboolean
-_gvalue_array_append_byte_array(GValueArray *array, guchar *bytes, gsize len)
-{
-	GArray *byte_array;
-	GValue *value;
-
-	byte_array = g_array_sized_new(FALSE, FALSE, sizeof(guchar), len);
-
-	if (byte_array == NULL)
-		return FALSE;
-
-	byte_array = g_array_append_vals(byte_array, bytes, len);
-
-	if ((value = g_new0(GValue, 1)) == NULL)
-	{
-		g_array_free(byte_array, TRUE);
-		return FALSE;
-	}
-
-	g_value_init(value, dbus_g_type_get_collection("GArray", G_TYPE_UCHAR));
-	g_value_set_boxed_take_ownership(value, byte_array);
-	g_value_array_append(array, value);
-
-	return TRUE;
-}
-
-gboolean
-notify_notification_set_icon_data_from_pixbuf(
-	NotifyNotification *notification, GdkPixbuf *icon)
-{
-	gint width;
-	gint height;
-	gint rowstride;
-	gboolean alpha;
-	gint bits_per_sample;
-	gint n_channels;
-	guchar *image;
-	gsize image_len;
-	GValueArray *image_struct;
-	GValue *value;
-	NotifyNotificationPrivate *priv;
-
-	priv = notification->priv;
-
-	width           = gdk_pixbuf_get_width(icon);
-	height          = gdk_pixbuf_get_height(icon);
-	rowstride       = gdk_pixbuf_get_rowstride(icon);
-	n_channels      = gdk_pixbuf_get_n_channels(icon);
-	bits_per_sample = gdk_pixbuf_get_bits_per_sample(icon);
-	alpha           = gdk_pixbuf_get_has_alpha(icon);
-	image_len       = (height - 1) * rowstride + width *
-	                  ((n_channels * bits_per_sample + 7) / 8);
-
-	image = gdk_pixbuf_get_pixels(icon);
-
-	image_struct = g_value_array_new(8);
-
-	if (image_struct == NULL)
-		goto fail;
-
-	_gvalue_array_append_int(image_struct, width);
-	_gvalue_array_append_int(image_struct, height);
-	_gvalue_array_append_int(image_struct, rowstride);
-	_gvalue_array_append_bool(image_struct, alpha);
-	_gvalue_array_append_int(image_struct, bits_per_sample);
-	_gvalue_array_append_int(image_struct, n_channels);
-	_gvalue_array_append_byte_array(image_struct, image, image_len);
-
-	value = g_new0(GValue, 1);
-
-	if (value == NULL)
-		goto fail;
-
-	g_value_init(value, G_TYPE_VALUE_ARRAY);
-	g_value_set_boxed(value, image_struct);
-
-	g_hash_table_insert(priv->hints, g_strdup("icon_data"), value);
-
-	return TRUE;
-
-fail:
-	if (image_struct != NULL)
-		g_value_array_free(image_struct);
-
-	return FALSE;
-}
-
-gboolean
-notify_notification_set_hint_int32(NotifyNotification *notification,
-								   const gchar *key, gint value)
-{
-	NotifyNotificationPrivate *priv;
-	GValue *hint_value;
-
-	priv = notification->priv;
-
-	hint_value = g_new0(GValue, 1);
-	g_value_init(hint_value, G_TYPE_INT);
-	g_value_set_int(hint_value, value);
-
-	g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
-
-	/* TODO: return FALSE on OOM */
-	return TRUE;
-}
-
-gboolean
-notify_notification_set_hint_double(NotifyNotification *notification,
-									const gchar *key, gdouble value)
-{
-	NotifyNotificationPrivate *priv;
-	GValue *hint_value;
-
-	priv = notification->priv;
-
-	hint_value = g_new0(GValue, 1);
-	g_value_init(hint_value, G_TYPE_FLOAT);
-	g_value_set_float(hint_value, value);
-
-	g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
-
-	/* TODO: return FALSE on OOM */
-	return TRUE;
-}
-
-gboolean
-notify_notification_set_hint_byte(NotifyNotification *notification,
-								  const gchar *key, guchar value)
-{
-	NotifyNotificationPrivate *priv;
-	GValue *hint_value;
-
-	priv = notification->priv;
-
-	hint_value = g_new0(GValue, 1);
-	g_value_init(hint_value, G_TYPE_UCHAR);
-	g_value_set_uchar(hint_value, value);
-
-	g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
-
-	/* TODO: return FALSE on OOM */
-	return TRUE;
-}
-
-gboolean
-notify_notification_set_hint_byte_array(NotifyNotification *notification,
-										const gchar *key,
-										const guchar *value, gsize len)
-{
-	NotifyNotificationPrivate *priv;
-	GValue *hint_value;
-	GArray *byte_array;
-
-	priv = notification->priv;
-
-	byte_array = g_array_sized_new(FALSE, FALSE, sizeof(guchar), len);
-	byte_array = g_array_append_vals(byte_array, value, len);
-
-	hint_value = g_new0(GValue, 1);
-	g_value_init(hint_value, dbus_g_type_get_collection("GArray",
-														G_TYPE_UCHAR));
-	g_value_set_boxed_take_ownership(hint_value, byte_array);
-
-	g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
-
-	/* TODO: return FALSE on OOM */
-	return TRUE;
-}
-
-gboolean
-notify_notification_set_hint_string(NotifyNotification *notification,
-									const gchar *key, const gchar *value)
-{
-	NotifyNotificationPrivate *priv;
-	GValue *hint_value;
-
-	priv = notification->priv;
-
-	hint_value = g_new0(GValue, 1);
-	g_value_init(hint_value, G_TYPE_STRING);
-	g_value_set_string(hint_value, value);
-
-	g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
-
-	/* TODO: return FALSE on OOM */
-	return TRUE;
-}
-
-static gboolean
-_remove_all(void)
-{
-	return TRUE;
-}
-
-void
-notify_notification_clear_hints(NotifyNotification *notification)
-{
-	g_hash_table_foreach_remove(notification->priv->hints,
-								(GHRFunc)_remove_all, NULL);
-}
-
-void
-notify_notification_clear_actions(NotifyNotification *notification)
-{
-	g_hash_table_foreach_remove(notification->priv->action_map,
-								(GHRFunc)_remove_all, NULL);
-
-	if (notification->priv->actions != NULL)
-	{
-		g_slist_foreach(notification->priv->actions, (GFunc)g_free, NULL);
-		g_slist_free(notification->priv->actions);
-	}
-
-	notification->priv->actions = NULL;
-}
-
-gboolean
-notify_notification_add_action(NotifyNotification *notification,
-							   const char *action,
-							   const char *label,
-							   NotifyActionCallback callback)
-{
-	NotifyNotificationPrivate *priv;
-
-	priv = notification->priv;
-
-	priv->actions = g_slist_append(priv->actions, g_strdup(action));
-	priv->actions = g_slist_append(priv->actions, g_strdup(label));
-
-	g_hash_table_insert(priv->action_map, g_strdup(action), callback);
-
-	return FALSE;
-}
-
-gboolean
-notify_notification_close(NotifyNotification *notification,
-						  GError **error)
-{
-	NotifyNotificationPrivate *priv;
-	GError *tmp_error;
-
-	g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
-
-	priv = notification->priv;
-
-	tmp_error = NULL;
-
-	if (priv->proxy == NULL)
-	{
-		DBusGConnection *bus = dbus_g_bus_get(DBUS_BUS_SESSION, &tmp_error);
-
-		if (tmp_error != NULL)
-		{
-			g_propagate_error(error, tmp_error);
-			return FALSE;
-		}
-
-		priv->proxy = dbus_g_proxy_new_for_name(bus,
-												NOTIFY_DBUS_NAME,
-												NOTIFY_DBUS_CORE_OBJECT,
-												NOTIFY_DBUS_CORE_INTERFACE);
-		dbus_g_connection_unref(bus);
-	}
-
-	dbus_g_proxy_call(priv->proxy, "CloseNotification", &tmp_error,
-					  G_TYPE_UINT, priv->id, G_TYPE_INVALID,
-					  G_TYPE_INVALID);
-
-	if (tmp_error != NULL)
-	{
-		g_propagate_error(error, tmp_error);
-		return FALSE;
-	}
-
-	return TRUE;
-}

Deleted: trunk/libnotify/libnotify/notifynotification.h
===================================================================
--- trunk/libnotify/libnotify/notifynotification.h	2006-01-20 05:56:49 UTC (rev 2439)
+++ trunk/libnotify/libnotify/notifynotification.h	2006-01-20 06:08:58 UTC (rev 2440)
@@ -1,140 +0,0 @@
-/**
- * @file libnotify/notifynotification.h Notification object
- *
- * @Copyright (C) 2006 Christian Hammond
- * @Copyright (C) 2006 John Palmieri
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA  02111-1307, USA.
- */
-#ifndef _NOTIFY_NOTIFICATION_H_
-#define _NOTIFY_NOTIFICATION_H_
-
-#include <glib.h>
-#include <glib-object.h>
-#include <gtk/gtk.h>
-
-#include "notifycommon.h"
-
-G_BEGIN_DECLS
-
-#define NOTIFY_TYPE_NOTIFICATION (notify_notification_get_type ())
-#define NOTIFY_NOTIFICATION(o) \
-	(G_TYPE_CHECK_INSTANCE_CAST ((o), NOTIFY_TYPE_NOTIFICATION, \
-								 NotifyNotification))
-#define NOTIFY_NOTIFICATION_CLASS(k) \
-	(G_TYPE_CHECK_CLASS_CAST((k), NOTIFY_TYPE_NOTIFICATION, \
-							 NotifyNotificationClass))
-#define NOTIFY_IS_NOTIFICATION(o) \
-	(G_TYPE_CHECK_INSTANCE_TYPE ((o), NOTIFY_TYPE_NOTIFICATION))
-#define NOTIFY_IS_NOTIFICATION_CLASS(k) \
-	(G_TYPE_CHECK_CLASS_TYPE ((k), NOTIFY_TYPE_NOTIFICATION))
-#define NOTIFY_NOTIFICATION_GET_CLASS(o) \
-	(G_TYPE_INSTANCE_GET_CLASS ((o), NOTIFY_TYPE_NOTIFICATION, \
-								NotifyNotificationClass))
-
-typedef struct _NotifyNotification        NotifyNotification;
-typedef struct _NotifyNotificationClass   NotifyNotificationClass;
-typedef struct _NotifyNotificationPrivate NotifyNotificationPrivate;
-
-struct _NotifyNotification
-{
-	GObject parent;
-	NotifyNotificationPrivate *priv;
-};
-
-struct _NotifyNotificationClass
-{
-	GObjectClass parent_class;
-
-	/* Signals */
-	void (*closed)(NotifyNotification *notification);
-};
-
-typedef void (*NotifyActionCallback)(NotifyNotification *, gchar *);
-
-GType notify_notification_get_type();
-
-NotifyNotification *notify_notification_new(const gchar *summary,
-											const gchar *message,
-											const gchar *icon,
-											GtkWidget *attach);
-
-gboolean notify_notification_update(NotifyNotification *notification,
-									const gchar *summary,
-									const gchar *message,
-									const gchar *icon);
-
-void notify_notification_attach_to_widget(NotifyNotification* notification,
-										  GtkWidget *attach);
-
-gboolean notify_notification_set_user_data(NotifyNotification *notification,
-										   void *user_data,
-										   GFreeFunc free_func);
-
-gpointer notify_notification_get_user_data(NotifyNotification *notification);
-
-gboolean notify_notification_show(NotifyNotification *notification,
-								  GError **error);
-
-gboolean notify_notification_show_and_forget(NotifyNotification *notification,
-											 GError **error);
-
-void notify_notification_set_timeout(NotifyNotification *notification,
-									 gint timeout);
-
-gboolean notify_notification_set_category(NotifyNotification *notification,
-										  const char *category);
-
-gboolean notify_notification_set_urgency(NotifyNotification *notification,
-										 NotifyUrgency l);
-
-gboolean notify_notification_set_icon_data_from_pixbuf(
-	NotifyNotification *notification, GdkPixbuf *icon);
-
-gboolean notify_notification_set_hint_int32(NotifyNotification *notification,
-											const gchar *key, gint value);
-
-gboolean notify_notification_set_hint_double(NotifyNotification *notification,
-											 const gchar *key,
-											 gdouble value);
-
-gboolean notify_notification_set_hint_string(NotifyNotification *notification,
-											 const gchar *key,
-											 const gchar *value);
-
-gboolean notify_notification_set_hint_byte(NotifyNotification *notification,
-										   const gchar *key,
-										   guchar value);
-
-gboolean notify_notification_set_hint_byte_array(
-	NotifyNotification *notification, const gchar *key,
-	const guchar *value, gsize len);
-
-void notify_notification_clear_hints(NotifyNotification *notification);
-
-gboolean notify_notification_add_action(NotifyNotification *notification,
-										const char *action,
-										const char *label,
-										NotifyActionCallback callback);
-
-void notify_notification_clear_actions(NotifyNotification *notification);
-gboolean notify_notification_close(NotifyNotification *notification,
-								   GError **error);
-
-NotifyNotification *notify_notification_ref(NotifyNotification *notification);
-void notify_notification_unref(NotifyNotification *notification);
-
-#endif /* NOTIFY_NOTIFICATION_H */



More information about the galago-commits mailing list