1
0
mirror of https://gitlab.gnome.org/GNOME/evince synced 2024-06-30 22:54:23 +00:00
Commit Graph

395 Commits

Author SHA1 Message Date
Pablo Correa Gómez
273511ac39
libdocument: simplify freeing memory by better exploiting glib functions
Mostly g_clear_object and g_clear_pointer. But also some small
simplifications depending on the context.
2023-03-24 09:58:48 +01:00
Pablo Correa Gómez
80d7ac219d libdocument: Remove trailing whitespaces 2023-03-22 20:15:51 +00:00
Pablo Correa Gómez
d1fad249c5 ev-backend-info: make private a function only used in the .c file 2023-03-21 03:39:05 +00:00
Nelson Benítez León
c76be8ba6f use default color when annotation has no color
Annotations may come with a NULL color, use
a default color there instead of letting
undefined GdkRGBA to crash the application.

We take the chance to share this default color
to be the same we already use when creating
an annotation from Evince.

We also take the chance to replace deprecated
function ev_annotation_set_color() with
ev_annotation_set_rgba()

Fixes crash in #1800
2022-06-05 11:52:56 -04:00
Germán Poo-Caamaño
204ec3a77b Add deprecation guards to now old find text related functions 2022-05-23 00:04:27 -04:00
Nelson Benítez León
495dd97e46 Add support for multi-line text search
which is available in Poppler since version 21.03.0

For that we create a new EvFindRectangle type to hold more match
information apart from coordinates, and use it all across Evince
including pdf backend (ev-poppler.cc) and djvu backend (djvu-document.c)
which are the only backends implementing the EvDocumentFindInterface.

To not break API compatibility, we added a new EvDocumentFindInterface
function which returns GList of this new EvFindRectangle type:

   GList *(* find_text_extended) (EvDocumentFind *document_find,
                                  EvPage         *page,
                                  const gchar    *text,
                                  EvFindOptions   options);

and changed Evince to use this new function instead of find_text_with_options().

Some info about how this new search feature works:

 - Ignores hyphen character while matching when:
      1) it's the last character of the line.
      2) its corresponding matching character in the search term
         is not an hyphen too.

 - Any whitespace characters in the search term will be allowed
   to match on the logic position where the lines split (i.e. what
   would normally be the newline character in a text file, but
   PDF text does not include newline characters between lines).

 - It won't match on text spanning more than two lines, i.e. it
   only matches text spanning from end of one line to start of
   next line.

Part of issue #333
2022-05-22 21:14:46 +00:00
Cédric Krier
395312868b libdocument: get backends directory from environment
When bundling evince library, the directory of the backends is copied in
another directory than the installation directory.

For example, cx_freeze is a popular Python package for creating
standalone executables from Python scripts. For applications using
Evince as a library, cx_freeze copies the evince dlls in the main
directory with the executable and the backends are copied to this
directory. So the directory is relative to the directory where the
executable is installed and not from the package installation
directory of evince (because it is not really installed).

Therefore, to help the use case where Evince is bundled as a library,
and not installes, we need a way to specify dynamically the path of this
new directory.

See MR !327 for more discussion.
2022-04-16 18:06:42 -04:00
Germán Poo-Caamaño
5819ea5ec4 libdocument: Fix annotations in functions
Add missing annotations, remove duplications, and fix arguments.
2022-03-28 23:58:35 -03:00
Germán Poo-Caamaño
781ed5fd73 libdocument: Remove headers of already removed functions
ev_document_get_doc_mutex and ev_document_get_fc_mutex were
removed on commit bf90f90e0a,
however their definition were not removed.
2022-03-28 23:58:10 -03:00
Christian Persch
f88af66538 libdocument: Add function to sniff MIME type from FD 2022-01-12 12:44:22 +00:00
Christian Persch
fdc8c4375d libdocument: Add portal helper function
Add ev_should_use_portal() copied from gtk+, which tries to find
out whether the portal should be used.
2022-01-12 02:05:56 +00:00
Cédric Krier
e5c359703a Restore fallback to mime type from URI on Windows
The changeset e7c974340 wrongly deactivate the fallback for Windows and
activate it for all others.
2022-01-11 23:33:39 +00:00
Christian Persch
11ba63defa libdocument: Add API to create EvDocument from file descriptor
Add new EvDocumentClass vfunc load_fd to load the document from
a file descriptor.
2022-01-08 00:03:15 -03:00
Qiu Wenbo
24be012d44 libdocument: make ev_attachment_launch_app use GdkDisplay
Signed-off-by: Qiu Wenbo <qiuwenbo@kylinos.com.cn>
2022-01-08 02:25:36 +00:00
Christian Persch
3c91921701 libdocument: Make XMP parser take data length 2022-01-07 23:27:26 +00:00
Christian Persch
8ad137e40b libdocument: Set EvDocumentInfo.fields_mask when parsing XMP 2022-01-07 23:27:26 +00:00
Christian Persch
9f2f09c357 libdocument: Plug some mem leaks in the XMP parser 2022-01-07 23:27:26 +00:00
Christian Persch
0d25eeddbf libdocument: Fix mismatched allocators
Make sure to only put glib-allocated strings into EvDocumentInfo, not
libxml allocated ones.
2022-01-07 23:27:26 +00:00
Christian Persch
db8b631ea6 libdocument: Factor out function to create GDateTime from tag 2022-01-07 23:27:26 +00:00
Christian Persch
e3d2e6dc42 libdocument: Only register XML namespaces once 2022-01-07 23:27:26 +00:00
Christian Persch
53bb117bec libdocument: Move XMP parsing from backend/pdf to libdocument
In preparation to adding XMP support to DJVU.

https://gitlab.gnome.org/GNOME/evince/-/merge_requests/342
2022-01-07 23:27:26 +00:00
Christian Persch
60ba7b0ee5 all: Replace include guards with pragma once
Instead of using the "#ifndef FOO_H", "#define FOO_H", …, "#endif FOO_H"
guards around the header file, use the "#pragma once".
2021-12-15 02:24:07 +00:00
Christian Persch
1e0a3efa24 libdocument: Move GDateTime members to the extended struct
Commit ed1e94af introduced an unintentional API and ABI break by
changing the creation_date and modified_date members of EvDocumentInfo
from GTime to GDateTime*.

Revert this API/ABI break by adding the created and modified GDateTime
members to EvDocumentInfoExtended, and add public getters and
backend-private setters.

Make the PDF backend set these, and adjust the properties view to use
the new accessor functions.

Fixes: https://gitlab.gnome.org/GNOME/evince/-/issues/1711
2021-12-02 18:35:18 +01:00
Christian Persch
8cd939fa58 libdocument: Make EvDocumentInfo extensible
Add a EvDocumentInfoExtended, and add ev_document_info_new() for use by
backends.
2021-12-02 18:35:18 +01:00
Christian Persch
6a9cd96802 libdocument: Move EvDocumentInfo to its own file
Move EvDocumentInfo and EvDocumentLicense into ev-document-info.c,
and add missing docs.
i
2021-12-02 18:35:18 +01:00
Christian Persch
802ef2ecc0 libdocument: Don't install private headers
Some private headers were mistakenly installed into the public include
directory.
2021-12-01 16:51:33 +01:00
Christian Persch
db2425ac86 libdocument: Use symbol visibility for exported symbols
Add EV_PUBLIC define that uses the visibility attribute to make a symbol
public, and use this to mark exported symbols, instead of exporting
every symbol starting with "ev_", to make sure only symbols actually
intended to be public are exported.

Also add EV_PRIVATE define as an alias for EV_PUBLIC to mark symbols
that are nominally public because they are needed from libview/ or
shell/, but are not actually public API.
2021-12-01 16:51:33 +01:00
Christian Persch
bc595ce828 build: Fix dependency tracking
The executables must declare their dependency on
libevdocument/libevview, so that a rebuild works correctly.
2021-11-30 22:16:19 +00:00
Christian Persch
fb03cdbda1 libdocument: Fix volatile misuse 2021-11-30 22:08:51 +00:00
Germán Poo-Caamaño
05b87a5a26 libdocument: Deprecate GTime usage in annotation's properties
* Use time_t instead of GTime which is not 2038-year safe.
* Add the deprecation information
2021-10-17 17:09:18 +00:00
Germán Poo-Caamaño
ed1e94af8d Use GDateTime for handling document properties
* GTime is deprecated as it not 2038-year safe
* Add deprecation information to no break the API (yet)
2021-10-17 17:09:18 +00:00
Nelson Benítez León
d4ab3574d1 EvTransitionEffect: support duration in decimal value
Property 'duration' of EvTransitionEffect was of
int type, so when passing a 0.5 value it would
cast to zero.

So let's add a new 'duration_real' property to hold
the duration in decimal format, and use it for the
effect's duration.

Fixes #637
2021-06-26 05:06:20 +00:00
Kalev Lember
ca4b7aaff6 Avoid changing soname
Bumping the major version to 40 in commit
288be740b5 inadvertently changed the
soname for shared libevdocument and libevview.

Fix this by making the soname calculation independent from the project
version as the library ABI hasn't actually changed.
2021-03-26 14:53:15 +01:00
Germán Poo-Caamaño
4645b3e5aa Bump to new version scheme
Only major and minor version numbers are used from now on.
2021-03-26 00:08:14 -03:00
Germán Poo-Caamaño
cf45b884a6 libdocument: Fix return value
It must return a gboolean, not a pointer.
2021-02-13 13:51:48 -03:00
Mike Vastola
c3ac0d3dc7 libdocument: Stop trusting phsyical dimensions from monitors
Per gtk#3115#note_904622, no gdk_*_get_*_mm methods may be trusted, so
use defaults.

Fixes #1403
2021-02-01 01:59:17 -03:00
Mike Vastola
36beda0577 libdocument: Fix parameter type in gtk-doc 2021-02-01 01:58:15 -03:00
Vincent Torri
dc631aa511 Windows: fix compilation, CLOEXEC does not exist 2021-01-24 10:56:44 -03:00
Nelson Benítez León
cf4c328ec2 EvDocumentInfo: add new field "contains_js"
and implement it for poppler backend. This field
tells the user if the pdf has any javascript in it.

This depends on the new poppler-glib api (0.90+):
gboolean poppler_document_has_javascript (PopplerDocument *document);
2021-01-24 02:07:52 +00:00
Chris Lamb
3a8954af85 Make the build reproducible
The Reproducible Builds effort <https://reproducible-builds.org/>
noticed that evince could not be built reproducibly.

This is because it generates .h header files that contain the absolute
build path via the @filename@ placeholder.

Use @basename@ instead — these are comments, after all.

Bug-Debian: https://bugs.debian.org/970383
2020-10-13 10:33:40 +01:00
Marek Kasik
fe9573da12 Handle reset form action
Add new type of action EV_LINK_ACTION_TYPE_RESET_FORM for EvLinkAction
together with properties "reset-fields" and "exclude-reset-fields".
The properties controls which fields are reset and are set in PDF document.
This commit extends EvDocumentFormsInterface with new method "reset_form".

Issue #46
2020-08-30 15:28:07 +00:00
Germán Poo-Caamaño
b1de8c2844 pdf: Reimplement 'de facto' tooltip with no ABI break
Structs in EvForm are not opaque, and
Commit e2ad8611a4 introduced a ABI change
2020-08-30 10:27:09 -04:00
vanadiae
35b297759e libdocument: Replace deprecated GTime by GDateTime
Add a new function to localize the time, and deprecate the old
one adding corresponding safeguards for GTime.

GTime is a 32bits in on some systems, and it is not safe year-2038 safe.

Signed-off-by: Germán Poo-Caamaño <gpoo@gnome.org>
2020-07-05 10:55:40 -04:00
Germán Poo-Caamaño
8d6d1a2891 libdocument: Annotate deprecated function
Add deprecation guards, and annotate the function to mention
the version it has been deprecated, plus add to serve as a
visual cue for the deprecation guard
2020-07-04 19:32:44 -04:00
Bastien Nocera
af53ba23d3 libdocument: Load application-specific gdk-pixbuf loaders
Use a new gdk-pixbuf feature to integrate application-provided
gdk-pixbuf loaders.

This makes it easy to include non-standard loaders without touching the
system installation.

See https://gitlab.gnome.org/GNOME/gdk-pixbuf/merge_requests/34
2020-05-31 09:08:23 -04:00
Iñigo Martínez
b27189bb3c build: Remove autotools
To avoid the burden of maintaining multiple build systems, autotools
support has been removed.

GitLab CI configuration has also been updated to use meson.
2020-05-30 22:39:51 -04:00
Germán Poo-Caamaño
c6b0ba3085 libdocument: Fix typos in comments and annotations 2020-05-21 21:59:57 -04:00
Nelson Benítez León
4cc58097a2 markup annotations: use markup text region
when determining if the mouse pointer is over
a markup annotation (used by evince to change
the pointer type). This is more accurate than
just using the annot area.

Implemented as a new libdocument method interface
that we pass it the 'annotation' and 'x,y' coords
and returns us whether that location is over the
actual markup text of the annotation. The poppler
implementation works by checking if there's any
quadrilateral under that location.

For pdf, quadrilaterals represent a more precise
shape of the annotation than just the annotation
area (which is currently used) so by checking
the quads region we avoid false positives when
hovering over blank space.

The "point over a quadrilateral" code is based on:
Algorithm: https://math.stackexchange.com/a/190203
Implementation: https://stackoverflow.com/a/37865332

Fixes issue #1275
2020-05-19 21:59:50 +00:00
Nelson Benítez León
e2ad8611a4 pdf: support 'de facto' tooltip feature
Most pdf readers implement a tooltip feature by
showing the string content of 'TU' field of a
widget annotation that is not linked to any
form field.

Normally, widget annotations carry a reference to a
form field which are used together to implement the
different form widgets. But, the PDF spec does not
forbid standalone (i.e. not linked to any form field)
widget annotations, and the fact is they're been used
by most pdf readers to show a tooltip when the area
of that AnnotWidget is hovered.

According to issue reported files, 'pdfTeX' seems to
be one of the pdf producers incorporating this tooltip
feature.

The support for this feature has been recently been
added to poppler-glib with following api:

gchar*
poppler_form_field_get_alternate_ui_name (PopplerFormField *field)

so this commit uses that api to show tooltips on pdf's
that carry them. For that we add a new 'alt_ui_name'
field to EvFormField and show it as a tooltip when
the field's area is hovered.

Evince issue #842

Poppler issue:
https://gitlab.freedesktop.org/poppler/poppler/issues/34
2020-05-08 04:14:59 +00:00
Matthew Leeds
8257a0555b libdocument: Ignore deprecation warnings in headers
GTime is deprecated, but there's no point in generating deprecation
warnings for projects that include these header files (which won't
change). Warnings are still generated for the corresponding C code.
2020-05-08 03:36:33 +00:00