Commit a7b3d73f authored by Moritz Lipp's avatar Moritz Lipp

Merge branch 'release/0.2.7'

parents 6d22f33f 0f005c0d
......@@ -18,3 +18,4 @@ doc/
zathura.1
zathurarc.5
.version-checks/
dbus-interface-definitions.c
Copyright (c) 2009-2013 pwmt.org
Copyright (c) 2009-2014 pwmt.org
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
......
......@@ -4,7 +4,7 @@ include config.mk
include common.mk
PROJECT = zathura
OSOURCE = $(wildcard *.c)
OSOURCE = $(filter-out dbus-interface-definitions.c, $(wildcard *.c))
HEADER = $(wildcard *.h)
HEADERINST = version.h document.h macros.h page.h types.h plugin-api.h links.h
......@@ -37,13 +37,13 @@ ifeq (,$(findstring -DLOCALEDIR,${CPPFLAGS}))
CPPFLAGS += -DLOCALEDIR=\"${LOCALEDIR}\"
endif
OBJECTS = $(patsubst %.c, %.o, $(SOURCE))
DOBJECTS = $(patsubst %.c, %.do, $(SOURCE))
OBJECTS = $(patsubst %.c, %.o, $(SOURCE)) dbus-interface-definitions.o
DOBJECTS = $(patsubst %.o, %.do, $(OBJECTS))
all: options ${PROJECT} po build-manpages
# pkg-config based version checks
.version-checks/%:
.version-checks/%: config.mk
$(QUIET)test $($(*)_VERSION_CHECK) -eq 0 || \
pkg-config --atleast-version $($(*)_MIN_VERSION) $($(*)_PKG_CONFIG_NAME) || ( \
echo "The minium required version of $(*) is $($(*)_MIN_VERSION)" && \
......@@ -64,7 +64,15 @@ version.h: version.h.in config.mk
-e 's/ZVMINOR/${ZATHURA_VERSION_MINOR}/' \
-e 's/ZVREV/${ZATHURA_VERSION_REV}/' \
-e 's/ZVAPI/${ZATHURA_API_VERSION}/' \
-e 's/ZVABI/${ZATHURA_ABI_VERSION}/' version.h.in > version.h
-e 's/ZVABI/${ZATHURA_ABI_VERSION}/' version.h.in > version.h.tmp
$(QUIET)mv version.h.tmp version.h
dbus-interface-definitions.c: data/org.pwmt.zathura.xml
$(QUIET)echo '#include "dbus-interface-definitions.h"' > dbus-interface-definitions.c.tmp
$(QUIET)echo 'const char* DBUS_INTERFACE_XML =' >> dbus-interface-definitions.c.tmp
$(QUIET)sed 's/^\(.*\)$$/"\1\\n"/' data/org.pwmt.zathura.xml >> dbus-interface-definitions.c.tmp
$(QUIET)echo ';' >> dbus-interface-definitions.c.tmp
$(QUIET)mv dbus-interface-definitions.c.tmp dbus-interface-definitions.c
%.o: %.c
$(ECHO) CC $<
......@@ -84,8 +92,18 @@ ${PROJECT}: ${OBJECTS}
$(QUIET)${CC} ${SFLAGS} ${LDFLAGS} -o $@ ${OBJECTS} ${LIBS}
clean:
$(QUIET)rm -rf ${PROJECT} ${OBJECTS} ${PROJECT}-${VERSION}.tar.gz \
${DOBJECTS} ${PROJECT}-debug .depend ${PROJECT}.pc doc version.h \
$(QUIET)rm -rf ${PROJECT} \
${OBJECTS} \
${PROJECT}-${VERSION}.tar.gz \
${DOBJECTS} \
${PROJECT}-debug \
.depend \
${PROJECT}.pc \
doc \
version.h \
version.h.tmp \
dbus-interface-definitions.c \
dbus-interface-definitions.c.tmp \
*gcda *gcno $(PROJECT).info gcov *.tmp \
.version-checks
ifneq "$(wildcard ${RSTTOMAN})" ""
......@@ -107,7 +125,7 @@ ${PROJECT}.pc: ${PROJECT}.pc.in config.mk
$(QUIET)echo abiversion=${ZATHURA_ABI_VERSION} >> ${PROJECT}.pc
$(QUIET)echo includedir=${INCLUDEDIR} >> ${PROJECT}.pc
$(QUIET)echo plugindir=${PLUGINDIR} >> ${PROJECT}.pc
$(QUIET)echo GTK_VERSION=${ZATHURA_GTK_VERSION} >> ${PROJECT}.pc
$(QUIET)echo GTK_VERSION=3 >> ${PROJECT}.pc
$(QUIET)cat ${PROJECT}.pc.in >> ${PROJECT}.pc
valgrind: debug
......@@ -129,6 +147,7 @@ dist: clean build-manpages
${PROJECT}.desktop version.h.in \
${PROJECT}.1 ${PROJECT}rc.5 \
${PROJECT}-${VERSION}
$(QUIET)cp -r data ${PROJECT}-${VERSION}
$(QUIET)cp tests/Makefile tests/config.mk tests/*.c \
${PROJECT}-${VERSION}/tests
$(QUIET)cp po/Makefile po/*.po ${PROJECT}-${VERSION}/po
......@@ -184,7 +203,12 @@ install-headers: ${PROJECT}.pc
$(QUIET)mkdir -m 755 -p ${DESTDIR}${LIBDIR}/pkgconfig
$(QUIET)install -m 644 ${PROJECT}.pc ${DESTDIR}${LIBDIR}/pkgconfig
install: all install-headers install-manpages
install-dbus:
$(ECHO) installing D-Bus interface definitions
$(QUIET)mkdir -m 755 -p $(DESTDIR)$(DBUSINTERFACEDIR)
$(QUIET)install -m 644 data/org.pwmt.zathura.xml $(DESTDIR)$(DBUSINTERFACEDIR)
install: all install-headers install-manpages install-dbus
$(ECHO) installing executable file
$(QUIET)mkdir -m 755 -p ${DESTDIR}${PREFIX}/bin
$(QUIET)install -m 755 ${PROJECT} ${DESTDIR}${PREFIX}/bin
......@@ -207,9 +231,12 @@ uninstall: uninstall-headers
$(QUIET)rm -f ${DESTDIR}${MANPREFIX}/man5/${PROJECT}rc.5
$(ECHO) removing desktop file
$(QUIET)rm -f ${DESTDIR}${DESKTOPPREFIX}/${PROJECT}.desktop
$(ECHO) removing D-Bus interface definitions
$(QUIET)rm -f $(DESTDIR)$(DBUSINTERFACEDIR)/org.pwmt.zathura.xml
$(MAKE) -C po uninstall
-include $(wildcard .depend/*.dep)
.PHONY: all options clean doc debug valgrind gdb dist doc install uninstall test \
po install-headers uninstall-headers update-po install-manpages build-manpages
.PHONY: all options clean doc debug valgrind gdb dist doc install uninstall \
test po install-headers uninstall-headers update-po install-manpages \
build-manpages install-dbus
......@@ -5,9 +5,9 @@ girara user interface library and several document libraries.
Requirements
------------
gtk2 (>= 2.18) or gtk3
gtk3
glib (>= 2.28)
girara
girara (>= 0.1.8)
sqlite3 (optional, >= 3.5.9)
check (for tests)
intltool
......
......@@ -146,20 +146,6 @@ page_is_visible(zathura_document_t *document, unsigned int page_number)
fabs(pos_y - page_y) < 0.5 * (double)(view_height + cell_height) / (double)doc_height);
}
GtkAdjustment*
zathura_adjustment_clone(GtkAdjustment* adjustment)
{
gdouble value = gtk_adjustment_get_value(adjustment);
gdouble lower = gtk_adjustment_get_lower(adjustment);
gdouble upper = gtk_adjustment_get_upper(adjustment);
gdouble step_increment = gtk_adjustment_get_step_increment(adjustment);
gdouble page_increment = gtk_adjustment_get_page_increment(adjustment);
gdouble page_size = gtk_adjustment_get_page_size(adjustment);
return GTK_ADJUSTMENT(gtk_adjustment_new(value, lower, upper, step_increment,
page_increment, page_size));
}
void
zathura_adjustment_set_value(GtkAdjustment* adjustment, gdouble value)
{
......
......@@ -69,17 +69,6 @@ void page_number_to_position(zathura_document_t* document, unsigned int page_num
*/
bool page_is_visible(zathura_document_t *document, unsigned int page_number);
/**
* Clone a GtkAdjustment
*
* Creates a new adjustment with the same value, lower and upper bounds, step
* and page increments and page_size as the original adjustment.
*
* @param adjustment Adjustment instance to be cloned
* @return Pointer to the new adjustment
*/
GtkAdjustment* zathura_adjustment_clone(GtkAdjustment* adjustment);
/**
* Set the adjustment value while enforcing its limits
*
......
......@@ -48,7 +48,10 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page)
return old;
}
zathura_bookmark_t* bookmark = g_malloc0(sizeof(zathura_bookmark_t));
zathura_bookmark_t* bookmark = g_try_malloc0(sizeof(zathura_bookmark_t));
if (bookmark == NULL) {
return NULL;
}
bookmark->id = g_strdup(id);
bookmark->page = page;
......
......@@ -50,7 +50,8 @@ cb_buffer_changed(girara_session_t* session)
}
static void
update_visible_pages(zathura_t* zathura) {
update_visible_pages(zathura_t* zathura)
{
const unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) {
......@@ -539,6 +540,11 @@ cb_page_widget_text_selected(ZathuraPage* page, const char* text, void* data)
g_return_if_fail(data != NULL);
zathura_t* zathura = data;
girara_mode_t mode = girara_mode_get(zathura->ui.session);
if (mode != zathura->modes.normal && mode != zathura->modes.fullscreen) {
return;
}
GdkAtom* selection = get_selection(zathura);
/* copy to clipboard */
......
......@@ -400,7 +400,10 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
}
}
girara_argument_t* arg = g_malloc0(sizeof(girara_argument_t));
girara_argument_t* arg = g_try_malloc0(sizeof(girara_argument_t));
if (arg == NULL) {
return false;
}
arg->n = FORWARD;
sc_search(session, arg, NULL, 0);
......
This diff is collapsed.
......@@ -3,9 +3,6 @@
#ifndef CONFIG_H
#define CONFIG_H
#define GLOBAL_RC "/etc/zathurarc"
#define ZATHURA_RC "zathurarc"
#include "zathura.h"
/**
......@@ -21,6 +18,6 @@ void config_load_default(zathura_t* zathura);
* @param zathura The zathura session
* @param path Path to the configuration file
*/
void config_load_file(zathura_t* zathura, char* path);
void config_load_files(zathura_t* zathura);
#endif // CONFIG_H
......@@ -3,31 +3,28 @@
ZATHURA_VERSION_MAJOR = 0
ZATHURA_VERSION_MINOR = 2
ZATHURA_VERSION_REV = 6
ZATHURA_VERSION_REV = 7
# If the API changes, the API version and the ABI version have to be bumped.
ZATHURA_API_VERSION = 2
# If the ABI breaks for any reason, this has to be bumped.
ZATHURA_ABI_VERSION = 2
VERSION = ${ZATHURA_VERSION_MAJOR}.${ZATHURA_VERSION_MINOR}.${ZATHURA_VERSION_REV}
# the GTK+ version to use
ZATHURA_GTK_VERSION ?= 3
# version checks
# If you want to disable any of the checks, set *_VERSION_CHECK to 0.
# girara
GIRARA_VERSION_CHECK ?= 1
GIRARA_MIN_VERSION = 0.1.8
GIRARA_PKG_CONFIG_NAME = girara-gtk$(ZATHURA_GTK_VERSION)
GIRARA_PKG_CONFIG_NAME = girara-gtk3
# glib
GLIB_VERSION_CHECK ?= 1
GLIB_MIN_VERSION = 2.28
GLIB_PKG_CONFIG_NAME = glib-2.0
# GTK
GTK_VERSION_CHECK ?= 1
GTK_MIN_VERSION = 2.18
GTK_PKG_CONFIG_NAME = gtk+-$(ZATHURA_GTK_VERSION).0
GTK_MIN_VERSION = 3.0
GTK_PKG_CONFIG_NAME = gtk+-3.0
# database
# To disable support for the sqlite backend set WITH_SQLITE to 0.
......@@ -43,6 +40,8 @@ MANPREFIX ?= ${PREFIX}/share/man
DESKTOPPREFIX ?= ${PREFIX}/share/applications
LIBDIR ?= ${PREFIX}/lib
INCLUDEDIR ?= ${PREFIX}/include
DBUSINTERFACEDIR ?= ${PREFIX}/share/dbus-1/interfaces
VIMFTPLUGINDIR ?= ${PREFIX}/share/vim/addons/ftplugin
# plugin directory
PLUGINDIR ?= ${LIBDIR}/zathura
......@@ -53,8 +52,8 @@ LOCALEDIR ?= ${PREFIX}/share/locale
RSTTOMAN ?= /usr/bin/rst2man
# libs
GTK_INC ?= $(shell pkg-config --cflags gtk+-${ZATHURA_GTK_VERSION}.0)
GTK_LIB ?= $(shell pkg-config --libs gtk+-${ZATHURA_GTK_VERSION}.0)
GTK_INC ?= $(shell pkg-config --cflags gtk+-3.0)
GTK_LIB ?= $(shell pkg-config --libs gtk+-3.0)
GTHREAD_INC ?= $(shell pkg-config --cflags gthread-2.0)
GTHREAD_LIB ?= $(shell pkg-config --libs gthread-2.0)
......@@ -65,8 +64,8 @@ GMODULE_LIB ?= $(shell pkg-config --libs gmodule-no-export-2.0)
GLIB_INC ?= $(shell pkg-config --cflags glib-2.0)
GLIB_LIB ?= $(shell pkg-config --libs glib-2.0)
GIRARA_INC ?= $(shell pkg-config --cflags girara-gtk${ZATHURA_GTK_VERSION})
GIRARA_LIB ?= $(shell pkg-config --libs girara-gtk${ZATHURA_GTK_VERSION})
GIRARA_INC ?= $(shell pkg-config --cflags girara-gtk3)
GIRARA_LIB ?= $(shell pkg-config --libs girara-gtk3)
ifneq (${WITH_SQLITE},0)
SQLITE_INC ?= $(shell pkg-config --cflags sqlite3)
......
/* See LICENSE file for license and copyright information */
#define _BSD_SOURCE
#define _XOPEN_SOURCE 700
#include "content-type.h"
#include "macros.h"
#include <girara/utils.h>
#ifdef WITH_MAGIC
#include <magic.h>
#else
#include <sys/types.h>
#include <sys/wait.h>
#endif
#include <stdio.h>
#include <glib.h>
#include <gio/gio.h>
/** Read a most GT_MAX_READ bytes before falling back to file. */
static const size_t GT_MAX_READ = 1 << 16;
#ifdef WITH_MAGIC
static const char*
guess_type_magic(const char* path) {
const char* mime_type = NULL;
/* creat magic cookie */
const int flags =
MAGIC_MIME_TYPE |
MAGIC_SYMLINK |
MAGIC_NO_CHECK_APPTYPE |
MAGIC_NO_CHECK_CDF |
MAGIC_NO_CHECK_ELF |
MAGIC_NO_CHECK_ENCODING;
magic_t magic = magic_open(flags);
if (magic == NULL) {
girara_debug("failed creating the magic cookie");
goto cleanup;
}
/* ... and load mime database */
if (magic_load(magic, NULL) < 0) {
girara_debug("failed loading the magic database: %s", magic_error(magic));
goto cleanup;
}
/* get the mime type */
mime_type = magic_file(magic, path);
if (mime_type == NULL) {
girara_debug("failed guessing filetype: %s", magic_error(magic));
goto cleanup;
}
/* dup so we own the memory */
mime_type = g_strdup(mime_type);
girara_debug("magic detected filetype: %s", mime_type);
cleanup:
if (magic != NULL) {
magic_close(magic);
}
return mime_type;
}
static const char*
guess_type_file(const char* UNUSED(path))
{
return NULL;
}
#else
static const char*
guess_type_magic(const char* UNUSED(path)) {
return NULL;
}
static const char*
guess_type_file(const char* path)
{
GString* command = g_string_new("file -b --mime-type ");
char* tmp = g_shell_quote(path);
g_string_append(command, tmp);
g_free(tmp);
GError* error = NULL;
char* out = NULL;
int ret = 0;
g_spawn_command_line_sync(command->str, &out, NULL, &ret, &error);
g_string_free(command, TRUE);
if (error != NULL) {
girara_warning("failed to execute command: %s", error->message);
g_error_free(error);
g_free(out);
return NULL;
}
if (WEXITSTATUS(ret) != 0) {
girara_warning("file failed with error code: %d", WEXITSTATUS(ret));
g_free(out);
return NULL;
}
g_strdelimit(out, "\n\r", '\0');
return out;
}
#endif
static const char*
guess_type_glib(const char* path)
{
gboolean uncertain = FALSE;
const char* content_type = g_content_type_guess(path, NULL, 0, &uncertain);
if (content_type == NULL) {
girara_debug("g_content_type failed\n");
} else {
if (uncertain == FALSE) {
girara_debug("g_content_type detected filetype: %s", content_type);
return content_type;
}
girara_debug("g_content_type is uncertain, guess: %s", content_type);
}
FILE* f = fopen(path, "rb");
if (f == NULL) {
return NULL;
}
const int fd = fileno(f);
guchar* content = NULL;
size_t length = 0u;
ssize_t bytes_read = -1;
while (uncertain == TRUE && length < GT_MAX_READ && bytes_read != 0) {
g_free((void*)content_type);
content_type = NULL;
guchar* temp_content = g_try_realloc(content, length + BUFSIZ);
if (temp_content == NULL) {
break;
}
content = temp_content;
bytes_read = read(fd, content + length, BUFSIZ);
if (bytes_read == -1) {
break;
}
length += bytes_read;
content_type = g_content_type_guess(NULL, content, length, &uncertain);
girara_debug("new guess: %s uncertain: %d, read: %zu", content_type, uncertain, length);
}
fclose(f);
g_free(content);
if (uncertain == FALSE) {
return content_type;
}
g_free((void*)content_type);
return NULL;
}
const char*
guess_content_type(const char* path)
{
/* try libmagic first */
const char* content_type = guess_type_magic(path);
if (content_type != NULL) {
return content_type;
}
/* else fallback to g_content_type_guess method */
content_type = guess_type_glib(path);
if (content_type != NULL) {
return content_type;
}
/* and if libmagic is not available, try file as last resort */
return guess_type_file(path);
}
/* See LICENSE file for license and copyright information */
#ifndef ZATHURA_CONTENT_TYPE_H
#define ZATHURA_CONTENT_TYPE_H
const char* guess_content_type(const char* path);
#endif
<!DOCTYPE node PUBLIC '-//freedesktop//DTD D-BUS Object Introspection 1.0//EN'
'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>
<node>
<interface name='org.pwmt.zathura'>
<!-- Open a document in a running zathura instance. -->
<method name='OpenDocument'>
<arg type='s' name='path' direction='in' />
<arg type='s' name='password' direction='in' />
<arg type='i' name='page' direction='in' />
<arg type='b' name='return' direction='out' />
</method>
<!-- Close open document. -->
<method name='CloseDocument'>
<arg type='b' name='return' direction='out' />
</method>
<!-- Go to a specific page . -->
<method name='GotoPage'>
<arg type='u' name='page' direction='in' />
<arg type='b' name='return' direction='out' />
</method>
<!-- Go to a page and highlight rectangles there. -->
<method name='HighlightRects'>
<arg type='u' name='page' direction='in' />
<arg type='a(dddd)' name='rectangles' direction='in' />
<arg type='a(udddd)' name='secondary_rectangles' direction='in' />
<arg type='b' name='return' direction='out' />
</method>
<property type='s' name='filename' access='read' />
<property type='u' name='pagenumber' access='read' />
<property type='u' name='numberofpages' access='read' />
</interface>
</node>
" See LICENSE file for license and copyright information
" This is a sample plugin that can be used for synctex forward synchronization.
" It currently uses latexsuite to obtain the file name of the document. If you
" are not using latexsuite, it should be enough to adopt the calculation of
" 'output' accordingly.
" avoid re-execution
if exists("b:did_zathura_synctex_plugin") || !exists("*Tex_GetMainFileName")
finish
endif
let b:did_zathura_synctex_plugin = 1
function! Zathura_SyncTexForward()
let source = expand("%:p")
let input = shellescape(line(".").":".col(".").":".source)
let output = Tex_GetMainFileName(":p:r").".pdf"
let execstr = "zathura --synctex-forward=".input." ".shellescape(output)
silent call system(execstr)
endfunction
nmap <buffer> <Leader>f :call Zathura_SyncTexForward()<Enter>
This diff is collapsed.
......@@ -388,9 +388,16 @@ sqlite_load_bookmarks(zathura_database_t* db, const char* file)
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
(girara_free_function_t) zathura_bookmark_free);
if (result != NULL) {
sqlite3_finalize(stmt);
return NULL;
}
while (sqlite3_step(stmt) == SQLITE_ROW) {
zathura_bookmark_t* bookmark = g_malloc0(sizeof(zathura_bookmark_t));
zathura_bookmark_t* bookmark = g_try_malloc0(sizeof(zathura_bookmark_t));
if (bookmark == NULL) {
continue;
}
bookmark->id = g_strdup((const char*) sqlite3_column_text(stmt, 0));
bookmark->page = sqlite3_column_int(stmt, 1);
......@@ -521,10 +528,17 @@ sqlite_load_jumplist(zathura_database_t* db, const char* file)
}
girara_list_t* jumplist = girara_list_new2(g_free);
int res = 0;
if (jumplist == NULL) {
sqlite3_finalize(stmt);
return NULL;
}
int res = 0;
while ((res = sqlite3_step(stmt)) == SQLITE_ROW) {
zathura_jump_t* jump = g_malloc0(sizeof(zathura_jump_t));
zathura_jump_t* jump = g_try_malloc0(sizeof(zathura_jump_t));
if (jump == NULL) {
continue;
}
jump->page = sqlite3_column_int(stmt, 0);
jump->x = sqlite3_column_double(stmt, 1);
......
/* See LICENSE file for license and copyright information */
#ifndef ZATHURA_DBUS_INTERFACE_DEFINITIONS
#define ZATHURA_DBUS_INTERFACE_DEFINITIONS
const char* DBUS_INTERFACE_XML;
#endif
This diff is collapsed.
/* See LICENSE file for license and copyright information */
#ifndef DBUS_INTERFACE_H
#define DBUS_INTERFACE_H
#include <stdbool.h>
#include <girara/types.h>
#include <glib-object.h>
#include <sys/types.h>
#include "types.h"
typedef struct zathura_dbus_class_s ZathuraDbusClass;
struct zathura_dbus_s
{
GObject parent;
};
struct zathura_dbus_class_s
{
GObjectClass parent_class;
};
#define ZATHURA_TYPE_DBUS \
(zathura_dbus_get_type())
#define ZATHURA_DBUS(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), ZATHURA_TYPE_DBUS, \
ZathuraDbus))
#define ZATHURA_DBUS_CLASS(obj) \
(G_TYPE_CHECK_CLASS_CAST((obj), ZATHURA_TYPE_DBUS, \
ZathuraDbus))
#define ZATHURA_IS_DBUS(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), ZATHURA_TYPE_DBUS))
#define ZATHURA_IS_DBUS_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((obj), ZATHURA_TYPE_DBUS))
#define ZATHURA_DBUS_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), ZATHURA_TYPE_DBUS, \
ZathuraDbusClass))
GType zathura_dbus_get_type(void);
ZathuraDbus* zathura_dbus_new(zathura_t* zathura);
/**
* Look for zathura instance having filename open and cause it to open give page
* and highlight rectangles on the given page
*
* @param filename filename
* @param page page number
* @param rectangles list of rectangles to highlight
* @param secondary_rects list of synctex_page_rect_ts for rectangles not on the
* page given by page
* @returns true if a instance was found that has the given filename open, false
* otherwise
*/
bool zathura_dbus_goto_page_and_highlight(const char* filename,
unsigned int page, girara_list_t* rectangles, girara_list_t* secondary_rects,
pid_t pidhint);
bool zathura_dbus_synctex_position(const char* filename, const char* position,
pid_t pidhint);
#endif
......@@ -3,39 +3,21 @@
#define _BSD_SOURCE
#define _XOPEN_SOURCE 700
#include <sys/wait.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <glib.h>
#include <glib/gi18n.h>
#ifdef WITH_MAGIC
#include <magic.h>
#endif
#include <unistd.h>
#include <girara/datastructures.h>
#include <girara/utils.h>
#include <girara/statusbar.h>
#include <girara/session.h>
#include <girara/settings.h>
#include "adjustment.h"
#include "document.h"
#include "utils.h"
#include "zathura.h"
#include "render.h"
#include "database.h"
#include "page.h"
#include "page-widget.h"
#include "plugin.h"
/** Read a most GT_MAX_READ bytes before falling back to file. */
static const size_t GT_MAX_READ = 1 << 16;
static const gchar* guess_type(const char* path);
#include "content-type.h"
/**
* Document
......@@ -86,7 +68,7 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
return NULL;
}
const gchar* content_type = guess_type(path);
const char* content_type = guess_content_type(path);
if (content_type == NULL) {
girara_error("Could not determine file type.");
return NULL;
......@@ -122,11 +104,19 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
if (plugin == NULL) {
girara_error("unknown file type\n");
if (error != NULL) {
*error = ZATHURA_ERROR_UNKNOWN;
}
goto error_free;
}
document = g_malloc0(sizeof(zathura_document_t));
document = g_try_malloc0(sizeof(zathura_document_t));
if (document == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_OUT_OF_MEMORY;
}
goto error_free;
}
document->file_path = real_path;
document->basename = g_path_get_basename(real_path);
......@@ -665,127 +655,6 @@ zathura_document_get_information(zathura_document_t* document, zathura_error_t*