[nautilus/antonioffix-menus-and-popovers: 28/28] view-icon-controller: Scroll only as necessary to reveal
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/antonioffix-menus-and-popovers: 28/28] view-icon-controller: Scroll only as necessary to reveal
- Date: Tue, 23 Jan 2018 08:25:38 +0000 (UTC)
commit 5ef1d34677d9241ec6bb6a03410032ef9d4d14ec
Author: António Fernandes <antoniof gnome org>
Date: Sat Jan 13 21:43:41 2018 +0000
view-icon-controller: Scroll only as necessary to reveal
Currently we always scroll the item to reveal to the top.
This will scroll the item even if it is already visible
but not in the first row.
Instead, scroll as little as necessary to reveal the whole
item, matching the behavior of list view and canvas view.
src/nautilus-view-icon-controller.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index 211f8fbb2..307fa9f07 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -397,6 +397,7 @@ real_reveal_selection (NautilusFilesView *files_view,
GtkAllocation allocation;
GtkWidget *content_widget;
GtkAdjustment *vadjustment;
+ int view_height;
selection = nautilus_view_get_selection (NAUTILUS_VIEW (files_view));
if (selection == NULL)
@@ -417,8 +418,20 @@ real_reveal_selection (NautilusFilesView *files_view,
gtk_widget_get_allocation (item_ui, &allocation);
content_widget = nautilus_files_view_get_content_widget (files_view);
+ view_height = gtk_widget_get_allocated_height (content_widget);
vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (content_widget));
- gtk_adjustment_set_value (vadjustment, allocation.y);
+
+ /* Scroll only as necessary */
+ if (allocation.y < gtk_adjustment_get_value (vadjustment))
+ {
+ gtk_adjustment_set_value (vadjustment, allocation.y);
+ }
+ else if (allocation.y + allocation.height >
+ gtk_adjustment_get_value (vadjustment) + view_height)
+ {
+ gtk_adjustment_set_value (vadjustment,
+ allocation.y + allocation.height - view_height);
+ }
if (revealed_area)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]