[Galago-commits] r2367 - trunk/libnotify-ng/libnotify
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Fri Dec 9 11:35:18 PST 2005
Author: johnp
Date: 2005-12-09 11:35:13 -0800 (Fri, 09 Dec 2005)
New Revision: 2367
Added:
trunk/libnotify-ng/libnotify/notifymarshal.c
trunk/libnotify-ng/libnotify/notifymarshal.h
Modified:
trunk/libnotify-ng/libnotify/Makefile.am
trunk/libnotify-ng/libnotify/Makefile.in
trunk/libnotify-ng/libnotify/notifynotification.c
Log:
* libnotify/notifymarshal.[c|h]: new files where GLib callback
marshalers are added
* libnotify/notifynotification.ci (notify_notifiaction_init): Add a
marshaller for signals with uint, string parameters
(_gslist_to_string_array): new internal method that coverts
a GSList to a NULL terminated array of strings
(_notify_notification_show_internal): send the actions list as an
array of strings, not a GSList which does not work with the bindings
* libnotify/Makefile.am: notifymarshal.[c|h] added
* tests/test-multi-actions.c: working example of using actions
Modified: trunk/libnotify-ng/libnotify/Makefile.am
===================================================================
--- trunk/libnotify-ng/libnotify/Makefile.am 2005-12-04 12:37:14 UTC (rev 2366)
+++ trunk/libnotify-ng/libnotify/Makefile.am 2005-12-09 19:35:13 UTC (rev 2367)
@@ -5,12 +5,14 @@
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)
Modified: trunk/libnotify-ng/libnotify/Makefile.in
===================================================================
--- trunk/libnotify-ng/libnotify/Makefile.in 2005-12-04 12:37:14 UTC (rev 2366)
+++ trunk/libnotify-ng/libnotify/Makefile.in 2005-12-09 19:35:13 UTC (rev 2367)
@@ -58,7 +58,8 @@
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 @@
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 @@
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/notify.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/notifymarshal.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/notifynotification.Plo at am__quote@
.c.o:
Added: trunk/libnotify-ng/libnotify/notifymarshal.c
===================================================================
--- trunk/libnotify-ng/libnotify/notifymarshal.c 2005-12-04 12:37:14 UTC (rev 2366)
+++ trunk/libnotify-ng/libnotify/notifymarshal.c 2005-12-09 19:35:13 UTC (rev 2367)
@@ -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);
+}
+
Added: trunk/libnotify-ng/libnotify/notifymarshal.h
===================================================================
--- trunk/libnotify-ng/libnotify/notifymarshal.h 2005-12-04 12:37:14 UTC (rev 2366)
+++ trunk/libnotify-ng/libnotify/notifymarshal.h 2005-12-09 19:35:13 UTC (rev 2367)
@@ -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 <glib-object.h>
+
+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
Modified: trunk/libnotify-ng/libnotify/notifynotification.c
===================================================================
--- trunk/libnotify-ng/libnotify/notifynotification.c 2005-12-04 12:37:14 UTC (rev 2366)
+++ trunk/libnotify-ng/libnotify/notifynotification.c 2005-12-09 19:35:13 UTC (rev 2367)
@@ -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 @@
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 @@
obj->priv->widget_old_y = 0;
obj->priv->proxy = NULL;
+
}
static void
@@ -417,9 +426,6 @@
{
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 @@
}
}
+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 @@
{
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_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 @@
/*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 @@
(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,13 +540,17 @@
(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)
{
g_propagate_error (error, tmp_error);
More information about the galago-commits
mailing list