Fix links for dual/continuous. Also, add a quick fix measuring of widths.
authorJonathan Blandford <jrb@redhat.com>
Sun, 24 Apr 2005 05:16:30 +0000 (05:16 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Sun, 24 Apr 2005 05:16:30 +0000 (05:16 +0000)
Sun Apr 24 01:07:27 2005  Jonathan Blandford  <jrb@redhat.com>

        * shell/ev-view.c: (find_page_at_location),
        (get_link_at_location),
        (ev_view_set_show_border), (ev_view_set_spacing),
        (ev_view_zoom_for_size_continuous_and_dual_page),
        (ev_view_zoom_for_size_continuous): Fix links for dual/continuous.
        Also, add a quick fix measuring of widths.  Also, removed
        ev_view_set_spacing and ev_view_set_show_border.

        * shell/ev-window.c: (ev_window_unfullscreen),
        (ev_window_cmd_view_fullscreen): Don't adjust the border/spacing.

ChangeLog
backend/ev-link.c
shell/ev-view.c
shell/ev-view.h
shell/ev-window.c

index e6924ddd2445eafb773fc5924f064a23b20ddc77..056c2d5cdb431c06962c3b59bc7936a740b9834c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+Sun Apr 24 01:07:27 2005  Jonathan Blandford  <jrb@redhat.com>
+
+       * shell/ev-view.c: (find_page_at_location),
+       (get_link_at_location),
+       (ev_view_set_show_border), (ev_view_set_spacing),
+       (ev_view_zoom_for_size_continuous_and_dual_page),
+       (ev_view_zoom_for_size_continuous): Fix links for dual/continuous.
+       Also, add a quick fix measuring of widths.  Also, removed
+       ev_view_set_spacing and ev_view_set_show_border.
+       
+       * shell/ev-window.c: (ev_window_unfullscreen),
+       (ev_window_cmd_view_fullscreen): Don't adjust the border/spacing.
+
 2005-04-24  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
 
        * shell/ev-view.c: (view_update_range_and_current_page),
index 7e26a580dae9ac43d784fa1c1badfc939d4de612..48ffca574352d48da1c4a99fba33d682cb2c8df8 100644 (file)
@@ -346,6 +346,7 @@ ev_link_mapping_find (GList   *link_mapping,
        int i;
        
        i = 0;
+
        for (list = link_mapping; list; list = list->next) {
                EvLinkMapping *mapping = list->data;
 
index 07a71ead20aca43ec66f1d267df493ab3d398b30..8a3dd2657fe97d1179d20d435c33b15fcb157e9e 100644 (file)
@@ -1001,16 +1001,6 @@ ev_view_copy (EvView *ev_view)
        g_free (text);
 }
 
-void
-ev_view_set_show_border (EvView *view, gboolean show_border)
-{
-       g_return_if_fail (EV_IS_VIEW (view));
-
-       view->show_border = show_border;
-
-       gtk_widget_queue_resize (GTK_WIDGET (view));
-}
-
 static void
 ev_view_primary_get_cb (GtkClipboard     *clipboard,
                        GtkSelectionData *selection_data,
@@ -1200,24 +1190,34 @@ find_page_at_location (EvView  *view,
                       gint    *x_offset,
                       gint    *y_offset)
 {
-       gint width, height;
+       int i;
 
-       ev_page_cache_get_size (view->page_cache,
-                               view->current_page,
-                               view->scale,
-                               &width, &height);
+       if (view->document == NULL)
+               return;
 
-       x -= (view->border.left + view->spacing);
-       y -= (view->border.top + view->spacing);
+       g_assert (page);
+       g_assert (x_offset);
+       g_assert (y_offset);
 
-       if ((x < 0) || (y < 0) ||
-           (x >= width) || (y >= height)) {
-               *page = -1;
-               return;
+       for (i = view->start_page; i <= view->end_page; i++) {
+               GdkRectangle page_area;
+               GtkBorder border;
+
+               if (! get_page_extents (view, i, &page_area, &border))
+                       continue;
+
+               if ((x >= page_area.x + border.left) &&
+                   (x < page_area.x + page_area.width - border.right) &&
+                   (y >= page_area.y + border.top) &&
+                   (y < page_area.y + page_area.height - border.bottom)) {
+                       *page = i;
+                       *x_offset = x - (page_area.x + border.left);
+                       *y_offset = y - (page_area.y + border.top);
+                       return;
+               }
        }
-       *page = view->current_page;
-       *x_offset = (gint) x;
-       *y_offset = (gint) y;
+
+       *page = -1;
 }
 
 static EvLink *
@@ -1225,17 +1225,21 @@ get_link_at_location (EvView  *view,
                      gdouble  x,
                      gdouble  y)
 {
-       gint page;
-       gint x_offset, y_offset;
+       gint page = -1;
+       gint x_offset = 0, y_offset = 0;
        GList *link_mapping;
 
        find_page_at_location (view, x, y, &page, &x_offset, &y_offset);
+
        if (page == -1)
                return NULL;
 
        link_mapping = ev_pixbuf_cache_get_link_mapping (view->pixbuf_cache, page);
 
-       return ev_link_mapping_find (link_mapping, x_offset /view->scale, y_offset /view->scale);
+       if (link_mapping)
+               return ev_link_mapping_find (link_mapping, x_offset / view->scale, y_offset / view->scale);
+       else
+               return NULL;
 }
 
 
@@ -1684,19 +1688,6 @@ ev_view_class_init (EvViewClass *class)
        add_scroll_binding_shifted (binding_set, GDK_BackSpace, EV_SCROLL_PAGE_BACKWARD, EV_SCROLL_PAGE_FORWARD, FALSE);
 }
 
-void
-ev_view_set_spacing (EvView     *view,
-                    int         spacing)
-{
-       g_return_if_fail (EV_IS_VIEW (view));
-
-       view->spacing = spacing;
-
-       if (view->document) {
-               gtk_widget_queue_resize (GTK_WIDGET (view));
-       }
-}
-
 static void
 ev_view_init (EvView *view)
 {
@@ -2164,10 +2155,10 @@ ev_view_zoom_for_size_continuous_and_dual_page (EvView *view,
        compute_border (view, doc_width, doc_height, &border);
 
        doc_width = doc_width * 2;
-       width -= ((border.left + border.right)* 2 + 3 * view->spacing);
+       width -= (2 * (border.left + border.right) + 3 * view->spacing);
        height -= (border.top + border.bottom + 2 * view->spacing);
 
-       /* FIXME: We really need to calculat the overall height here, not the
+       /* FIXME: We really need to calculate the overall height here, not the
         * page height.  We assume there's always a vertical scrollbar for
         * now.  We need to fix this. */
        if (view->sizing_mode == EV_SIZING_FIT_WIDTH)
@@ -2202,10 +2193,13 @@ ev_view_zoom_for_size_continuous (EvView *view,
        width -= (border.left + border.right + 2 * view->spacing);
        height -= (border.top + border.bottom + 2 * view->spacing);
 
+       /* FIXME: We really need to calculate the overall height here, not the
+        * page height.  We assume there's always a vertical scrollbar for
+        * now.  We need to fix this. */
        if (view->sizing_mode == EV_SIZING_FIT_WIDTH)
-               scale = zoom_for_size_fit_width (doc_width, doc_height, width, height, vsb_width);
+               scale = zoom_for_size_fit_width (doc_width, doc_height, width - vsb_width, height, 0);
        else if (view->sizing_mode == EV_SIZING_BEST_FIT)
-               scale = zoom_for_size_best_fit (doc_width, doc_height, width, height, vsb_width, hsb_height);
+               scale = zoom_for_size_best_fit (doc_width, doc_height, width - vsb_width, height, 0, hsb_height);
        else
                g_assert_not_reached ();
 
index 3c4fdbb5dc7a71bfea5aa26320e03fa4e7f66ac2..b87d345ebbd477643e1b91e82150b46f68fff02e 100644 (file)
@@ -82,10 +82,6 @@ void         ev_view_zoom_normal     (EvView     *view);
 void           ev_view_set_size        (EvView     *view,
                                         int         width,
                                         int         height);
-void           ev_view_set_spacing     (EvView     *view,
-                                        int         spacing);
-void           ev_view_set_show_border (EvView     *view,
-                                        gboolean    show_border);
 
 /* Find */
 gboolean       ev_view_can_find_next   (EvView     *view);
index 8b54d27f565f7de60fa41a613a024316df24d365..b7b172dc91822b32b39594b871f5befb278fb0f8 100644 (file)
@@ -135,7 +135,6 @@ static const GtkTargetEntry ev_drop_types[] = {
 #define GCONF_SIDEBAR_SIZE      "/apps/evince/sidebar_size"
 
 #define SIDEBAR_DEFAULT_SIZE    132
-#define VIEW_SPACING           10
 
 static void     ev_window_update_fullscreen_popup (EvWindow         *window);
 static void     ev_window_sidebar_visibility_changed_cb (EvSidebar *ev_sidebar, GParamSpec *pspec,
@@ -1378,8 +1377,9 @@ ev_window_unfullscreen (EvWindow *window)
                                              (gpointer) fullscreen_motion_notify_cb,
                                              window);
 
-       ev_view_set_show_border (view, TRUE);
-       ev_view_set_spacing (view, VIEW_SPACING);       
+       g_object_set (G_OBJECT (view),
+                     "full-screen", FALSE,
+                     NULL);
        update_chrome_visibility (window);
 }
 
@@ -1400,8 +1400,9 @@ ev_window_cmd_view_fullscreen (GtkAction *action, EvWindow *window)
                gtk_window_unfullscreen (GTK_WINDOW (window));
        }
 
-       ev_view_set_show_border (view, FALSE);
-       ev_view_set_spacing (view, 0);  
+       g_object_set (G_OBJECT (view),
+                     "full-screen", TRUE,
+                     NULL);
 }
 
 static gboolean
@@ -2470,7 +2471,6 @@ ev_window_init (EvWindow *ev_window)
                        ev_window->priv->scrolled_window);
 
        ev_window->priv->view = ev_view_new ();
-       ev_view_set_spacing (EV_VIEW (ev_window->priv->view), VIEW_SPACING);    
        ev_window->priv->password_view = ev_password_view_new ();
        g_signal_connect_swapped (ev_window->priv->password_view,
                                  "unlock",