From 1ba891658c705d774da1740e644d761c3f65edb9 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Wed, 27 Apr 2011 19:03:08 +0200 Subject: [PATCH] Moved plugins to own repositories Every plugin is now accesible in a separate repository --- Makefile | 14 +- ft/Makefile | 20 --- ft/djvu/Makefile | 57 -------- ft/djvu/config.mk | 21 --- ft/djvu/djvu.c | 269 ---------------------------------- ft/djvu/djvu.h | 30 ---- ft/pdf-mupdf/Makefile | 57 -------- ft/pdf-mupdf/config.mk | 21 --- ft/pdf-mupdf/pdf.c | 244 ------------------------------- ft/pdf-mupdf/pdf.h | 33 ----- ft/pdf-poppler/Makefile | 57 -------- ft/pdf-poppler/config.mk | 21 --- ft/pdf-poppler/pdf.c | 301 --------------------------------------- ft/pdf-poppler/pdf.h | 28 ---- ft/ps/Makefile | 57 -------- ft/ps/config.mk | 21 --- ft/ps/ps.c | 180 ----------------------- ft/ps/ps.h | 22 --- 18 files changed, 8 insertions(+), 1445 deletions(-) delete mode 100644 ft/Makefile delete mode 100644 ft/djvu/Makefile delete mode 100644 ft/djvu/config.mk delete mode 100644 ft/djvu/djvu.c delete mode 100644 ft/djvu/djvu.h delete mode 100644 ft/pdf-mupdf/Makefile delete mode 100644 ft/pdf-mupdf/config.mk delete mode 100644 ft/pdf-mupdf/pdf.c delete mode 100644 ft/pdf-mupdf/pdf.h delete mode 100644 ft/pdf-poppler/Makefile delete mode 100644 ft/pdf-poppler/config.mk delete mode 100644 ft/pdf-poppler/pdf.c delete mode 100644 ft/pdf-poppler/pdf.h delete mode 100644 ft/ps/Makefile delete mode 100644 ft/ps/config.mk delete mode 100644 ft/ps/ps.c delete mode 100644 ft/ps/ps.h diff --git a/Makefile b/Makefile index f73901f..2e2616c 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,11 @@ include config.mk PROJECT = zathura -SOURCE = $(shell find . -iname "*.c" -a ! -iwholename "*./ft*") +SOURCE = $(shell find . -iname "*.c") OBJECTS = $(patsubst %.c, %.o, $(SOURCE)) DOBJECTS = $(patsubst %.c, %.do, $(SOURCE)) all: options ${PROJECT} - ${MAKE} -C ft options: @echo ${PROJECT} build options: @@ -37,14 +36,12 @@ ${PROJECT}: ${OBJECTS} clean: @rm -rf ${PROJECT} ${OBJECTS} ${PROJECT}-${VERSION}.tar.gz \ ${DOBJECTS} ${PROJECT}-debug .depend - @${MAKE} -C ft clean ${PROJECT}-debug: ${DOBJECTS} @echo CC -o ${PROJECT}-debug @${CC} ${LDFLAGS} -o ${PROJECT}-debug ${DOBJECTS} ${LIBS} debug: ${PROJECT}-debug - @${MAKE} -C ft debug valgrind: debug valgrind --tool=memcheck --leak-check=yes --show-reachable=yes \ @@ -66,18 +63,23 @@ install: all @mkdir -p ${DESTDIR}${PREFIX}/bin @cp -f ${PROJECT} ${DESTDIR}${PREFIX}/bin @chmod 755 ${PROJECT} ${DESTDIR}${PREFIX}/bin/${PROJECT} + @echo installing header file + @mkdir -p ${DESTDIR}${PREFIX}/include/${PROJECT} + @cp -f document.h ${DESTDIR}${PREFIX}/include/${PROJECT} + @cp -f zathura.h ${DESTDIR}${PREFIX}/include/${PROJECT} @echo installing manual page @mkdir -p ${DESTDIR}${MANPREFIX}/man1 @sed "s/VERSION/${VERSION}/g" < ${PROJECT}.1 > ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1 @chmod 644 ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1 - @${MAKE} -C ft install uninstall: @echo removing executable file @rm -f ${DESTDIR}${PREFIX}/bin/${PROJECT} + @echo removing header file + @rm -f ${DESTDIR}${PREFIX}/include/${PROJECT}/document.h + @rm -f ${DESTDIR}${PREFIX}/include/${PROJECT}/zathura.h @echo removing manual page @rm -f ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1 - @${MAKE} -C ft uninstall -include $(wildcard .depend/*.dep) diff --git a/ft/Makefile b/ft/Makefile deleted file mode 100644 index 254eeb4..0000000 --- a/ft/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# See LICENSE file for license and copyright information - -SUBDIRS = $(shell find -mindepth 2 -maxdepth 2 -iname "Makefile" -exec dirname '{}' \;) - -all: - @for dir in ${SUBDIRS}; do ${MAKE} -C $${dir}; done - -debug: - @for dir in ${SUBDIRS}; do ${MAKE} -C $${dir} debug; done - -clean: - @for dir in ${SUBDIRS}; do ${MAKE} -C $${dir} clean; done - -install: - @for dir in ${SUBDIRS}; do ${MAKE} -C $${dir} install; done - -uninstall: - @for dir in ${SUBDIRS}; do ${MAKE} -C $${dir} uninstall; done - -.PHONY: all debug clean install uninstall diff --git a/ft/djvu/Makefile b/ft/djvu/Makefile deleted file mode 100644 index a19da49..0000000 --- a/ft/djvu/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -# See LICENSE file for license and copyright information - -include config.mk - -PLUGIN = djvu -SOURCE = djvu.c -OBJECTS = ${SOURCE:.c=.o} -DOBJECTS = ${SOURCE:.c=.do} - -all: options ${PLUGIN} - -options: - @echo ${PLUGIN} build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "DFLAGS = ${DFLAGS}" - @echo "CC = ${CC}" - -%.o: %.c - @echo CC $< - @mkdir -p .depend - @${CC} -c ${CFLAGS} -o $@ $< -MMD -MF .depend/$@.dep - -%.do: %.c - @echo CC $< - @mkdir -p .depend - @${CC} -c ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep - -${OBJECTS}: config.mk -${DOBJECTS}: config.mk - -${PLUGIN}: ${OBJECTS} - @echo LD $@ - @${CC} -shared ${LDFLAGS} -o ${PLUGIN}.so $(OBJECTS) ${LIBS} - -${PLUGIN}-debug: ${DOBJECTS} - @echo LD $@ - @${CC} -shared ${LDFLAGS} -o ${PLUGIN}.so $(DOBJECTS) ${LIBS} - -clean: - @rm -rf ${OBJECTS} ${DOBJECTS} $(PLUGIN).so .depend - -debug: options ${PLUGIN}-debug - -install: all - @echo installing ${PLUGIN} plugin - @mkdir -p ${DESTDIR}${PREFIX}/lib/zathura - @cp -f ${PLUGIN}.so ${DESTDIR}${PREFIX}/lib/zathura - -uninstall: - @echo uninstalling ${PLUGIN} plugin - @rm -f ${DESTDIR}${PREFIX}/lib/zathura/${PLUGIN}.so - @rm -rf ${DESTDIR}${PREFIX}/lib/zathura - --include $(wildcard .depend/*.dep) - -.PHONY: all options clean debug install uninstall diff --git a/ft/djvu/config.mk b/ft/djvu/config.mk deleted file mode 100644 index 54154b3..0000000 --- a/ft/djvu/config.mk +++ /dev/null @@ -1,21 +0,0 @@ -# See LICENSE file for license and copyright information - -# paths -PREFIX ?= /usr - -# libs -DJVU_INC = $(shell pkg-config --cflags gtk+-2.0 ddjvuapi) -DJVU_LIB = $(shell pkg-config --libs gtk+-2.0 ddjvuapi) - -INCS = -I. -I/usr/include ${DJVU_INC} -LIBS = -lc ${DJVU_LIB} - -# flags -CFLAGS += -std=c99 -fPIC -pedantic -Wall -Wno-format-zero-length $(INCS) - -# debug -DFLAGS = -g - -# compiler -CC ?= gcc -LD ?= ld diff --git a/ft/djvu/djvu.c b/ft/djvu/djvu.c deleted file mode 100644 index 46908c2..0000000 --- a/ft/djvu/djvu.c +++ /dev/null @@ -1,269 +0,0 @@ -/* See LICENSE file for license and copyright information */ - -#include - -#include "djvu.h" -#include "../../zathura.h" - -void -plugin_register(zathura_document_plugin_t* plugin) -{ - plugin->file_extension = "djvu"; - plugin->open_function = djvu_document_open; -} - -bool -djvu_document_open(zathura_document_t* document) -{ - if (!document) { - goto error_out; - } - - document->functions.document_free = djvu_document_free; - document->functions.document_index_generate = djvu_document_index_generate;; - document->functions.document_save_as = djvu_document_save_as; - document->functions.document_attachments_get = djvu_document_attachments_get; - document->functions.page_get = djvu_page_get; - document->functions.page_search_text = djvu_page_search_text; - document->functions.page_links_get = djvu_page_links_get; - document->functions.page_form_fields_get = djvu_page_form_fields_get; - document->functions.page_render = djvu_page_render; - document->functions.page_free = djvu_page_free; - - document->data = malloc(sizeof(djvu_document_t)); - if (!document->data) { - goto error_out; - } - - djvu_document_t* djvu_document = (djvu_document_t*) document->data; - djvu_document->context = NULL; - djvu_document->document = NULL; - djvu_document->format = NULL; - - /* setup format */ - djvu_document->format = ddjvu_format_create(DDJVU_FORMAT_RGB24, 0, NULL); - - if (!djvu_document->format) { - goto error_free; - } - - ddjvu_format_set_row_order(djvu_document->format, TRUE); - - /* setup context */ - djvu_document->context = ddjvu_context_create("zathura"); - - if (!djvu_document->context) { - goto error_free; - } - - /* setup document */ - djvu_document->document = ddjvu_document_create_by_filename(djvu_document->context, document->file_path, FALSE); - - if (!djvu_document->document) { - goto error_free; - } - - /* load document info */ - ddjvu_message_t* msg; - ddjvu_message_wait(djvu_document->context); - - while ((msg = ddjvu_message_peek(djvu_document->context)) && (msg->m_any.tag != DDJVU_DOCINFO)) { - if (msg->m_any.tag == DDJVU_ERROR) { - goto error_free; - } - - ddjvu_message_pop(djvu_document->context); - } - - /* decoding error */ - if (ddjvu_document_decoding_error(djvu_document->document)) { - goto error_free; - } - - document->number_of_pages = ddjvu_document_get_pagenum(djvu_document->document); - - return true; - -error_free: - - if (djvu_document->format) { - ddjvu_format_release(djvu_document->format); - } - - if (djvu_document->context) { - ddjvu_context_release(djvu_document->context); - } - - free(document->data); - document->data = NULL; - -error_out: - - return false; -} - -bool -djvu_document_free(zathura_document_t* document) -{ - if (!document) { - return false; - } - - if (document->data) { - djvu_document_t* djvu_document = (djvu_document_t*) document->data; - ddjvu_context_release(djvu_document->context); - ddjvu_document_release(djvu_document->document); - ddjvu_format_release(djvu_document->format); - free(document->data); - } - - return true; -} - -girara_tree_node_t* -djvu_document_index_generate(zathura_document_t* document) -{ - return NULL; -} - -bool -djvu_document_save_as(zathura_document_t* document, const char* path) -{ - if (!document || !document->data || !path) { - return false; - } - - djvu_document_t* djvu_document = (djvu_document_t*) document->data; - - FILE* fp = fopen(path, "w"); - if (!fp) { - return false; - } - - ddjvu_document_save(djvu_document->document, fp, 0, NULL); - fclose(fp); - - return true; -} - -zathura_list_t* -djvu_document_attachments_get(zathura_document_t* document) -{ - return NULL; -} - -zathura_page_t* -djvu_page_get(zathura_document_t* document, unsigned int page) -{ - if (!document || !document->data) { - return NULL; - } - - djvu_document_t* djvu_document = (djvu_document_t*) document->data; - zathura_page_t* document_page = malloc(sizeof(zathura_page_t)); - - if (!document_page) { - return NULL; - } - - document_page->document = document; - document_page->data = NULL; - - ddjvu_status_t status; - ddjvu_pageinfo_t page_info; - - while ((status = ddjvu_document_get_pageinfo(djvu_document->document, page, &page_info)) < DDJVU_JOB_OK); - - if (status >= DDJVU_JOB_FAILED) { - free(document_page); - return NULL; - } - - document_page->width = 0.2 * page_info.width; - document_page->height = 0.2 * page_info.height; - - return document_page; -} - -bool -djvu_page_free(zathura_page_t* page) -{ - if (!page) { - return false; - } - - free(page); - - return true; -} - -zathura_list_t* -djvu_page_search_text(zathura_page_t* page, const char* text) -{ - return NULL; -} - -zathura_list_t* -djvu_page_links_get(zathura_page_t* page) -{ - return NULL; -} - -zathura_list_t* -djvu_page_form_fields_get(zathura_page_t* page) -{ - return NULL; -} - -zathura_image_buffer_t* -djvu_page_render(zathura_page_t* page) -{ - if (!page || !page->document) { - return NULL; - } - - /* calculate sizes */ - unsigned int page_width = page->document->scale * page->width; - unsigned int page_height = page->document->scale * page->height; - - if (!page_width || !page_height) { - goto error_out; - } - - /* init ddjvu render data */ - djvu_document_t* djvu_document = (djvu_document_t*) page->document->data; - ddjvu_page_t* djvu_page = ddjvu_page_create_by_pageno(djvu_document->document, page->number); - - if (!djvu_page) { - goto error_out; - } - - while (!ddjvu_page_decoding_done(djvu_page)); - - ddjvu_rect_t rrect = { 0, 0, page_width, page_height }; - ddjvu_rect_t prect = { 0, 0, page_width, page_height }; - - zathura_image_buffer_t* image_buffer = zathura_image_buffer_create(page_width, page_height); - - if (image_buffer == NULL) { - goto error_free; - } - - /* set rotation */ - ddjvu_page_set_rotation(djvu_page, DDJVU_ROTATE_0); - - /* render page */ - ddjvu_page_render(djvu_page, DDJVU_RENDER_COLOR, &prect, &rrect, djvu_document->format, - 3 * page_width, (char*) image_buffer->data); - - return image_buffer; - -error_free: - - ddjvu_page_release(djvu_page); - zathura_image_buffer_free(image_buffer); - -error_out: - - return NULL; -} diff --git a/ft/djvu/djvu.h b/ft/djvu/djvu.h deleted file mode 100644 index 31444ff..0000000 --- a/ft/djvu/djvu.h +++ /dev/null @@ -1,30 +0,0 @@ -/* See LICENSE file for license and copyright information */ - -#ifndef DJVU_H -#define DJVU_H - -#include -#include - -#include "../../document.h" - -typedef struct djvu_document_s -{ - ddjvu_context_t* context; - ddjvu_document_t* document; - ddjvu_format_t* format; -} djvu_document_t; - -bool djvu_document_open(zathura_document_t* document); -bool djvu_document_free(zathura_document_t* document); -girara_tree_node_t* djvu_document_index_generate(zathura_document_t* document); -bool djvu_document_save_as(zathura_document_t* document, const char* path); -zathura_list_t* djvu_document_attachments_get(zathura_document_t* document); -zathura_page_t* djvu_page_get(zathura_document_t* document, unsigned int page); -zathura_list_t* djvu_page_search_text(zathura_page_t* page, const char* text); -zathura_list_t* djvu_page_links_get(zathura_page_t* page); -zathura_list_t* djvu_page_form_fields_get(zathura_page_t* page); -zathura_image_buffer_t* djvu_page_render(zathura_page_t* page); -bool djvu_page_free(zathura_page_t* page); - -#endif // DJVU_H diff --git a/ft/pdf-mupdf/Makefile b/ft/pdf-mupdf/Makefile deleted file mode 100644 index cdc30ff..0000000 --- a/ft/pdf-mupdf/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -# See LICENSE file for license and copyright information - -include config.mk - -PLUGIN = pdf -SOURCE = pdf.c -OBJECTS = ${SOURCE:.c=.o} -DOBJECTS = ${SOURCE:.c=.do} - -all: options ${PLUGIN} - -options: - @echo ${PLUGIN} build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "DFLAGS = ${DFLAGS}" - @echo "CC = ${CC}" - -%.o: %.c - @echo CC $< - @mkdir -p .depend - @${CC} -c ${CFLAGS} -o $@ $< -MMD -MF .depend/$@.dep - -%.do: %.c - @echo CC $< - @mkdir -p .depend - @${CC} -c ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep - -${OBJECTS}: config.mk -${DOBJECTS}: config.mk - -${PLUGIN}: ${OBJECTS} - @echo LD $@ - @${CC} -shared ${LDFLAGS} -o ${PLUGIN}.so $(OBJECTS) ${LIBS} - -${PLUGIN}-debug: ${DOBJECTS} - @echo LD $@ - @${CC} -shared ${LDFLAGS} -o ${PLUGIN}.so $(DOBJECTS) ${LIBS} - -clean: - @rm -rf ${OBJECTS} ${DOBJECTS} $(PLUGIN).so .depend - -debug: options ${PLUGIN}-debug - -install: all - @echo installing ${PLUGIN} plugin - @mkdir -p ${DESTDIR}${PREFIX}/lib/zathura - @cp -f ${PLUGIN}.so ${DESTDIR}${PREFIX}/lib/zathura - -uninstall: - @echo uninstalling ${PLUGIN} plugin - @rm -f ${DESTDIR}${PREFIX}/lib/zathura/${PLUGIN}.so - @rm -rf ${DESTDIR}${PREFIX}/lib/zathura - --include $(wildcard .depend/*.dep) - -.PHONY: all options clean debug install uninstall diff --git a/ft/pdf-mupdf/config.mk b/ft/pdf-mupdf/config.mk deleted file mode 100644 index 9aeb43a..0000000 --- a/ft/pdf-mupdf/config.mk +++ /dev/null @@ -1,21 +0,0 @@ -# See LICENSE file for license and copyright information - -# paths -PREFIX ?= /usr - -# libs -GTK_INC = $(shell pkg-config --cflags gtk+-2.0) -GTK_LIB = $(shell pkg-config --libs gtk+-2.0) - -INCS = -I. -I/usr/include ${GTK_INC} -LIBS = -lc ${GTK_LIB} -lmupdf -ljbig2dec -ljpeg -lopenjpeg - -# flags -CFLAGS += -std=c99 -fPIC -pedantic -Wall -Wno-format-zero-length $(INCS) - -# debug -DFLAGS = -g - -# compiler -CC ?= gcc -LD ?= ld diff --git a/ft/pdf-mupdf/pdf.c b/ft/pdf-mupdf/pdf.c deleted file mode 100644 index 31d7cb2..0000000 --- a/ft/pdf-mupdf/pdf.c +++ /dev/null @@ -1,244 +0,0 @@ -/* See LICENSE file for license and copyright information */ - -#include - -#include "pdf.h" -#include "../../zathura.h" - -void -plugin_register(zathura_document_plugin_t* plugin) -{ - plugin->file_extension = "pdf"; - plugin->open_function = pdf_document_open; -} - -bool -pdf_document_open(zathura_document_t* document) -{ - if (!document) { - goto error_ret; - } - - document->functions.document_free = pdf_document_free; - document->functions.page_get = pdf_page_get; - document->functions.page_search_text = pdf_page_search_text; - document->functions.page_links_get = pdf_page_links_get; - document->functions.page_form_fields_get = pdf_page_form_fields_get; - document->functions.page_render = pdf_page_render; - document->functions.page_free = pdf_page_free; - - document->data = malloc(sizeof(pdf_document_t)); - if (!document->data) { - goto error_ret; - } - - pdf_document_t* pdf_document = (pdf_document_t*) document->data; - - fz_accelerate(); - pdf_document->glyphcache = fz_newglyphcache(); - - if (pdf_openxref(&(pdf_document->document), document->file_path, NULL)) { - fprintf(stderr, "error: could not open file\n"); - goto error_free; - } - - if (pdf_loadpagetree(pdf_document->document)) { - fprintf(stderr, "error: could not open file\n"); - goto error_free; - } - - document->number_of_pages = pdf_getpagecount(pdf_document->document); - - return true; - -error_free: - - if (pdf_document->document) { - pdf_freexref(pdf_document->document); - } - - if (pdf_document->glyphcache) { - fz_freeglyphcache(pdf_document->glyphcache); - } - - free(document->data); - document->data = NULL; - -error_ret: - - return false; -} - -bool -pdf_document_free(zathura_document_t* document) -{ - if (!document) { - return false; - } - - if (document->data) { - pdf_document_t* pdf_document = (pdf_document_t*) document->data; - pdf_freexref(pdf_document->document); - fz_freeglyphcache(pdf_document->glyphcache); - free(document->data); - document->data = NULL; - } - - return true; -} - -zathura_page_t* -pdf_page_get(zathura_document_t* document, unsigned int page) -{ - if (!document || !document->data) { - return NULL; - } - - pdf_document_t* pdf_document = (pdf_document_t*) document->data; - zathura_page_t* document_page = malloc(sizeof(zathura_page_t)); - - if (document_page == NULL) { - goto error_ret; - } - - mupdf_page_t* mupdf_page = malloc(sizeof(mupdf_page_t)); - - if (mupdf_page == NULL) { - goto error_free; - } - - document_page->document = document; - document_page->data = mupdf_page; - - mupdf_page->page_object = pdf_getpageobject(pdf_document->document, page + 1); - - if (pdf_loadpage(&(mupdf_page->page), pdf_document->document, mupdf_page->page_object)) { - goto error_free; - } - - document_page->width = mupdf_page->page->mediabox.x1 - mupdf_page->page->mediabox.x0; - document_page->height = mupdf_page->page->mediabox.y1 - mupdf_page->page->mediabox.y0; - - return document_page; - -error_free: - - if (mupdf_page && mupdf_page->page_object) { - fz_dropobj(mupdf_page->page_object); - } - - if (mupdf_page && mupdf_page->page) { - pdf_freepage(mupdf_page->page); - } - - free(document_page); - free(mupdf_page); - -error_ret: - - return NULL; -} - -bool -pdf_page_free(zathura_page_t* page) -{ - if (!page) { - return false; - } - - mupdf_page_t* mupdf_page = (mupdf_page_t*) page->data; - pdf_freepage(mupdf_page->page); - fz_dropobj(mupdf_page->page_object); - free(mupdf_page); - free(page); - - return true; -} - -zathura_list_t* -pdf_page_search_text(zathura_page_t* page, const char* text) -{ - return NULL; -} - -zathura_list_t* -pdf_page_links_get(zathura_page_t* page) -{ - return NULL; -} - -zathura_list_t* -pdf_page_form_fields_get(zathura_page_t* page) -{ - return NULL; -} - -zathura_image_buffer_t* -pdf_page_render(zathura_page_t* page) -{ - if (!page || !page->data || !page->document) { - return NULL; - } - - /* calculate sizes */ - unsigned int page_width = page->document->scale * page->width; - unsigned int page_height = page->document->scale * page->height; - - if (page->document->rotate == 90 || page->document->rotate == 270) { - unsigned int dim_temp = 0; - dim_temp = page_width; - page_width = page_height; - page_height = dim_temp; - } - - /* create image buffer */ - zathura_image_buffer_t* image_buffer = zathura_image_buffer_create(page_width, page_height); - - if (image_buffer == NULL) { - return NULL; - } - - pdf_document_t* pdf_document = (pdf_document_t*) page->document->data; - mupdf_page_t* mupdf_page = (mupdf_page_t*) page->data; - - /* render */ - fz_displaylist* display_list = fz_newdisplaylist(); - fz_device* device = fz_newlistdevice(display_list); - - if (pdf_runpage(pdf_document->document, mupdf_page->page, device, fz_identity)) { - return NULL; - } - - fz_freedevice(device); - - pdf_agestore(pdf_document->document->store, 3); - - fz_matrix ctm = fz_identity; - ctm = fz_concat(ctm, fz_translate(0, -mupdf_page->page->mediabox.y1)); - ctm = fz_concat(ctm, fz_scale(page->document->scale, -page->document->scale)); - ctm = fz_concat(ctm, fz_rotate(mupdf_page->page->rotate)); - ctm = fz_concat(ctm, fz_rotate(page->document->rotate)); - fz_bbox bbox = fz_roundrect(fz_transformrect(ctm, mupdf_page->page->mediabox)); - - fz_pixmap* pixmap = fz_newpixmapwithrect(fz_devicergb, bbox); - fz_clearpixmapwithcolor(pixmap, 0xFF); - - device = fz_newdrawdevice(pdf_document->glyphcache, pixmap); - fz_executedisplaylist(display_list, device, ctm); - fz_freedevice(device); - - for (unsigned int y = 0; y < pixmap->h; y++) { - for (unsigned int x = 0; x < pixmap->w; x++) { - unsigned char *s = pixmap->samples + y * pixmap->w * 4 + x * 4; - guchar* p = image_buffer->data + y * image_buffer->rowstride + x * 3; - p[0] = s[0]; - p[1] = s[1]; - p[2] = s[2]; - } - } - - fz_droppixmap(pixmap); - fz_freedisplaylist(display_list); - - return image_buffer; -} diff --git a/ft/pdf-mupdf/pdf.h b/ft/pdf-mupdf/pdf.h deleted file mode 100644 index 84d7b38..0000000 --- a/ft/pdf-mupdf/pdf.h +++ /dev/null @@ -1,33 +0,0 @@ -/* See LICENSE file for license and copyright information */ - -#ifndef PDF_H -#define PDF_H - -#include -#include -#include - -#include "../../document.h" - -typedef struct pdf_document_s -{ - fz_glyphcache *glyphcache; - pdf_xref *document; -} pdf_document_t; - -typedef struct mupdf_page_s -{ - fz_obj* page_object; - pdf_page* page; -} mupdf_page_t; - -bool pdf_document_open(zathura_document_t* document); -bool pdf_document_free(zathura_document_t* document); -zathura_page_t* pdf_page_get(zathura_document_t* document, unsigned int page); -zathura_list_t* pdf_page_search_text(zathura_page_t* page, const char* text); -zathura_list_t* pdf_page_links_get(zathura_page_t* page); -zathura_list_t* pdf_page_form_fields_get(zathura_page_t* page); -zathura_image_buffer_t* pdf_page_render(zathura_page_t* page); -bool pdf_page_free(zathura_page_t* page); - -#endif // PDF_H diff --git a/ft/pdf-poppler/Makefile b/ft/pdf-poppler/Makefile deleted file mode 100644 index cdc30ff..0000000 --- a/ft/pdf-poppler/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -# See LICENSE file for license and copyright information - -include config.mk - -PLUGIN = pdf -SOURCE = pdf.c -OBJECTS = ${SOURCE:.c=.o} -DOBJECTS = ${SOURCE:.c=.do} - -all: options ${PLUGIN} - -options: - @echo ${PLUGIN} build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "DFLAGS = ${DFLAGS}" - @echo "CC = ${CC}" - -%.o: %.c - @echo CC $< - @mkdir -p .depend - @${CC} -c ${CFLAGS} -o $@ $< -MMD -MF .depend/$@.dep - -%.do: %.c - @echo CC $< - @mkdir -p .depend - @${CC} -c ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep - -${OBJECTS}: config.mk -${DOBJECTS}: config.mk - -${PLUGIN}: ${OBJECTS} - @echo LD $@ - @${CC} -shared ${LDFLAGS} -o ${PLUGIN}.so $(OBJECTS) ${LIBS} - -${PLUGIN}-debug: ${DOBJECTS} - @echo LD $@ - @${CC} -shared ${LDFLAGS} -o ${PLUGIN}.so $(DOBJECTS) ${LIBS} - -clean: - @rm -rf ${OBJECTS} ${DOBJECTS} $(PLUGIN).so .depend - -debug: options ${PLUGIN}-debug - -install: all - @echo installing ${PLUGIN} plugin - @mkdir -p ${DESTDIR}${PREFIX}/lib/zathura - @cp -f ${PLUGIN}.so ${DESTDIR}${PREFIX}/lib/zathura - -uninstall: - @echo uninstalling ${PLUGIN} plugin - @rm -f ${DESTDIR}${PREFIX}/lib/zathura/${PLUGIN}.so - @rm -rf ${DESTDIR}${PREFIX}/lib/zathura - --include $(wildcard .depend/*.dep) - -.PHONY: all options clean debug install uninstall diff --git a/ft/pdf-poppler/config.mk b/ft/pdf-poppler/config.mk deleted file mode 100644 index 2e505e9..0000000 --- a/ft/pdf-poppler/config.mk +++ /dev/null @@ -1,21 +0,0 @@ -# See LICENSE file for license and copyright information - -# paths -PREFIX ?= /usr - -# libs -PDF_INC = $(shell pkg-config --cflags gtk+-2.0 poppler-glib) -PDF_LIB = $(shell pkg-config --libs gtk+-2.0 poppler-glib) - -INCS = -I. -I/usr/include ${PDF_INC} -LIBS = -lc ${PDF_LIB} - -# flags -CFLAGS += -std=c99 -fPIC -pedantic -Wall -Wno-format-zero-length $(INCS) - -# debug -DFLAGS = -g - -# compiler -CC ?= gcc -LD ?= ld diff --git a/ft/pdf-poppler/pdf.c b/ft/pdf-poppler/pdf.c deleted file mode 100644 index e0ce1cc..0000000 --- a/ft/pdf-poppler/pdf.c +++ /dev/null @@ -1,301 +0,0 @@ -/* See LICENSE file for license and copyright information */ - -#include -#include - -#include "pdf.h" -#include "../../zathura.h" - -void -plugin_register(zathura_document_plugin_t* plugin) -{ - plugin->file_extension = "pdf"; - plugin->open_function = pdf_document_open; -} - -bool -pdf_document_open(zathura_document_t* document) -{ - if (!document) { - goto error_out; - } - - document->functions.document_free = pdf_document_free; - document->functions.document_index_generate = pdf_document_index_generate;; - document->functions.document_save_as = pdf_document_save_as; - document->functions.document_attachments_get = pdf_document_attachments_get; - document->functions.page_get = pdf_page_get; - document->functions.page_search_text = pdf_page_search_text; - document->functions.page_links_get = pdf_page_links_get; - document->functions.page_form_fields_get = pdf_page_form_fields_get; - document->functions.page_render = pdf_page_render; - document->functions.page_free = pdf_page_free; - - document->data = malloc(sizeof(pdf_document_t)); - if (!document->data) { - goto error_out; - } - - /* format path */ - GError* error = NULL; - char* file_uri = g_filename_to_uri(document->file_path, NULL, &error); - - if (!file_uri) { - fprintf(stderr, "error: could not open file: %s\n", error->message); - goto error_free; - } - - pdf_document_t* pdf_document = (pdf_document_t*) document->data; - pdf_document->document = poppler_document_new_from_file(file_uri, document->password, &error); - - if (!pdf_document->document) { - fprintf(stderr, "error: could not open file: %s\n", error->message); - goto error_free; - } - - document->number_of_pages = poppler_document_get_n_pages(pdf_document->document); - - g_free(file_uri); - - return true; - -error_free: - - if (error) { - g_error_free(error); - } - - if (file_uri) { - g_free(file_uri); - } - - free(document->data); - document->data = NULL; - -error_out: - - return false; -} - -bool -pdf_document_free(zathura_document_t* document) -{ - if (!document) { - return false; - } - - if (document->data) { - pdf_document_t* pdf_document = (pdf_document_t*) document->data; - g_object_unref(pdf_document->document); - free(document->data); - document->data = NULL; - } - - return true; -} - -static void -build_index(pdf_document_t* pdf, girara_tree_node_t* root, PopplerIndexIter* iter) -{ - if (!root || !iter) { - return; - } - - do - { - PopplerAction* action = poppler_index_iter_get_action(iter); - - if (!action) { - continue; - } - - gchar* markup = g_markup_escape_text(action->any.title, -1); - zathura_index_element_t* index_element = zathura_index_element_new(markup); - - if (action->type == POPPLER_ACTION_URI) { - index_element->type = ZATHURA_LINK_EXTERNAL; - index_element->target.uri = g_strdup(action->uri.uri); - } else if (action->type == POPPLER_ACTION_GOTO_DEST) { - index_element->type = ZATHURA_LINK_TO_PAGE; - - if (action->goto_dest.dest->type == POPPLER_DEST_NAMED) { - PopplerDest* dest = poppler_document_find_dest(pdf->document, action->goto_dest.dest->named_dest); - if (dest) { - index_element->target.page_number = dest->page_num - 1; - poppler_dest_free(dest); - } - } else { - index_element->target.page_number = action->goto_dest.dest->page_num - 1; - } - } else { - poppler_action_free(action); - zathura_index_element_free(index_element); - continue; - } - - poppler_action_free(action); - - girara_tree_node_t* node = girara_node_append_data(root, index_element); - PopplerIndexIter* child = poppler_index_iter_get_child(iter); - - if (child) { - build_index(pdf, node, child); - } - - poppler_index_iter_free(child); - - } while (poppler_index_iter_next(iter)); -} - -girara_tree_node_t* -pdf_document_index_generate(zathura_document_t* document) -{ - if (!document || !document->data) { - return NULL; - } - - pdf_document_t* pdf_document = (pdf_document_t*) document->data; - PopplerIndexIter* iter = poppler_index_iter_new(pdf_document->document); - - if (!iter) { - // XXX: error message? - return NULL; - } - - girara_tree_node_t* root = girara_node_new(zathura_index_element_new("ROOT")); - girara_node_set_free_function(root, (girara_free_function_t)zathura_index_element_free); - build_index(pdf_document, root, iter); - - poppler_index_iter_free(iter); - return root; -} - -bool -pdf_document_save_as(zathura_document_t* document, const char* path) -{ - if (!document || !document->data || !path) { - return false; - } - - pdf_document_t* pdf_document = (pdf_document_t*) document->data; - - char* file_path = g_strdup_printf("file://%s", path); - poppler_document_save(pdf_document->document, file_path, NULL); - g_free(file_path); - - return false; -} - -zathura_list_t* -pdf_document_attachments_get(zathura_document_t* document) -{ - return NULL; -} - -zathura_page_t* -pdf_page_get(zathura_document_t* document, unsigned int page) -{ - if (!document || !document->data) { - return NULL; - } - - pdf_document_t* pdf_document = (pdf_document_t*) document->data; - zathura_page_t* document_page = malloc(sizeof(zathura_page_t)); - - if (!document_page) { - return NULL; - } - - document_page->document = document; - document_page->data = poppler_document_get_page(pdf_document->document, page); - - if (!document_page->data) { - free(document_page); - return NULL; - } - - poppler_page_get_size(document_page->data, &(document_page->width), &(document_page->height)); - - return document_page; -} - -bool -pdf_page_free(zathura_page_t* page) -{ - if (!page) { - return false; - } - - g_object_unref(page->data); - free(page); - - return true; -} - -zathura_list_t* -pdf_page_search_text(zathura_page_t* page, const char* text) -{ - return NULL; -} - -zathura_list_t* -pdf_page_links_get(zathura_page_t* page) -{ - return NULL; -} - -zathura_list_t* -pdf_page_form_fields_get(zathura_page_t* page) -{ - return NULL; -} - -zathura_image_buffer_t* -pdf_page_render(zathura_page_t* page) -{ - if (!page || !page->data || !page->document) { - return NULL; - } - - /* calculate sizes */ - unsigned int page_width = page->document->scale * page->width; - unsigned int page_height = page->document->scale * page->height; - - /* create pixbuf */ - GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, - page_width, page_height); - - if (pixbuf == NULL) { - return NULL; - } - - poppler_page_render_to_pixbuf(page->data, 0, 0, page_width, page_height, - page->document->scale, 0, pixbuf); - - /* create image buffer */ - zathura_image_buffer_t* image_buffer = zathura_image_buffer_create(page_width, page_height); - - if (image_buffer == NULL) { - g_object_unref(pixbuf); - return NULL; - } - - /* copy buffer */ - guchar* pixels = gdk_pixbuf_get_pixels(pixbuf); - int rowstride = gdk_pixbuf_get_rowstride(pixbuf); - int n_channels = gdk_pixbuf_get_n_channels(pixbuf); - - for (unsigned int y = 0; y < page_height; y++) { - for (unsigned int x = 0; x < page_width; x++) { - unsigned char *s = pixels + y * rowstride + x * n_channels; - guchar* p = image_buffer->data + y * image_buffer->rowstride + x * 3; - p[0] = s[0]; - p[1] = s[1]; - p[2] = s[2]; - } - } - - g_object_unref(pixbuf); - - return image_buffer; -} diff --git a/ft/pdf-poppler/pdf.h b/ft/pdf-poppler/pdf.h deleted file mode 100644 index ce76613..0000000 --- a/ft/pdf-poppler/pdf.h +++ /dev/null @@ -1,28 +0,0 @@ -/* See LICENSE file for license and copyright information */ - -#ifndef PDF_H -#define PDF_H - -#include -#include - -#include "../../document.h" - -typedef struct pdf_document_s -{ - PopplerDocument *document; -} pdf_document_t; - -bool pdf_document_open(zathura_document_t* document); -bool pdf_document_free(zathura_document_t* document); -girara_tree_node_t* pdf_document_index_generate(zathura_document_t* document); -bool pdf_document_save_as(zathura_document_t* document, const char* path); -zathura_list_t* pdf_document_attachments_get(zathura_document_t* document); -zathura_page_t* pdf_page_get(zathura_document_t* document, unsigned int page); -zathura_list_t* pdf_page_search_text(zathura_page_t* page, const char* text); -zathura_list_t* pdf_page_links_get(zathura_page_t* page); -zathura_list_t* pdf_page_form_fields_get(zathura_page_t* page); -zathura_image_buffer_t* pdf_page_render(zathura_page_t* page); -bool pdf_page_free(zathura_page_t* page); - -#endif // PDF_H diff --git a/ft/ps/Makefile b/ft/ps/Makefile deleted file mode 100644 index df35a2a..0000000 --- a/ft/ps/Makefile +++ /dev/null @@ -1,57 +0,0 @@ -# See LICENSE file for license and copyright information - -include config.mk - -PLUGIN = ps -SOURCE = ps.c -OBJECTS = ${SOURCE:.c=.o} -DOBJECTS = ${SOURCE:.c=.do} - -all: options ${PLUGIN} - -options: - @echo ${PLUGIN} build options: - @echo "CFLAGS = ${CFLAGS}" - @echo "LDFLAGS = ${LDFLAGS}" - @echo "DFLAGS = ${DFLAGS}" - @echo "CC = ${CC}" - -%.o: %.c - @echo CC $< - @mkdir -p .depend - @${CC} -c ${CFLAGS} -o $@ $< -MMD -MF .depend/$@.dep - -%.do: %.c - @echo CC $< - @mkdir -p .depend - @${CC} -c ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep - -${OBJECTS}: config.mk -${DOBJECTS}: config.mk - -${PLUGIN}: ${OBJECTS} - @echo LD $@ - @${CC} -shared ${LDFLAGS} -o ${PLUGIN}.so $(OBJECTS) ${LIBS} - -${PLUGIN}-debug: ${DOBJECTS} - @echo LD $@ - @${CC} -shared ${LDFLAGS} -o ${PLUGIN}.so $(DOBJECTS) ${LIBS} - -clean: - @rm -rf ${OBJECTS} ${DOBJECTS} $(PLUGIN).so .depend - -debug: options ${PLUGIN}-debug - -install: all - @echo installing ${PLUGIN} plugin - @mkdir -p ${DESTDIR}${PREFIX}/lib/zathura - @cp -f ${PLUGIN}.so ${DESTDIR}${PREFIX}/lib/zathura - -uninstall: - @echo uninstalling ${PLUGIN} plugin - @rm -f ${DESTDIR}${PREFIX}/lib/zathura/${PLUGIN}.so - @rm -rf ${DESTDIR}${PREFIX}/lib/zathura - --include $(wildcard .depend/*.dep) - -.PHONY: all options clean debug install uninstall diff --git a/ft/ps/config.mk b/ft/ps/config.mk deleted file mode 100644 index d44baaf..0000000 --- a/ft/ps/config.mk +++ /dev/null @@ -1,21 +0,0 @@ -# See LICENSE file for license and copyright information - -# paths -PREFIX ?= /usr - -# libs -GTK_INC = $(shell pkg-config --cflags gtk+-2.0) -GTK_LIB = $(shell pkg-config --libs gtk+-2.0) - -INCS = -I. -I/usr/include ${GTK_INC} -LIBS = -lc ${GTK_LIB} -lspectre - -# flags -CFLAGS += -std=c99 -fPIC -pedantic -Wall -Wno-format-zero-length $(INCS) - -# debug -DFLAGS = -g - -# compiler -CC ?= gcc -LD ?= ld diff --git a/ft/ps/ps.c b/ft/ps/ps.c deleted file mode 100644 index d5f5a0e..0000000 --- a/ft/ps/ps.c +++ /dev/null @@ -1,180 +0,0 @@ -/* See LICENSE file for license and copyright information */ - -#include - -#include "ps.h" -#include "../../zathura.h" - -void -plugin_register(zathura_document_plugin_t* plugin) -{ - plugin->file_extension = "ps"; - plugin->open_function = ps_document_open; -} - -bool -ps_document_open(zathura_document_t* document) -{ - if (!document) { - goto error_ret; - } - - document->functions.document_free = ps_document_free; - document->functions.page_get = ps_page_get; - document->functions.page_render = ps_page_render; - document->functions.page_free = ps_page_free; - - document->data = malloc(sizeof(ps_document_t)); - if (!document->data) { - goto error_ret; - } - - ps_document_t* ps_document = (ps_document_t*) document->data; - ps_document->document = spectre_document_new(); - - if (ps_document->document == NULL) { - goto error_free; - } - - spectre_document_load(ps_document->document, document->file_path); - - if (spectre_document_status(ps_document->document) != SPECTRE_STATUS_SUCCESS) { - goto error_free; - } - - document->number_of_pages = spectre_document_get_n_pages(ps_document->document); - - return true; - -error_free: - - if (ps_document->document != NULL) { - spectre_document_free(ps_document->document); - } - - free(document->data); - document->data = NULL; - -error_ret: - - return false; -} - -bool -ps_document_free(zathura_document_t* document) -{ - if (!document) { - return false; - } - - if (document->data != NULL) { - ps_document_t* ps_document = (ps_document_t*) document->data; - spectre_document_free(ps_document->document); - free(document->data); - document->data = NULL; - } - - return true; -} - -zathura_page_t* -ps_page_get(zathura_document_t* document, unsigned int page) -{ - if (!document || !document->data) { - return NULL; - } - - ps_document_t* ps_document = (ps_document_t*) document->data; - zathura_page_t* document_page = malloc(sizeof(zathura_page_t)); - - if (document_page == NULL) { - goto error_ret; - } - - SpectrePage* ps_page = spectre_document_get_page(ps_document->document, page); - - if (ps_page == NULL) { - goto error_free; - } - - int page_width; - int page_height; - spectre_page_get_size(ps_page, &(page_width), &(page_height)); - - document_page->width = page_width; - document_page->height = page_height; - document_page->document = document; - document_page->data = ps_page; - - return document_page; - -error_free: - - free(document_page); - -error_ret: - - return NULL; -} - -bool -ps_page_free(zathura_page_t* page) -{ - if (page == NULL) { - return false; - } - - if (page->data != NULL) { - SpectrePage* ps_page = (SpectrePage*) page->data; - spectre_page_free(ps_page); - } - - free(page); - - return true; -} - -zathura_image_buffer_t* -ps_page_render(zathura_page_t* page) -{ - if (!page || !page->data || !page->document) { - return NULL; - } - - /* calculate sizes */ - unsigned int page_width = page->document->scale * page->width; - unsigned int page_height = page->document->scale * page->height; - - /* create image buffer */ - zathura_image_buffer_t* image_buffer = zathura_image_buffer_create(page_width, page_height); - - if (image_buffer == NULL) { - return NULL; - } - - SpectrePage* ps_page = (SpectrePage*) page->data; - SpectreRenderContext* context = spectre_render_context_new(); - - spectre_render_context_set_scale(context, page->document->scale, page->document->scale); - spectre_render_context_set_rotation(context, 0); - - unsigned char* page_data; - int row_length; - spectre_page_render(ps_page, context, &page_data, &row_length); - - for (unsigned int y = 0; y < page_height; y++) { - for (unsigned int x = 0; x < page_width; x++) { - unsigned char *s = page_data + y * row_length + x * 4; - guchar* p = image_buffer->data + y * image_buffer->rowstride + x * 3; - p[0] = s[0]; - p[1] = s[1]; - p[2] = s[2]; - } - } - - spectre_render_context_free(context); - - ps_document_t* ps_document = (ps_document_t*) page->document->data; - - return image_buffer; -} diff --git a/ft/ps/ps.h b/ft/ps/ps.h deleted file mode 100644 index 4ef3560..0000000 --- a/ft/ps/ps.h +++ /dev/null @@ -1,22 +0,0 @@ -/* See LICENSE file for license and copyright information */ - -#ifndef PS_H -#define PS_H - -#include -#include - -#include "../../document.h" - -typedef struct ps_document_s -{ - SpectreDocument* document; -} ps_document_t; - -bool ps_document_open(zathura_document_t* document); -bool ps_document_free(zathura_document_t* document); -zathura_page_t* ps_page_get(zathura_document_t* document, unsigned int page); -zathura_image_buffer_t* ps_page_render(zathura_page_t* page); -bool ps_page_free(zathura_page_t* page); - -#endif // PS_H