]> www.fi.muni.cz Git - evince.git/commitdiff
Implement fitr links
authorMarco Pesenti Gritti <mpg@redhat.com>
Sat, 24 Sep 2005 14:58:58 +0000 (14:58 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Sat, 24 Sep 2005 14:58:58 +0000 (14:58 +0000)
2005-09-24  Marco Pesenti Gritti  <mpg@redhat.com>

        * backend/ev-link.c: (ev_link_type_get_type), (ev_link_get_bottom),
        (ev_link_get_right), (ev_link_get_property),
        (ev_link_set_property), (ev_link_class_init),
        (ev_link_new_page_fitv), (ev_link_new_page_fitr):
        * backend/ev-link.h:
        * pdf/ev-poppler.cc:
        * shell/ev-view.c: (goto_fitr_link), (ev_view_goto_link):

        Implement fitr links

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

index 7be2008ed9b34e44741116d26697c48782128e87..71e8678c473f66c2d088e23cc8e7652d9004a336 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-09-24  Marco Pesenti Gritti  <mpg@redhat.com>
+
+       * backend/ev-link.c: (ev_link_type_get_type), (ev_link_get_bottom),
+       (ev_link_get_right), (ev_link_get_property),
+       (ev_link_set_property), (ev_link_class_init),
+       (ev_link_new_page_fitv), (ev_link_new_page_fitr):
+       * backend/ev-link.h:
+       * pdf/ev-poppler.cc:
+       * shell/ev-view.c: (goto_fitr_link), (ev_view_goto_link):
+
+       Implement fitr links
+
 2005-09-24  Marco Pesenti Gritti  <mpg@redhat.com>
 
        * shell/ev-view.c: (ev_view_get_width), (ev_view_get_height),
index 82fce8dda58bd20db3322c21896fb27aa1d3aace..57af5fa26151bb2049c9e247ef0e6b4ca02fc81e 100644 (file)
@@ -32,6 +32,8 @@ enum {
        PROP_URI,
        PROP_LEFT,
        PROP_TOP,
+       PROP_BOTTOM,
+       PROP_RIGHT,
        PROP_ZOOM
 };
 
@@ -52,6 +54,8 @@ struct _EvLinkPrivate {
        int page;
        double top;
        double left;
+       double bottom;
+       double right;
        double zoom;
 };
 
@@ -73,6 +77,7 @@ ev_link_type_get_type (void)
                        { 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_PAGE_FITR, "EV_LINK_TYPE_PAGE_FITR", "page-fitr" },
                        { EV_LINK_TYPE_EXTERNAL_URI, "EV_LINK_TYPE_EXTERNAL_URI", "external" },
                        { 0, NULL, NULL }
                 };
@@ -131,6 +136,22 @@ ev_link_get_left (EvLink *self)
        return self->priv->left;
 }
 
