[evince] libdocument: Add ev_link_dest_equal() and ev_link_action_equal()



commit 0ed75bf068614a8dbc470947a3331553175767ff
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sun Feb 17 18:24:02 2013 +0100

    libdocument: Add ev_link_dest_equal() and ev_link_action_equal()

 libdocument/ev-link-action.c |   38 +++++++++++++++++++++++++++
 libdocument/ev-link-action.h |    3 ++
 libdocument/ev-link-dest.c   |   58 ++++++++++++++++++++++++++++++++++++++++++
 libdocument/ev-link-dest.h   |    3 ++
 4 files changed, 102 insertions(+), 0 deletions(-)
---
diff --git a/libdocument/ev-link-action.c b/libdocument/ev-link-action.c
index 999bc7f..415108e 100644
--- a/libdocument/ev-link-action.c
+++ b/libdocument/ev-link-action.c
@@ -478,3 +478,41 @@ ev_link_action_new_layers_state (GList *show_list,
                                             "type", EV_LINK_ACTION_TYPE_LAYERS_STATE,
                                             NULL));
 }
+
+gboolean
+ev_link_action_equal (EvLinkAction *a,
+                      EvLinkAction *b)
+{
+        g_return_val_if_fail (EV_IS_LINK_ACTION (a), FALSE);
+        g_return_val_if_fail (EV_IS_LINK_ACTION (b), FALSE);
+
+        if (a == b)
+                return TRUE;
+
+        if (a->priv->type != b->priv->type)
+                return FALSE;
+
+        switch (a->priv->type) {
+        case EV_LINK_ACTION_TYPE_GOTO_DEST:
+                return ev_link_dest_equal (a->priv->dest, b->priv->dest);
+
+        case EV_LINK_ACTION_TYPE_GOTO_REMOTE:
+                return ev_link_dest_equal (a->priv->dest, b->priv->dest) &&
+                        !g_strcmp0 (a->priv->filename, b->priv->filename);
+
+        case EV_LINK_ACTION_TYPE_EXTERNAL_URI:
+                return !g_strcmp0 (a->priv->uri, b->priv->uri);
+
+        case EV_LINK_ACTION_TYPE_LAUNCH:
+                return !g_strcmp0 (a->priv->filename, b->priv->filename) &&
+                        !g_strcmp0 (a->priv->params, b->priv->params);
+
+        case EV_LINK_ACTION_TYPE_NAMED:
+                return !g_strcmp0 (a->priv->name, b->priv->name);
+
+        default:
+                return FALSE;
+        }
+
+        return FALSE;
+}
diff --git a/libdocument/ev-link-action.h b/libdocument/ev-link-action.h
index 43d1673..3d6c5fd 100644
--- a/libdocument/ev-link-action.h
+++ b/libdocument/ev-link-action.h
@@ -75,6 +75,9 @@ EvLinkAction    *ev_link_action_new_layers_state (GList        *show_list,
                                                  GList        *hide_list,
                                                  GList        *toggle_list);
 
+gboolean         ev_link_action_equal            (EvLinkAction *a,
+                                                  EvLinkAction *b);
+
 G_END_DECLS
 
 #endif /* EV_LINK_ACTION_H */
diff --git a/libdocument/ev-link-dest.c b/libdocument/ev-link-dest.c
index 355c49b..a8413da 100644
--- a/libdocument/ev-link-dest.c
+++ b/libdocument/ev-link-dest.c
@@ -519,3 +519,61 @@ ev_link_dest_new_page_label (const gchar *page_label)
                                           "type", EV_LINK_DEST_TYPE_PAGE_LABEL,
                                           NULL));
 }
+
+gboolean
+ev_link_dest_equal (EvLinkDest *a,
+                    EvLinkDest *b)
+{
+        g_return_val_if_fail (EV_IS_LINK_DEST (a), FALSE);
+        g_return_val_if_fail (EV_IS_LINK_DEST (b), FALSE);
+
+        if (a == b)
+                return TRUE;
+
+        if (a->priv->type != b->priv->type)
+                return FALSE;
+
+        switch (a->priv->type) {
+        case EV_LINK_DEST_TYPE_PAGE:
+                return a->priv->page == b->priv->page;
+
+        case EV_LINK_DEST_TYPE_XYZ:
+                return a->priv->page == b->priv->page &&
+                        a->priv->left == b->priv->left &&
+                        a->priv->top == b->priv->top &&
+                        a->priv->zoom == b->priv->zoom &&
+                        a->priv->change == b->priv->change;
+
+        case EV_LINK_DEST_TYPE_FIT:
+                return a->priv->page == b->priv->page;
+
+        case EV_LINK_DEST_TYPE_FITH:
+                return a->priv->page == b->priv->page &&
+                        a->priv->top == b->priv->top &&
+                        a->priv->change == b->priv->change;
+
+        case EV_LINK_DEST_TYPE_FITV:
+                return a->priv->page == b->priv->page &&
+                        a->priv->left == b->priv->left &&
+                        a->priv->change == b->priv->change;
+
+        case EV_LINK_DEST_TYPE_FITR:
+                return a->priv->page == b->priv->page &&
+                        a->priv->left == b->priv->left &&
+                        a->priv->top == b->priv->top &&
+                        a->priv->right == b->priv->right &&
+                        a->priv->bottom == b->priv->bottom &&
+                        a->priv->change == b->priv->change;
+
+        case EV_LINK_DEST_TYPE_NAMED:
+                return !g_strcmp0 (a->priv->named, b->priv->named);
+
+        case EV_LINK_DEST_TYPE_PAGE_LABEL:
+                return !g_strcmp0 (a->priv->page_label, b->priv->page_label);
+
+        default:
+                return FALSE;
+        }
+
+        return FALSE;
+}
diff --git a/libdocument/ev-link-dest.h b/libdocument/ev-link-dest.h
index 995a048..8e0e8eb 100644
--- a/libdocument/ev-link-dest.h
+++ b/libdocument/ev-link-dest.h
@@ -90,6 +90,9 @@ EvLinkDest     *ev_link_dest_new_fitr       (gint         page,
 EvLinkDest     *ev_link_dest_new_named      (const gchar *named_dest);
 EvLinkDest     *ev_link_dest_new_page_label (const gchar *page_label);
 
+gboolean        ev_link_dest_equal          (EvLinkDest  *a,
+                                             EvLinkDest  *b);
+
 G_END_DECLS
 
 #endif /* EV_LINK_DEST_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]