rubberbanding through icon selection



Hi,

Here's a patch that lets you rubberband by holding shift while clicking
on icons.

James
? blah
? nautilus_jwillcox_scroll_save_v1.diff
? nautilus_jwillcox_scroll_save_v2.diff
? nautilus_jwillcox_select_pattern_v4.diff
? nautilus_jwillcox_shift_rubberband_v1.diff
? stamp-h1
? libnautilus-private/blah.diff
? libnautilus-private/nautilus-icon-private.h.rubber
? src/.nautilus-object-window.c.swp
? src/.nautilus-object-window.h.swp
? src/.nautilus-view-frame.c.swp
? src/.nautilus-window-manage-views.c.swp
? src/blah.c
? src/file-manager/.fm-directory-view.h.swp
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5942
diff -u -r1.5942 ChangeLog
--- ChangeLog	27 Sep 2003 14:46:21 -0000	1.5942
+++ ChangeLog	28 Sep 2003 20:08:50 -0000
@@ -1,3 +1,17 @@
+2003-09-28  James Willcox  <james ximian com>
+
+	* libnautilus-private/nautilus-icon-container.c:
+	(set_rubberband_start), (clear_rubberband_start),
+	(button_event_modifies_selection), (button_event_is_rubberband),
+	(keyboard_move_to), (select_matching_name), (button_press_event),
+	(handle_icon_button_press), (nautilus_icon_container_clear),
+	(icon_destroy):
+	* libnautilus-private/nautilus-icon-private.h:
+
+	Make holding shift when selecting an icon to a rubberband selection
+	instead of just selecting the file (which you can already do
+	by holding ctrl).
+	
 2003-09-27  James Willcox  <james ximian com>
 
 	* src/file-manager/fm-directory-view.c: (pattern_select_response_cb)
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.347
diff -u -r1.347 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c	20 Aug 2003 18:26:22 -0000	1.347
+++ libnautilus-private/nautilus-icon-container.c	28 Sep 2003 20:08:52 -0000
@@ -709,16 +709,16 @@
 }
 
 static void