+double
+ev_link_get_bottom (EvLink *self)
+{
+       g_return_val_if_fail (EV_IS_LINK (self), 0);
+       
+       return self->priv->bottom;
+}
+
+double
+ev_link_get_right (EvLink *self)
+{
+       g_return_val_if_fail (EV_IS_LINK (self), 0);
+       
+       return self->priv->right;
+}
+
 double
 ev_link_get_zoom (EvLink *self)
 {
@@ -166,6 +187,12 @@ ev_link_get_property (GObject *object, guint prop_id, GValue *value,
        case PROP_LEFT:
                g_value_set_double (value, self->priv->left);
                break;
+       case PROP_BOTTOM:
+               g_value_set_double (value, self->priv->bottom);
+               break;
+       case PROP_RIGHT:
+               g_value_set_double (value, self->priv->left);
+               break;
        case PROP_ZOOM:
                g_value_set_double (value, self->priv->zoom);
                break;
@@ -202,6 +229,12 @@ ev_link_set_property (GObject *object, guint prop_id, const GValue *value,
        case PROP_LEFT:
                link->priv->left = g_value_get_double (value);
                break;
+       case PROP_BOTTOM:
+               link->priv->bottom = g_value_get_double (value);
+               break;
+       case PROP_RIGHT:
+               link->priv->right = g_value_get_double (value);
+               break;
        case PROP_ZOOM:
                link->priv->zoom = g_value_get_double (value);
                break;
@@ -311,6 +344,27 @@ ev_link_class_init (EvLinkClass *ev_window_class)
                                                              0,
                                                              G_PARAM_READWRITE |
                                                              G_PARAM_CONSTRUCT_ONLY));
+       g_object_class_install_property (g_object_class,
+                                        PROP_BOTTOM,
+                                        g_param_spec_double ("bottom",
+                                                             "Bottom coordinate",
+                                                             "The bottom coordinate",
+                                                             -G_MAXDOUBLE,
+                                                             G_MAXDOUBLE,
+                                                             0,
+                                                             G_PARAM_READWRITE |
+                                                             G_PARAM_CONSTRUCT_ONLY));
+       g_object_class_install_property (g_object_class,
+                                        PROP_RIGHT,
+                                        g_param_spec_double ("right",
+                                                             "Right coordinate",
+                                                             "The right coordinate",
+                                                             -G_MAXDOUBLE,
+                                                             G_MAXDOUBLE,
+                                                             0,
+                                                             G_PARAM_READWRITE |
+                                                             G_PARAM_CONSTRUCT_ONLY));
+
        g_object_class_install_property (g_object_class,
                                         PROP_ZOOM,
                                         g_param_spec_double ("zoom",
@@ -396,6 +450,25 @@ ev_link_new_page_fitv (const char *title,
                                      NULL));
 }
 
+EvLink *
+ev_link_new_page_fitr (const char     *title,
+                      int             page,
+                      double          left,
+                      double          bottom,
+                      double          right,
+                      double          top)
+{
+       return EV_LINK (g_object_new (EV_TYPE_LINK,
+                                     "title", title,
+                                     "page", page,
+                                     "type", EV_LINK_TYPE_PAGE_FITR,
+                                     "left", left,
+                                     "bottom", bottom,
+                                     "right", right,
+                                     "top", top,
+                                     NULL));
+}
+
 EvLink *
 ev_link_new_external (const char *title, const char *uri)
 {
index 86b3cc2b4117b2569caccebfae7e941f28945b95..c014c0102ca0fa86b417085e872b7e4904f53207 100644 (file)
@@ -47,6 +47,7 @@ typedef enum
        EV_LINK_TYPE_PAGE_FIT,
        EV_LINK_TYPE_PAGE_FITH,
        EV_LINK_TYPE_PAGE_FITV,
+       EV_LINK_TYPE_PAGE_FITR,
        EV_LINK_TYPE_EXTERNAL_URI,
        /* We'll probably fill this in more as we support the other types of
         * links */
@@ -69,6 +70,12 @@ EvLink              *ev_link_new_page_fith   (const char     *title,
 EvLink        *ev_link_new_page_fitv   (const char     *title,
                                         int             page,
                                         double          left);
+EvLink        *ev_link_new_page_fitr   (const char     *title,
+                                        int             page,
+                                        double          left,
+                                        double          bottom,
+                                        double          right,
+                                        double          top);
 EvLink        *ev_link_new_page_fit    (const char     *title,
                                         int             page);
 EvLink        *ev_link_new_external    (const char     *title,
@@ -80,6 +87,8 @@ EvLinkType    ev_link_get_link_type   (EvLink     *link);
 int            ev_link_get_page        (EvLink     *link);
 double         ev_link_get_top         (EvLink     *link);
 double         ev_link_get_left        (EvLink     *link);
+double         ev_link_get_bottom      (EvLink     *link);
+double         ev_link_get_right       (EvLink     *link);
 double         ev_link_get_zoom        (EvLink     *link);
 
 /* Link Mapping stuff */
index 5e95943eda7365be5e1046aa175ee7f20dedbd19..30b5a72e0964c6adacad8fd7532d7777174a0b79 100644 (file)
@@ -734,7 +734,12 @@ ev_link_from_dest (PopplerAction *action)
                                              action->goto_dest.dest->left);
                break;
        case POPPLER_DEST_FITR:
-               unimplemented_dest = "POPPLER_DEST_FITR";
+               link = ev_link_new_page_fitr (action->any.title,
+                                             action->goto_dest.dest->page_num - 1,
+                                             action->goto_dest.dest->left,
+                                             action->goto_dest.dest->bottom,
+                                             action->goto_dest.dest->right,
+                                             action->goto_dest.dest->top);
                break;
        case POPPLER_DEST_FITB:
                unimplemented_dest = "POPPLER_DEST_FITB";
index ae335665a74222f1cc71a40aaa311f67a0b74316..c5cc5038a7e1018e2126536241960ebfa21a0cf7 100644 (file)
@@ -1112,6 +1112,32 @@ get_link_at_location (EvView  *view,
                return NULL;
 }
 
+static void
+goto_fitr_link (EvView *view, EvLink *link)
+{
+       GdkPoint view_point;
+       EvPoint doc_point;
+       int doc_width, doc_height, page;
+       double zoom;
+
+       page = ev_link_get_page (link);
+       ev_page_cache_get_size (view->page_cache, page, 0, 1.0, &doc_width, &doc_height);
+
+       doc_point.x = ev_link_get_left (link);
+       doc_point.y = ev_link_get_top (link);
+       doc_point_to_view_point (view, page, &doc_point, &view_point);
+
+       zoom = zoom_for_size_best_fit (ev_link_get_right (link) - ev_link_get_left (link),
+                                      ev_link_get_top (link) - ev_link_get_bottom (link),
+                                      ev_view_get_width (view),
+                                      ev_view_get_height (view), 0, 0);
+
+       ev_view_set_sizing_mode (view, EV_SIZING_FREE);
+       ev_view_set_zoom (view, zoom, FALSE);
+       ev_page_cache_set_current_page (view->page_cache, page);
+       gtk_adjustment_set_value (view->hadjustment, view_point.x);
+}
+
 static void
 goto_fitv_link (EvView *view, EvLink *link)
 {
@@ -1229,6 +1255,9 @@ ev_view_goto_link (EvView *view, EvLink *link)
                case EV_LINK_TYPE_PAGE_FITV:
                        goto_fitv_link (view, link);
                        break;
+               case EV_LINK_TYPE_PAGE_FITR:
+                       goto_fitr_link (view, link);
+                       break;
                case EV_LINK_TYPE_PAGE_XYZ:
                        goto_xyz_link (view, link);
                        break;