Browse Source

Reply the the caller for plugin events.

Return to the client if a plugin event was handled.
upstream/xfce4-panel-4.10.1
Nick Schermer 10 years ago
parent
commit
628154e59e
  1. 10
      panel/main.c
  2. 2
      panel/panel-dbus-client.c
  3. 1
      panel/panel-dbus-client.h
  4. 6
      panel/panel-dbus-service-infos.xml
  5. 14
      panel/panel-dbus-service.c

10
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;
}

2
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);

1
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,

6
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>
<!--

14
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;
}

Loading…
Cancel
Save