-set_keyboard_rubberband_start (NautilusIconContainer *container,
+set_rubberband_start (NautilusIconContainer *container,
 			       NautilusIcon *icon)
 {
-	container->details->keyboard_rubberband_start = icon;
+	container->details->rubberband_start = icon;
 }
 
 static void
-clear_keyboard_rubberband_start (NautilusIconContainer *container)
+clear_rubberband_start (NautilusIconContainer *container)
 {
-	container->details->keyboard_rubberband_start = NULL;
+	container->details->rubberband_start = NULL;
 }
 
 static void
@@ -1695,7 +1695,13 @@
 static gboolean
 button_event_modifies_selection (GdkEventButton *event)
 {
-	return (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) != 0;
+	return (event->state & GDK_CONTROL_MASK) != 0;
+}
+
+static gboolean
+button_event_is_rubberband (GdkEventButton *event)
+{
+	return (event->state & GDK_SHIFT_MASK) != 0;
 }
 
 /* invalidate the cached label sizes for all the icons */
@@ -2503,28 +2509,28 @@
 		 * rather than Alt to avoid Sawfish conflict.
 		 */
 		set_keyboard_focus (container, icon);
-		container->details->keyboard_rubberband_start = NULL;
+		container->details->rubberband_start = NULL;
 	} else if ((event->state & GDK_SHIFT_MASK) != 0) {
 		/* Do rubberband selection */		
 		ArtDRect rect;
 
-		if (from && !container->details->keyboard_rubberband_start) {
-			set_keyboard_rubberband_start (container, from);
+		if (from && !container->details->rubberband_start) {
+			set_rubberband_start (container, from);
 		} 
 
 		unselect_all (container);	
 		icon_set_selected (container, icon, TRUE);
 		set_keyboard_focus (container, icon);
 
-		if (icon && container->details->keyboard_rubberband_start && container->details->keyboard_rubberband_start != icon) {
-			rect = get_rubberband (container->details->keyboard_rubberband_start,
+		if (icon && container->details->rubberband_start && container->details->rubberband_start != icon) {
+			rect = get_rubberband (container->details->rubberband_start,
 					       icon);
 			rubberband_select (container, NULL, &rect);
 		}
 	} else {
 		/* Select icons and get rid of the special keyboard focus. */
 		clear_keyboard_focus (container);
-		clear_keyboard_rubberband_start (container);
+		clear_rubberband_start (container);
 		
 		if (select_one_unselect_others (container, icon)) {
 			g_signal_emit (container,
@@ -2839,7 +2845,7 @@
 
 	/* Select icons and get rid of the special keyboard focus. */
 	clear_keyboard_focus (container);
-	clear_keyboard_rubberband_start (container);
+	clear_rubberband_start (container);
 	if (select_one_unselect_others (container, icon)) {
 		g_signal_emit (container,
 				 signals[SELECTION_CHANGED], 0);
@@ -3079,7 +3085,6 @@
 	
         /* Forget about the old keyboard selection now that we've started mousing. */
         clear_keyboard_focus (container);
-	clear_keyboard_rubberband_start (container);
 
 	/* Forget about where we began with the arrow keys now that we're mousing. */
 	container->details->arrow_key_axis = AXIS_NONE;
@@ -3108,6 +3113,9 @@
 		return TRUE;
 	}
 
+	/* Clear the keyboard/icon-selection-based rubberbanding */
+	clear_rubberband_start (container);
+
 	/* Button 1 does rubber banding. */
 	if (event->button == RUBBERBAND_BUTTON) {
 		if (! button_event_modifies_selection (event)) {
@@ -4284,12 +4292,24 @@
 			icon_toggle_selected (container, icon);
 			g_signal_emit (container,
 				       signals[SELECTION_CHANGED], 0);
+		} else if (button_event_is_rubberband (event) &&
+			   container->details->rubberband_start != NULL &&
+			   container->details->rubberband_start != icon) {
+			ArtDRect rect;
+		
+			rect = get_rubberband (container->details->rubberband_start, icon);
+			rubberband_select (container, NULL, &rect);
+			g_signal_emit (container,
+				       signals[SELECTION_CHANGED], 0);
 		} else {
 			unselect_all (container);
 			icon_set_selected (container, icon, TRUE);
+			set_rubberband_start (container, icon);
 			g_signal_emit (container,
 				       signals[SELECTION_CHANGED], 0);
 		}
+	} else if (button_event_is_rubberband (event)) {
+		set_rubberband_start (container, icon);
 	}
 
 	if (event->button == CONTEXTUAL_MENU_BUTTON) {
@@ -4357,7 +4377,7 @@
 	end_renaming_mode (container, TRUE);
 	
 	clear_keyboard_focus (container);
-	clear_keyboard_rubberband_start (container);
+	clear_rubberband_start (container);
 	unschedule_keyboard_icon_reveal (container);
 	set_pending_icon_to_reveal (container, NULL);
 	details->stretch_icon = NULL;
@@ -4524,8 +4544,8 @@
 		}
 	}
 	
-	if (details->keyboard_rubberband_start == icon) {
-		clear_keyboard_rubberband_start (container);
+	if (details->rubberband_start == icon) {
+		clear_rubberband_start (container);
 	}
 
 	if (details->keyboard_icon_to_reveal == icon) {
Index: libnautilus-private/nautilus-icon-private.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-private.h,v
retrieving revision 1.74
diff -u -r1.74 nautilus-icon-private.h
--- libnautilus-private/nautilus-icon-private.h	20 Aug 2003 18:26:26 -0000	1.74
+++ libnautilus-private/nautilus-icon-private.h	28 Sep 2003 20:08:52 -0000
@@ -119,7 +119,9 @@
 
 	/* Current icon for keyboard navigation. */
 	NautilusIcon *keyboard_focus;
-	NautilusIcon *keyboard_rubberband_start;
+
+	/* For icon-selection-based rubberbanding */
+	NautilusIcon *rubberband_start;
 
 	/* Current icon with stretch handles, so we have only one. */
 	NautilusIcon *stretch_icon;


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