[Xfce4-commits] <xfce4-panel:master> Showdesktop: Allow middle-click to shade windows (bug #7177).

Nick Schermer noreply at xfce.org
Sat Apr 23 00:00:02 CEST 2011


Updating branch refs/heads/master
         to 9a341b06c17348d6aae5197d20630ae5791bbe26 (commit)
       from b84c22ebdd7ad150f6887ea07201c1296ba8b82f (commit)

commit 9a341b06c17348d6aae5197d20630ae5791bbe26
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Apr 22 23:05:27 2011 +0200

    Showdesktop: Allow middle-click to shade windows (bug #7177).
    
    This will toggle the window's shade state on the active workspace.
    Seems like an effective way to quickly switch between visible
    windows on the workspace.

 plugins/showdesktop/showdesktop.c |   42 +++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/plugins/showdesktop/showdesktop.c b/plugins/showdesktop/showdesktop.c
index 451ab63..b7d7388 100644
--- a/plugins/showdesktop/showdesktop.c
+++ b/plugins/showdesktop/showdesktop.c
@@ -36,6 +36,9 @@ static gboolean show_desktop_plugin_size_changed            (XfcePanelPlugin
                                                              gint                    size);
 static void     show_desktop_plugin_toggled                 (GtkToggleButton        *button,
                                                              ShowDesktopPlugin      *plugin);
+static gboolean show_desktop_plugin_button_release_event    (GtkToggleButton        *button,
+                                                             GdkEventButton         *event,
+                                                             ShowDesktopPlugin      *plugin);
 static void     show_desktop_plugin_showing_desktop_changed (WnckScreen             *wnck_screen,
                                                              ShowDesktopPlugin      *plugin);
 
@@ -94,6 +97,8 @@ show_desktop_plugin_init (ShowDesktopPlugin *plugin)
   gtk_widget_set_name (button, "showdesktop-button");
   g_signal_connect (G_OBJECT (button), "toggled",
       G_CALLBACK (show_desktop_plugin_toggled), plugin);
+  g_signal_connect (G_OBJECT (button), "button-release-event",
+      G_CALLBACK (show_desktop_plugin_button_release_event), plugin);
   xfce_panel_plugin_add_action_widget (XFCE_PANEL_PLUGIN (plugin), button);
   gtk_widget_show (button);
 
@@ -201,6 +206,43 @@ show_desktop_plugin_toggled (GtkToggleButton   *button,
 
 
 
+static gboolean
+show_desktop_plugin_button_release_event (GtkToggleButton   *button,
+                                          GdkEventButton    *event,
+                                          ShowDesktopPlugin *plugin)
+{
+  WnckWorkspace *active_ws;
+  GList         *windows, *li;
+  WnckWindow    *window;
+
+  panel_return_val_if_fail (XFCE_IS_SHOW_DESKTOP_PLUGIN (plugin), FALSE);
+  panel_return_val_if_fail (WNCK_IS_SCREEN (plugin->wnck_screen), FALSE);
+
+  if (event->button == 2)
+    {
+      active_ws = wnck_screen_get_active_workspace (plugin->wnck_screen);
+      windows = wnck_screen_get_windows (plugin->wnck_screen);
+
+      for (li = windows; li != NULL; li = li->next)
+        {
+          window = WNCK_WINDOW (li->data);
+
+          if (wnck_window_get_workspace (window) != active_ws)
+            continue;
+
+          /* toggle the shade state */
+          if (wnck_window_is_shaded (window))
+            wnck_window_unshade (window);
+          else
+            wnck_window_shade (window);
+        }
+    }
+
+  return FALSE;
+}
+
+
+
 static void
 show_desktop_plugin_showing_desktop_changed (WnckScreen        *wnck_screen,
                                              ShowDesktopPlugin *plugin)



More information about the Xfce4-commits mailing list