[nautilus/antonioffix-menus-and-popovers: 26/26] view-icon-controller: Scroll only as necessary to reveal
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/antonioffix-menus-and-popovers: 26/26] view-icon-controller: Scroll only as necessary to reveal
- Date: Sat, 13 Jan 2018 23:28:15 +0000 (UTC)
commit 95aa0a5a2dd407af259af88f27df102adb9564a2
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 | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index e1eed1826..07d3b039a 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -394,7 +394,7 @@ real_reveal_selection (NautilusFilesView *files_view,
g_autoptr (GList) selection;
NautilusViewIconController *self = NAUTILUS_VIEW_ICON_CONTROLLER (files_view);
GtkWidget *item_ui;
- GtkAllocation allocation;
+ GtkAllocation item_allocation, view_allocation;
GtkWidget *content_widget;
GtkAdjustment *vadjustment;
@@ -415,17 +415,29 @@ real_reveal_selection (NautilusFilesView *files_view,
item_ui = GTK_WIDGET (list->data);
}
- gtk_widget_get_allocation (item_ui, &allocation);
+ gtk_widget_get_allocation (item_ui, &item_allocation);
content_widget = nautilus_files_view_get_content_widget (files_view);
+ gtk_widget_get_allocation (content_widget, &view_allocation);
vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (content_widget));
- gtk_adjustment_set_value (vadjustment, allocation.y);
+
+ /* Scroll only as necessary */
+ if (item_allocation.y < gtk_adjustment_get_value (vadjustment))
+ {
+ gtk_adjustment_set_value (vadjustment, item_allocation.y);
+ }
+ else if (item_allocation.y + item_allocation.height >
+ gtk_adjustment_get_value (vadjustment) + view_allocation.height)
+ {
+ gtk_adjustment_set_value (vadjustment,
+ item_allocation.y + item_allocation.height - view_allocation.height);
+ }
if (revealed_area)
{
- revealed_area->x = allocation.x;
- revealed_area->y = allocation.y - gtk_adjustment_get_value (vadjustment);
- revealed_area->width = allocation.width;
- revealed_area->height = allocation.height;
+ revealed_area->x = item_allocation.x;
+ revealed_area->y = item_allocation.y - gtk_adjustment_get_value (vadjustment);
+ revealed_area->width = item_allocation.width;
+ revealed_area->height = item_allocation.height;
}
g_list_foreach (selection, (GFunc) g_object_unref, NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]