]> www.fi.muni.cz Git - evince.git/commitdiff
Implement FIT_HEIGHT mode (only for links). Implement FITH links
authorMarco Pesenti Gritti <mpg@redhat.com>
Sat, 24 Sep 2005 10:57:13 +0000 (10:57 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Sat, 24 Sep 2005 10:57:13 +0000 (10:57 +0000)
2005-09-24  Marco Pesenti Gritti  <mpg@redhat.com>

        * backend/ev-link.c: (ev_link_type_get_type),
        (ev_link_new_page_fith), (ev_link_new_page_fitv):
        * backend/ev-link.h:
        * pdf/ev-poppler.cc:
        * shell/ev-view.c: (goto_fitv_link), (goto_fith_link),
        (ev_view_goto_link), (ev_view_size_request_continuous_dual_page),
        (ev_view_size_request_continuous),
        (ev_view_size_request_dual_page),
        (ev_view_size_request_single_page), (ev_view_size_allocate),
        (zoom_for_size_fit_height),
        (ev_view_zoom_for_size_continuous_and_dual_page),
        (ev_view_zoom_for_size_continuous),
        (ev_view_zoom_for_size_dual_page),
        (ev_view_zoom_for_size_single_page), (ev_view_set_zoom_for_size),
        (ev_sizing_mode_get_type):
        * shell/ev-view.h:
        * shell/ev-window.c: (ev_window_sizing_mode_changed_cb):

        Implement FIT_HEIGHT mode (only for links).
        Implement FITH links

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

index d91b7acb59bd870cf69139e14bccdcd314baed8c..6666e0b1e65c3b5183835e227f5b62cc8f5c2f6c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2005-09-24  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * backend/ev-link.c: (ev_link_type_get_type),
+       (ev_link_new_page_fith), (ev_link_new_page_fitv):
+       * backend/ev-link.h:
+       * pdf/ev-poppler.cc:
+       * shell/ev-view.c: (goto_fitv_link), (goto_fith_link),
+       (ev_view_goto_link), (ev_view_size_request_continuous_dual_page),
+       (ev_view_size_request_continuous),
+       (ev_view_size_request_dual_page),
+       (ev_view_size_request_single_page), (ev_view_size_allocate),
+       (zoom_for_size_fit_height),
+       (ev_view_zoom_for_size_continuous_and_dual_page),
+       (ev_view_zoom_for_size_continuous),
+       (ev_view_zoom_for_size_dual_page),
+       (ev_view_zoom_for_size_single_page), (ev_view_set_zoom_for_size),
+       (ev_sizing_mode_get_type):
+       * shell/ev-view.h:
+       * shell/ev-window.c: (ev_window_sizing_mode_changed_cb):
+
+       Implement FIT_HEIGHT mode (only for links).
+       Implement FITH links
+
 2005-09-24  Marco Pesenti Gritti  <mpg@redhat.com>
 
        * shell/ev-window-title.c: (get_filename_from_uri),
index 071d6af5edbcceaf83afdbd603dc586ce75d6315..82fce8dda58bd20db3322c21896fb27aa1d3aace 100644 (file)
@@ -72,6 +72,7 @@ ev_link_type_get_type (void)
                        { EV_LINK_TYPE_PAGE_XYZ, "EV_LINK_TYPE_PAGE_XYZ", "page-xyz" },
                        { EV_LINK_TYPE_PAGE_FIT, "EV_LINK_TYPE_PAGE_FIT", "page-fit" },
                        { EV_LINK_TYPE_PAGE_FITH, "EV_LINK_TYPE_PAGE_FITH", "page-fith" },
+                       { EV_LINK_TYPE_PAGE_FITV, "EV_LINK_TYPE_PAGE_FITV", "page-fitv" },
                        { EV_LINK_TYPE_EXTERNAL_URI, "EV_LINK_TYPE_EXTERNAL_URI", "external" },
                        { 0, NULL, NULL }
                 };
@@ -382,6 +383,19 @@ ev_link_new_page_fith (const char *title,
                                      NULL));
 }
 
