Browse Source

Add popup under cursor for applications menu.

upstream/xfce4-panel-4.10.1
Nick Schermer 13 years ago
parent
commit
eb09e532d4
  1. 33
      plugins/applicationsmenu/applicationsmenu.c
  2. 8
      plugins/applicationsmenu/xfce4-popup-applicationsmenu.sh

33
plugins/applicationsmenu/applicationsmenu.c

@ -531,8 +531,8 @@ applications_menu_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
static gboolean
applications_menu_plugin_remote_event (XfcePanelPlugin *panel_plugin,
const gchar *name,
const GValue *value)
const gchar *name,
const GValue *value)
{
ApplicationsMenuPlugin *plugin = XFCE_APPLICATIONS_MENU_PLUGIN (panel_plugin);
@ -542,8 +542,18 @@ applications_menu_plugin_remote_event (XfcePanelPlugin *panel_plugin,
&& GTK_WIDGET_VISIBLE (panel_plugin)
&& !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (plugin->button)))
{
/* show the menu */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (plugin->button), TRUE);
if (value != NULL
&& G_VALUE_HOLDS_BOOLEAN (value)
&& g_value_get_boolean (value))
{
/* show menu under cursor */
applications_menu_plugin_menu (NULL, plugin);
}
else
{
/* show the menu at the button */
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (plugin->button), TRUE);
}
/* don't popup another menu */
return TRUE;
@ -558,16 +568,18 @@ static void
applications_menu_plugin_menu_deactivate (GtkWidget *menu,
GtkWidget *button)
{
panel_return_if_fail (GTK_IS_TOGGLE_BUTTON (button));
panel_return_if_fail (button == NULL || GTK_IS_TOGGLE_BUTTON (button));
panel_return_if_fail (GTK_IS_MENU (menu));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
if (button != NULL)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
/* delay destruction so we can handle the activate event first */
exo_gtk_object_destroy_later (GTK_OBJECT (menu));
}
static void
applications_menu_plugin_append_quoted (GString *string,
const gchar *unquoted)
@ -801,9 +813,10 @@ applications_menu_plugin_menu (GtkWidget *button,
GError *error = NULL;
panel_return_if_fail (XFCE_IS_APPLICATIONS_MENU_PLUGIN (plugin));
panel_return_if_fail (plugin->button == button);
panel_return_if_fail (button == NULL || plugin->button == button);
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
if (button != NULL
&& !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
return;
if (G_UNLIKELY (plugin->custom_menu
@ -827,8 +840,8 @@ applications_menu_plugin_menu (GtkWidget *button,
}
gtk_menu_popup (GTK_MENU (gtk_menu), NULL, NULL,
xfce_panel_plugin_position_menu, plugin,
1, gtk_get_current_event_time ());
button != NULL ? xfce_panel_plugin_position_menu : NULL,
plugin, 1, gtk_get_current_event_time ());
}
else
{

8
plugins/applicationsmenu/xfce4-popup-applicationsmenu.sh

@ -20,12 +20,15 @@
export TEXTDOMAIN="xfce4-panel"
export TEXTDOMAINDIR="@localedir@"
ATPOINTER="false"
case "$1" in
-h|--help)
echo "$(gettext "Usage:")"
echo " $(basename $0) [$(gettext "OPTION")...]"
echo
echo "$(gettext "Options:")"
echo " -p, --pointer $(gettext "Popup menu at current mouse position")"
echo " -h, --help $(gettext "Show help options")"
echo " -V, --version $(gettext "Print version information and exit")"
exit 0
@ -34,8 +37,11 @@ case "$1" in
exec @bindir@/xfce4-panel -V "$(basename $0)"
exit 0
;;
-p|--pointer)
ATPOINTER="true"
;;
esac
exec @bindir@/xfce4-panel --plugin-event=applicationsmenu:popup
exec @bindir@/xfce4-panel --plugin-event=applicationsmenu:popup:bool:$ATPOINTER
# vim:set ts=2 sw=2 et ai:

Loading…
Cancel
Save