diff --git a/libnotify/Makefile.am b/libnotify/Makefile.am index 0748d1d..70154c3 100644 --- a/libnotify/Makefile.am +++ b/libnotify/Makefile.am @@ -5,12 +5,14 @@ lib_LTLIBRARIES = libnotify.la notifyinc_HEADERS = \ notify.h \ notifynotification.h \ - notifycommon.h + notifycommon.h \ + notifymarshal.h libnotify_la_SOURCES = \ dbus-compat.h \ notify.c \ - notifynotification.c + notifynotification.c \ + notifymarshal.c libnotify_la_LIBADD = \ $(PACKAGE_LIBS) diff --git a/libnotify/Makefile.in b/libnotify/Makefile.in index 3b4c7eb..cfd2584 100644 --- a/libnotify/Makefile.in +++ b/libnotify/Makefile.in @@ -58,7 +58,8 @@ libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = libnotify_la_DEPENDENCIES = $(am__DEPENDENCIES_1) -am_libnotify_la_OBJECTS = notify.lo notifynotification.lo +am_libnotify_la_OBJECTS = notify.lo notifynotification.lo \ + notifymarshal.lo libnotify_la_OBJECTS = $(am_libnotify_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -191,12 +192,14 @@ lib_LTLIBRARIES = libnotify.la notifyinc_HEADERS = \ notify.h \ notifynotification.h \ - notifycommon.h + notifycommon.h \ + notifymarshal.h libnotify_la_SOURCES = \ dbus-compat.h \ notify.c \ - notifynotification.c + notifynotification.c \ + notifymarshal.c libnotify_la_LIBADD = \ $(PACKAGE_LIBS) @@ -277,6 +280,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/notify.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/notifymarshal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/notifynotification.Plo@am__quote@ .c.o: diff --git a/libnotify/notifymarshal.c b/libnotify/notifymarshal.c new file mode 100644 index 0000000..40fa0b6 --- /dev/null +++ b/libnotify/notifymarshal.c @@ -0,0 +1,56 @@ +/* + * This program 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 program 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 main.c; if not, write to: + * The Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include "notifymarshal.h" + +void +_notify_marshal_VOID__UINT_STRING (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data) +{ + typedef void (*GMarshalFunc_VOID__UINT_STRING) (gpointer data1, + gpointer arg_1, + gpointer arg_2, + gpointer data2); + register GMarshalFunc_VOID__UINT_STRING callback; + register GCClosure *cc = (GCClosure*) closure; + register gpointer data1, data2; + + g_return_if_fail (n_param_values == 3); + + if (G_CCLOSURE_SWAP_DATA (closure)) + { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } + else + { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = (GMarshalFunc_VOID__UINT_STRING) (marshal_data ? marshal_data : cc->callback); + + callback (data1, + g_value_get_uint (param_values + 1), + g_value_get_string (param_values + 2), + data2); +} + diff --git a/libnotify/notifymarshal.h b/libnotify/notifymarshal.h new file mode 100644 index 0000000..8f441f0 --- /dev/null +++ b/libnotify/notifymarshal.h @@ -0,0 +1,36 @@ +/* + * This program 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 program 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 main.c; if not, write to: + * The Free Software Foundation, Inc., + * 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __notify_marshal_MARSHAL_H__ +#define __notify_marshal_MARSHAL_H__ + +#include + +G_BEGIN_DECLS + +void +_notify_marshal_VOID__UINT_STRING (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + + +G_END_DECLS +#endif diff --git a/libnotify/notifynotification.c b/libnotify/notifynotification.c index c31d07d..71fe584 100644 --- a/libnotify/notifynotification.c +++ b/libnotify/notifynotification.c @@ -21,6 +21,7 @@ #include "notify.h" #include "notifynotification.h" +#include "notifymarshal.h" static void notify_notification_class_init (NotifyNotificationClass * klass); static void notify_notification_init (NotifyNotification * sp); @@ -124,6 +125,13 @@ notify_notification_class_init (NotifyNotificationClass * klass) 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 @@ -167,6 +175,7 @@ notify_notification_init (NotifyNotification * obj) obj->priv->widget_old_y = 0; obj->priv->proxy = NULL; + } static void @@ -417,9 +426,6 @@ _action_signal_handler (DBusGProxy *proxy, { g_assert (NOTIFY_IS_NOTIFICATION (notification)); - printf ("Got the ActionInvoked signal for action %s (id = %i, notification->id = %i)\n", - action, id, notification->priv->id); - if (id == notification->priv->id) { NotifyActionCallback callback; @@ -435,6 +441,31 @@ _action_signal_handler (DBusGProxy *proxy, } } +static gchar ** +_gslist_to_string_array (GSList *list) +{ + GSList *element; + GArray *a; + gsize len; + gchar **result; + + len = g_slist_length (list); + + a = g_array_sized_new (TRUE, FALSE, sizeof (gchar *), len); + + element = list; + while (element != NULL) + { + g_array_append_val (a, element->data); + + element = g_slist_next (element); + } + + result = (gchar **)g_array_free (a, FALSE); + + return result; +} + static gboolean _notify_notification_show_internal (NotifyNotification *notification, GError **error, @@ -442,6 +473,8 @@ _notify_notification_show_internal (NotifyNotification *notification, { NotifyNotificationPrivate *priv; GError *tmp_error; + gchar **action_array; + int i; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -466,13 +499,13 @@ _notify_notification_show_internal (NotifyNotification *notification, NOTIFY_DBUS_CORE_INTERFACE); dbus_g_proxy_add_signal (priv->proxy, "NotificationClosed", - G_TYPE_UINT, NULL); + G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->proxy, "NotificationClosed", (GCallback) _close_signal_handler, notification, NULL); dbus_g_proxy_add_signal (priv->proxy, "ActionInvoked", - G_TYPE_UINT, G_TYPE_STRING, NULL); + G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->proxy, "ActionInvoked", (GCallback) _action_signal_handler, notification, NULL); @@ -484,6 +517,8 @@ _notify_notification_show_internal (NotifyNotification *notification, /*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, @@ -492,8 +527,8 @@ _notify_notification_show_internal (NotifyNotification *notification, (priv->icon_name != NULL) ? priv->icon_name : "", G_TYPE_UINT, priv->id, G_TYPE_STRING, priv->summary, G_TYPE_STRING, priv->message, - dbus_g_type_get_collection ("GSList", G_TYPE_STRING), - priv->actions, dbus_g_type_get_map ("GHashTable", + 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, @@ -505,12 +540,16 @@ _notify_notification_show_internal (NotifyNotification *notification, (priv->icon_name != NULL) ? priv->icon_name : "", G_TYPE_UINT, priv->id, G_TYPE_STRING, priv->summary, G_TYPE_STRING, priv->message, - dbus_g_type_get_collection ("GSList", G_TYPE_STRING), - priv->actions, dbus_g_type_get_map ("GHashTable", + 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) {