Browse Source

Allow sending a plugin-event without value.

upstream/xfce4-panel-4.10.1
Nick Schermer 13 years ago
parent
commit
3d03a31ada
  1. 2
      libxfce4panel/xfce-panel-plugin-provider.c
  2. 2
      libxfce4panel/xfce-panel-plugin.c
  3. 48
      panel/panel-dbus-client.c
  4. 10
      panel/panel-dbus-service.c
  5. 13
      panel/panel-plugin-external.c
  6. 2
      plugins/launcher/launcher.c
  7. 2
      plugins/windowmenu/windowmenu.c
  8. 21
      wrapper/main.c

2
libxfce4panel/xfce-panel-plugin-provider.c

@ -211,6 +211,8 @@ xfce_panel_plugin_provider_remote_event (XfcePanelPluginProvider *provider,
const GValue *value)
{
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider), TRUE);
panel_return_val_if_fail (name != NULL, TRUE);
panel_return_val_if_fail (value == NULL || G_IS_VALUE (value), TRUE);
return (*XFCE_PANEL_PLUGIN_PROVIDER_GET_IFACE (provider)->remote_event) (provider, name, value);
}

2
libxfce4panel/xfce-panel-plugin.c

@ -1250,7 +1250,7 @@ xfce_panel_plugin_remote_event (XfcePanelPluginProvider *provider,
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (provider), TRUE);
panel_return_val_if_fail (name != NULL, TRUE);
panel_return_val_if_fail (G_IS_VALUE (value), TRUE);
panel_return_val_if_fail (value == NULL || G_IS_VALUE (value), TRUE);
g_signal_emit (G_OBJECT (provider), plugin_signals[REMOTE_EVENT], 0,
name, value, &stop_emission);

48
panel/panel-dbus-client.c

