[evince/wip/gpoo/gtk4-rebase-port: 87/89] libview: Fix EvView start up page position




commit ad38078afe2f5a756d70544085cab67140031248
Author: Qiu Wenbo <qiuwenbo kylinos com cn>
Date:   Sat Dec 11 16:47:34 2021 +0800

    libview: Fix EvView start up page position
    
    Before this patch, Evince will jump to the end page when open a new PDF documentat the first time.
    
    Signed-off-by: Qiu Wenbo <qiuwenbo kylinos com cn>

 libview/ev-view.c | 36 +++++++++++++-----------------------
 1 file changed, 13 insertions(+), 23 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 1719366a9..aab8f9708 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -612,6 +612,9 @@ ev_view_scroll_to_page_position (EvView *view, GtkOrientation orientation)
                ev_view_get_page_extents (view, view->current_page, &page_area, &border);
                x = page_area.x;
                y = page_area.y;
+
+               if (view->current_page == 0)
+                       y = 0.;
        } else {
                GdkPoint view_point;
 
@@ -626,7 +629,9 @@ ev_view_scroll_to_page_position (EvView *view, GtkOrientation orientation)
 
 static void
 ev_view_set_adjustment_values (EvView         *view,
-                              GtkOrientation  orientation)
+                              GtkOrientation  orientation,
+                              int             width,
+                              int             height)
 {
        GtkWidget *widget = GTK_WIDGET (view);
        GtkAdjustment *adjustment;
@@ -869,7 +874,6 @@ ev_view_set_scroll_adjustment (EvView         *view,
                          G_CALLBACK (on_adjustment_value_changed),
                          view);
        *to_set = g_object_ref_sink (adjustment);
-       ev_view_set_adjustment_values (view, orientation);
 
        g_object_notify (G_OBJECT (view), prop_name);
 }
@@ -4342,21 +4346,6 @@ ev_view_size_request (GtkWidget      *widget,
                return;
        }
 
-       /* Get zoom for size here when not called from
-        * ev_view_size_allocate()
-        */
-       if (!view->internal_size_request &&
-           (view->sizing_mode == EV_SIZING_FIT_WIDTH ||
-            view->sizing_mode == EV_SIZING_FIT_PAGE ||
-            view->sizing_mode == EV_SIZING_AUTOMATIC)) {
-               GtkAllocation allocation;
-
-               gtk_widget_get_allocation (widget, &allocation);
-               ev_view_zoom_for_size (view,
-                                      allocation.width,
-                                      allocation.height);
-       }
-
        dual_page = is_dual_page (view, NULL);
        if (view->continuous && dual_page)
                ev_view_size_request_continuous_dual_page (view, &view->requisition);
@@ -4412,11 +4401,10 @@ ev_view_size_allocate (GtkWidget      *widget,
                view->internal_size_request = FALSE;
        }
 
-       ev_view_set_adjustment_values (view, GTK_ORIENTATION_HORIZONTAL);
-       ev_view_set_adjustment_values (view, GTK_ORIENTATION_VERTICAL);
+       ev_view_set_adjustment_values (view, GTK_ORIENTATION_HORIZONTAL, width, height);
+       ev_view_set_adjustment_values (view, GTK_ORIENTATION_VERTICAL, width, height);
 
-       if (view->document)
-               view_update_range_and_current_page (view);
+       view_update_range_and_current_page (view);
 
        view->pending_scroll = SCROLL_TO_KEEP_POSITION;
        view->pending_resize = FALSE;
@@ -8102,7 +8090,7 @@ ev_view_init (EvView *view)
        view->end_page = -1;
        view->spacing = 14;
        view->scale = 1.0;
-       view->current_page = 0;
+       view->current_page = -1;
        view->pressed_button = -1;
        view->cursor = EV_VIEW_CURSOR_NORMAL;
        view->drag_info.in_drag = FALSE;
@@ -8114,7 +8102,9 @@ ev_view_init (EvView *view)
        view->fullscreen = FALSE;
        view->sizing_mode = EV_SIZING_FIT_WIDTH;
        view->page_layout = EV_PAGE_LAYOUT_SINGLE;
-       view->pending_scroll = SCROLL_TO_KEEP_POSITION;
+       view->pending_scroll = SCROLL_TO_PAGE_POSITION;
+       view->pending_point.x = 0;
+       view->pending_point.y = 0;
        view->find_page = -1;
        view->jump_to_find_result = TRUE;
        view->highlight_find_results = FALSE;


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