[Xfce4-commits] <xfce4-panel:master> Tasklist: Pushed a patch for #8096 (close a window on middle click)

Andrzej noreply at xfce.org
Sun Apr 28 15:50:01 CEST 2013


Updating branch refs/heads/master
         to b3c92349f9dd7c973996b306e117fc66e5100100 (commit)
       from 74df6cab0ec6d783ba7ab7ae45fcc6aef168c0df (commit)

commit b3c92349f9dd7c973996b306e117fc66e5100100
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Sun Apr 28 14:35:30 2013 +0100

    Tasklist: Pushed a patch for #8096 (close a window on middle click)
    
    A patch submitted by André Miranda (thanks!) with minor corrections.

 plugins/tasklist/tasklist-dialog.glade |   13 +++++++++++
 plugins/tasklist/tasklist-widget.c     |   35 +++++++++++++++++++++++++++++++-
 plugins/tasklist/tasklist.c            |    2 +
 3 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/plugins/tasklist/tasklist-dialog.glade b/plugins/tasklist/tasklist-dialog.glade
index db6db74..8fa64c4 100644
--- a/plugins/tasklist/tasklist-dialog.glade
+++ b/plugins/tasklist/tasklist-dialog.glade
@@ -220,6 +220,19 @@
                             <property name="position">3</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkCheckButton" id="middle-button-close">
+                            <property name="label" translatable="yes">_Close windows using middle mouse button</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="use_underline">True</property>
+                            <property name="draw_indicator">True</property>
+                          </object>
+                          <packing>
+                            <property name="position">4</property>
+                          </packing>
+                        </child>
                       </object>
                     </child>
                   </object>
diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c
index 5978dbd..d818e0a 100644
--- a/plugins/tasklist/tasklist-widget.c
+++ b/plugins/tasklist/tasklist-widget.c
@@ -95,7 +95,8 @@ enum
   PROP_SHOW_HANDLE,
   PROP_SORT_ORDER,
   PROP_WINDOW_SCROLLING,
-  PROP_INCLUDE_ALL_BLINKING
+  PROP_INCLUDE_ALL_BLINKING,
+  PROP_MIDDLE_BUTTON_CLOSE
 };
 
 struct _XfceTasklistClass
@@ -160,6 +161,9 @@ struct _XfceTasklist
    * or only the active workspace */
   guint                 all_blinking : 1;
 
+  /* close window with the mouse middle button */
+  guint                 middle_button_close : 1;
+
   /* whether we only show windows that are in the geometry of
    * the monitor the tasklist is on */
   guint                 all_monitors : 1;
@@ -472,6 +476,13 @@ xfce_tasklist_class_init (XfceTasklistClass *klass)
                                                          TRUE,
                                                          EXO_PARAM_READWRITE));
 
+  g_object_class_install_property (gobject_class,
+                                   PROP_MIDDLE_BUTTON_CLOSE,
+                                   g_param_spec_boolean ("middle-button-close",
+                                                         NULL, NULL,
+                                                         FALSE,
+                                                         EXO_PARAM_READWRITE));
+
   gtk_widget_class_install_style_property (gtkwidget_class,
                                            g_param_spec_int ("max-button-length",
                                                              NULL,
@@ -549,6 +560,7 @@ xfce_tasklist_init (XfceTasklist *tasklist)
   tasklist->all_monitors = TRUE;
   tasklist->window_scrolling = TRUE;
   tasklist->all_blinking = TRUE;
+  tasklist->middle_button_close = FALSE;
   xfce_tasklist_geometry_set_invalid (tasklist);
 #ifdef GDK_WINDOWING_X11
   tasklist->wireframe_window = 0;
@@ -639,6 +651,10 @@ xfce_tasklist_get_property (GObject    *object,
       g_value_set_boolean (value, tasklist->all_blinking);
       break;
 
+    case PROP_MIDDLE_BUTTON_CLOSE:
+      g_value_set_boolean (value, tasklist->middle_button_close);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -713,6 +729,10 @@ xfce_tasklist_set_property (GObject      *object,
       tasklist->all_blinking = g_value_get_boolean (value);
       break;
 
+    case PROP_MIDDLE_BUTTON_CLOSE:
+      tasklist->middle_button_close = g_value_get_boolean (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -2716,6 +2736,19 @@ xfce_tasklist_button_button_release_event (GtkWidget         *button,
       xfce_tasklist_button_activate (child, event->time);
     }
 
+  /* close the window on middle mouse button */
+  if (event->type == GDK_BUTTON_RELEASE
+      && !xfce_taskbar_is_locked (child->tasklist)
+      && event->button == 2
+      && child->tasklist->middle_button_close
+      && !(event->x == 0 && event->y == 0) /* 0,0 = outside the widget in Gtk */
+      && event->x >= 0 && event->x < button->allocation.width
+      && event->y >= 0 && event->y < button->allocation.height)
+    {
+      wnck_window_close (child->window, event->time);
+      return TRUE;
+    }
+
   return FALSE;
 }
 
diff --git a/plugins/tasklist/tasklist.c b/plugins/tasklist/tasklist.c
index 71881c5..b705c4d 100644
--- a/plugins/tasklist/tasklist.c
+++ b/plugins/tasklist/tasklist.c
@@ -141,6 +141,7 @@ tasklist_plugin_construct (XfcePanelPlugin *panel_plugin)
     { "sort-order", G_TYPE_UINT },
     { "window-scrolling", G_TYPE_BOOLEAN },
     { "include-all-blinking", G_TYPE_BOOLEAN },
+    { "middle-button-close", G_TYPE_BOOLEAN },
     { NULL }
   };
 
@@ -253,6 +254,7 @@ tasklist_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
   TASKLIST_DIALOG_BIND ("show-handle", "active")
   TASKLIST_DIALOG_BIND ("sort-order", "active")
   TASKLIST_DIALOG_BIND ("window-scrolling", "active")
+  TASKLIST_DIALOG_BIND ("middle-button-close", "active")
 
 #ifndef GDK_WINDOWING_X11
   /* not functional in x11, so avoid confusion */


More information about the Xfce4-commits mailing list