From: Carlos Garcia Campos Date: Thu, 11 Jan 2007 16:58:45 +0000 (+0000) Subject: Use max and min scale values in the view iby taking dpi into account. X-Git-Tag: EVINCE_0_7_2~107 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=fe8ea2226d06f58142a9c192960bc369ac442e20;p=evince.git Use max and min scale values in the view iby taking dpi into account. 2007-01-11 Carlos Garcia Campos * 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 --- diff --git a/ChangeLog b/ChangeLog index 266ab378..758dfbad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-01-11 Carlos Garcia Campos + + * 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 * configure.ac: diff --git a/shell/ev-view-private.h b/shell/ev-view-private.h index ec1fa020..eb7ec726 100644 --- a/shell/ev-view-private.h +++ b/shell/ev-view-private.h @@ -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; diff --git a/shell/ev-view.c b/shell/ev-view.c index 549c2569..7353e7d2 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -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 diff --git a/shell/ev-view.h b/shell/ev-view.h index e6dd3958..ba736ca3 100644 --- a/shell/ev-view.h +++ b/shell/ev-view.h @@ -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, diff --git a/shell/ev-window.c b/shell/ev-window.c index ffbc1f0c..ba8de920 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -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",