]> www.fi.muni.cz Git - evince.git/commitdiff
Horizontal scroll and zooming with mouse wheel
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Sun, 24 Apr 2005 20:40:54 +0000 (20:40 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Sun, 24 Apr 2005 20:40:54 +0000 (20:40 +0000)
ChangeLog
shell/ev-view.c
shell/ev-window.c

index d3cb732713075072ff2f9fcacd54a6cf1c8c7c67..32b223ee824473fc94bc141b106f0fd2baa23aa9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2005-04-25  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * shell/ev-view.c: (ev_view_scroll_event), (ev_view_class_init),
+       (ev_view_set_sizing_mode),
+       (ev_view_zoom_for_size_continuous_and_dual_page),
+       (ev_view_zoom_for_size_continuous):
+       * shell/ev-window.c: (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_sizing_mode_changed_cb),
+       (ev_window_init):
+
+       Control + Scroll does zooming, Shift + Scroll scrolls horizontally
+       Fix for 165473 and 165472.
+
 2005-04-24  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
 
        * po/POTFILES.in:
index 851b5e4d42b08d8772f6974bdf999748370df2e6..ef7d299655bb30d7d38cd1388ffb8985f4d00e6b 100644 (file)
@@ -653,6 +653,37 @@ ev_view_unrealize (GtkWidget *widget)
        GTK_WIDGET_CLASS (ev_view_parent_class)->unrealize (widget);
 }
 
+static gboolean
+ev_view_scroll_event (GtkWidget *widget, GdkEventScroll *event)
+{
+       EvView *view = EV_VIEW (widget); 
+
+       if ((event->state & GDK_CONTROL_MASK) != 0) {   
+
+                ev_view_set_sizing_mode (view, EV_SIZING_FREE);         
+
+                if ((event->direction == GDK_SCROLL_DOWN || 
+                       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);
+                }               
+
+                return TRUE;
+       }
+       
+       if ((event->state & GDK_SHIFT_MASK) != 0) {     
+               if (event->direction == GDK_SCROLL_UP)
+                       event->direction = GDK_SCROLL_LEFT;
+               if (event->direction == GDK_SCROLL_DOWN)
+                       event->direction = GDK_SCROLL_RIGHT;
+       }
+
+       return FALSE;
+}
+
+
 #if 0
 static guint32
 ev_gdk_color_to_rgb (const GdkColor *color)
@@ -1594,6 +1625,7 @@ ev_view_class_init (EvViewClass *class)
        widget_class->size_allocate = ev_view_size_allocate;
        widget_class->realize = ev_view_realize;
        widget_class->unrealize = ev_view_unrealize;
+       widget_class->scroll_event = ev_view_scroll_event;
        gtk_object_class->destroy = ev_view_destroy;
 
        class->set_scroll_adjustments = ev_view_set_scroll_adjustments;
@@ -2061,7 +2093,6 @@ ev_view_set_sizing_mode (EvView       *view,
                view->sizing_mode = sizing_mode;
                gtk_widget_queue_resize (GTK_WIDGET (view));
        }
-
        g_object_notify (G_OBJECT (view), "sizing-mode");
 }
 
