[Xfce4-commits] <xfce4-panel:master> Reply the the caller for plugin events.
Nick Schermer
noreply at xfce.org
Sat Mar 10 20:02:01 CET 2012
Updating branch refs/heads/master
to 628154e59e09b3dd16129304a1d450ac4824268b (commit)
from 4447f270fdd14f3782ad524e57543670ded52edf (commit)
commit 628154e59e09b3dd16129304a1d450ac4824268b
Author: Nick Schermer <nick at xfce.org>
Date: Sat Mar 10 19:22:34 2012 +0100
Reply the the caller for plugin events.
Return to the client if a plugin event was handled.
panel/main.c | 10 +++++++++-
panel/panel-dbus-client.c | 2 ++
panel/panel-dbus-client.h | 1 +
panel/panel-dbus-service-infos.xml | 6 ++++--
panel/panel-dbus-service.c | 14 ++++++++++++++
5 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/panel/main.c b/panel/main.c
index 3747d8a..4ed389a 100644
--- a/panel/main.c
+++ b/panel/main.c
@@ -205,6 +205,7 @@ main (gint argc, gchar **argv)
GError *error = NULL;
PanelDBusService *dbus_service;
gboolean succeed = FALSE;
+ gboolean remote_succeed;
guint i;
const gint signums[] = { SIGINT, SIGQUIT, SIGTERM, SIGABRT, SIGUSR1 };
const gchar *error_msg;
@@ -296,7 +297,14 @@ main (gint argc, gchar **argv)
else if (opt_plugin_event != NULL)
{
/* send the plugin event to the running instance */
- succeed = panel_dbus_client_plugin_event (opt_plugin_event, &error);
+ remote_succeed = FALSE;
+ succeed = panel_dbus_client_plugin_event (opt_plugin_event, &remote_succeed, &error);
+
+ /* the panel returns EXIT_FAILURE if the dbus event succeeds, but
+ * no suitable plugin was found on the service side */
+ if (succeed && !remote_succeed)
+ succeed = FALSE;
+
goto dbus_return;
}
diff --git a/panel/panel-dbus-client.c b/panel/panel-dbus-client.c
index be259ec..07214a2 100644
--- a/panel/panel-dbus-client.c
+++ b/panel/panel-dbus-client.c
@@ -184,6 +184,7 @@ panel_dbus_client_gtype_from_string (const gchar *str)
gboolean
panel_dbus_client_plugin_event (const gchar *plugin_event,
+ gboolean *return_succeed,
GError **error)
{
DBusGProxy *dbus_proxy;
@@ -258,6 +259,7 @@ panel_dbus_client_plugin_event (const gchar *plugin_event,
tokens[PLUGIN_NAME],
tokens[NAME],
&value,
+ return_succeed,
error);
g_value_unset (&value);
diff --git a/panel/panel-dbus-client.h b/panel/panel-dbus-client.h
index c952706..e8b8fce 100644
--- a/panel/panel-dbus-client.h
+++ b/panel/panel-dbus-client.h
@@ -36,6 +36,7 @@ gboolean panel_dbus_client_add_new_item (const gchar *plugin_nam
GError **error);
gboolean panel_dbus_client_plugin_event (const gchar *plugin_event,
+ gboolean *return_succeed,
GError **error);
gboolean panel_dbus_client_terminate (gboolean restart,
diff --git a/panel/panel-dbus-service-infos.xml b/panel/panel-dbus-service-infos.xml
index b171d8b..d1a6316 100644
--- a/panel/panel-dbus-service-infos.xml
+++ b/panel/panel-dbus-service-infos.xml
@@ -56,12 +56,13 @@
</method>
<!--
- PluginEvent (plugin-name : STRING, name : STRING, value : VARIANT)
+ PluginEvent (plugin-name : STRING, name : STRING, value : VARIANT, succeed (return) : BOOL)
plugin-name : Name of the panel plugins to send this event to.
name : Event signal name.
value : GValue holding the event data.
-
+ succeed : Boolean if a suitable plugin was found.
+
Send a plugin to a group of plugins using the remote-event
XfcePanelPlugin signal.
-->
@@ -69,6 +70,7 @@
<arg name="plugin_name" direction="in" type="s" />
<arg name="name" direction="in" type="s" />
<arg name="value" direction="in" type="v" />
+ <arg name="succeed" direction="out" type="b" />
</method>
<!--
diff --git a/panel/panel-dbus-service.c b/panel/panel-dbus-service.c
index c0c6e9a..21537c5 100644
--- a/panel/panel-dbus-service.c
+++ b/panel/panel-dbus-service.c
@@ -61,6 +61,7 @@ static gboolean panel_dbus_service_plugin_event (PanelDBusService
const gchar *plugin_name,
const gchar *name,
const GValue *value,
+ gboolean *OUT_succeed,
GError **error);
static gboolean panel_dbus_service_terminate (PanelDBusService *service,
gboolean restart,
@@ -350,6 +351,7 @@ panel_dbus_service_plugin_event (PanelDBusService *service,
const gchar *plugin_name,
const gchar *name,
const GValue *value,
+ gboolean *OUT_succeed,
GError **error)
{
GSList *plugins, *li, *lnext;
@@ -357,6 +359,7 @@ panel_dbus_service_plugin_event (PanelDBusService *service,
PluginEvent *event;
guint handle;
gboolean result;
+ gboolean plugin_replied = FALSE;
panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -394,11 +397,18 @@ panel_dbus_service_plugin_event (PanelDBusService *service,
g_signal_connect (G_OBJECT (li->data), "remote-event-result",
G_CALLBACK (panel_dbus_service_plugin_event_result), service);
+ /* not entirely sure the event is handled, but at least suitable
+ * plugins were found */
+ plugin_replied = TRUE;
+
/* we're going to wait until the plugin replied */
break;
}
else if (result)
{
+ /* we've handled the event */
+ plugin_replied = TRUE;
+
/* plugin returned %TRUE, so abort the event notification */
break;
}
@@ -407,6 +417,10 @@ panel_dbus_service_plugin_event (PanelDBusService *service,
g_slist_free (plugins);
g_object_unref (G_OBJECT (factory));
+ /* return status for the panel */
+ if (OUT_succeed)
+ *OUT_succeed = plugin_replied;
+
return TRUE;
}
More information about the Xfce4-commits
mailing list