From 0ffd0f07ed24fe71b88dc3cda30f944e4407fac0 Mon Sep 17 00:00:00 2001 From: "Nickolay V. Shmyrev" Date: Sun, 22 May 2005 15:09:31 +0000 Subject: [PATCH] Fix minor points related to moving best fit up. Introduce "zoom" property and make zoom control change it's value on notify::zoom signals. Fix for 305080. --- ChangeLog | 15 ++++++++++ cut-n-paste/zoom-control/ephy-zoom.c | 2 +- cut-n-paste/zoom-control/ephy-zoom.h | 2 +- shell/ev-view.c | 42 +++++++++++++++++++++------- shell/ev-window.c | 17 +++++++++-- 5 files changed, 63 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a2df4d6..69bc2721 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-05-22 Nickolay V. Shmyrev + + * cut-n-paste/zoom-control/ephy-zoom.c: + (ephy_zoom_get_changed_zoom_level): + * cut-n-paste/zoom-control/ephy-zoom.h: + * shell/ev-view.c: (ev_view_scroll_event), (ev_view_set_property), + (ev_view_get_property), (ev_view_class_init), (ev_view_set_zoom): + * shell/ev-window.c: (ev_window_cmd_view_zoom_in), + (ev_window_cmd_view_zoom_out), (ev_window_zoom_changed_cb), + (zoom_control_changed_cb), (ev_window_init): + + Fix minor points related to moving best fit up. Introduce + "zoom" property and make zoom control change it's value on + notify::zoom signals. Fix for 305080. + 2005-05-22 Nickolay V. Shmyrev * data/evince-ui.xml: diff --git a/cut-n-paste/zoom-control/ephy-zoom.c b/cut-n-paste/zoom-control/ephy-zoom.c index ee917846..34e25ec5 100644 --- a/cut-n-paste/zoom-control/ephy-zoom.c +++ b/cut-n-paste/zoom-control/ephy-zoom.c @@ -59,7 +59,7 @@ ephy_zoom_get_changed_zoom_level (float level, gint steps) guint index; index = ephy_zoom_get_zoom_level_index (level); - return zoom_levels[CLAMP(index + steps, 0, n_zoom_levels - 1)].level; + return zoom_levels[CLAMP(index + steps, 3, n_zoom_levels - 1)].level; } float ephy_zoom_get_nearest_zoom_level (float level) diff --git a/cut-n-paste/zoom-control/ephy-zoom.h b/cut-n-paste/zoom-control/ephy-zoom.h index 5632b4ff..e8fb52ad 100644 --- a/cut-n-paste/zoom-control/ephy-zoom.h +++ b/cut-n-paste/zoom-control/ephy-zoom.h @@ -61,7 +61,7 @@ zoom_levels[] = static const guint n_zoom_levels = G_N_ELEMENTS (zoom_levels); #define ZOOM_MINIMAL (EPHY_ZOOM_SEPARATOR) -#define ZOOM_MAXIMAL (zoom_levels[n_zoom_levels - 4].level) +#define ZOOM_MAXIMAL (zoom_levels[n_zoom_levels - 1].level) #define ZOOM_IN (-1.0) #define ZOOM_OUT (-2.0) diff --git a/shell/ev-view.c b/shell/ev-view.c index ef0ddf48..9f66d8ac 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -49,6 +49,7 @@ enum { PROP_FULLSCREEN, PROP_PRESENTATION, PROP_SIZING_MODE, + PROP_ZOOM, }; enum { @@ -86,7 +87,7 @@ typedef enum { #define ZOOM_OUT_FACTOR (1.0/ZOOM_IN_FACTOR) #define MIN_SCALE 0.05409 -#define MAX_SCALE 6.0 +#define MAX_SCALE 4.0 typedef struct { EvRectangle rect; @@ -1303,14 +1304,16 @@ ev_view_scroll_event (GtkWidget *widget, GdkEventScroll *event) ev_view_set_sizing_mode (view, EV_SIZING_FREE); - if ((event->direction == GDK_SCROLL_UP || - event->direction == GDK_SCROLL_LEFT) && - ev_view_can_zoom_in (view)) { - ev_view_zoom_in (view); - } else if (ev_view_can_zoom_out (view)) { - ev_view_zoom_out (view); - } - + if (event->direction == GDK_SCROLL_UP || + event->direction == GDK_SCROLL_LEFT) { + if (ev_view_can_zoom_in (view)) { + ev_view_zoom_in (view); + } + } else { + if (ev_view_can_zoom_out (view)) { + ev_view_zoom_out (view); + } + } return TRUE; } @@ -1712,6 +1715,9 @@ ev_view_set_property (GObject *object, case PROP_SIZING_MODE: ev_view_set_sizing_mode (view, g_value_get_enum (value)); break; + case PROP_ZOOM: + ev_view_set_zoom (view, g_value_get_double (value), FALSE); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -1748,6 +1754,9 @@ ev_view_get_property (GObject *object, case PROP_SIZING_MODE: g_value_set_enum (value, view->sizing_mode); break; + case PROP_ZOOM: + g_value_set_double (value, view->scale); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -1863,6 +1872,16 @@ ev_view_class_init (EvViewClass *class) EV_SIZING_FIT_WIDTH, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_ZOOM, + g_param_spec_double ("zoom", + "Zoom factor", + "Zoom factor", + MIN_SCALE, + MAX_SCALE, + 1.0, + G_PARAM_READWRITE)); + binding_set = gtk_binding_set_by_class (class); add_scroll_binding_keypad (binding_set, GDK_Left, GTK_SCROLL_STEP_BACKWARD, TRUE); @@ -2008,10 +2027,13 @@ ev_view_set_zoom (EvView *view, if (ABS (view->scale - scale) < EPSILON) return; + view->scale = scale; view->pending_resize = TRUE; - + gtk_widget_queue_resize (GTK_WIDGET (view)); + + g_object_notify (G_OBJECT (view), "zoom"); } double diff --git a/shell/ev-window.c b/shell/ev-window.c index 761599e1..4671e4ed 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -158,6 +158,9 @@ static gboolean start_loading_document (EvWindow *ev_wi static void ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec, EvWindow *ev_window); +static void ev_window_zoom_changed_cb (EvView *view, + GParamSpec *pspec, + EvWindow *ev_window); static void ev_window_add_recent (EvWindow *window, const char *filename); static void ev_window_fullscreen (EvWindow *window); @@ -1726,7 +1729,6 @@ ev_window_cmd_view_zoom_in (GtkAction *action, EvWindow *ev_window) ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE); ev_view_zoom_in (EV_VIEW (ev_window->priv->view)); - update_action_sensitivity (ev_window); } static void @@ -1736,7 +1738,6 @@ ev_window_cmd_view_zoom_out (GtkAction *action, EvWindow *ev_window) ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE); ev_view_zoom_out (EV_VIEW (ev_window->priv->view)); - update_action_sensitivity (ev_window); } static void @@ -1923,6 +1924,13 @@ ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec, update_sizing_buttons (ev_window); } +static void +ev_window_zoom_changed_cb (EvView *view, GParamSpec *pspec, + EvWindow *ev_window) +{ + update_action_sensitivity (ev_window); +} + static char * build_comments_string (void) { @@ -2233,7 +2241,6 @@ zoom_control_changed_cb (EphyZoomAction *action, } ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), mode); - update_action_sensitivity (ev_window); } static void @@ -2881,6 +2888,10 @@ ev_window_init (EvWindow *ev_window) "notify::sizing-mode", G_CALLBACK (ev_window_sizing_mode_changed_cb), ev_window); + g_signal_connect (ev_window->priv->view, + "notify::zoom", + G_CALLBACK (ev_window_zoom_changed_cb), + ev_window); ev_window->priv->statusbar = gtk_statusbar_new (); gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box), -- 2.43.5