@@ -2156,7 +2187,7 @@ ev_view_zoom_for_size_continuous_and_dual_page (EvView *view,
 
        doc_width = doc_width * 2;
        width -= (2 * (border.left + border.right) + 3 * view->spacing);
-       height -= (border.top + border.bottom + 2 * view->spacing);
+       height -= (border.top + border.bottom + 2 * view->spacing - 1);
 
        /* FIXME: We really need to calculate the overall height here, not the
         * page height.  We assume there's always a vertical scrollbar for
@@ -2191,7 +2222,7 @@ ev_view_zoom_for_size_continuous (EvView *view,
        compute_border (view, doc_width, doc_height, &border);
 
        width -= (border.left + border.right + 2 * view->spacing);
-       height -= (border.top + border.bottom + 2 * view->spacing);
+       height -= (border.top + border.bottom + 2 * view->spacing - 1);
 
        /* FIXME: We really need to calculate the overall height here, not the
         * page height.  We assume there's always a vertical scrollbar for
index b7b172dc91822b32b39594b871f5befb278fb0f8..9f18753f38e26d651e66c8a06106b8b2b7d795fb 100644 (file)
@@ -144,10 +144,8 @@ static void     ev_window_set_page_mode           (EvWindow         *window,
 static gboolean start_loading_document            (EvWindow         *ev_window,
                                                   EvDocument       *document,
                                                   const char       *uri);
-static void     ev_window_set_sizing_mode         (EvWindow         *ev_window,
-                                                  EvSizingMode      sizing_mode,
-                                                  gboolean          first_time);
-
+static void     ev_window_sizing_mode_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);
 
@@ -325,9 +323,9 @@ static void
 ev_window_cmd_view_best_fit (GtkAction *action, EvWindow *ev_window)
 {
        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
-               ev_window_set_sizing_mode (ev_window, EV_SIZING_BEST_FIT, FALSE);
+               ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_BEST_FIT);
        } else {
-               ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE, FALSE);
+               ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
        }
        update_action_sensitivity (ev_window);
 }
@@ -336,9 +334,9 @@ static void
 ev_window_cmd_view_page_width (GtkAction *action, EvWindow *ev_window)
 {
        if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
-               ev_window_set_sizing_mode (ev_window, EV_SIZING_FIT_WIDTH, FALSE);
+               ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FIT_WIDTH);
        } else {
-               ev_window_set_sizing_mode (ev_window, EV_SIZING_FREE, FALSE);
+               ev_view_set_sizing_mode (EV_VIEW (ev_window->priv->view), EV_SIZING_FREE);
        }
        update_action_sensitivity (ev_window);
 }
@@ -1514,7 +1512,7 @@ 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, FALSE);
+       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);
 }
@@ -1524,7 +1522,7 @@ 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, FALSE);
+       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);
 }
@@ -1664,37 +1662,29 @@ size_allocate_cb (GtkWidget     *scrolled_window,
        update_view_size (window);
 }
 
-static void
-ev_window_set_sizing_mode (EvWindow     *ev_window,
-                          EvSizingMode  sizing_mode,
-                          gboolean      first_time)
+static void     
+ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
+                                 EvWindow   *ev_window)
 {
        GtkWidget *scrolled_window;
+       EvSizingMode sizing_mode;
 
-       /* Short circuit the call if it's not the first time we call this */
-       if (!first_time) {
-               EvSizingMode old_sizing_mode;
-
-               g_object_get (ev_window->priv->view,
-                             "sizing-mode", &old_sizing_mode,
-                             NULL);
-               if (old_sizing_mode == sizing_mode)
-                       return;
-       }
+       g_object_get (ev_window->priv->view,
+                     "sizing-mode", &sizing_mode,
+                     NULL);
 
        scrolled_window = ev_window->priv->scrolled_window;
-       g_object_set (ev_window->priv->view,
-                     "sizing-mode", sizing_mode,
-                     NULL);
+
        g_signal_handlers_disconnect_by_func (scrolled_window, size_allocate_cb, ev_window);
 
-       update_view_size (ev_window);
+       if (sizing_mode != EV_SIZING_FREE)
+               update_view_size (ev_window);
 
        switch (sizing_mode) {
        case EV_SIZING_BEST_FIT:
                g_object_set (G_OBJECT (scrolled_window),
                              "hscrollbar-policy", GTK_POLICY_NEVER,
-                             "vscrollbar-policy", GTK_POLICY_NEVER,
+                             "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
                              NULL);
                g_signal_connect (scrolled_window, "size-allocate",
                                  G_CALLBACK (size_allocate_cb),
@@ -2487,6 +2477,7 @@ ev_window_init (EvWindow *ev_window)
 
        gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
                           ev_window->priv->view);
+
        g_signal_connect (ev_window->priv->view,
                          "notify::find-status",
                          G_CALLBACK (view_find_status_changed_cb),
@@ -2495,6 +2486,10 @@ ev_window_init (EvWindow *ev_window)
                          "notify::status",
                          G_CALLBACK (view_status_changed_cb),
                          ev_window);
+       g_signal_connect (ev_window->priv->view,
+                         "notify::sizing-mode",
+                         G_CALLBACK (ev_window_sizing_mode_changed_cb),
+                         ev_window);
 
        ev_window->priv->statusbar = gtk_statusbar_new ();
        gtk_box_pack_end (GTK_BOX (ev_window->priv->main_box),
@@ -2559,6 +2554,7 @@ ev_window_init (EvWindow *ev_window)
                          G_CALLBACK (drag_data_received_cb), NULL);
 
        /* Set it to something random to force a change */
-       ev_window_set_sizing_mode (ev_window,  EV_SIZING_FIT_WIDTH, TRUE);
+
+        ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window);
        update_action_sensitivity (ev_window);
 }