Index: gtktreeview.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktreeview.c,v
retrieving revision 1.334
diff -u -p -r1.334 gtktreeview.c
--- gtktreeview.c	15 Aug 2003 20:07:40 -0000	1.334
+++ gtktreeview.c	19 Aug 2003 22:40:25 -0000
@@ -1988,7 +1988,7 @@ gtk_tree_view_button_press (GtkWidget   
       GtkTreeViewColumn *column = NULL;
       GtkCellRenderer *focus_cell = NULL;
       gint column_handled_click = FALSE;
-      gboolean emit_row_activated = FALSE;
+      gboolean row_double_click = FALSE;
       gboolean rtl;
 
       /* are we in an arrow? */
@@ -2027,6 +2027,46 @@ gtk_tree_view_button_press (GtkWidget   
 				    tree_view->priv->expander_size);
       background_area.x = 0;
 
+
+      /* Test if a double click happened on the same row. */
+      if (event->button == 1)
+        {
+          /* We also handle triple clicks here, because a user could have done
+           * a first click and a second double click on different rows.
+           */
+          if ((event->type == GDK_2BUTTON_PRESS
+               || event->type == GDK_3BUTTON_PRESS)
+              && tree_view->priv->last_button_press)
+            {
+              GtkTreePath *lsc;
+
+              lsc = gtk_tree_row_reference_get_path (tree_view->priv->last_button_press);
+
+              if (lsc)
+                {
+                  row_double_click = !gtk_tree_path_compare (lsc, path);
+                  gtk_tree_path_free (lsc);
+                }
+            }
+
+          if (row_double_click)
+            {
+              if (tree_view->priv->last_button_press)
+                gtk_tree_row_reference_free (tree_view->priv->last_button_press);
+              if (tree_view->priv->last_button_press_2)
+                gtk_tree_row_reference_free (tree_view->priv->last_button_press_2);
+              tree_view->priv->last_button_press = NULL;
+              tree_view->priv->last_button_press_2 = NULL;
+            }
+          else
+            {
+              if (tree_view->priv->last_button_press)
+                gtk_tree_row_reference_free (tree_view->priv->last_button_press);
+              tree_view->priv->last_button_press = tree_view->priv->last_button_press_2;
+              tree_view->priv->last_button_press_2 = gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view), tree_view->priv->model, path);
+            }
+        }
+
       /* Let the column have a chance at selecting it. */
       rtl = (gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL);
       for (list = (rtl ? g_list_last (tree_view->priv->columns) : g_list_first (tree_view->priv->columns));
@@ -2179,38 +2219,9 @@ gtk_tree_view_button_press (GtkWidget   
           tree_view->priv->press_start_y = event->y;
         }
 
-      if (event->button == 1 && event->type == GDK_2BUTTON_PRESS &&
-	  tree_view->priv->last_button_press)
-	{
-	  GtkTreePath *lsc;
-
-	  lsc = gtk_tree_row_reference_get_path (tree_view->priv->last_button_press);
-
-	  if (tree_view->priv->last_button_press)
-	    gtk_tree_row_reference_free (tree_view->priv->last_button_press);
-	  if (tree_view->priv->last_button_press_2)
-	    gtk_tree_row_reference_free (tree_view->priv->last_button_press_2);
-	  tree_view->priv->last_button_press = NULL;
-	  tree_view->priv->last_button_press_2 = NULL;
-
-	  if (lsc)
-	    {
-	      if (!gtk_tree_path_compare (lsc, path))
-		emit_row_activated = TRUE;
-	      gtk_tree_path_free (lsc);
-	    }
-	}
-      else if (event->button == 1 && event->type == GDK_BUTTON_PRESS)
-        {
-	  if (tree_view->priv->last_button_press)
-	    gtk_tree_row_reference_free (tree_view->priv->last_button_press);
-	  tree_view->priv->last_button_press = tree_view->priv->last_button_press_2;
-	  tree_view->priv->last_button_press_2 = gtk_tree_row_reference_new_proxy (G_OBJECT (tree_view), tree_view->priv->model, path);
-	}
-
       GTK_TREE_VIEW_UNSET_FLAG (tree_view, GTK_TREE_VIEW_DRAW_KEYFOCUS);
 
-      if (emit_row_activated)
+      if (row_double_click)
 	{
 	  gtk_grab_remove (widget);
 	  gtk_tree_view_row_activated (tree_view, path, column);
