[Xfce4-commits] <xfce4-panel:devel> Add xfce4-popup-windowmenu program.

Nick Schermer noreply at xfce.org
Thu Nov 19 22:44:02 CET 2009


Updating branch refs/heads/devel
         to 542ca64ef3c02da6ecb6fb8b8273a3806dffef98 (commit)
       from 698394d9836458f7aeeb6985f070b80a2695d78e (commit)

commit 542ca64ef3c02da6ecb6fb8b8273a3806dffef98
Author: Nick Schermer <nick at xfce.org>
Date:   Thu Nov 19 22:42:05 2009 +0100

    Add xfce4-popup-windowmenu program.
    
    This is simple script using the remote-event signal
    for panel plugins.

 plugins/windowmenu/Makefile.am               |    9 +++++++
 plugins/windowmenu/windowmenu.c              |   32 ++++++++++++++++++++++++++
 plugins/windowmenu/xfce4-popup-windowmenu.in |   22 +++++++++++++++++
 3 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/plugins/windowmenu/Makefile.am b/plugins/windowmenu/Makefile.am
index 1f424e0..46c3814 100644
--- a/plugins/windowmenu/Makefile.am
+++ b/plugins/windowmenu/Makefile.am
@@ -49,6 +49,15 @@ libwindowmenu_la_DEPENDENCIES = \
 	$(top_builddir)/common/libpanel-common.la
 
 #
+# xfce4-popup-windowmenu script
+#
+bin_SCRIPTS = \
+	xfce4-popup-windowmenu
+
+xfce4-popup-windowmenu: xfce4-popup-windowmenu.in Makefile
+	$(AM_V_GEN) sed -e "s,\@bindir\@,$(bindir),g" $< >$@
+
+#
 # .desktop file
 #
 desktopdir = $(datadir)/xfce4/panel
diff --git a/plugins/windowmenu/windowmenu.c b/plugins/windowmenu/windowmenu.c
index 1019ad8..211137d 100644
--- a/plugins/windowmenu/windowmenu.c
+++ b/plugins/windowmenu/windowmenu.c
@@ -98,6 +98,9 @@ static void      window_menu_plugin_screen_position_changed (XfcePanelPlugin
 static gboolean  window_menu_plugin_size_changed            (XfcePanelPlugin    *panel_plugin,
                                                              gint                size);
 static void      window_menu_plugin_configure_plugin        (XfcePanelPlugin    *panel_plugin);
+static gboolean  window_menu_plugin_remote_event            (XfcePanelPlugin    *panel_plugin,
+                                                             const gchar        *name,
+                                                             const GValue       *value);
 static void      window_menu_plugin_active_window_changed   (WnckScreen         *screen,
                                                              WnckWindow         *previous_window,
                                                              WindowMenuPlugin   *plugin);
@@ -146,6 +149,7 @@ window_menu_plugin_class_init (WindowMenuPluginClass *klass)
   plugin_class->screen_position_changed = window_menu_plugin_screen_position_changed;
   plugin_class->size_changed = window_menu_plugin_size_changed;
   plugin_class->configure_plugin = window_menu_plugin_configure_plugin;
+  plugin_class->remote_event = window_menu_plugin_remote_event;
 
   g_object_class_install_property (gobject_class,
                                    PROP_STYLE,
@@ -514,6 +518,34 @@ window_menu_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
 
 
 
+static gboolean
+window_menu_plugin_remote_event (XfcePanelPlugin *panel_plugin,
+                                 const gchar     *name,
+                                 const GValue    *value)
+{
+  WindowMenuPlugin *plugin = XFCE_WINDOW_MENU_PLUGIN (panel_plugin);
+  GdkEventButton    event;
+
+  if (strcmp (name, "popup") == 0
+      && GTK_WIDGET_VISIBLE (panel_plugin)
+      && !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (plugin->button)))
+    {
+      /* create fake event */
+      event.type = GDK_BUTTON_PRESS;
+      event.button = 1;
+      event.time = gtk_get_current_event_time ();
+
+      window_menu_plugin_button_press_event (plugin->button, &event, plugin);
+
+      /* don't popup another menu */
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
+
+
 static void
 window_menu_plugin_active_window_changed (WnckScreen       *screen,
                                           WnckWindow       *previous_window,
diff --git a/plugins/windowmenu/xfce4-popup-windowmenu.in b/plugins/windowmenu/xfce4-popup-windowmenu.in
new file mode 100644
index 0000000..17356b2
--- /dev/null
+++ b/plugins/windowmenu/xfce4-popup-windowmenu.in
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# Copyright (C) 2009 Nick Schermer <nick at xfce.org>
+#
+# 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 Library General Public License
+# along with this library; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+#
+
+exec @bindir@/xfce4-panel --plugin-event=windowmenu:popup:bool:true
+
+# vim:set ts=2 sw=2 et ai:



More information about the Xfce4-commits mailing list