]> www.fi.muni.cz Git - evince.git/commitdiff
Fix normal size zoom. Make zoom in/zoom out unsensitive when they are
authorMarco Pesenti Gritti <mpg@redhat.com>
Fri, 22 Apr 2005 09:46:25 +0000 (09:46 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Fri, 22 Apr 2005 09:46:25 +0000 (09:46 +0000)
2005-04-22  Marco Pesenti Gritti <mpg@redhat.com>

        * 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
shell/ev-view.c
shell/ev-view.h
shell/ev-window.c

index 3cd403d34666c7413c4a6d46172c589b1aaa0013..fbff7cdb50cbf7cdc62cba6251ff6efe2d0653bf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2005-04-22  Marco Pesenti Gritti <mpg@redhat.com>
+
+       * 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 <mpg@redhat.com>
 
        * configure.ac:
index cca39477c4fdb6fdce5460d7ba5bd5cad6c0ce4f..796aaddbc7b8473a3a7e2406d528ea82f01c2ce1 100644 (file)
@@ -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,
index daa871fc528a68ddf834f00e4813eb4d6050d956..a10f0bc3497288e9edbcf290afa2844044dc3624 100644 (file)
@@ -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);
index e45d485608e509ddd3612280ab0dad8d41f13237..38bbdca6bad517637cc7d96a7e6f08a89473d5d6 100644 (file)
@@ -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