← Back to team overview

ayatana-commits team mailing list archive

[Branch ~dbusmenu-team/dbusmenu/trunk] Rev 153: Report event status up the chain

 

Merge authors:
  Ted Gould (ted)
Related merge proposals:
  https://code.launchpad.net/~ted/dbusmenu/report-errors-to-caller/+merge/33830
  proposed by: Ted Gould (ted)
  review: Approve - Cody Russell (bratsche)
------------------------------------------------------------
revno: 153 [merge]
committer: Ted Gould <ted@xxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-08-26 15:11:45 -0500
message:
  Report event status up the chain
modified:
  libdbusmenu-glib/client-marshal.list
  libdbusmenu-glib/client.c
  libdbusmenu-glib/client.h
  tests/test-gtk-label-client.c


--
lp:dbusmenu
https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk

Your team ayatana-commits is subscribed to branch lp:dbusmenu.
To unsubscribe from this branch go to https://code.launchpad.net/~dbusmenu-team/dbusmenu/trunk/+edit-subscription
=== modified file 'libdbusmenu-glib/client-marshal.list'
--- libdbusmenu-glib/client-marshal.list	2010-08-18 01:42:22 +0000
+++ libdbusmenu-glib/client-marshal.list	2010-08-26 19:45:26 +0000
@@ -1,1 +1,2 @@
 VOID: OBJECT, UINT
+VOID: OBJECT, STRING, POINTER, UINT, POINTER

=== modified file 'libdbusmenu-glib/client.c'
--- libdbusmenu-glib/client.c	2010-08-25 18:18:47 +0000
+++ libdbusmenu-glib/client.c	2010-08-26 19:45:26 +0000
@@ -56,6 +56,7 @@
 	ROOT_CHANGED,
 	NEW_MENUITEM,
 	ITEM_ACTIVATE,
+	EVENT_RESULT,
 	LAST_SIGNAL
 };
 
@@ -102,6 +103,16 @@
 	gboolean replied;
 };
 
+typedef struct _event_data_t event_data_t;
+struct _event_data_t {
+	DbusmenuClient * client;
+	DbusmenuMenuitem * menuitem;
+	gchar * event;
+	GValue data;
+	guint timestamp;
+};
+
+
 #define DBUSMENU_CLIENT_GET_PRIVATE(o) \
 (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_TYPE_CLIENT, DbusmenuClientPrivate))
 
@@ -206,6 +217,25 @@
 	                                        NULL, NULL,
 	                                        _dbusmenu_client_marshal_VOID__OBJECT_UINT,
 	                                        G_TYPE_NONE, 2, G_TYPE_OBJECT, G_TYPE_UINT);
