]> www.fi.muni.cz Git - evince.git/commitdiff
Use max and min scale values in the view iby taking dpi into account.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Thu, 11 Jan 2007 16:58:45 +0000 (16:58 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Thu, 11 Jan 2007 16:58:45 +0000 (16:58 +0000)
2007-01-11  Carlos Garcia Campos  <carlosgc@gnome.org>
* shell/ev-view-private.h:
* shell/ev-window.c: (ev_window_screen_changed), (ev_window_init):
* shell/ev-view.[ch]: (ev_view_class_init), (ev_view_set_zoom),
(ev_view_set_screen_dpi), (ev_view_can_zoom_in),
(ev_view_can_zoom_out):
Use max and min scale values in the view iby taking dpi into account.

svn path=/trunk/; revision=2214

ChangeLog
shell/ev-view-private.h
shell/ev-view.c
shell/ev-view.h
shell/ev-window.c

index 266ab378c311c19b64cb6a66c6ef06cc8866f55f..758dfbad6f64426ff460f0bcef1ae0f5fba247a7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2007-01-11  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * shell/ev-view-private.h:
+       * shell/ev-window.c: (ev_window_screen_changed), (ev_window_init):
+       * shell/ev-view.[ch]: (ev_view_class_init), (ev_view_set_zoom),
+       (ev_view_set_screen_dpi), (ev_view_can_zoom_in),
+       (ev_view_can_zoom_out):
+
+       Use max and min scale values in the view iby taking dpi into account. 
+
 2007-01-10  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * configure.ac:
index ec1fa020f16bc8a3ea384011ae0a5ecebc4a14ae..eb7ec7269e7eeb6680fc0db1682ae39e54231425 100644 (file)
@@ -104,9 +104,12 @@ struct _EvView {
        gint end_page;
        gint current_page;
 
-       int rotation;
-       double scale;
-       int spacing;
+       gint rotation;
+       gdouble scale;
+       gint spacing;
+       gdouble dpi;
+       gdouble max_scale;
+       gdouble min_scale;
 
        gboolean loading;
        gboolean continuous;
index 549c25694d17b359f89bf6b8d60005fa940a4990..7353e7d2d659331d49e947425fbeafc1f6fc4d1f 100644 (file)
@@ -3252,20 +3252,20 @@ ev_view_class_init (EvViewClass *class)
                                         PROP_ZOOM,
                                         g_param_spec_double ("zoom",
                                                              "Zoom factor",
-                                                              "Zoom factor",
-                                                              MIN_SCALE,
-                                                              MAX_SCALE,
-                                                              1.0,
-                                                              G_PARAM_READWRITE));
+                                                             "Zoom factor",
+                                                             0,
+                                                             G_MAXDOUBLE,
+                                                             1.0,
+                                                             G_PARAM_READWRITE));
        g_object_class_install_property (object_class,
                                         PROP_ROTATION,
                                         g_param_spec_double ("rotation",
                                                              "Rotation",
-                                                              "Rotation",
-                                                              0,
-                                                              360,
-                                                              0,
-                                                              G_PARAM_READWRITE));
+                                                             "Rotation",
+                                                             0,
+                                                             360,
+                                                             0,
+                                                             G_PARAM_READWRITE));
        g_object_class_install_property (object_class,
                                         PROP_HAS_SELECTION,
                                         g_param_spec_boolean ("has-selection",
@@ -3493,7 +3493,7 @@ ev_view_set_zoom (EvView   *view,
        else
                scale = factor;
 
-       scale = CLAMP (scale, MIN_SCALE, MAX_SCALE);
+       scale = CLAMP (scale, view->min_scale, view->max_scale);
 
        if (ABS (view->scale - scale) < EPSILON)
                return;
@@ -3512,6 +3512,18 @@ ev_view_get_zoom (EvView *view)
        return view->scale;
 }
 
+void
+ev_view_set_screen_dpi (EvView  *view,
+                       gdouble  dpi)
+{
+       g_return_if_fail (EV_IS_VIEW (view));
+       g_return_if_fail (dpi > 0);
+
+       view->dpi = dpi;
+       view->min_scale = MIN_SCALE * dpi / 72.0;
+       view->max_scale = MAX_SCALE * dpi / 72.0;
+}
+
 gboolean
 ev_view_get_continuous (EvView *view)
 {
@@ -3704,13 +3716,13 @@ ev_view_get_sizing_mode (EvView *view)
 gboolean
 ev_view_can_zoom_in (EvView *view)
 {
-       return view->scale * ZOOM_IN_FACTOR <= MAX_SCALE;
+       return view->scale * ZOOM_IN_FACTOR <= view->max_scale;
 }
 
 gboolean
 ev_view_can_zoom_out (EvView *view)
 {
-       return view->scale * ZOOM_OUT_FACTOR >= MIN_SCALE;
+       return view->scale * ZOOM_OUT_FACTOR >= view->min_scale;
 }
 
 void
index e6dd3958486fcd410c38111a0813d9f66278d52f..ba736ca39d24054aea6898ae2a3c50bec7044a45 100644 (file)
@@ -112,6 +112,8 @@ void                ev_view_set_zoom_for_size (EvView         *view,
                                           int             height,
                                           int             vsb_width,
                                           int             hsb_height);
+void            ev_view_set_screen_dpi    (EvView         *view,
+                                          gdouble         dpi);
 void           ev_view_rotate_left       (EvView         *view);
 void            ev_view_rotate_right      (EvView         *view);
 void            ev_view_set_rotation      (EvView         *view,
index ffbc1f0c9c6d38509333ad81ca7b1fd1a527460f..ba8de920e667def9a030dd6482e2c1bdb67a6467 100644 (file)
@@ -2717,6 +2717,9 @@ ev_window_screen_changed (GtkWidget *widget,
                                  window);
 #endif
        
+       ev_view_set_screen_dpi (EV_VIEW (window->priv->view),
+                               ev_window_get_screen_dpi (window));
+       
        if (GTK_WIDGET_CLASS (ev_window_parent_class)->screen_changed) {
                GTK_WIDGET_CLASS (ev_window_parent_class)->screen_changed (widget, old_screen);
        }
@@ -4663,6 +4666,8 @@ ev_window_init (EvWindow *ev_window)
                        ev_window->priv->scrolled_window);
 
        ev_window->priv->view = ev_view_new ();
+       ev_view_set_screen_dpi (EV_VIEW (ev_window->priv->view),
+                               ev_window_get_screen_dpi (ev_window));
        ev_window->priv->password_view = ev_password_view_new ();
        g_signal_connect_swapped (ev_window->priv->password_view,
                                  "unlock",