mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-28 21:06:01 +01:00
Began to add djvu support
This commit is contained in:
parent
3d027dd773
commit
f8aa8773f3
6 changed files with 166 additions and 4 deletions
|
@ -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
|
||||
|
|
127
ft/djvu/djvu.c
Normal file
127
ft/djvu/djvu.c
Normal file
|
@ -0,0 +1,127 @@
|
|||
/* See LICENSE file for license and copyright information */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#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;
|
||||
}
|
29
ft/djvu/djvu.h
Normal file
29
ft/djvu/djvu.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* See LICENSE file for license and copyright information */
|
||||
|
||||
#ifndef DJVU_H
|
||||
#define DJVU_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <libdjvu/ddjvuapi.h>
|
||||
|
||||
#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
|
|
@ -10,14 +10,16 @@
|
|||
#include <limits.h>
|
||||
|
||||
#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*
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue