Commit ff5da0f2 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Merge branch 'release/0.3.3'

parents 2bedb3b3 bec9edb5
*.o
*~
.depend
pdf.so
*.swp
zathura-version-check
.ycm_extra_conf.*
compile_commands.json
tags
build/
# See LICENSE file for license and copyright information
# General information
PROJECT_NAME = zathura-pdf-mupdf
OUTPUT_DIRECTORY = ./doc/
OUTPUT_LANGUAGE = English
TAB_SIZE = 2
EXTRACT_ALL = YES
OPTIMIZE_OUTPUT_FOR_C = YES
DOXYFILE_ENCODING = UTF-8
TYPEDEF_HIDES_STRUCT = YES
# Warning and progress messages
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
# Input files
INPUT =
FILE_PATTERNS = *.h *.c
RECURSIVE = YES
# Output files
GENERATE_HTML = YES
GENERATE_LATEX = NO
GENERATE_RTF = NO
GENERATE_XML = NO
SOURCE_BROWSER = YES
# See LICENSE file for license and copyright information
include config.mk
include common.mk
PROJECT = zathura-pdf-mupdf
PLUGIN = pdf
SOURCE = $(sort $(wildcard *.c))
HEADER = $(sort $(wildcard *.h))
OBJECTS = ${SOURCE:.c=.o}
DOBJECTS = ${SOURCE:.c=.do}
CPPFLAGS += "-DVERSION_MAJOR=${VERSION_MAJOR}"
CPPFLAGS += "-DVERSION_MINOR=${VERSION_MINOR}"
CPPFLAGS += "-DVERSION_REV=${VERSION_REV}"
all: options ${PLUGIN}.so
zathura-version-check:
ifneq ($(ZATHURA_VERSION_CHECK), 0)
$(error "The minimum required version of zathura is ${ZATHURA_MIN_VERSION}")
endif
$(QUIET)touch zathura-version-check
options:
$(ECHO) ${PLUGIN} build options:
$(ECHO) "CFLAGS = ${CFLAGS}"
$(ECHO) "LDFLAGS = ${LDFLAGS}"
$(ECHO) "DFLAGS = ${DFLAGS}"
$(ECHO) "CC = ${CC}"
%.o: %.c
$(ECHO) CC $<
@mkdir -p .depend
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
%.do: %.c
$(ECHO) CC $<
@mkdir -p .depend
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
${OBJECTS}: config.mk zathura-version-check
${DOBJECTS}: config.mk zathura-version-check
${PLUGIN}.so: ${OBJECTS}
$(ECHO) LD $@
$(QUIET)${CC} -shared ${LDFLAGS} -o $@ $(OBJECTS) ${LIBS}
${PLUGIN}-debug.so: ${DOBJECTS}
$(ECHO) LD $@
$(QUIET)${CC} -shared ${LDFLAGS} -o $@ $(DOBJECTS) ${LIBS}
clean:
$(QUIET)rm -rf ${OBJECTS} ${DOBJECTS} $(PLUGIN).so $(PLUGIN)-debug.so \
doc .depend ${PROJECT}-${VERSION}.tar.gz zathura-version-check
debug: options ${PLUGIN}-debug.so
dist: clean
$(QUIET)mkdir -p ${PROJECT}-${VERSION}
$(QUIET)cp -R LICENSE Makefile config.mk common.mk Doxyfile \
${HEADER} ${SOURCE} AUTHORS ${PROJECT}.desktop \
${PROJECT}-${VERSION}
$(QUIET)tar -cf ${PROJECT}-${VERSION}.tar ${PROJECT}-${VERSION}
$(QUIET)gzip ${PROJECT}-${VERSION}.tar
$(QUIET)rm -rf ${PROJECT}-${VERSION}
doc: clean
$(QUIET)doxygen Doxyfile
install: all
$(ECHO) installing ${PLUGIN} plugin
$(QUIET)mkdir -p ${DESTDIR}${PLUGINDIR}
$(QUIET)cp -f ${PLUGIN}.so ${DESTDIR}${PLUGINDIR}
$(QUIET)mkdir -m 755 -p ${DESTDIR}${DESKTOPPREFIX}
$(ECHO) installing desktop file
$(QUIET)install -m 644 ${PROJECT}.desktop ${DESTDIR}${DESKTOPPREFIX}
uninstall:
$(ECHO) uninstalling ${PLUGIN} plugin
$(QUIET)rm -f ${DESTDIR}${PLUGINDIR}/${PLUGIN}.so
$(QUIET)rmdir --ignore-fail-on-non-empty ${DESTDIR}${PLUGINDIR} 2> /dev/null
$(ECHO) removing desktop file
$(QUIET)rm -f ${DESTDIR}${DESKTOPPREFIX}/${PROJECT}.desktop
$(QUIET)rmdir --ignore-fail-on-non-empty ${DESTDIR}${DESKTOPPREFIX} 2> /dev/null
-include $(wildcard .depend/*.dep)
.PHONY: all options clean debug doc dist install uninstall
......@@ -7,8 +7,7 @@ Requirements
------------
zathura (>= 0.2.0)
girara
mupdf (>= 1.7)
openjpeg (>= 2.0)
mupdf (>= 1.12)
Installation
------------
......
# See LICENSE file for license and copyright information
ifeq "$(VERBOSE)" "0"
ECHO=@echo
QUIET=@
else
ECHO=@\#
QUIET=
endif
# See LICENSE file for license and copyright information
VERSION_MAJOR = 0
VERSION_MINOR = 3
VERSION_REV = 2
VERSION = ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}
PKG_CONFIG ?= pkg-config
# minimum required zathura version
ZATHURA_MIN_VERSION = 0.3.8
ZATHURA_VERSION_CHECK ?= $(shell $(PKG_CONFIG) --atleast-version=$(ZATHURA_MIN_VERSION) zathura; echo $$?)
ZATHURA_GTK_VERSION ?= $(shell $(PKG_CONFIG) --variable=GTK_VERSION zathura)
# paths
PREFIX ?= /usr
LIBDIR ?= ${PREFIX}/lib
DESKTOPPREFIX ?= ${PREFIX}/share/applications
# libs
CAIRO_INC ?= $(shell $(PKG_CONFIG) --cflags cairo)
CAIRO_LIB ?= $(shell $(PKG_CONFIG) --libs cairo)
GTK_INC ?= $(shell $(PKG_CONFIG) --cflags gtk+-${ZATHURA_GTK_VERSION}.0)
GTK_LIB ?= $(shell $(PKG_CONFIG) --libs gtk+-${ZATHURA_GTK_VERSION}.0)
GIRARA_INC ?= $(shell $(PKG_CONFIG) --cflags girara-gtk${ZATHURA_GTK_VERSION})
GIRARA_LIB ?= $(shell $(PKG_CONFIG) --libs girara-gtk${ZATHURA_GTK_VERSION})
ZATHURA_INC ?= $(shell $(PKG_CONFIG) --cflags zathura)
PLUGINDIR ?= $(shell $(PKG_CONFIG) --variable=plugindir zathura)
ifeq (,${PLUGINDIR})
PLUGINDIR = ${LIBDIR}/zathura
endif
OPENSSL_INC ?= $(shell $(PKG_CONFIG) --cflags libcrypto)
OPENSSL_LIB ?= $(shell $(PKG_CONFIG) --libs libcrypto)
FREETYPE_INC ?= $(shell $(PKG_CONFIG) --cflags freetype2)
FREETYPE_LIB ?= $(shell $(PKG_CONFIG) --libs freetype2)
HARFBUZZ_INC ?= $(shell $(PKG_CONFIG) --cflags harfbuzz)
HARFBUZZ_LIB ?= $(shell $(PKG_CONFIG) --libs harfbuzz)
MUPDF_LIB ?= -lmupdf -lmupdfthird
INCS = ${GTK_INC} ${GIRARA_INC} ${OPENSSL_INC} ${CAIRO_INC} ${ZATHURA_INC} ${FREETYPE_INC} ${HARFBUZZ_INC}
LIBS = ${GTK_LIB} ${GIRARA_LIB} ${MUPDF_LIB} ${OPENSSL_LIB} ${CAIRO_LIB} ${FREETYPE_LIB} ${HARFBUZZ_LIB} -ljbig2dec -lopenjp2 -ljpeg -lz
# compiler flags
CFLAGS += -std=c99 -fPIC -pedantic -Wall -Wno-format-zero-length $(INCS)
# linker flags
LDFLAGS += -fPIC
# debug
DFLAGS ?= -g
# compiler
CC ?= gcc
LD ?= ld
# set to something != 0 if you want verbose build output
VERBOSE ?= 0
install_data('org.pwmt.zathura-pdf-mupdf.metainfo.xml', install_dir: metainfodir)
install_data('org.pwmt.zathura-pdf-mupdf.desktop', install_dir: desktopdir)
[Desktop Entry]
Version=1.0
Type=Application
Name=Zathura
Comment=A minimalistic document viewer
Exec=zathura %U
Terminal=false
NoDisplay=true
Categories=Office;Viewer;
MimeType=application/pdf;application/oxps;application/epub+zip;
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2015-2018 pwmt.org -->
<component type="addon">
<id>org.pwmt.zathura-pdf-mupdf</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>Zlib</project_license>
<extends>org.pwmt.zathura</extends>
<name>Zathura-PDF-MuPDF</name>
<summary>PDF plugin for zathura based on MuPDF</summary>
<url type="homepage">https://pwmt.org/projects/zathura-pdf-mupdf/</url>
<update_contact>zathura@lists.pwmt.org</update_contact>
</component>
project('zathura-pdf-mupdf', 'c',
version: '0.3.3',
meson_version: '>=0.43',
default_options: 'c_std=c11'
)
version = meson.project_version()
version_array = version.split('.')
cc = meson.get_compiler('c')
prefix = get_option('prefix')
datadir = get_option('datadir')
metainfodir = join_paths(datadir, 'metainfo')
desktopdir = join_paths(datadir, 'applications')
# required dependencies
zathura = dependency('zathura', version: '>=0.3.9')
girara = dependency('girara-gtk3')
glib = dependency('glib-2.0')
cairo = dependency('cairo')
mupdf = cc.find_library('mupdf')
mupdfthird = cc.find_library('mupdfthird')
build_dependencies = [zathura, girara, glib, cairo, mupdf, mupdfthird]
# defines
defines = [
'-DVERSION_MAJOR=@0@'.format(version_array[0]),
'-DVERSION_MINOR=@0@'.format(version_array[1]),
'-DVERSION_REV=@0@'.format(version_array[2]),
'-D_DEFAULT_SOURCE',
]
# compile flags
flags = [
'-Wall',
'-Wextra',
'-pedantic',
'-Werror=implicit-function-declaration',
'-Werror=vla',
'-fvisibility=hidden'
]
flags = cc.get_supported_arguments(flags)
sources = files(
'zathura-pdf-mupdf/document.c',
'zathura-pdf-mupdf/image.c',
'zathura-pdf-mupdf/index.c',
'zathura-pdf-mupdf/links.c',
'zathura-pdf-mupdf/page.c',
'zathura-pdf-mupdf/plugin.c',
'zathura-pdf-mupdf/render.c',
'zathura-pdf-mupdf/search.c',
'zathura-pdf-mupdf/select.c',
'zathura-pdf-mupdf/utils.c'
)
pdf = shared_module('pdf-mupdf',
sources,
dependencies: build_dependencies,
c_args: defines + flags,
install: true,
install_dir: zathura.get_pkgconfig_variable('plugindir')
)
subdir('data')
/* See LICENSE file for license and copyright information */
#define _POSIX_C_SOURCE 1
#include "plugin.h"
ZATHURA_PLUGIN_REGISTER_WITH_FUNCTIONS(
"pdf-mupdf",
VERSION_MAJOR, VERSION_MINOR, VERSION_REV,
ZATHURA_PLUGIN_FUNCTIONS({
.document_open = (zathura_plugin_document_open_t) pdf_document_open,
.document_free = (zathura_plugin_document_free_t) pdf_document_free,
.document_save_as = (zathura_plugin_document_save_as_t) pdf_document_save_as,
.document_index_generate = (zathura_plugin_document_index_generate_t) pdf_document_index_generate,
.document_get_information = (zathura_plugin_document_get_information_t) pdf_document_get_information,
.page_init = (zathura_plugin_page_init_t) pdf_page_init,
.page_clear = (zathura_plugin_page_clear_t) pdf_page_clear,
.page_search_text = (zathura_plugin_page_search_text_t) pdf_page_search_text,
.page_links_get = (zathura_plugin_page_links_get_t) pdf_page_links_get,
.page_images_get = (zathura_plugin_page_images_get_t) pdf_page_images_get,
.page_get_text = (zathura_plugin_page_get_text_t) pdf_page_get_text,
.page_render = (zathura_plugin_page_render_t) pdf_page_render,
.page_render_cairo = (zathura_plugin_page_render_cairo_t) pdf_page_render_cairo,
.page_image_get_cairo = (zathura_plugin_page_image_get_cairo_t) pdf_page_image_get_cairo
}),
ZATHURA_PLUGIN_MIMETYPES({
"application/pdf",
"application/oxps",
"application/epub+zip"
})
)
[Desktop Entry]
Version=1.0
Type=Application
Name=Zathura
Comment=A minimalistic document viewer
Comment[ca]=Un visualitzador de documents minimalista
Comment[de]=Ein minimalistischer Dokumenten-Betrachter
Comment[el]=Ένας ελαφρύς προβολέας κειμένων
Comment[eo]=Malpeza dokumento spektanto
Comment[es_CL]=Un visor de documentos minimalista
Comment[fr]=Un visionneur de document minimaliste
Comment[he]=מציג מסמכים מינימליסטי
Comment[id_ID]=Pembaca dokumen minimalis
Comment[it]=Un visualizzatore di documenti minimalista
Comment[pl]=Minimalistyczna przeglądarka dokumentów
Comment[pt_BR]=Um visualizador de documentos minimalista
Comment[ru]=Минималистичный просмотрщик документов
Comment[tr]=Minimalist bir belge görüntüleyicisi
Comment[uk_UA]=Легкий переглядач документів
Exec=zathura %U
Terminal=false
NoDisplay=true
Categories=Office;Viewer;
MimeType=application/pdf;
/* See LICENSE file for license and copyright information */
#define _POSIX_C_SOURCE 1
#include <mupdf/fitz.h>
#include <mupdf/pdf.h>
......@@ -53,7 +51,7 @@ pdf_document_open(zathura_document_t* document)
/* authenticate if password is required and given */
if (fz_needs_password(mupdf_document->ctx, mupdf_document->document) != 0) {
if (password == NULL || fz_authenticate_password(mupdf_document->ctx, mupdf_document->document, (char*) password) == 0) {
if (password == NULL || fz_authenticate_password(mupdf_document->ctx, mupdf_document->document, password) == 0) {
error = ZATHURA_ERROR_INVALID_PASSWORD;
goto error_free;
}
......@@ -62,7 +60,7 @@ pdf_document_open(zathura_document_t* document)
zathura_document_set_number_of_pages(document, fz_count_pages(mupdf_document->ctx, mupdf_document->document));
zathura_document_set_data(document, mupdf_document);
return error;
return ZATHURA_ERROR_OK;
error_free:
......@@ -85,8 +83,10 @@ error_ret:
}
zathura_error_t
pdf_document_free(zathura_document_t* document, mupdf_document_t* mupdf_document)
pdf_document_free(zathura_document_t* document, void* data)
{
mupdf_document_t* mupdf_document = data;
if (document == NULL || mupdf_document == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
......@@ -100,15 +100,16 @@ pdf_document_free(zathura_document_t* document, mupdf_document_t* mupdf_document
}
zathura_error_t
pdf_document_save_as(zathura_document_t* document, mupdf_document_t*
mupdf_document, const char* path)
pdf_document_save_as(zathura_document_t* document, void* data, const char* path)
{
mupdf_document_t* mupdf_document = data;
if (document == NULL || mupdf_document == NULL || path == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
fz_try (mupdf_document->ctx) {
pdf_save_document(mupdf_document->ctx, (pdf_document*) mupdf_document->document, (char*) path, NULL);
pdf_save_document(mupdf_document->ctx, (pdf_document*) mupdf_document->document, path, NULL);
} fz_catch (mupdf_document->ctx) {
return ZATHURA_ERROR_UNKNOWN;
}
......@@ -117,9 +118,10 @@ pdf_document_save_as(zathura_document_t* document, mupdf_document_t*
}
girara_list_t*
pdf_document_get_information(zathura_document_t* document, mupdf_document_t*
mupdf_document, zathura_error_t* error)
pdf_document_get_information(zathura_document_t* document, void* data, zathura_error_t* error)
{
mupdf_document_t* mupdf_document = data;
if (document == NULL || mupdf_document == NULL || error == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......
/* See LICENSE file for license and copyright information */
#define _POSIX_C_SOURCE 1
#include <glib.h>
#include <girara/datastructures.h>
#include <mupdf/pdf.h>
......@@ -12,8 +10,10 @@
static void pdf_zathura_image_free(zathura_image_t* image);
girara_list_t*
pdf_page_images_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error)
pdf_page_images_get(zathura_page_t* page, void* data, zathura_error_t* error)
{
mupdf_page_t* mupdf_page = data;
if (page == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......@@ -76,9 +76,11 @@ error_ret:
}
cairo_surface_t*
pdf_page_image_get_cairo(zathura_page_t* page, mupdf_page_t* mupdf_page,
pdf_page_image_get_cairo(zathura_page_t* page, void* data,
zathura_image_t* image, zathura_error_t* error)
{
mupdf_page_t* mupdf_page = data;
if (page == NULL || mupdf_page == NULL || image == NULL || image->data == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......@@ -107,8 +109,10 @@ pdf_page_image_get_cairo(zathura_page_t* page, mupdf_page_t* mupdf_page,
unsigned char* s = fz_pixmap_samples(mupdf_page->ctx, pixmap);
unsigned int n = fz_pixmap_components(mupdf_page->ctx, pixmap);
for (unsigned int y = 0; y < fz_pixmap_height(mupdf_page->ctx, pixmap); y++) {
for (unsigned int x = 0; x < fz_pixmap_width(mupdf_page->ctx, pixmap); x++) {
const int height = fz_pixmap_height(mupdf_page->ctx, pixmap);
const int width = fz_pixmap_width(mupdf_page->ctx, pixmap);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
guchar* p = surface_data + y * rowstride + x * 4;
// RGB
......
/* See LICENSE file for license and copyright information */
#define _POSIX_C_SOURCE 1
#include <girara/datastructures.h>
#include "plugin.h"
......@@ -10,8 +8,10 @@ static void build_index(fz_context* ctx, fz_document* document, fz_outline*
outline, girara_tree_node_t* root);
girara_tree_node_t*
pdf_document_index_generate(zathura_document_t* document, mupdf_document_t* mupdf_document, zathura_error_t* error)
pdf_document_index_generate(zathura_document_t* document, void* data, zathura_error_t* error)
{
mupdf_document_t* mupdf_document = data;
if (document == NULL || mupdf_document == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......@@ -70,7 +70,7 @@ build_index(fz_context* ctx, fz_document* document, fz_outline* outline, girara_
target.page_number = fz_resolve_link(ctx, document, outline->uri, &x, &y);
target.left = x;
target.top = y;
target.scale = 0.0;
target.zoom = 0.0;
}
index_element->link = zathura_link_new(type, rect, target);
......
/* See LICENSE file for license and copyright information */
#define _POSIX_C_SOURCE 1
#include <glib.h>
#include "plugin.h"
girara_list_t*
pdf_page_links_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error)
pdf_page_links_get(zathura_page_t* page, void* data, zathura_error_t* error)
{
if (page == NULL) {
if (error != NULL) {
......@@ -16,6 +14,7 @@ pdf_page_links_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error
goto error_ret;
}
mupdf_page_t* mupdf_page = data;
zathura_document_t* document = zathura_page_get_document(page);
if (document == NULL || mupdf_page == NULL || mupdf_page->page == NULL) {
goto error_ret;
......@@ -61,7 +60,7 @@ pdf_page_links_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error
mupdf_document->document, link->uri, &x, &y);
target.left = x;
target.top = y;
target.scale = 0.0;
target.zoom = 0.0;
}
zathura_link_t* zathura_link = zathura_link_new(type, position, target);
......
/* See LICENSE file for license and copyright information */
#define _POSIX_C_SOURCE 1
#include "plugin.h"
zathura_error_t
......@@ -60,12 +58,13 @@ error_free:
}
zathura_error_t
pdf_page_clear(zathura_page_t* page, mupdf_page_t* mupdf_page)
pdf_page_clear(zathura_page_t* page, void* data)
{
if (page == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
mupdf_page_t* mupdf_page = data;
zathura_document_t* document = zathura_page_get_document(page);
mupdf_document_t* mupdf_document = zathura_document_get_data(document);
......
/* See LICENSE file for license and copyright information */
#include "plugin.h"
ZATHURA_PLUGIN_REGISTER_WITH_FUNCTIONS(
"pdf-mupdf",
VERSION_MAJOR, VERSION_MINOR, VERSION_REV,
ZATHURA_PLUGIN_FUNCTIONS({
.document_open = pdf_document_open,
.document_free = pdf_document_free,
.document_save_as = pdf_document_save_as,
.document_index_generate = pdf_document_index_generate,
.document_get_information = pdf_document_get_information,
.page_init = pdf_page_init,
.page_clear = pdf_page_clear,
.page_search_text = pdf_page_search_text,
.page_links_get = pdf_page_links_get,
.page_images_get = pdf_page_images_get,
.page_get_text = pdf_page_get_text,
.page_render = pdf_page_render,
.page_render_cairo = pdf_page_render_cairo,
.page_image_get_cairo = pdf_page_image_get_cairo
}),
ZATHURA_PLUGIN_MIMETYPES({
"application/pdf",
"application/oxps",
"application/epub+zip"
})
)
......@@ -39,7 +39,7 @@ zathura_error_t pdf_document_open(zathura_document_t* document);
* @param document Zathura document
* @return true if no error occurred, otherwise false
*/
zathura_error_t pdf_document_free(zathura_document_t* document, mupdf_document_t* mupdf_document);
zathura_error_t pdf_document_free(zathura_document_t* document, void* mupdf_document);
/**
* Saves the document to the given path
......@@ -50,7 +50,7 @@ zathura_error_t pdf_document_free(zathura_document_t* document, mupdf_document_t
* zathura_error_t
*/
zathura_error_t pdf_document_save_as(zathura_document_t* document,
mupdf_document_t* mupdf_document, const char* path);
void* mupdf_document, const char* path);
/**
* Generates the index of the document
......@@ -62,7 +62,7 @@ zathura_error_t pdf_document_save_as(zathura_document_t* document,
* no index)
*/
girara_tree_node_t* pdf_document_index_generate(zathura_document_t* document,
mupdf_document_t* mupdf_document, zathura_error_t* error);
void* mupdf_document, zathura_error_t* error);
/**
* Returns a reference to a page
......@@ -78,7 +78,7 @@ zathura_error_t pdf_page_init(zathura_page_t* page);
* @param page Page
* @return true if no error occurred, otherwise false
*/
zathura_error_t pdf_page_clear(zathura_page_t* page, mupdf_page_t* mupdf_page);
zathura_error_t pdf_page_clear(zathura_page_t* page, void* mupdf_page);
/**
* Searches for a specific text on a page and returns a list of results
......@@ -89,7 +89,7 @@ zathura_error_t pdf_page_clear(zathura_page_t* page, mupdf_page_t* mupdf_page);
* error occurred
* @return List of search results or NULL if an error occurred
*/
girara_list_t* pdf_page_search_text(zathura_page_t* page, mupdf_page_t* mupdf_page, const char* text, zathura_error_t* error);
girara_list_t* pdf_page_search_text(zathura_page_t* page, void* mupdf_page, const char* text, zathura_error_t* error);
/**
* Returns a list of internal/external links that are shown on the given page
......@@ -99,7 +99,7 @@ girara_list_t* pdf_page_search_text(zathura_page_t* page, mupdf_page_t* mupdf_pa
* error occurred
* @return List of links or NULL if an error occurred
*/
girara_list_t* pdf_page_links_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error);
girara_list_t* pdf_page_links_get(zathura_page_t* page, void* mupdf_page, zathura_error_t* error);
/**
* Returns a list of images included on the zathura page
......@@ -109,7 +109,7 @@ girara_list_t* pdf_page_links_get(zathura_page_t* page, mupdf_page_t* mupdf_page
* error occurred
* @return List of images
*/
girara_list_t* pdf_page_images_get(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error);
girara_list_t* pdf_page_images_get(zathura_page_t* page, void* mupdf_page, zathura_error_t* error);
/**
* Gets the content of the image in a cairo surface
......@@ -120,7 +120,7 @@ girara_list_t* pdf_page_images_get(zathura_page_t* page, mupdf_page_t* mupdf_pag
* error occurred
* @return The cairo image surface or NULL if an error occurred
*/
cairo_surface_t* pdf_page_image_get_cairo(zathura_page_t* page, mupdf_page_t*
cairo_surface_t* pdf_page_image_get_cairo(zathura_page_t* page, void*
mupdf_page, zathura_image_t* image, zathura_error_t* error);
/**
......@@ -131,7 +131,7 @@ cairo_surface_t* pdf_page_image_get_cairo(zathura_page_t* page, mupdf_page_t*
* occurred
* @return The selected text (needs to be deallocated with g_free)
*/
char* pdf_page_get_text(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_rectangle_t rectangle, zathura_error_t* error);
char* pdf_page_get_text(zathura_page_t* page, void* mupdf_page, zathura_rectangle_t rectangle, zathura_error_t* error);
/**
* Returns a list of document information entries of the document
......@@ -142,7 +142,7 @@ char* pdf_page_get_text(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_
* @return List of information entries or NULL if an error occurred
*/
girara_list_t* pdf_document_get_information(zathura_document_t* document,
mupdf_document_t* mupdf_document, zathura_error_t* error);
void* mupdf_document, zathura_error_t* error);
/**
* Renders a page and returns a allocated image buffer which has to be freed
......@@ -153,7 +153,7 @@ girara_list_t* pdf_document_get_information(zathura_document_t* document,
* error occurred
* @return Image buffer or NULL if an error occurred
*/
zathura_image_buffer_t* pdf_page_render(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error);
zathura_image_buffer_t* pdf_page_render(zathura_page_t* page, void* mupdf_page, zathura_error_t* error);
/**
* Renders a page onto a cairo object
......@@ -162,6 +162,6 @@ zathura_image_buffer_t* pdf_page_render(zathura_page_t* page, mupdf_page_t* mupd
* @param cairo Cairo object
* @return true if no error occurred, otherwise false
*/
zathura_error_t pdf_page_render_cairo(zathura_page_t* page, mupdf_page_t* mupdf_page, cairo_t* cairo, bool printing);
zathura_error_t pdf_page_render_cairo(zathura_page_t* page, void* mupdf_page, cairo_t* cairo, bool printing);
#endif // PDF_H
/* See LICENSE file for license and copyright information */
#define _POSIX_C_SOURCE 1
#include <glib.h>
#include "plugin.h"
static zathura_error_t
pdf_page_render_to_buffer(mupdf_document_t* mupdf_document, mupdf_page_t* mupdf_page,
unsigned char* image, int rowstride, int components,
unsigned char* image, int GIRARA_UNUSED(rowstride), int GIRARA_UNUSED(components),
unsigned int page_width, unsigned int page_height,
double scalex, double scaley)
{
......@@ -55,8 +53,10 @@ pdf_page_render_to_buffer(mupdf_document_t* mupdf_document, mupdf_page_t* mupdf_
}
zathura_image_buffer_t*
pdf_page_render(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t* error)
pdf_page_render(zathura_page_t* page, void* data, zathura_error_t* error)
{
mupdf_page_t* mupdf_page = data;
if (page == NULL || mupdf_page == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_INVALID_ARGUMENTS;
......@@ -105,8 +105,10 @@ pdf_page_render(zathura_page_t* page, mupdf_page_t* mupdf_page, zathura_error_t*
}
zathura_error_t
pdf_page_render_cairo(zathura_page_t* page, mupdf_page_t* mupdf_page, cairo_t* cairo, bool GIRARA_UNUSED(printing))
pdf_page_render_cairo(zathura_page_t* page, void* data, cairo_t* cairo, bool GIRARA_UNUSED(printing))
{
mupdf_page_t* mupdf_page = data;
if (page == NULL || mupdf_page == NULL) {
return ZATHURA_ERROR_INVALID_ARGUMENTS;
}
......
/* See LICENSE file for license and copyright information */
#define _POSIX_C_SOURCE 1
#define N_SEARCH_RESULTS 512
#include <glib.h>
......@@ -10,8 +8,10 @@
#include "utils.h"