@ -218,6 +218,7 @@ panel_dbus_client_plugin_event (const gchar *plugin_event,
gchar **tokens;
GType type;
GValue value = { 0, };
guint n_tokens;
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@ -226,10 +227,25 @@ panel_dbus_client_plugin_event (const gchar *plugin_event,
return FALSE;
tokens = g_strsplit (plugin_event, ":", -1);
if (G_LIKELY (g_strv_length (tokens) == N_TOKENS
&& IS_STRING (tokens[VALUE])
&& IS_STRING (tokens[NAME])
&& *tokens[NAME] != SIGNAL_PREFIX))
n_tokens = g_strv_length (tokens);
if (!(n_tokens == 2 || n_tokens == N_TOKENS)
|| !IS_STRING (tokens[PLUGIN_NAME])
|| !IS_STRING (tokens[NAME])
|| *tokens[NAME] == SIGNAL_PREFIX)
{
g_set_error_literal (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
_("Invalid plugin event syntax specified. "
"Use PLUGIN-NAME:NAME[:TYPE:VALUE]."));
goto out;
}
else if (n_tokens == 2)
{
/* set noop value, recognized by the dbus service as %NULL value */
g_value_init (&value, G_TYPE_UCHAR);
g_value_set_uchar (&value, '\0');
}
else if (n_tokens == N_TOKENS)
{
type = panel_dbus_client_gtype_from_string (tokens[TYPE]);
if (G_LIKELY (type != G_TYPE_NONE))
@ -248,14 +264,6 @@ panel_dbus_client_plugin_event (const gchar *plugin_event,
g_value_set_uint (&value, strtol (tokens[VALUE], NULL, 0));
else
panel_assert_not_reached ();
result = _panel_dbus_client_plugin_event (dbus_proxy,
tokens[PLUGIN_NAME],
tokens[NAME],
&value,
error);
g_value_unset (&value);
}
else
{
@ -263,15 +271,25 @@ panel_dbus_client_plugin_event (const gchar *plugin_event,
_("Invalid hint type \"%s\". Valid types "
"are bool, double, int, string and uint."),
tokens[TYPE]);
goto out;
}
}
else
{
g_set_error_literal (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
_("Invalid plugin event syntax specified. "
"Use PLUGIN-NAME:NAME:TYPE:VALUE."));
panel_assert_not_reached ();
goto out;
}
/* send value over dbus */
panel_return_val_if_fail (G_IS_VALUE (&value), FALSE);
result = _panel_dbus_client_plugin_event (dbus_proxy,
tokens[PLUGIN_NAME],
tokens[NAME],
&value,
error);
g_value_unset (&value);
out:
g_strfreev (tokens);
g_object_unref (G_OBJECT (dbus_proxy));

10
panel/panel-dbus-service.c

@ -255,6 +255,7 @@ panel_dbus_service_plugin_event (PanelDBusService *service,
{
GSList *plugins, *li;
PanelModuleFactory *factory;
const GValue *real_value = value;
panel_return_val_if_fail (PANEL_IS_DBUS_SERVICE (service), FALSE);
panel_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@ -262,6 +263,13 @@ panel_dbus_service_plugin_event (PanelDBusService *service,
panel_return_val_if_fail (name != NULL, FALSE);
panel_return_val_if_fail (G_IS_VALUE (value), FALSE);
/* if no type and value is send with the signal we send a char type
* with nul value */
g_message ("%s", G_VALUE_TYPE_NAME (value));
if (G_VALUE_HOLDS_UCHAR (value)
&& g_value_get_uchar (value) == '\0')
real_value = NULL;
factory = panel_module_factory_get ();
plugins = panel_module_factory_get_plugins (factory, plugin_name);
@ -269,7 +277,7 @@ panel_dbus_service_plugin_event (PanelDBusService *service,
for (li = plugins; li != NULL; li = li->next)
{
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (li->data), FALSE);
if (xfce_panel_plugin_provider_remote_event (li->data, name, value))
if (xfce_panel_plugin_provider_remote_event (li->data, name, real_value))
break;
}

13
panel/panel-plugin-external.c

@ -818,13 +818,24 @@ panel_plugin_external_remote_event (XfcePanelPluginProvider *provider,
const gchar *name,
const GValue *value)
{
GValue noop_value = { 0, };
const GValue *real_value = value;
panel_return_val_if_fail (PANEL_IS_PLUGIN_EXTERNAL (provider), TRUE);
panel_return_val_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider), TRUE);
panel_return_val_if_fail (value == NULL || G_IS_VALUE (value), FALSE);
/* TODO handle the return value */
if (value == NULL)
{
g_value_init (&noop_value, G_TYPE_UCHAR);
g_value_set_uchar (&noop_value, '\0');
real_value = &noop_value;
}
panel_plugin_external_queue_add (PANEL_PLUGIN_EXTERNAL (provider),
FALSE, name, value);
FALSE, name, real_value);
return TRUE;
}

2
plugins/launcher/launcher.c

@ -1029,6 +1029,8 @@ launcher_plugin_remote_event (XfcePanelPlugin *panel_plugin,
{
LauncherPlugin *plugin = XFCE_LAUNCHER_PLUGIN (panel_plugin);
panel_return_val_if_fail (value == NULL || G_IS_VALUE (value), FALSE);
if (exo_str_is_equal (name, "popup")
&& LIST_HAS_TWO_OR_MORE_ENTRIES (plugin->items)
&& (plugin->menu == NULL || !GTK_WIDGET_VISIBLE (plugin->menu)))

2
plugins/windowmenu/windowmenu.c

@ -526,6 +526,8 @@ window_menu_plugin_remote_event (XfcePanelPlugin *panel_plugin,
WindowMenuPlugin *plugin = XFCE_WINDOW_MENU_PLUGIN (panel_plugin);
GdkEventButton event;
panel_return_val_if_fail (value == NULL || G_IS_VALUE (value), FALSE);
if (strcmp (name, "popup") == 0
&& GTK_WIDGET_VISIBLE (panel_plugin)
&& !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (plugin->button)))

21
wrapper/main.c

@ -60,12 +60,13 @@ wrapper_gproxy_set (DBusGProxy *dbus_gproxy,
const GPtrArray *array,
XfcePanelPluginProvider *provider)
{
WrapperPlug *plug;
guint i;
GValue *value;
gchar *property;
guint reply_id;
GValue msg = { 0, };
WrapperPlug *plug;
guint i;
GValue *value;
gchar *property;
guint reply_id;
GValue msg = { 0, };
const GValue *real_value;
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN_PROVIDER (provider));
@ -112,7 +113,13 @@ wrapper_gproxy_set (DBusGProxy *dbus_gproxy,
}
else
{
xfce_panel_plugin_provider_remote_event (provider, property, value);
if (G_VALUE_HOLDS_UCHAR (value)
&& g_value_get_uchar (value) == '\0')
real_value = NULL;
else
real_value = value;
xfce_panel_plugin_provider_remote_event (provider, property, real_value);
}
g_free (property);

Loading…
Cancel
Save