diff --git a/config.mk b/config.mk index c9a7738..fbb9fd4 100644 --- a/config.mk +++ b/config.mk @@ -8,8 +8,8 @@ PREFIX ?= /usr MANPREFIX ?= ${PREFIX}/share/man # libs -GTK_INC = $(shell pkg-config --cflags gtk+-2.0 poppler-glib) -GTK_LIB = $(shell pkg-config --libs gtk+-2.0 gthread-2.0 poppler-glib) +GTK_INC = $(shell pkg-config --cflags gtk+-2.0 poppler-glib ddjvuapi) +GTK_LIB = $(shell pkg-config --libs gtk+-2.0 gthread-2.0 poppler-glib ddjvuapi) INCS = -I. -I/usr/include ${GTK_INC} LIBS = -lc ${GTK_LIB} -lpthread -lm -lgirara diff --git a/ft/djvu/djvu.c b/ft/djvu/djvu.c new file mode 100644 index 0000000..19a53b5 --- /dev/null +++ b/ft/djvu/djvu.c @@ -0,0 +1,127 @@ +/* See LICENSE file for license and copyright information */ + +#include + +#include "djvu.h" + +bool +djvu_document_open(zathura_document_t* document) +{ + if(!document) { + return false; + } + + 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) { + return false; + } + + djvu_document_t* djvu_document = (djvu_document_t*) document->data; + djvu_document->context = ddjvu_context_create("zathura"); + + if(!djvu_document->context) { + free(document->data); + document->data = NULL; + return false; + } + + djvu_document->document = ddjvu_document_create_by_filename(djvu_document->context, document->file_path, FALSE); + + if(!djvu_document->document) { + ddjvu_context_release(djvu_document->context); + free(document->data); + document->data = NULL; + return false; + } + + document->number_of_pages = ddjvu_document_get_pagenum(djvu_document->document); + + return true; +} + +bool +djvu_document_free(zathura_document_t* document) +{ + if(!document) { + return false; + } + + return true; +} + +zathura_list_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; + } + + return false; +} + +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; + } + + return NULL; +} + +bool +djvu_page_free(zathura_page_t* page) +{ + if(!page) { + return false; + } + + 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; +} + +cairo_surface_t* +djvu_page_render(zathura_page_t* page) +{ + return NULL; +} diff --git a/ft/djvu/djvu.h b/ft/djvu/djvu.h new file mode 100644 index 0000000..92f94c8 --- /dev/null +++ b/ft/djvu/djvu.h @@ -0,0 +1,29 @@ +/* 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; +} djvu_document_t; + +bool djvu_document_open(zathura_document_t* document); +bool djvu_document_free(zathura_document_t* document); +zathura_list_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); +cairo_surface_t* djvu_page_render(zathura_page_t* page); +bool djvu_page_free(zathura_page_t* page); + +#endif // DJVU_H diff --git a/ft/document.c b/ft/document.c index f4e354d..69180b8 100644 --- a/ft/document.c +++ b/ft/document.c @@ -10,14 +10,16 @@ #include #include "document.h" +#include "pdf/pdf.h" +#include "djvu/djvu.h" #include "../utils.h" #include "../zathura.h" -#include "pdf/pdf.h" #define LENGTH(x) (sizeof(x)/sizeof((x)[0])) zathura_document_plugin_t zathura_document_plugins[] = { - { "pdf", pdf_document_open }, + { "pdf", pdf_document_open }, + { "djvu", djvu_document_open }, }; zathura_document_t* diff --git a/ft/pdf/pdf.c b/ft/pdf/pdf.c index e201092..2928dae 100644 --- a/ft/pdf/pdf.c +++ b/ft/pdf/pdf.c @@ -34,6 +34,7 @@ pdf_document_open(zathura_document_t* document) fprintf(stderr, "error: could not open file: %s\n", error->message); g_error_free(error); free(document->data); + document->data = NULL; return false; } @@ -44,6 +45,7 @@ pdf_document_open(zathura_document_t* document) fprintf(stderr, "error: could not open file: %s\n", error->message); g_error_free(error); free(document->data); + document->data = NULL; return false; } @@ -63,6 +65,7 @@ pdf_document_free(zathura_document_t* document) pdf_document_t* pdf_document = (pdf_document_t*) document->data; g_object_unref(pdf_document->document); free(document->data); + document->data = NULL; } return true; diff --git a/zathura.c b/zathura.c index dd456c4..d1a747b 100644 --- a/zathura.c +++ b/zathura.c @@ -67,6 +67,7 @@ document_open(const char* path, const char* password) Zathura.document = document; if(!page_set(0)) { + zathura_document_free(document); return false; }