]> www.fi.muni.cz Git - evince.git/commitdiff
[libview] Keep our own GtkRequisition and use it to set adjusment values
authorCarlos Garcia Campos <carlosgc@gnome.org>
Sun, 9 May 2010 10:58:39 +0000 (12:58 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 10 May 2010 11:58:30 +0000 (13:58 +0200)
libview/ev-view-private.h
libview/ev-view.c

index f5368be55d696e790686b9b44783895ab7a21ff0..01e260b8cc1584cbffe4e7166e8426ae98944e1f 100644 (file)
@@ -125,6 +125,9 @@ struct _EvView {
        EvViewCursor cursor;
        EvJobRender *current_job;
 
+       GtkRequisition requisition;
+       gboolean       internal_size_request;
+
        /* Scrolling */
        GtkAdjustment *hadjustment;
        GtkAdjustment *vadjustment;
index ac8b9498c73e0f9c30fd59170136998262e992aa..c766dd27f59b1b06cd47d81c2958aafae4378c36 100644 (file)
@@ -465,12 +465,12 @@ ev_view_get_scrollbar_size (EvView        *view,
                return 0;
 
        if (orientation == GTK_ORIENTATION_VERTICAL) {
-               if (widget->allocation.height >= widget->requisition.height)
+               if (widget->allocation.height >= view->requisition.height)
                        sb = gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (swindow));
                else
                        return 0;
        } else {
-               if (widget->allocation.width >= widget->requisition.width)
+               if (widget->allocation.width >= view->requisition.width)
                        sb = gtk_scrolled_window_get_hscrollbar (GTK_SCROLLED_WINDOW (swindow));
                else
                        return 0;
@@ -555,11 +555,11 @@ view_set_adjustment_values (EvView         *view,
        gint new_value;
 
        if (orientation == GTK_ORIENTATION_HORIZONTAL)  {
-               requisition = widget->requisition.width;
+               requisition = view->requisition.width;
                allocation = widget->allocation.width;
                adjustment = view->hadjustment;
        } else {
-               requisition = widget->requisition.height;
+               requisition = view->requisition.height;
                allocation = widget->allocation.height;
                adjustment = view->vadjustment;
        }
@@ -2835,19 +2835,35 @@ ev_view_size_request (GtkWidget      *widget,
        EvView *view = EV_VIEW (widget);
        
        if (view->document == NULL) {
-               requisition->width = 1;
-               requisition->height = 1;
+               view->requisition.width = 1;
+               view->requisition.height = 1;
+
+               *requisition = view->requisition;
+
                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_BEST_FIT)) {
+               ev_view_zoom_for_size (view,
+                                      widget->allocation.width,
+                                      widget->allocation.height);
+       }
+
        if (view->continuous && view->dual_page)
-               ev_view_size_request_continuous_dual_page (view, requisition);
+               ev_view_size_request_continuous_dual_page (view, &view->requisition);
        else if (view->continuous)
-               ev_view_size_request_continuous (view, requisition);
+               ev_view_size_request_continuous (view, &view->requisition);
        else if (view->dual_page)
-               ev_view_size_request_dual_page (view, requisition);
+               ev_view_size_request_dual_page (view, &view->requisition);
        else
-               ev_view_size_request_single_page (view, requisition);
+               ev_view_size_request_single_page (view, &view->requisition);
+
+       *requisition = view->requisition;
 }
 
 static void
@@ -2862,10 +2878,14 @@ ev_view_size_allocate (GtkWidget      *widget,
        
        if (view->sizing_mode == EV_SIZING_FIT_WIDTH ||
            view->sizing_mode == EV_SIZING_BEST_FIT) {
+               GtkRequisition req;
+
                ev_view_zoom_for_size (view,
                                       allocation->width,
                                       allocation->height);
-               ev_view_size_request (widget, &widget->requisition);
+               view->internal_size_request = TRUE;
+               ev_view_size_request (widget, &req);
+               view->internal_size_request = FALSE;
        }
        
        view_set_adjustment_values (view, GTK_ORIENTATION_HORIZONTAL);