From a6e6d94bd65dd562a9e802b7a27aa71f8e4ad160 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 22 Apr 2005 09:46:25 +0000 Subject: [PATCH] Fix normal size zoom. Make zoom in/zoom out unsensitive when they are 2005-04-22 Marco Pesenti Gritti * shell/ev-view.c: (ev_view_can_zoom_in), (ev_view_can_zoom_out), (ev_view_zoom_out), (ev_view_zoom_normal): * shell/ev-view.h: * shell/ev-window.c: (update_action_sensitivity), (ev_window_cmd_view_best_fit), (ev_window_cmd_view_page_width), (ev_window_cmd_view_zoom_in), (ev_window_cmd_view_zoom_out), (ev_window_cmd_view_normal_size): Fix normal size zoom. Make zoom in/zoom out unsensitive when they are behyond the limits. Tweak MAX_ZOOM to 6, sucks but better than oom. --- ChangeLog | 14 ++++++++++++++ shell/ev-view.c | 28 +++++++++++++++++++++++++++- shell/ev-view.h | 3 +++ shell/ev-window.c | 19 +++++++++++++------ 4 files changed, 57 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3cd403d3..fbff7cdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-04-22 Marco Pesenti Gritti + + * shell/ev-view.c: (ev_view_can_zoom_in), (ev_view_can_zoom_out), + (ev_view_zoom_out), (ev_view_zoom_normal): + * shell/ev-view.h: + * shell/ev-window.c: (update_action_sensitivity), + (ev_window_cmd_view_best_fit), (ev_window_cmd_view_page_width), + (ev_window_cmd_view_zoom_in), (ev_window_cmd_view_zoom_out), + (ev_window_cmd_view_normal_size): + + Fix normal size zoom. Make zoom in/zoom out unsensitive when + they are behyond the limits. Tweak MAX_ZOOM to 6, sucks but + better than oom. + 2005-04-22 Marco Pesenti Gritti * configure.ac: diff --git a/shell/ev-view.c b/shell/ev-view.c index cca39477..796aaddb 100644 --- a/shell/ev-view.c +++ b/shell/ev-view.c @@ -77,7 +77,7 @@ typedef enum { #define ZOOM_OUT_FACTOR (1.0/ZOOM_IN_FACTOR) #define MIN_SCALE 0.05409 -#define MAX_SCALE 18.4884 +#define MAX_SCALE 6.0 struct _EvView { GtkWidget parent_instance; @@ -1597,6 +1597,26 @@ ev_view_zoom (EvView *view, gtk_widget_queue_resize (GTK_WIDGET (view)); } +gboolean +ev_view_can_zoom_in (EvView *view) +{ + if (view->width != -1 || view->height != -1) { + return TRUE; + } + + return view->scale * ZOOM_IN_FACTOR <= MAX_SCALE; +} + +gboolean +ev_view_can_zoom_out (EvView *view) +{ + if (view->width != -1 || view->height != -1) { + return TRUE; + } + + return view->scale * ZOOM_OUT_FACTOR >= MIN_SCALE; +} + void ev_view_zoom_in (EvView *view) { @@ -1609,6 +1629,12 @@ ev_view_zoom_out (EvView *view) ev_view_zoom (view, ZOOM_OUT_FACTOR, TRUE); } +void +ev_view_zoom_normal (EvView *view) +{ + ev_view_zoom (view, 1.0, FALSE); +} + void ev_view_set_size (EvView *view, int width, diff --git a/shell/ev-view.h b/shell/ev-view.h index daa871fc..a10f0bc3 100644 --- a/shell/ev-view.h +++ b/shell/ev-view.h @@ -44,8 +44,11 @@ void ev_view_copy (EvView *view); void ev_view_select_all (EvView *view); /* Page size */ +gboolean ev_view_can_zoom_in (EvView *view); void ev_view_zoom_in (EvView *view); +gboolean ev_view_can_zoom_out (EvView *view); void ev_view_zoom_out (EvView *view); +void ev_view_zoom_normal (EvView *view); void ev_view_set_size (EvView *view, int width, int height); diff --git a/shell/ev-window.c b/shell/ev-window.c index e45d4856..38bbdca6 100644 --- a/shell/ev-window.c +++ b/shell/ev-window.c @@ -173,11 +173,13 @@ set_action_sensitive (EvWindow *ev_window, static void update_action_sensitivity (EvWindow *ev_window) { + EvView *view; EvDocument *document; EvWindowPageMode page_mode; gboolean sensitive, has_pages = FALSE, has_document; int n_pages = 0, page = -1; + view = EV_VIEW (ev_window->priv->view); document = ev_window->priv->document; page_mode = ev_window->priv->page_mode; has_document = document != NULL; @@ -201,11 +203,13 @@ update_action_sensitivity (EvWindow *ev_window) set_action_sensitive (ev_window, "EditFind", has_pages && EV_IS_DOCUMENT_FIND (document)); set_action_sensitive (ev_window, "EditFindNext", - ev_view_can_find_next (EV_VIEW (ev_window->priv->view))); + ev_view_can_find_next (view)); /* View menu */ - set_action_sensitive (ev_window, "ViewZoomIn", has_pages); - set_action_sensitive (ev_window, "ViewZoomOut", has_pages); + set_action_sensitive (ev_window, "ViewZoomIn", + has_pages && ev_view_can_zoom_in (view)); + set_action_sensitive (ev_window, "ViewZoomOut", + has_pages && ev_view_can_zoom_out (view)); set_action_sensitive (ev_window, "ViewNormalSize", has_pages); set_action_sensitive (ev_window, "ViewBestFit", has_pages); set_action_sensitive (ev_window, "ViewPageWidth", has_pages); @@ -306,6 +310,7 @@ ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window) } else { ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE); } + update_action_sensitivity (ev_window); } static void @@ -316,6 +321,7 @@ ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window) } else { ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE); } + update_action_sensitivity (ev_window); } static void @@ -1480,8 +1486,8 @@ ev_window_cmd_view_zoom_in (GtkAction *action, EvWindow *ev_window) g_return_if_fail (EV_IS_WINDOW (ev_window)); ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE); - ev_view_zoom_in (EV_VIEW (ev_window->priv->view)); + update_action_sensitivity (ev_window); } static void @@ -1490,8 +1496,8 @@ ev_window_cmd_view_zoom_out (GtkAction *action, EvWindow *ev_window) g_return_if_fail (EV_IS_WINDOW (ev_window)); ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE); - ev_view_zoom_out (EV_VIEW (ev_window->priv->view)); + update_action_sensitivity (ev_window); } static void @@ -1499,7 +1505,8 @@ ev_window_cmd_view_normal_size (GtkAction *action, EvWindow *ev_window) { g_return_if_fail (EV_IS_WINDOW (ev_window)); - ev_view_set_size (EV_VIEW (ev_window->priv->view), -1, -1); + ev_view_zoom_normal (EV_VIEW (ev_window->priv->view)); + update_action_sensitivity (ev_window); } static void -- 2.43.5