[Xfce4-commits] <xfce4-panel:devel> Add popup under cursor for applications menu.
Nick Schermer
noreply at xfce.org
Tue Feb 23 19:30:02 CET 2010
Updating branch refs/heads/devel
to 84d77ce898395f339513ce78f43258d581730e4a (commit)
from c6753a8cf0b5188b971cd14ad402850955a0aa50 (commit)
commit 84d77ce898395f339513ce78f43258d581730e4a
Author: Nick Schermer <nick at xfce.org>
Date: Tue Feb 23 19:10:09 2010 +0100
Add popup under cursor for applications menu.
plugins/applicationsmenu/applicationsmenu.c | 33 ++++++++++++++------
.../xfce4-popup-applicationsmenu.sh | 8 ++++-
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/plugins/applicationsmenu/applicationsmenu.c b/plugins/applicationsmenu/applicationsmenu.c
index 60d5359..9d53ca0 100644
--- a/plugins/applicationsmenu/applicationsmenu.c
+++ b/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
{
diff --git a/plugins/applicationsmenu/xfce4-popup-applicationsmenu.sh b/plugins/applicationsmenu/xfce4-popup-applicationsmenu.sh
index 7e9a95b..0ef5ef6 100644
--- a/plugins/applicationsmenu/xfce4-popup-applicationsmenu.sh
+++ b/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:
More information about the Xfce4-commits
mailing list