+	/**
+		DbusmenuClient::event-error:
+		@arg0: The #DbusmenuClient object
+		@arg1: The #DbusmenuMenuitem sent an event
+		@arg2: The ID of the event sent
+		@arg3: The data sent along with the event
+		@arg4: A timestamp that the event happened at
+		@arg5: Possibly the error in sending the event (or NULL)
+
+		Signal sent to show that there was an error in sending the event
+		to the server.
+	*/
+	signals[EVENT_RESULT]    = g_signal_new(DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT,
+	                                        G_TYPE_FROM_CLASS (klass),
+	                                        G_SIGNAL_RUN_LAST,
+	                                        G_STRUCT_OFFSET (DbusmenuClientClass, event_result),
+	                                        NULL, NULL,
+	                                        _dbusmenu_client_marshal_VOID__OBJECT_STRING_POINTER_UINT_POINTER,
+	                                        G_TYPE_NONE, 5, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_UINT, G_TYPE_POINTER);
 
 	g_object_class_install_property (object_class, PROP_DBUSOBJECT,
 	                                 g_param_spec_string(DBUSMENU_CLIENT_PROP_DBUS_OBJECT, "DBus Object we represent",
@@ -1025,10 +1055,19 @@
 static void
 menuitem_call_cb (DBusGProxy * proxy, GError * error, gpointer userdata)
 {
+	event_data_t * edata = (event_data_t *)userdata;
+
 	if (error != NULL) {
 		g_warning("Unable to call menu item %d: %s", GPOINTER_TO_INT(userdata), error->message);
 	}
 
+	g_signal_emit(edata->client, signals[EVENT_RESULT], 0, edata->menuitem, edata->event, edata->data, edata->timestamp, error, TRUE);
+
+	g_value_unset(&edata->data);
+	g_free(edata->event);
+	g_object_unref(edata->menuitem);
+	g_free(edata);
+
 	return;
 }
 
@@ -1041,6 +1080,13 @@
 	g_return_if_fail(id >= 0);
 	g_return_if_fail(name != NULL);
 
+	DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
+	DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id);
+	if (mi == NULL) {
+		g_warning("Asked to activate a menuitem %d that we don't know about", id);
+		return;
+	}
+
 	if (value == NULL) {
 		GValue internalval = {0};
 		g_value_init(&internalval, G_TYPE_INT);
@@ -1048,8 +1094,16 @@
 		value = &internalval;
 	}
 
-	DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
-	org_ayatana_dbusmenu_event_async (priv->menuproxy, id, name, value, timestamp, menuitem_call_cb, GINT_TO_POINTER(id));
+	event_data_t * edata = g_new0(event_data_t, 1);
+	edata->client = client;
+	edata->menuitem = mi;
+	g_object_ref(edata->menuitem);
+	edata->event = g_strdup(name);
+	g_value_init(&edata->data, G_VALUE_TYPE(value));
+	g_value_copy(value, &edata->data);
+	edata->timestamp = timestamp;
+
+	org_ayatana_dbusmenu_event_async (priv->menuproxy, id, name, value, timestamp, menuitem_call_cb, edata);
 	return;
 }
 

=== modified file 'libdbusmenu-glib/client.h'
--- libdbusmenu-glib/client.h	2010-08-18 01:42:22 +0000
+++ libdbusmenu-glib/client.h	2010-08-26 19:45:26 +0000
@@ -47,6 +47,7 @@
 #define DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED    "root-changed"
 #define DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM    "new-menuitem"
 #define DBUSMENU_CLIENT_SIGNAL_ITEM_ACTIVATE   "item-activate"
+#define DBUSMENU_CLIENT_SIGNAL_EVENT_RESULT    "event-result"
 
 #define DBUSMENU_CLIENT_PROP_DBUS_NAME     "dbus-name"
 #define DBUSMENU_CLIENT_PROP_DBUS_OBJECT   "dbus-object"
@@ -60,10 +61,10 @@
 	@parent_class: #GObjectClass
 	@layout_updated: Slot for #DbusmenuClient::layout-updated.
 	@new_menuitem: Slot for #DbusmenuClient::new-menuitem.
-	@item_activate: Slote for #DbusmenuClient::item-activate.
+	@item_activate: Slot for #DbusmenuClient::item-activate.
+	@event_result: Slot for #DbusmenuClient::event-error.
 	@reserved1: Reserved for future use.
 	@reserved2: Reserved for future use.
-	@reserved3: Reserved for future use.
 
 	A simple class that takes all of the information from a
 	#DbusmenuServer over DBus and makes the same set of 
@@ -77,11 +78,12 @@
 	void (*root_changed) (DbusmenuMenuitem * newroot);
 	void (*new_menuitem) (DbusmenuMenuitem * newitem);
 	void (*item_activate) (DbusmenuMenuitem * item, guint timestamp);
+	void (*event_result) (DbusmenuMenuitem * item, gchar * event, GValue * data, guint timestamp, GError * error);
 
 	/* Reserved for future use */
 	void (*reserved1) (void);
 	void (*reserved2) (void);
-	void (*reserved3) (void);
+	/* void (*reserved3) (void); */
 	/* void (*reserved4) (void); */
 };
 

=== modified file 'tests/test-gtk-label-client.c'
--- tests/test-gtk-label-client.c	2009-12-17 22:41:01 +0000
+++ tests/test-gtk-label-client.c	2010-08-26 19:17:39 +0000
@@ -105,7 +105,6 @@
 static gboolean
 timer_func (gpointer data)
 {
-	g_debug("Death timer.  Oops.  Got to: %d", layouton);
 	passed = TRUE;
 	g_main_loop_quit(mainloop);
 	return FALSE;