diff --git a/plugins/applicationsmenu/Makefile.am b/plugins/applicationsmenu/Makefile.am index 5967919..f93aa53 100644 --- a/plugins/applicationsmenu/Makefile.am +++ b/plugins/applicationsmenu/Makefile.am @@ -50,12 +50,13 @@ libapplicationsmenu_la_DEPENDENCIES = \ $(top_builddir)/common/libpanel-common.la # -# xfce4-popup-applicationsmenu script +# xfce4-popup-applicationsmenu and xfce4-toggle-applicationsmenu script # bin_SCRIPTS = \ - xfce4-popup-applicationsmenu + xfce4-popup-applicationsmenu \ + xfce4-toggle-applicationsmenu -xfce4-popup-applicationsmenu: xfce4-popup-applicationsmenu.sh Makefile +xfce4-popup-applicationsmenu: xfce4-popup-applicationsmenu.sh xfce4-toggle-applicationsmenu.sh Makefile $(AM_V_GEN) $(SED) -e "s,\@bindir\@,$(bindir),g" \ -e "s,\@localedir\@,$(localedir),g" $< >$@ diff --git a/plugins/applicationsmenu/applicationsmenu.c b/plugins/applicationsmenu/applicationsmenu.c index dc34e93..5a718f7 100644 --- a/plugins/applicationsmenu/applicationsmenu.c +++ b/plugins/applicationsmenu/applicationsmenu.c @@ -699,6 +699,24 @@ applications_menu_plugin_remote_event (XfcePanelPlugin *panel_plugin, /* don't popup another menu */ return TRUE; } + else if (strcmp (name, "toggle") == 0 + && GTK_WIDGET_VISIBLE (panel_plugin) + && panel_utils_grab_available ()) + { + if(gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (plugin->button))) + { + /* hide the menu */ + applications_menu_plugin_menu_deactivate (plugin->menu, plugin->button); + } + else + { + /* show the menu at the button */ + applications_menu_plugin_menu (plugin->button, NULL, plugin); + } + + /* don't popup another menu */ + return TRUE; + } return FALSE; } diff --git a/plugins/applicationsmenu/xfce4-toggle-applicationsmenu.sh b/plugins/applicationsmenu/xfce4-toggle-applicationsmenu.sh new file mode 100644 index 0000000..bb8764f --- /dev/null +++ b/plugins/applicationsmenu/xfce4-toggle-applicationsmenu.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# +# Copyright (C) 2010 Nick Schermer +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) +# any later version. +# +# This library is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + +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 "Toggle menu at current mouse position")" + echo " -h, --help $(gettext "Show help options")" + echo " -V, --version $(gettext "Print version information and exit")" + exit 0 + ;; + -V|--version) + exec @bindir@/xfce4-panel -V "$(basename $0)" + exit 0 + ;; + -p|--pointer) + ATPOINTER="true" + ;; +esac + +# try to toggle panel menu, if this fails try xfdesktop +@bindir@/xfce4-panel --plugin-event=applicationsmenu:toggle:bool:$ATPOINTER || xfdesktop --menu + +# vim:set ts=2 sw=2 et ai: