From f8f762475601a9b308ddd302210aa29b20694f01 Mon Sep 17 00:00:00 2001 From: Masamichi Hosoda Date: Sun, 28 Aug 2016 16:14:12 +0900 Subject: [PATCH v3 1/2] Add poppler_dest_equal() to glib frontend Compare two PopplerDest and returns TRUE if they are equal. It can be passed to g_hash_table_new() as the key_equal_func parameter. bug 97262 --- glib/poppler-action.cc | 37 +++++++++++++++++++++++++++++++++++++ glib/poppler-action.h | 4 ++++ 2 files changed, 41 insertions(+) diff --git a/glib/poppler-action.cc b/glib/poppler-action.cc index 384530f..ea49c65 100644 --- a/glib/poppler-action.cc +++ b/glib/poppler-action.cc @@ -1,6 +1,8 @@ /* poppler-action.cc: glib wrapper for poppler -*- c-basic-offset: 8 -*- * Copyright (C) 2005, Red Hat, Inc. * + * Copyright (C) 2016 Masamichi Hosoda + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -67,6 +69,41 @@ poppler_dest_free (PopplerDest *dest) g_slice_free (PopplerDest, dest); } +/** + * poppler_dest_equal: + * @v1: a #PopplerDest. + * @v2: a #PopplerDest to compare with v1. + * + * Compare two #PopplerDest and returns %TRUE if they are equal. + * It can be passed to %g_hash_table_new() as the %key_equal_func parameter. + **/ +gboolean +poppler_dest_equal (gconstpointer v1, gconstpointer v2) +{ + const PopplerDest *dest1, *dest2; + + dest1 = static_cast(v1); + dest2 = static_cast(v2); + + if (dest1->type == dest2->type && + dest1->page_num == dest2->page_num && + dest1->left == dest2->left && + dest1->bottom == dest2->bottom && + dest1->right == dest2->right && + dest1->top == dest2->top && + dest1->zoom == dest2->zoom && + dest1->change_left == dest2->change_left && + dest1->change_top == dest2->change_top && + dest1->change_zoom == dest2->change_zoom) { + if (dest1->type == POPPLER_DEST_NAMED) + return (strcmp (dest1->named_dest, + dest2->named_dest) == 0); + else + return TRUE; + } + return FALSE; +} + static void poppler_action_layer_free (PopplerActionLayer *action_layer) { diff --git a/glib/poppler-action.h b/glib/poppler-action.h index 2a5d7f8..bfe717e 100644 --- a/glib/poppler-action.h +++ b/glib/poppler-action.h @@ -1,6 +1,8 @@ /* poppler-action.h: glib interface to poppler * Copyright (C) 2004, Red Hat, Inc. * + * Copyright (C) 2016 Masamichi Hosoda + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -310,6 +312,8 @@ GType poppler_dest_get_type (void) G_GNUC_CONST; void poppler_dest_free (PopplerDest *dest); PopplerDest *poppler_dest_copy (PopplerDest *dest); +gboolean poppler_dest_equal (gconstpointer v1, + gconstpointer v2); G_END_DECLS -- 2.8.3