[PATCH] Spatial mode middle-click behaviour should honour single/double-click preference



Hi again :-), this is a patch to fix a regression while keeping the
behavior implemented on the bug that caused it. Please see
http://bugs.gnome.org/574506 for more info.  Patch attached.

Thanks.
From 2169c0845a28b6207e4bcc7c69c8d7d6f3eb5f37 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Nelson=20Ben=C3=ADtez=20Le=C3=B3n?= <nbenitezl+gnome gmail com>
Date: Thu, 30 Apr 2009 17:11:55 +0200
Subject: [PATCH] Make middle-click behaviour honour single/double-click preferences

In spatial mode, fix regression about middle-click behaviour not honouring
single/double-click preferences, fixes bgo#574506.
---
 libnautilus-private/nautilus-icon-container.c |   40 ++++++++++++++++++++----
 1 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index 7bf4c12..0ab2a59 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -4221,12 +4221,17 @@ button_press_event (GtkWidget *widget,
 		    GdkEventButton *event)
 {
 	NautilusIconContainer *container;
+	NautilusWindowInfo *winfo;
 	gboolean selection_changed;
 	gboolean return_value;
 	gboolean clicked_on_icon;
+	gboolean is_spatial;
 
 	container = NAUTILUS_ICON_CONTAINER (widget);
         container->details->button_down_time = event->time;
+
+	winfo = NAUTILUS_WINDOW_INFO (gtk_widget_get_toplevel(GTK_WIDGET (container)));
+	is_spatial = nautilus_window_info_get_window_type (winfo) == NAUTILUS_WINDOW_SPATIAL;
 	
         /* Forget about the old keyboard selection now that we've started mousing. */
         clear_keyboard_focus (container);
@@ -4251,7 +4256,7 @@ button_press_event (GtkWidget *widget,
 		return TRUE;
 	}
 
-	if (event->button == DRAG_BUTTON &&
+	if ((event->button == DRAG_BUTTON || (event->button == MIDDLE_BUTTON && is_spatial)) &&
 	    event->type == GDK_BUTTON_PRESS) {
 		/* Clear the last click icon for double click */
 		container->details->double_click_icon[1] = container->details->double_click_icon[0];
@@ -4310,6 +4315,8 @@ nautilus_icon_container_did_not_drag (NautilusIconContainer *container,
 				      GdkEventButton *event)
 {
 	NautilusIconContainerDetails *details;
+	NautilusWindowInfo *winfo;
+	gboolean is_spatial;
 	gboolean selection_changed;
 	static gint64 last_click_time = 0;
 	static gint click_count = 0;
@@ -4318,6 +4325,9 @@ nautilus_icon_container_did_not_drag (NautilusIconContainer *container,
 		
 	details = container->details;
 
+	winfo = NAUTILUS_WINDOW_INFO (gtk_widget_get_toplevel(GTK_WIDGET (container)));
+	is_spatial = nautilus_window_info_get_window_type (winfo) == NAUTILUS_WINDOW_SPATIAL;
+
 	if (details->icon_selected_on_button_down &&
 	    ((event->state & GDK_CONTROL_MASK) != 0 ||
 	     (event->state & GDK_SHIFT_MASK) == 0)) {
@@ -4340,7 +4350,7 @@ nautilus_icon_container_did_not_drag (NautilusIconContainer *container,
 	
 	if (details->drag_icon != NULL &&
 	    (details->single_click_mode ||
-	     event->button == MIDDLE_BUTTON)) {
+	     (event->button == MIDDLE_BUTTON && !is_spatial))) {
 		/* Determine click count */
 		g_object_get (G_OBJECT (gtk_widget_get_settings (GTK_WIDGET (container))), 
 			      "gtk-double-click-time", &double_click_time,
@@ -6311,8 +6321,13 @@ handle_icon_double_click (NautilusIconContainer *container,
 			  GdkEventButton *event)
 {
 	NautilusIconContainerDetails *details;
+	NautilusWindowInfo *winfo;
+	gboolean is_spatial;
+
+	winfo = NAUTILUS_WINDOW_INFO (gtk_widget_get_toplevel(GTK_WIDGET (container)));
+	is_spatial = nautilus_window_info_get_window_type (winfo) == NAUTILUS_WINDOW_SPATIAL;
 
-	if (event->button != DRAG_BUTTON) {
+	if ((event->button != DRAG_BUTTON) && !is_spatial) {
 		return FALSE;
 	}
 
@@ -6323,9 +6338,15 @@ handle_icon_double_click (NautilusIconContainer *container,
 	    details->double_click_icon[0] == details->double_click_icon[1] &&
 	    details->double_click_button[0] == details->double_click_button[1]) {
 		if (!button_event_modifies_selection (event)) {
-			activate_selected_items (container);
-			return TRUE;
-		} else if ((event->state & GDK_CONTROL_MASK) == 0 &&
+			if (event->button == MIDDLE_BUTTON) {
+				activate_selected_items_alternate (container, NULL);
+				return TRUE;
+			} else if (event->button == DRAG_BUTTON) {
+				activate_selected_items (container);
+				return TRUE;
+			}
+		} else if (event->button == DRAG_BUTTON &&
+			   (event->state & GDK_CONTROL_MASK) == 0 &&
 			   (event->state & GDK_SHIFT_MASK) != 0) {
 			activate_selected_items_alternate (container, icon);
 			return TRUE;
@@ -6352,6 +6373,11 @@ handle_icon_button_press (NautilusIconContainer *container,
 			  GdkEventButton *event)
 {
 	NautilusIconContainerDetails *details;
+	NautilusWindowInfo *winfo;
+	gboolean is_spatial;
+
+	winfo = NAUTILUS_WINDOW_INFO (gtk_widget_get_toplevel(GTK_WIDGET (container)));
+	is_spatial = nautilus_window_info_get_window_type (winfo) == NAUTILUS_WINDOW_SPATIAL;
 
 	details = container->details;
 
@@ -6365,7 +6391,7 @@ handle_icon_button_press (NautilusIconContainer *container,
 		return TRUE;
 	}
 
-	if ((event->button == DRAG_BUTTON) &&
+	if ((event->button == DRAG_BUTTON || (event->button == MIDDLE_BUTTON && is_spatial)) &&
 	    event->type == GDK_BUTTON_PRESS) {
 		/* The next double click has to be on this icon */
 		details->double_click_icon[1] = details->double_click_icon[0];
-- 
1.6.0.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]