[nautilus] list-view: Make double-click star work normally



commit b878f11abf21eebf68eb50fd01af48327137974e
Author: Alexandru Fazakas <alex fazakas97 yahoo com>
Date:   Sat Feb 24 19:19:47 2018 +0200

    list-view: Make double-click star work normally
    
    When we double click a star, the file is starred and then unstarred,
    and then opened (no change regarding star status).
    
    The intended behaviour is to treat this as a single click.
    
    This patch solves this by allowing double clicks only outside of
    the star icon. If a double click happens on a star, we treat it
    as a simple one. It also offers solution for checking if a click
    happened on a star icon or not.
    
    Fixes https://gitlab.gnome.org/GNOME/nautilus/issues/159

 src/nautilus-list-view.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 2cc37e838..41fe79654 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -515,6 +515,7 @@ button_press_callback (GtkWidget      *widget,
     gboolean call_parent, on_expander, show_expanders;
     gboolean is_simple_click, path_selected;
     NautilusFile *file;
+    gboolean on_star;
 
     view = NAUTILUS_LIST_VIEW (callback_data);
     tree_view = GTK_TREE_VIEW (widget);
@@ -626,7 +627,20 @@ button_press_callback (GtkWidget      *widget,
         view->details->double_click_path[0] = gtk_tree_path_copy (path);
     }
 
-    if (event->type == GDK_2BUTTON_PRESS)
+    on_star = (g_strcmp0 (gtk_tree_view_column_get_title (column), "Star") == 0 &&
+               !gtk_tree_view_is_blank_at_pos (tree_view,
+                                               event->x,
+                                               event->y,
+                                               NULL,
+                                               NULL,
+                                               NULL,
+                                               NULL));
+
+    if (is_simple_click && click_count <= 0 && on_star)
+    {
+            on_star_cell_renderer_clicked (path, view);
+    }
+    if (event->type == GDK_2BUTTON_PRESS && !on_star)
     {
         /* Double clicking does not trigger a D&D action. */
         view->details->drag_button = 0;
@@ -704,7 +718,7 @@ button_press_callback (GtkWidget      *widget,
                     }
                 }
                 else
-                {
+                    {
                     gtk_tree_selection_select_path (selection, path);
                 }
                 selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
@@ -751,21 +765,6 @@ button_press_callback (GtkWidget      *widget,
         }
     }
 
-    if (is_simple_click &&
-        g_strcmp0 (gtk_tree_view_column_get_title (column), "Star") == 0)
-    {
-        gdouble cell_middle_x;
-
-        cell_middle_x = gtk_tree_view_column_get_width (column) / 2 +
-                        gtk_tree_view_column_get_x_offset (column);
-
-        if (event->x > cell_middle_x - 10 &&
-            event->x < cell_middle_x + 10)
-        {
-            on_star_cell_renderer_clicked (path, view);
-        }
-    }
-
     gtk_tree_path_free (path);
 
     /* We chained to the default handler in this method, so never


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