David Liang <dliang@novell.com>
bugzilla.gnome.org :  bug 94618
bugzilla.novell.com:  bug 5322  196520  285052
diff -Npur nau-old/src/file-manager/fm-list-view.c nau-new/src/file-manager/fm-list-view.c
--- nau-old/src/file-manager/fm-list-view.c	2008-06-05 16:41:22.000000000 +0800
+++ nau-new/src/file-manager/fm-list-view.c	2008-06-05 16:41:37.000000000 +0800
@@ -108,6 +108,12 @@ struct FMListViewDetails {
 	GtkWidget *column_editor;
 
 	char *original_name;
+
+/* add the following members to realize the function of choosing files by mouse only action*/
+        gboolean start_rubber;
+        gboolean start_outside;
+        gdouble  start_y;
+        GtkTreePath *start_path;
 	
 	NautilusFile *renaming_file;
 	gboolean rename_done;
@@ -465,6 +471,28 @@ motion_notify_callback (GtkWidget *widge
 		return FALSE;
 	}
 
+        if (view->details->start_rubber) {
+                GtkTreeSelection *selection;
+                GtkTreePath *path;
+                selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
+                gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), 0, event->y, &path, NULL,NULL,NULL);
+                if (path) {
+                        if (gtk_tree_selection_count_selected_rows (selection) == 0 ) {
+                                if (view->details->start_path == NULL)
+                                        view->details->start_path  = path;
+                                gtk_tree_selection_select_path (selection,path);
+                        } else {
+                                gtk_tree_selection_unselect_all (selection);
+                                gtk_tree_selection_select_range (selection, view->details->start_path, path);
+                                gtk_tree_path_free (path);
+                        }
+                } else {
+                        if (view->details->start_outside  && view->details->start_y < event->y )
+                                gtk_tree_selection_unselect_all (selection);
+                }
+                return TRUE;
+        }
+
 	if (click_policy_auto_value == NAUTILUS_CLICK_POLICY_SINGLE) {
 		GtkTreePath *old_hover_path;
 
@@ -526,6 +554,9 @@ leave_notify_callback (GtkWidget *widget
 
 	view = FM_LIST_VIEW (callback_data);
 
+	if (view->details->start_rubber == TRUE)
+		return FALSE;
+
 	if (click_policy_auto_value == NAUTILUS_CLICK_POLICY_SINGLE &&
 	    view->details->hover_path != NULL) {
 		gtk_tree_path_free (view->details->hover_path);
@@ -577,6 +608,7 @@ button_press_callback (GtkWidget *widget
 {
 	FMListView *view;
 	GtkTreeView *tree_view;
+	GtkTreeViewColumn *column;
 	GtkTreePath *path;
 	gboolean call_parent;
 	gboolean allow_drag;
@@ -588,7 +620,7 @@ button_press_callback (GtkWidget *widget
 	int double_click_time;
 	int expander_size, horizontal_separator;
 	gboolean on_expander;
-
+	
 	view = FM_LIST_VIEW (callback_data);
 	tree_view = GTK_TREE_VIEW (widget);
 	tree_view_class = GTK_WIDGET_GET_CLASS (tree_view);
@@ -628,7 +660,7 @@ button_press_callback (GtkWidget *widget
 	call_parent = TRUE;
 	allow_drag = FALSE;
 	if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
-					   &path, NULL, NULL, NULL)) {
+					   &path, &column, NULL, NULL)) {
 		/* Keep track of path of last click so double clicks only happen
 		 * on the same item */
 		if ((event->button == 1 || event->button == 2)  && 
@@ -702,7 +734,22 @@ button_press_callback (GtkWidget *widget
 			} else if (gtk_tree_selection_path_is_selected (selection, path)) {
 				gtk_widget_grab_focus (widget);
 			}
-			
+			 			
+			/*leave the shift and control key press the default function*/
+			gboolean    is_filename_col_selected = TRUE;
+			if ((event->state & GDK_SHIFT_MASK) == 0  && (event->state & GDK_CONTROL_MASK) == 0) {
+				if (column && column != view->details->file_name_column)
+					is_filename_col_selected = FALSE;
+				else
+					is_filename_col_selected = TRUE;
+				if (event->button == 1 && is_filename_col_selected == FALSE) {
+					view->details->start_path = path;
+					view->details->start_rubber = TRUE;
+					view->details->start_y	    = event->y;
+					view->details->start_outside = FALSE;
+				} 
+			}
+
 			if ((event->button == 1 || event->button == 2) &&
 			    event->type == GDK_BUTTON_PRESS) {
 				view->details->drag_started = FALSE;
@@ -712,12 +759,23 @@ button_press_callback (GtkWidget *widget
 			}
 			
 			if (event->button == 3) {
-				do_popup_menu (widget, view, event);
-			}
+				if (is_filename_col_selected == TRUE)
+					do_popup_menu (widget, view, event);
+				else
+				        fm_directory_view_pop_up_background_context_menu (FM_DIRECTORY_VIEW (view), event);     
+				
+ 			}
 		}
-
-		gtk_tree_path_free (path);
+		if (view->details->start_rubber == FALSE)
+			gtk_tree_path_free (path);
 	} else {
+			/*leave the shift and control key press the default function*/
+		if (event->button == 1 && (event->state & GDK_SHIFT_MASK) == 0  && (event->state & GDK_CONTROL_MASK) == 0) {
+			view->details->start_rubber = TRUE;
+			view->details->start_y	    = event->y;
+			view->details->start_outside = TRUE;
+		}
+
 		if ((event->button == 1 || event->button == 2)  && 
 		    event->type == GDK_BUTTON_PRESS) {
 			if (view->details->double_click_path[1]) {
@@ -749,6 +807,14 @@ button_release_callback (GtkWidget *widg
 	
 	view = FM_LIST_VIEW (callback_data);
 
+	if (view->details->start_rubber) {
+		view->details->start_rubber = FALSE;
+		if (view->details->start_path) {
+			gtk_tree_path_free (view->details->start_path);
+			view->details->start_path = NULL;
+		}
+	}
+
 	if (event->button == view->details->drag_button) {
 		stop_drag_check (view);
 		if (!view->details->drag_started &&
@@ -1294,6 +1360,9 @@ create_and_set_up_tree_view (FMListView
 
 	view->details->drag_dest = 
 		nautilus_tree_view_drag_dest_new (view->details->tree_view);
+	view->details->start_rubber = FALSE;
+	view->details->start_outside = FALSE;
+	view->details->start_path = NULL;
 
 	g_signal_connect_object (view->details->drag_dest,
 				 "get_root_uri",