+EvLink *
+ev_link_new_page_fitv (const char *title,
+                      int         page,
+                      double      left)
+{
+       return EV_LINK (g_object_new (EV_TYPE_LINK,
+                                     "title", title,
+                                     "page", page,
+                                     "type", EV_LINK_TYPE_PAGE_FITV,
+                                     "left", left,
+                                     NULL));
+}
+
 EvLink *
 ev_link_new_external (const char *title, const char *uri)
 {
index 508e89deb39d79fc49d956ac5e21671f76b89fd8..86b3cc2b4117b2569caccebfae7e941f28945b95 100644 (file)
@@ -46,6 +46,7 @@ typedef enum
        EV_LINK_TYPE_PAGE_XYZ,
        EV_LINK_TYPE_PAGE_FIT,
        EV_LINK_TYPE_PAGE_FITH,
+       EV_LINK_TYPE_PAGE_FITV,
        EV_LINK_TYPE_EXTERNAL_URI,
        /* We'll probably fill this in more as we support the other types of
         * links */
@@ -65,6 +66,9 @@ EvLink               *ev_link_new_page_xyz    (const char     *title,
 EvLink        *ev_link_new_page_fith   (const char     *title,
                                         int             page,
                                         double          top);
+EvLink        *ev_link_new_page_fitv   (const char     *title,
+                                        int             page,
+                                        double          left);
 EvLink        *ev_link_new_page_fit    (const char     *title,
                                         int             page);
 EvLink        *ev_link_new_external    (const char     *title,
index 9b1fc47d2fedbaeb8f18c7f81f374c47c696374e..5e95943eda7365be5e1046aa175ee7f20dedbd19 100644 (file)
@@ -729,7 +729,9 @@ ev_link_from_dest (PopplerAction *action)
                                              action->goto_dest.dest->top);
                break;
        case POPPLER_DEST_FITV:
-               unimplemented_dest = "POPPLER_DEST_FITV";
+               link = ev_link_new_page_fitv (action->any.title,
+                                             action->goto_dest.dest->page_num - 1,
+                                             action->goto_dest.dest->left);
                break;
        case POPPLER_DEST_FITR:
                unimplemented_dest = "POPPLER_DEST_FITR";
index 612ffc5cf2f7995b913b60214d6b9c3c7115b115..c7125d9eab95275f84acdee26b4f7122a756de60 100644 (file)
@@ -1095,6 +1095,24 @@ get_link_at_location (EvView  *view,
                return NULL;
 }
 
+static void
+goto_fitv_link (EvView *view, EvLink *link)
+{
+       GdkPoint view_point;
+       EvPoint doc_point;
+       int page;
+
+       page = ev_link_get_page (link);
+
+       ev_view_set_sizing_mode (view, EV_SIZING_FIT_HEIGHT);
+
+       doc_point.x = ev_link_get_left (link);
+       doc_point.y = 0;
+       doc_point_to_view_point (view, page, &doc_point, &view_point);
+
+       gtk_adjustment_set_value (view->hadjustment, view_point.x);
+}
+
 static void
 goto_fith_link (EvView *view, EvLink *link)
 {
@@ -1105,7 +1123,7 @@ goto_fith_link (EvView *view, EvLink *link)
        page = ev_link_get_page (link);
        ev_page_cache_get_size (view->page_cache, page, 0, 1.0, NULL, &height);
 
-       ev_view_set_sizing_mode (view, EV_SIZING_BEST_FIT);
+       ev_view_set_sizing_mode (view, EV_SIZING_FIT_WIDTH);
 
        doc_point.x = 0;
        doc_point.y = height - ev_link_get_top (link);
@@ -1163,6 +1181,9 @@ ev_view_goto_link (EvView *view, EvLink *link)
                case EV_LINK_TYPE_PAGE_FITH:
                        goto_fith_link (view, link);
                        break;
+               case EV_LINK_TYPE_PAGE_FITV:
+                       goto_fitv_link (view, link);
+                       break;
                case EV_LINK_TYPE_PAGE_XYZ:
                        goto_xyz_link (view, link);
                        break;
@@ -1260,6 +1281,8 @@ ev_view_size_request_continuous_dual_page (EvView         *view,
 
        if (view->sizing_mode == EV_SIZING_FIT_WIDTH) {
                requisition->width = 1;
+       } else if (view->sizing_mode == EV_SIZING_FIT_HEIGHT) {
+               requisition->height = 1;
        } else if (view->sizing_mode == EV_SIZING_BEST_FIT) {
                requisition->width = 1;
                /* FIXME: This could actually be set on one page docs or docs
@@ -1287,6 +1310,8 @@ ev_view_size_request_continuous (EvView         *view,
 
        if (view->sizing_mode == EV_SIZING_FIT_WIDTH) {
                requisition->width = 1;
+       } else if (view->sizing_mode == EV_SIZING_FIT_HEIGHT) {
+               requisition->height = 1;
        } else if (view->sizing_mode == EV_SIZING_BEST_FIT) {
                requisition->width = 1;
                /* FIXME: This could actually be set on one page docs or docs
@@ -1329,6 +1354,8 @@ ev_view_size_request_dual_page (EvView         *view,
 
        if (view->sizing_mode == EV_SIZING_FIT_WIDTH) {
                requisition->width = 1;
+       } else if (view->sizing_mode == EV_SIZING_FIT_HEIGHT) {
+               requisition->height = 1;
        } else if (view->sizing_mode == EV_SIZING_BEST_FIT) {
                requisition->width = 1;
                requisition->height = 1;
@@ -1355,6 +1382,8 @@ ev_view_size_request_single_page (EvView         *view,
        if (view->sizing_mode == EV_SIZING_FIT_WIDTH) {
                requisition->width = 1;
                requisition->height = height + border.top + border.bottom + (2 * view->spacing);
+       } else if (view->sizing_mode == EV_SIZING_FIT_HEIGHT) {
+               requisition->height = 1;
        } else if (view->sizing_mode == EV_SIZING_BEST_FIT) {
                requisition->width = 1;
                requisition->height = 1;
@@ -1396,7 +1425,8 @@ ev_view_size_allocate (GtkWidget      *widget,
        EvView *view = EV_VIEW (widget);
 
        if (view->sizing_mode == EV_SIZING_FIT_WIDTH ||
-                 view->sizing_mode == EV_SIZING_BEST_FIT) {
+           view->sizing_mode == EV_SIZING_FIT_HEIGHT ||
+           view->sizing_mode == EV_SIZING_BEST_FIT) {
 
                g_signal_emit (view, signals[SIGNAL_ZOOM_INVALID], 0);
 
@@ -2704,6 +2734,23 @@ zoom_for_size_fit_width (int doc_width,
        return scale;
 }
 
+static double
+zoom_for_size_fit_height (int doc_width,
+                         int doc_height,
+                         int target_width,
+                         int target_height,
+                         int vsb_height)
+{
+       double scale;
+
+       scale = (double)target_height / doc_height;
+
+       if (doc_width * scale > target_width)
+               scale = (double) (target_height - vsb_height) / doc_height;
+
+       return scale;
+}
+
 static double
 zoom_for_size_best_fit (int doc_width,
                        int doc_height,
@@ -2775,6 +2822,8 @@ ev_view_zoom_for_size_continuous_and_dual_page (EvView *view,
         * 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 - vsb_width, height, 0);
+       else if (view->sizing_mode == EV_SIZING_FIT_HEIGHT)
+                scale = zoom_for_size_fit_height (doc_width, doc_height, width - vsb_width, height, hsb_height);
        else if (view->sizing_mode == EV_SIZING_BEST_FIT)
                scale = zoom_for_size_best_fit (doc_width, doc_height, width - vsb_width, height, 0, hsb_height);
        else
@@ -2812,6 +2861,8 @@ ev_view_zoom_for_size_continuous (EvView *view,
         * 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 - vsb_width, height, 0);
+       else if (view->sizing_mode == EV_SIZING_FIT_HEIGHT)
+               scale = zoom_for_size_fit_height (doc_width, doc_height, width - vsb_width, height, hsb_height);
        else if (view->sizing_mode == EV_SIZING_BEST_FIT)
                scale = zoom_for_size_best_fit (doc_width, doc_height, width - vsb_width, height, 0, hsb_height);
        else
@@ -2861,6 +2912,8 @@ ev_view_zoom_for_size_dual_page (EvView *view,
 
        if (view->sizing_mode == EV_SIZING_FIT_WIDTH)
                scale = zoom_for_size_fit_width (doc_width, doc_height, width, height, vsb_width);
+       else if (view->sizing_mode == EV_SIZING_FIT_HEIGHT)
+               scale = zoom_for_size_fit_height (doc_width, doc_height, width, height, hsb_height);
        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);
        else
@@ -2894,6 +2947,8 @@ ev_view_zoom_for_size_single_page (EvView *view,
 
        if (view->sizing_mode == EV_SIZING_FIT_WIDTH)
                scale = zoom_for_size_fit_width (doc_width, doc_height, width, height, vsb_width);
+       else if (view->sizing_mode == EV_SIZING_FIT_HEIGHT)
+               scale = zoom_for_size_fit_height (doc_width, doc_height, width, height, hsb_height);
        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);
        else
@@ -2910,6 +2965,7 @@ ev_view_set_zoom_for_size (EvView *view,
                           int     hsb_height)
 {
        g_return_if_fail (view->sizing_mode == EV_SIZING_FIT_WIDTH ||
+                         view->sizing_mode == EV_SIZING_FIT_HEIGHT ||
                          view->sizing_mode == EV_SIZING_BEST_FIT);
        g_return_if_fail (width >= 0);
        g_return_if_fail (height >= 0);
@@ -3675,6 +3731,7 @@ ev_sizing_mode_get_type (void)
   if (etype == 0) {
     static const GEnumValue values[] = {
       { EV_SIZING_FIT_WIDTH, "EV_SIZING_FIT_WIDTH", "fit-width" },
+      { EV_SIZING_FIT_HEIGHT, "EV_SIZING_FIT_HEIGHT", "fit-height" },
       { EV_SIZING_BEST_FIT, "EV_SIZING_BEST_FIT", "best-fit" },
       { EV_SIZING_FREE, "EV_SIZING_FREE", "free" },
       { 0, NULL, NULL }
index 77914929413e52b18065eecbd19c38471bb24daf..586c6ad0550acfc033396e910cafcfddf39e5a98 100644 (file)
@@ -41,6 +41,7 @@ typedef struct _EvViewClass  EvViewClass;
 typedef enum {
        EV_SIZING_BEST_FIT,
        EV_SIZING_FIT_WIDTH,
+       EV_SIZING_FIT_HEIGHT,
        EV_SIZING_FREE,
 } EvSizingMode;
 
index 9acf50567134d089902c6e0607ddd9eb170ade4b..17baf74402de94012764ea89b02b86eb670e2480 100644 (file)
@@ -311,7 +311,9 @@ update_action_sensitivity (EvWindow *ev_window)
        set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
        set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION,  has_pages);
 
-       if (has_pages && ev_view_get_sizing_mode (view) == EV_SIZING_FREE) {
+       if (has_pages &&
+           ev_view_get_sizing_mode (view) != EV_SIZING_FIT_WIDTH &&
+           ev_view_get_sizing_mode (view) != EV_SIZING_BEST_FIT) {
                GtkAction *action;
                float      zoom;
                float      real_zoom;
@@ -2343,6 +2345,15 @@ ev_window_sizing_mode_changed_cb (EvView *view, GParamSpec *pspec,
                                  G_CALLBACK (update_view_size),
                                  ev_window);
                break;
+       case EV_SIZING_FIT_HEIGHT:
+               g_object_set (G_OBJECT (scrolled_window),
+                             "hscrollbar-policy", GTK_POLICY_AUTOMATIC,
+                             "vscrollbar-policy", GTK_POLICY_NEVER,
+                             NULL);
+               g_signal_connect (ev_window->priv->view, "zoom_invalid",
+                                 G_CALLBACK (update_view_size),
+                                 ev_window);
+               break;
        case EV_SIZING_FREE:
                g_object_set (G_OBJECT (scrolled_window),
                              "hscrollbar-policy", GTK_POLICY_AUTOMATIC,