[nautilus/antonioffix-menus-and-popovers: 2/14] files-view: Reveal file to be renamed



commit f48fe9702a1b60d79f88104d76c6fc2dad435ac8
Author: António Fernandes <antoniof gnome org>
Date:   Sat Jan 6 19:28:34 2018 +0000

    files-view: Reveal file to be renamed
    
    When renaming, if the item is out of view, the popover may pop up
    outside of the window or even outside of the screen.
    
    It is conveninent to see the whole item to be renamed and provide
    a visible target for the popover.
    
    So, reveal selection before popping up a rename popover.
    
    Fixes: https://gitlab.gnome.org/GNOME/nautilus/issues/5

 src/nautilus-files-view.c |  5 +++++
 src/nautilus-list-view.c  | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index e74123a7a..68728683b 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -1948,6 +1948,11 @@ nautilus_files_view_rename_file_popover_new (NautilusFilesView *view,
         return;
     }
 
+    /* Make sure the whole item is visible. The selection is a single item, the
+     * one to rename with the popover, so we can use reveal_selection() for this.
+     */
+    nautilus_files_view_reveal_selection (view);
+
     pointing_to = nautilus_files_view_compute_rename_popover_pointing_to (view);
 
     priv->rename_file_controller =
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 5ceb0c229..8321b7289 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -3708,6 +3708,7 @@ nautilus_list_view_compute_rename_popover_pointing_to (NautilusFilesView *view)
     GList *list;
     GtkTreePath *path;
     GdkRectangle *rect = g_malloc0 (sizeof (GdkRectangle));
+    int header_height;
 
     list_view = NAUTILUS_LIST_VIEW (view);
     tree_view = list_view->details->tree_view;
@@ -3732,6 +3733,24 @@ nautilus_list_view_compute_rename_popover_pointing_to (NautilusFilesView *view)
 
     g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);
 
+    /* FIXME Due to smooth scrolling, we get the cell area while the view is
+     * still scrolling (and still outside the view), not at the final position
+     * of the cell after scrolling.
+     * https://bugzilla.gnome.org/show_bug.cgi?id=746773
+     * The following workaround guesses the final "y" coordinate by clamping it
+     * to the widget edge. Note that the top edge has got columns header, which
+     * is private, so first guess the header height from the difference between
+     * widget coordinates and bin cooridinates.
+     */
+    gtk_tree_view_convert_bin_window_to_widget_coords (tree_view,
+                                                       0, 0,
+                                                       NULL, &header_height);
+
+    rect->y = CLAMP (rect->y,
+                     header_height,
+                     gtk_widget_get_allocated_height (GTK_WIDGET (view)) - rect->height);
+    /* End of workaround */
+
     return rect;
 }
 


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