[nautilus/antonioffix-menus-and-popovers: 6/13] files-view: Reveal selection for rename popover/context menu
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/antonioffix-menus-and-popovers: 6/13] files-view: Reveal selection for rename popover/context menu
- Date: Sun, 14 Jan 2018 17:47:07 +0000 (UTC)
commit 1f656746f8ee083b4aca1ca528b66e46e87ef725
Author: António Fernandes <antoniof gnome org>
Date: Mon Jan 8 00:59:52 2018 +0000
files-view: Reveal selection for rename popover/context menu
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 item to be renamed and provide a
visible target for the popover. The same is true for context
menus.
So, reveal selection before popping up a popover or context menu.
Fixes: https://gitlab.gnome.org/GNOME/nautilus/issues/5
src/nautilus-files-view.c | 12 +++++++-----
src/nautilus-list-view.c | 19 +++++++++++++++++++
2 files changed, 26 insertions(+), 5 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index dc4a35366..56693bb60 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -1946,6 +1946,8 @@ nautilus_files_view_rename_file_popover_new (NautilusFilesView *view,
return;
}
+ nautilus_files_view_reveal_selection (view);
+
pointing_to = nautilus_files_view_get_rectangle_for_popup (view);
priv->rename_file_controller =
@@ -8127,12 +8129,12 @@ nautilus_files_view_pop_up_selection_context_menu (NautilusFilesView *view,
if (!event)
{
- /* If triggered from the keyboard, popup at selection, not pointer */
+ /* It was triggered from the keyboard, so we need to popup at selection,
+ * not pointer. But first make sure the selection is scrolled into view.
+ */
+ nautilus_files_view_reveal_selection (view);
+
rectangle = nautilus_files_view_get_rectangle_for_popup (view);
- /* Don't popup from outside the view area */
- rectangle->y = CLAMP (rectangle->y,
- 0 - rectangle->height,
- gtk_widget_get_allocated_height (GTK_WIDGET (view)));
}
nautilus_pop_up_context_menu (GTK_WIDGET (view), priv->selection_menu, event, rectangle);
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index eb17d2b37..65d275989 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -3710,6 +3710,7 @@ nautilus_list_view_get_rectangle_for_popup (NautilusFilesView *view)
GtkTreeView *tree_view;
GList *list;
NautilusListView *list_view;
+ int header_h;
rect = g_malloc0 (sizeof (GdkRectangle));
list_view = NAUTILUS_LIST_VIEW (view);
@@ -3731,6 +3732,24 @@ nautilus_list_view_get_rectangle_for_popup (NautilusFilesView *view)
g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);
+ /* Workaround to https://bugzilla.gnome.org/show_bug.cgi?id=746773
+ * In short: 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.
+ * This 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,
+ NULL, 0,
+ NULL, &header_h);
+
+ rect->y = CLAMP (rect->y,
+ header_h,
+ gtk_widget_get_allocated_height (GTK_WIDGET (view)) - rect->height);
+ /* End of workaroud */
+
return rect;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]