[Nautilus-list] [PATCH] fix single click activation in the list view, bug 76197



Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5176
diff -p -u -r1.5176 ChangeLog
--- ChangeLog	4 Apr 2002 11:35:30 -0000	1.5176
+++ ChangeLog	4 Apr 2002 19:03:52 -0000
@@ -1,3 +1,15 @@
+2002-03-30  David Emory Watson  <dwatson cs ucr edu>
+
+	This fixes single click activation in the list view, bug 76197.
+
+	* /src/file-manager/fm-list-view.c:
+	(list_activate_callback): only do this if the double click activation
+	preference is set.
+	(event_after_callback): handle single click activation preference.
+	(click_policy_changed): new function to handle whether file names
+	are underlined or not.
+	(create_and_set_up_tree_view): connect click policy preference callback
+
 2002-04-02  Michael Meeks  <michael ximian com>
 
 	* This commit requires a newer eel, which requires gail.
Index: ./src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.163
diff -p -u -r1.163 fm-list-view.c
--- ./src/file-manager/fm-list-view.c	11 Mar 2002 10:17:49 -0000	1.163
+++ ./src/file-manager/fm-list-view.c	4 Apr 2002 19:03:53 -0000
@@ -86,10 +86,12 @@ list_activate_callback (GtkTreeView *tre
 	GList *file_list;
 	
 	view = FM_DIRECTORY_VIEW (user_data);
-	
-	file_list = fm_list_view_get_selection (view);
-	fm_directory_view_activate_files (view, file_list);
-	nautilus_file_list_free (file_list);
+
+	if (eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY) == NAUTILUS_CLICK_POLICY_DOUBLE) {
+		file_list = fm_list_view_get_selection (view);
+		fm_directory_view_activate_files (view, file_list);
+		nautilus_file_list_free (file_list);
+	}
 }
 
 /* Move these to eel? */
@@ -124,16 +126,26 @@ tree_view_has_selection (GtkTreeView *vi
 static void
 event_after_callback (GtkWidget *widget, GdkEventAny *event, gpointer callback_data)
 {
-	/* Put up the right kind of menu if we right click in the tree view. */
+	FMDirectoryView *view;
+	GList *file_list;
+
+	view = FM_DIRECTORY_VIEW (callback_data);
+
 	if (event->type == GDK_BUTTON_PRESS
-	    && event->window == gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))
-	    && ((GdkEventButton *) event)->button == 3) {
-		if (tree_view_has_selection (GTK_TREE_VIEW (widget))) {
-			fm_directory_view_pop_up_selection_context_menu
-				(FM_DIRECTORY_VIEW (callback_data), (GdkEventButton *) event);
-		} else {
-			fm_directory_view_pop_up_background_context_menu
-				(FM_DIRECTORY_VIEW (callback_data), (GdkEventButton *) event);
+	    && event->window == gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget))) {
+		if (((GdkEventButton *) event)->button == 1
+		    && eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY) == NAUTILUS_CLICK_POLICY_SINGLE) {
+			/* Handle single click activation preference. */
+			file_list = fm_list_view_get_selection (view);
+			fm_directory_view_activate_files (view, file_list);
+			nautilus_file_list_free (file_list);
+		} else if (((GdkEventButton *) event)->button == 3) {
+			/* Put up the right kind of menu if we right click in the tree view. */
+			if (tree_view_has_selection (GTK_TREE_VIEW (widget))) {
+				fm_directory_view_pop_up_selection_context_menu (view, (GdkEventButton *) event);
+			} else {
+				fm_directory_view_pop_up_background_context_menu (view, (GdkEventButton *) event);
+			}
 		}
 	}
 }
@@ -180,6 +192,24 @@ cell_renderer_edited (GtkCellRendererTex
 }
 
 static void
+click_policy_changed (gpointer callback_data)
+{
+	GtkCellRenderer *cell;
+
+	cell = GTK_CELL_RENDERER (callback_data);
+
+	if (eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY) == NAUTILUS_CLICK_POLICY_SINGLE) {
+		g_object_set (G_OBJECT (cell),
+			      "underline", PANGO_UNDERLINE_SINGLE,
+			      NULL);
+	} else {
+		g_object_set (G_OBJECT (cell),
+			      "underline", PANGO_UNDERLINE_NONE,
+			      NULL);
+	}
+}
+
+static void
 create_and_set_up_tree_view (FMListView *view)
 {
 	GtkCellRenderer *cell;
@@ -221,13 +251,19 @@ create_and_set_up_tree_view (FMListView 
 
 	cell = gtk_cell_renderer_text_new ();
 	g_signal_connect (cell, "edited", G_CALLBACK (cell_renderer_edited), view);
-	
+
 	gtk_tree_view_column_pack_start (view->details->file_name_column, cell, TRUE);
 	gtk_tree_view_column_set_attributes (view->details->file_name_column, cell,
 					     "text", FM_LIST_MODEL_NAME_COLUMN,
 					     "editable", FM_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN,
 					     NULL);
 	gtk_tree_view_append_column (view->details->tree_view, view->details->file_name_column);
+
+	/* Set up underline of file name. */
+	eel_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY,
+				      click_policy_changed,
+				      cell);
+	click_policy_changed (cell);
 
 	/* Create the size column */
 	cell = gtk_cell_renderer_text_new ();


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