Merge branch 'release/0.3.5'

This commit is contained in:
Moritz Lipp 2016-02-14 23:52:42 +01:00
commit c124b18056
33 changed files with 552 additions and 362 deletions

View file

@ -1,4 +1,4 @@
Copyright (c) 2009-2015 pwmt.org Copyright (c) 2009-2016 pwmt.org
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages

2
README
View file

@ -12,7 +12,7 @@ sqlite3 (optional, >= 3.5.9)
check (for tests) check (for tests)
intltool intltool
libmagic from file(1) (optional, for mime-type detection) libmagic from file(1) (optional, for mime-type detection)
libsynctex from TeXLive (option, for SyncTeX support) libsynctex from TeXLive (optional, for SyncTeX support)
Sphinx (optional, for manpages and HTML documentation) Sphinx (optional, for manpages and HTML documentation)
doxygen (optional, for HTML documentation) doxygen (optional, for HTML documentation)
breathe (optional, for HTML documentation) breathe (optional, for HTML documentation)

View file

@ -6,7 +6,7 @@ PROJECT = zathura
ZATHURA_VERSION_MAJOR = 0 ZATHURA_VERSION_MAJOR = 0
ZATHURA_VERSION_MINOR = 3 ZATHURA_VERSION_MINOR = 3
ZATHURA_VERSION_REV = 4 ZATHURA_VERSION_REV = 5
# If the API changes, the API version and the ABI version have to be bumped. # If the API changes, the API version and the ABI version have to be bumped.
ZATHURA_API_VERSION = 2 ZATHURA_API_VERSION = 2
# If the ABI breaks for any reason, this has to be bumped. # If the ABI breaks for any reason, this has to be bumped.

View file

@ -6,7 +6,7 @@ include ../colors.mk
include config.mk include config.mk
MAN_SOURCES=$(wildcard man/*.rst) $(wildcard man/*.txt) man/conf.py MAN_SOURCES=$(wildcard man/*.rst) $(wildcard man/*.txt) man/conf.py
DOXYGEN_SOURCES=$(wildcard ../*.h) Doxyfile DOXYGEN_SOURCES=$(wildcard ../zathura/*.h) Doxyfile
HTML_SOURCES=$(wildcard *.rst api/*.rst configuration/*.rst installation/*.rst usage/*.rst) conf.py HTML_SOURCES=$(wildcard *.rst api/*.rst configuration/*.rst installation/*.rst usage/*.rst) conf.py
SPHINX_OPTS+=-d $(SPHINX_BUILDDIR)/doctrees SPHINX_OPTS+=-d $(SPHINX_BUILDDIR)/doctrees
@ -18,15 +18,17 @@ clean:
$(QUIET)rm -rf $(SPHINX_BUILDDIR)/ $(QUIET)rm -rf $(SPHINX_BUILDDIR)/
$(SPHINX_BUILDDIR)/html/index.html: $(HTML_SOURCES) $(SPHINX_BUILDDIR)/doxygen/xml/index.xml $(SPHINX_BUILDDIR)/html/index.html: $(HTML_SOURCES) $(SPHINX_BUILDDIR)/doxygen/xml/index.xml
$(QUIET)mkdir -p $(SPHINX_BUILDDIR)/html
$(call colorecho,DOC,"Build HTML documentation") $(call colorecho,DOC,"Build HTML documentation")
$(QUIET)$(SPHINX_BIN) -b html $(SPHINX_OPTS) . $(SPHINX_BUILDDIR)/html $(QUIET)$(SPHINX_BIN) -b html $(SPHINX_OPTS) . $(SPHINX_BUILDDIR)/html
$(SPHINX_BUILDDIR)/zathura.1 $(SPHINX_BUILDDIR)/zathurarc.5: $(MAN_SOURCES) $(SPHINX_BUILDDIR)/zathura.1 $(SPHINX_BUILDDIR)/zathurarc.5: $(MAN_SOURCES)
$(QUIET)mkdir -p $(SPHINX_BUILDDIR)
$(call colorecho,DOC,"Build man pages") $(call colorecho,DOC,"Build man pages")
$(QUIET)$(SPHINX_BIN) -b man $(SPHINX_OPTS) man $(SPHINX_BUILDDIR) $(QUIET)$(SPHINX_BIN) -b man $(SPHINX_OPTS) man $(SPHINX_BUILDDIR)
$(SPHINX_BUILDDIR)/doxygen/xml/index.xml: $(DOXYGEN_SOURCES) $(SPHINX_BUILDDIR)/doxygen/xml/index.xml: $(DOXYGEN_SOURCES)
$(QUIET)mkdir -p $(SPHINX_BUILDDIR) $(QUIET)mkdir -p $(SPHINX_BUILDDIR)/doxygen/xml
$(call colorecho,DOC,"Run doxygen") $(call colorecho,DOC,"Run doxygen")
$(QUIET)$(DOXYGEN_BIN) Doxyfile $(QUIET)$(DOXYGEN_BIN) Doxyfile

View file

@ -16,9 +16,6 @@ exec
info info
Show document information Show document information
help
Show help page
open open
Open a document Open a document

View file

@ -28,7 +28,13 @@
--synctex-forward=input --synctex-forward=input
Jump to the given position. The switch expects the same format as specified Jump to the given position. The switch expects the same format as specified
for synctex's view -i. for synctex's view -i. If no instance is running for the specified document,
a new instance will be launched (only if --synctex-pid is not specified).
--synctex-pid=pid
Instead of looking for an instance having the correct file opened, try only
the instance with the given PID. Note that if the given PID does not have the
correct file open or does not exist, no new instance will be spanned.
--fork --fork
Fork into background Fork into background

View file

@ -1,6 +1,6 @@
Both synctex forward and backwards synchronization are supported by zathura, To Both synctex forward and backwards synchronization are supported by zathura, To
enable synctex forward synchronization, please look at the *--syntex* and enable synctex forward synchronization, please look at the *--synctex-forward*
*--synctex-editor* options. zathura will also emit a signal via the D-Bus and *--synctex-editor* options. zathura will also emit a signal via the D-Bus
interface. To support synctex backwards synchronization, zathura provides a interface. To support synctex backwards synchronization, zathura provides a
D-Bus interface that can be called by the editor. For convince zathura also D-Bus interface that can be called by the editor. For convince zathura also
knows how to parse the output of the *synctex view* command. It is enough to knows how to parse the output of the *synctex view* command. It is enough to

View file

@ -1,2 +1,3 @@
zathura [-e XID] [-c PATH] [-d PATH] [-p PATH] [-w PASSWORD] [-P NUMBER] zathura [-e XID] [-c PATH] [-d PATH] [-p PATH] [-w PASSWORD] [-P NUMBER]
[--fork] [-l LEVEL] [-s] [-x CMD] [--synctex-forward INPUT] <files> [--fork] [-l LEVEL] [-s] [-x CMD] [--synctex-forward INPUT] [--synctex-pid PID]
<files>

View file

@ -307,6 +307,13 @@ The following shortcut functions can be mapped:
Zoom in or out. Zoom in or out.
* ``mark_add``
Set a quickmark.
* ``mark_evaluate``
Go to a quickmark.
Pass arguments Pass arguments
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
Some shortcut function require or have optional arguments which influence the Some shortcut function require or have optional arguments which influence the
@ -454,8 +461,8 @@ guioptions
Shows or hides GUI elements. Shows or hides GUI elements.
If it contains 'c', the command line is displayed. If it contains 'c', the command line is displayed.
If it contains 's', the statusbar is displayed. If it contains 's', the statusbar is displayed.
If it contains 'h', the vertical scrollbar is displayed. If it contains 'h', the horizontal scrollbar is displayed.
If it contains 'v', the horizontal scrollbar is displayed. If it contains 'v', the vertical scrollbar is displayed.
* Value type: String * Value type: String
* Default value: s * Default value: s

View file

@ -5,4 +5,4 @@ Usage
:maxdepth: 2 :maxdepth: 2
:numbered: :numbered:
commands commands

View file

@ -19,10 +19,10 @@ all: ${MOS}
clean: clean:
$(QUIET)rm -rf POTFILES.in POTFILES.in.tmp $(patsubst %.po, %, $(CATALOGS)) ${PROJECT}.pot $(QUIET)rm -rf POTFILES.in POTFILES.in.tmp $(patsubst %.po, %, $(CATALOGS)) ${PROJECT}.pot
POTFILES.in: $(sort $(wildcard ../girara/*.c)) POTFILES.in: $(sort $(wildcard ../zathura/*.c))
$(QUIET) set -e && rm -f $@.tmp && touch $@.tmp && \ $(QUIET) set -e && rm -f $@.tmp && touch $@.tmp && \
for f in $(^F) ; do \ for f in $(^F) ; do \
echo girara/$$f >> $@.tmp ; \ echo zathura/$$f >> $@.tmp ; \
done && \ done && \
mv $@.tmp $@ mv $@.tmp $@

View file

@ -5,9 +5,10 @@
#include "document.h" #include "document.h"
START_TEST(test_open) { START_TEST(test_open) {
fail_unless(zathura_document_open(NULL, NULL, NULL, NULL) == NULL, "Could create document", NULL); fail_unless(zathura_document_open(NULL, NULL, NULL, NULL, NULL) == NULL, "Could create document", NULL);
fail_unless(zathura_document_open(NULL, "fl", NULL, NULL) == NULL, "Could create document", NULL); fail_unless(zathura_document_open(NULL, "fl", NULL, NULL, NULL) == NULL, "Could create document", NULL);
fail_unless(zathura_document_open(NULL, "fl", "pw", NULL) == NULL, "Could create document", NULL); fail_unless(zathura_document_open(NULL, "fl", "ur", NULL, NULL) == NULL, "Could create document", NULL);
fail_unless(zathura_document_open(NULL, "fl", NULL, "pw", NULL) == NULL, "Could create document", NULL);
} END_TEST } END_TEST
Suite* suite_document() Suite* suite_document()

View file

@ -16,7 +16,7 @@
* *
* @param widget The gtk window of zathura * @param widget The gtk window of zathura
* @param zathura Correspondending zathura session * @param zathura Correspondending zathura session
* @return true if no error occured and the event has been handled * @return true if no error occurred and the event has been handled
*/ */
gboolean cb_destroy(GtkWidget* widget, zathura_t* zathura); gboolean cb_destroy(GtkWidget* widget, zathura_t* zathura);
@ -108,7 +108,7 @@ void cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path,
* *
* @param entry The dialog inputbar * @param entry The dialog inputbar
* @param session The girara session * @param session The girara session
* @return true if no error occured and the event has been handled * @return true if no error occurred and the event has been handled
*/ */
bool cb_sc_follow(GtkEntry* entry, girara_session_t* session); bool cb_sc_follow(GtkEntry* entry, girara_session_t* session);
@ -117,7 +117,7 @@ bool cb_sc_follow(GtkEntry* entry, girara_session_t* session);
* *
* @param entry The dialog inputbar * @param entry The dialog inputbar
* @param session The girara session * @param session The girara session
* @return true if no error occured and the event has been handled * @return true if no error occurred and the event has been handled
*/ */
bool cb_sc_display_link(GtkEntry* entry, girara_session_t* session); bool cb_sc_display_link(GtkEntry* entry, girara_session_t* session);

View file

@ -11,7 +11,7 @@
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_bookmark_create(girara_session_t* session, girara_list_t* argument_list); bool cmd_bookmark_create(girara_session_t* session, girara_list_t* argument_list);
@ -20,7 +20,7 @@ bool cmd_bookmark_create(girara_session_t* session, girara_list_t* argument_list
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_bookmark_delete(girara_session_t* session, girara_list_t* argument_list); bool cmd_bookmark_delete(girara_session_t* session, girara_list_t* argument_list);
@ -29,7 +29,7 @@ bool cmd_bookmark_delete(girara_session_t* session, girara_list_t* argument_list
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_bookmark_open(girara_session_t* session, girara_list_t* argument_list); bool cmd_bookmark_open(girara_session_t* session, girara_list_t* argument_list);
@ -38,7 +38,7 @@ bool cmd_bookmark_open(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_close(girara_session_t* session, girara_list_t* argument_list); bool cmd_close(girara_session_t* session, girara_list_t* argument_list);
@ -47,7 +47,7 @@ bool cmd_close(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_info(girara_session_t* session, girara_list_t* argument_list); bool cmd_info(girara_session_t* session, girara_list_t* argument_list);
@ -56,7 +56,7 @@ bool cmd_info(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_help(girara_session_t* session, girara_list_t* argument_list); bool cmd_help(girara_session_t* session, girara_list_t* argument_list);
@ -65,7 +65,7 @@ bool cmd_help(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_hlsearch(girara_session_t* session, girara_list_t* argument_list); bool cmd_hlsearch(girara_session_t* session, girara_list_t* argument_list);
@ -74,7 +74,7 @@ bool cmd_hlsearch(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_open(girara_session_t* session, girara_list_t* argument_list); bool cmd_open(girara_session_t* session, girara_list_t* argument_list);
@ -83,7 +83,7 @@ bool cmd_open(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_print(girara_session_t* session, girara_list_t* argument_list); bool cmd_print(girara_session_t* session, girara_list_t* argument_list);
@ -92,7 +92,7 @@ bool cmd_print(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_nohlsearch(girara_session_t* session, girara_list_t* argument_list); bool cmd_nohlsearch(girara_session_t* session, girara_list_t* argument_list);
@ -101,7 +101,7 @@ bool cmd_nohlsearch(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_quit(girara_session_t* session, girara_list_t* argument_list); bool cmd_quit(girara_session_t* session, girara_list_t* argument_list);
@ -110,7 +110,7 @@ bool cmd_quit(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_save(girara_session_t* session, girara_list_t* argument_list); bool cmd_save(girara_session_t* session, girara_list_t* argument_list);
@ -119,7 +119,7 @@ bool cmd_save(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_savef(girara_session_t* session, girara_list_t* argument_list); bool cmd_savef(girara_session_t* session, girara_list_t* argument_list);
@ -129,7 +129,7 @@ bool cmd_savef(girara_session_t* session, girara_list_t* argument_list);
* @param session The used girara session * @param session The used girara session
* @param input The current input * @param input The current input
* @param argument Passed argument * @param argument Passed argument
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_search(girara_session_t* session, const char* input, girara_argument_t* argument); bool cmd_search(girara_session_t* session, const char* input, girara_argument_t* argument);
@ -138,7 +138,7 @@ bool cmd_search(girara_session_t* session, const char* input, girara_argument_t*
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_export(girara_session_t* session, girara_list_t* argument_list); bool cmd_export(girara_session_t* session, girara_list_t* argument_list);
@ -147,7 +147,7 @@ bool cmd_export(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_exec(girara_session_t* session, girara_list_t* argument_list); bool cmd_exec(girara_session_t* session, girara_list_t* argument_list);
@ -156,7 +156,7 @@ bool cmd_exec(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_offset(girara_session_t* session, girara_list_t* argument_list); bool cmd_offset(girara_session_t* session, girara_list_t* argument_list);
@ -165,7 +165,7 @@ bool cmd_offset(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The used girara session * @param session The used girara session
* @param argument_list List of passed arguments * @param argument_list List of passed arguments
* @return true if no error occured * @return true if no error occurred
*/ */
bool cmd_version(girara_session_t* session, girara_list_t* argument_list); bool cmd_version(girara_session_t* session, girara_list_t* argument_list);

View file

@ -11,7 +11,7 @@
* *
* @param session The used girara session * @param session The used girara session
* @param input The current input * @param input The current input
* @return The completion object or NULL if an error occured * @return The completion object or NULL if an error occurred
*/ */
girara_completion_t* cc_open(girara_session_t* session, const char* input); girara_completion_t* cc_open(girara_session_t* session, const char* input);
@ -21,7 +21,7 @@ girara_completion_t* cc_open(girara_session_t* session, const char* input);
* *
* @param session The used girara session * @param session The used girara session
* @param input The current input * @param input The current input
* @return The completion object or NULL if an error occured * @return The completion object or NULL if an error occurred
*/ */
girara_completion_t* cc_write(girara_session_t* session, const char* input); girara_completion_t* cc_write(girara_session_t* session, const char* input);
@ -30,7 +30,7 @@ girara_completion_t* cc_write(girara_session_t* session, const char* input);
* *
* @param session The used girara session * @param session The used girara session
* @param input The current input * @param input The current input
* @return The completion object or NULL if an error occured * @return The completion object or NULL if an error occurred
*/ */
girara_completion_t* cc_bookmarks(girara_session_t* session, const char* input); girara_completion_t* cc_bookmarks(girara_session_t* session, const char* input);

View file

@ -466,6 +466,8 @@ config_load_default(zathura_t* zathura)
girara_shortcut_mapping_add(gsession, "goto", sc_goto); girara_shortcut_mapping_add(gsession, "goto", sc_goto);
girara_shortcut_mapping_add(gsession, "jumplist", sc_jumplist); girara_shortcut_mapping_add(gsession, "jumplist", sc_jumplist);
girara_shortcut_mapping_add(gsession, "bisect", sc_bisect); girara_shortcut_mapping_add(gsession, "bisect", sc_bisect);
girara_shortcut_mapping_add(gsession, "mark_add", sc_mark_add);
girara_shortcut_mapping_add(gsession, "mark_evaluate", sc_mark_evaluate);
girara_shortcut_mapping_add(gsession, "navigate", sc_navigate); girara_shortcut_mapping_add(gsession, "navigate", sc_navigate);
girara_shortcut_mapping_add(gsession, "navigate_index", sc_navigate_index); girara_shortcut_mapping_add(gsession, "navigate_index", sc_navigate_index);
girara_shortcut_mapping_add(gsession, "print", sc_print); girara_shortcut_mapping_add(gsession, "print", sc_print);

View file

@ -17,14 +17,23 @@
#include <glib.h> #include <glib.h>
#include <gio/gio.h> #include <gio/gio.h>
/** Read a most GT_MAX_READ bytes before falling back to file. */ struct zathura_content_type_context_s
static const size_t GT_MAX_READ = 1 << 16; {
#ifdef WITH_MAGIC
magic_t magic;
#endif
};
zathura_content_type_context_t*
zathura_content_type_new(void)
{
zathura_content_type_context_t* context =
g_try_malloc0(sizeof(zathura_content_type_context_t));
if (context == NULL) {
return NULL;
}
#ifdef WITH_MAGIC #ifdef WITH_MAGIC
static const char*
guess_type_magic(const char* path) {
const char* mime_type = NULL;
/* creat magic cookie */ /* creat magic cookie */
const int flags = const int flags =
MAGIC_MIME_TYPE | MAGIC_MIME_TYPE |
@ -36,46 +45,78 @@ guess_type_magic(const char* path) {
magic_t magic = magic_open(flags); magic_t magic = magic_open(flags);
if (magic == NULL) { if (magic == NULL) {
girara_debug("failed creating the magic cookie"); girara_debug("failed creating the magic cookie");
goto cleanup; return context;
} }
/* ... and load mime database */ /* ... and load mime database */
if (magic_load(magic, NULL) < 0) { if (magic_load(magic, NULL) < 0) {
girara_debug("failed loading the magic database: %s", magic_error(magic)); 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); magic_close(magic);
return context;
} }
return mime_type; context->magic = magic;
#endif
return context;
} }
static const char* void
zathura_content_type_free(zathura_content_type_context_t* context)
{
if (context == NULL) {
return;
}
#ifdef WITH_MAGIC
if (context->magic != NULL) {
magic_close(context->magic);
}
#endif
g_free(context);
}
/** 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 char*
guess_type_magic(zathura_content_type_context_t* context, const char* path)
{
if (context == NULL || context->magic == NULL) {
return NULL;
}
const char* mime_type = NULL;
/* get the mime type */
mime_type = magic_file(context->magic, path);
if (mime_type == NULL) {
girara_debug("failed guessing filetype: %s", magic_error(context->magic));
return NULL;
}
girara_debug("magic detected filetype: %s", mime_type);
/* dup so we own the memory */
return g_strdup(mime_type);;
}
static char*
guess_type_file(const char* UNUSED(path)) guess_type_file(const char* UNUSED(path))
{ {
return NULL; return NULL;
} }
#else #else
static const char* static const char*
guess_type_magic(const char* UNUSED(path)) { guess_type_magic(zathura_content_type_context_t* UNUSED(context),
const char* UNUSED(path))
{
return NULL; return NULL;
} }
static const char* static char*
guess_type_file(const char* path) guess_type_file(const char* path)
{ {
GString* command = g_string_new("file -b --mime-type "); GString* command = g_string_new("file -b --mime-type ");
@ -106,11 +147,11 @@ guess_type_file(const char* path)
} }
#endif #endif
static const char* static char*
guess_type_glib(const char* path) guess_type_glib(const char* path)
{ {
gboolean uncertain = FALSE; gboolean uncertain = FALSE;
const char* content_type = g_content_type_guess(path, NULL, 0, &uncertain); char* content_type = g_content_type_guess(path, NULL, 0, &uncertain);
if (content_type == NULL) { if (content_type == NULL) {
girara_debug("g_content_type failed\n"); girara_debug("g_content_type failed\n");
} else { } else {
@ -160,11 +201,12 @@ guess_type_glib(const char* path)
return NULL; return NULL;
} }
const char* char*
guess_content_type(const char* path) zathura_content_type_guess(zathura_content_type_context_t* context,
const char* path)
{ {
/* try libmagic first */ /* try libmagic first */
const char* content_type = guess_type_magic(path); char* content_type = guess_type_magic(context, path);
if (content_type != NULL) { if (content_type != NULL) {
return content_type; return content_type;
} }

View file

@ -3,13 +3,30 @@
#ifndef ZATHURA_CONTENT_TYPE_H #ifndef ZATHURA_CONTENT_TYPE_H
#define ZATHURA_CONTENT_TYPE_H #define ZATHURA_CONTENT_TYPE_H
#include "types.h"
/**
* Create new context for MIME type detection.
*
* @return new context
*/
zathura_content_type_context_t* zathura_content_type_new(void);
/**
* Free MIME type detection context.
*
* @param context The context.
*/
void zathura_content_type_free(zathura_content_type_context_t* context);
/** /**
* "Guess" the content type of a file. Various methods are tried depending on * "Guess" the content type of a file. Various methods are tried depending on
* the available libraries. * the available libraries.
* *
* @param path file name * @param path file name
* @return content type of path * @return content type of path, needs to freeed with g_free.
*/ */
const char* guess_content_type(const char* path); char* zathura_content_type_guess(zathura_content_type_context_t* context,
const char* path);
#endif #endif

View file

@ -469,7 +469,7 @@ iterate_instances_call_synctex_view(const char* filename,
const bool ret = call_synctex_view(connection, filename, well_known_name, const bool ret = call_synctex_view(connection, filename, well_known_name,
input_file, line, column); input_file, line, column);
g_free(well_known_name); g_free(well_known_name);
return ret ? 1 : 0; return ret ? 1 : -1;
} }
GVariant* vnames = g_dbus_connection_call_sync( GVariant* vnames = g_dbus_connection_call_sync(

View file

@ -61,16 +61,16 @@ check_set_error(zathura_error_t* error, zathura_error_t code) {
} }
zathura_document_t* zathura_document_t*
zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char* zathura_document_open(zathura_t* zathura, const char* path, const char* uri,
path, const char *uri, const char* password, zathura_error_t* error) const char* password, zathura_error_t* error)
{ {
if (path == NULL) { if (zathura == NULL || path == NULL) {
return NULL; return NULL;
} }
GFile* file = g_file_new_for_path(path); GFile* file = g_file_new_for_path(path);
char* real_path = NULL; char* real_path = NULL;
const char* content_type = NULL; char* content_type = NULL;
zathura_plugin_t* plugin = NULL; zathura_plugin_t* plugin = NULL;
zathura_document_t* document = NULL; zathura_document_t* document = NULL;
@ -87,14 +87,14 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
goto error_free; goto error_free;
} }
content_type = guess_content_type(real_path); content_type = zathura_content_type_guess(zathura->content_type_context, real_path);
if (content_type == NULL) { if (content_type == NULL) {
girara_error("Could not determine file type."); girara_error("Could not determine file type.");
check_set_error(error, ZATHURA_ERROR_UNKNOWN); check_set_error(error, ZATHURA_ERROR_UNKNOWN);
goto error_free; goto error_free;
} }
plugin = zathura_plugin_manager_get_plugin(plugin_manager, content_type); plugin = zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type);
if (plugin == NULL) { if (plugin == NULL) {
girara_error("Unknown file type: '%s'", content_type); girara_error("Unknown file type: '%s'", content_type);
@ -106,7 +106,7 @@ zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
goto error_free; goto error_free;
} }
g_free((void*)content_type); g_free(content_type);
content_type = NULL; content_type = NULL;
document = g_try_malloc0(sizeof(zathura_document_t)); document = g_try_malloc0(sizeof(zathura_document_t));

View file

@ -11,21 +11,21 @@
/** /**
* Open the document * Open the document
* *
* @param plugin_manager The plugin manager * @param plugin_manager The zathura instance
* @param path Path to the document * @param path Path to the document
* @param password Password of the document or NULL * @param password Password of the document or NULL
* @param error Optional error parameter * @param error Optional error parameter
* @return The document object and NULL if an error occurs * @return The document object and NULL if an error occurs
*/ */
zathura_document_t* zathura_document_open(zathura_plugin_manager_t* zathura_document_t* zathura_document_open(zathura_t* zathura,
plugin_manager, const char* path, const char *uri, const char* password, zathura_error_t* const char* path, const char *uri, const char* password, zathura_error_t*
error); error);
/** /**
* Free the document * Free the document
* *
* @param document * @param document
* @return ZATHURA_ERROR_OK when no error occured, otherwise see * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
* zathura_error_t * zathura_error_t
*/ */
zathura_error_t zathura_document_free(zathura_document_t* document); zathura_error_t zathura_document_free(zathura_document_t* document);
@ -67,7 +67,7 @@ const char* zathura_document_get_password(zathura_document_t* document);
* *
* @param document The document * @param document The document
* @param index The index of the page * @param index The index of the page
* @return The page or NULL if an error occured * @return The page or NULL if an error occurred
*/ */
zathura_page_t* zathura_document_get_page(zathura_document_t* document, unsigned int index); zathura_page_t* zathura_document_get_page(zathura_document_t* document, unsigned int index);
@ -283,7 +283,7 @@ void zathura_document_set_page_layout(zathura_document_t* document, unsigned int
unsigned int pages_per_row, unsigned int first_page_column); unsigned int pages_per_row, unsigned int first_page_column);
/** /**
* Returns the padding in pixels betwen pages * Returns the padding in pixels between pages
* *
* @param document The document * @param document The document
* @return The padding in pixels between pages * @return The padding in pixels between pages
@ -311,7 +311,7 @@ unsigned int zathura_document_get_first_page_column(zathura_document_t* document
* *
* @param document The document object * @param document The document object
* @param path Path for the saved file * @param path Path for the saved file
* @return ZATHURA_ERROR_OK when no error occured, otherwise see * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
* zathura_error_t * zathura_error_t
*/ */
zathura_error_t zathura_document_save_as(zathura_document_t* document, const char* path); zathura_error_t zathura_document_save_as(zathura_document_t* document, const char* path);
@ -321,7 +321,7 @@ zathura_error_t zathura_document_save_as(zathura_document_t* document, const cha
* *
* @param document The document object * @param document The document object
* @param error Set to an error value (see \ref zathura_error_t) if an * @param error Set to an error value (see \ref zathura_error_t) if an
* error occured * error occurred
* @return Generated index * @return Generated index
*/ */
@ -332,7 +332,7 @@ girara_tree_node_t* zathura_document_index_generate(zathura_document_t* document
* *
* @param document The document object * @param document The document object
* @param error Set to an error value (see \ref zathura_error_t) if an * @param error Set to an error value (see \ref zathura_error_t) if an
* error occured * error occurred
* @return List of attachments * @return List of attachments
*/ */
girara_list_t* zathura_document_attachments_get(zathura_document_t* document, zathura_error_t* error); girara_list_t* zathura_document_attachments_get(zathura_document_t* document, zathura_error_t* error);
@ -343,7 +343,7 @@ girara_list_t* zathura_document_attachments_get(zathura_document_t* document, za
* @param document The document objects * @param document The document objects
* @param attachment name of the attachment * @param attachment name of the attachment
* @param file the target filename * @param file the target filename
* @return ZATHURA_ERROR_OK when no error occured, otherwise see * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
* zathura_error_t * zathura_error_t
*/ */
zathura_error_t zathura_document_attachment_save(zathura_document_t* document, const char* attachment, const char* file); zathura_error_t zathura_document_attachment_save(zathura_document_t* document, const char* attachment, const char* file);
@ -353,8 +353,8 @@ zathura_error_t zathura_document_attachment_save(zathura_document_t* document, c
* *
* @param document The zathura document * @param document The zathura document
* @param error Set to an error value (see \ref zathura_error_t) if an * @param error Set to an error value (see \ref zathura_error_t) if an
* error occured * error occurred
* @return List of document information entries or NULL if information could not be retreived * @return List of document information entries or NULL if information could not be retrieved
*/ */
girara_list_t* zathura_document_get_information(zathura_document_t* document, zathura_error_t* error); girara_list_t* zathura_document_get_information(zathura_document_t* document, zathura_error_t* error);

View file

@ -18,6 +18,10 @@
#include "synctex.h" #include "synctex.h"
#endif #endif
#ifndef GDK_WINDOWING_X11
typedef int Window;
#endif
/* Init locale */ /* Init locale */
static void static void
init_locale(void) init_locale(void)
@ -45,7 +49,7 @@ set_log_level(const char* loglevel)
#ifdef WITH_SYNCTEX #ifdef WITH_SYNCTEX
static int static int
run_synctex_forward(const char* synctex_fwd, const char* filename, run_synctex_forward(const char* synctex_fwd, const char* filename,
int synctex_pid) int synctex_pid)
{ {
GFile* file = g_file_new_for_commandline_arg(filename); GFile* file = g_file_new_for_commandline_arg(filename);
if (file == NULL) { if (file == NULL) {
@ -60,8 +64,8 @@ run_synctex_forward(const char* synctex_fwd, const char* filename,
return -1; return -1;
} }
int line = 0; int line = 0;
int column = 0; int column = 0;
char* input_file = NULL; char* input_file = NULL;
if (synctex_parse_input(synctex_fwd, &input_file, &line, &column) == false) { if (synctex_parse_input(synctex_fwd, &input_file, &line, &column) == false) {
girara_error("Failed to parse argument to --synctex-forward."); girara_error("Failed to parse argument to --synctex-forward.");
@ -69,13 +73,15 @@ run_synctex_forward(const char* synctex_fwd, const char* filename,
return -1; return -1;
} }
const int ret = zathura_dbus_synctex_position(real_path, input_file, line, column, synctex_pid); const int ret = zathura_dbus_synctex_position(real_path, input_file, line,
column, synctex_pid);
g_free(input_file); g_free(input_file);
g_free(real_path); g_free(real_path);
if (ret == -1) { if (ret == -1) {
/* D-Bus or SyncTeX failed */ /* D-Bus or SyncTeX failed */
girara_error("Got no usable data from SyncTeX or D-Bus failed in some way."); girara_error(
"Got no usable data from SyncTeX or D-Bus failed in some way.");
} }
return ret; return ret;
@ -84,12 +90,8 @@ run_synctex_forward(const char* synctex_fwd, const char* filename,
static zathura_t* static zathura_t*
init_zathura(const char* config_dir, const char* data_dir, init_zathura(const char* config_dir, const char* data_dir,
const char* cache_dir, const char* plugin_path, char** argv, const char* cache_dir, const char* plugin_path, char** argv,
#ifdef GDK_WINDOWING_X11 char* synctex_editor, Window embed)
char* synctex_editor, Window embed)
#else
char* synctex_editor)
#endif
{ {
/* create zathura session */ /* create zathura session */
zathura_t* zathura = zathura_create(); zathura_t* zathura = zathura_create();
@ -112,11 +114,10 @@ init_zathura(const char* config_dir, const char* data_dir,
return NULL; return NULL;
} }
#ifdef WITH_SYNCTEX
if (synctex_editor != NULL) { if (synctex_editor != NULL) {
girara_setting_set(zathura->ui.session, "synctex-editor-command", synctex_editor); girara_setting_set(zathura->ui.session, "synctex-editor-command",
synctex_editor);
} }
#endif
return zathura; return zathura;
} }
@ -135,20 +136,16 @@ main(int argc, char* argv[])
gchar* plugin_path = NULL; gchar* plugin_path = NULL;
gchar* loglevel = NULL; gchar* loglevel = NULL;
gchar* password = NULL; gchar* password = NULL;
#ifdef WITH_SYNCTEX
gchar* synctex_editor = NULL; gchar* synctex_editor = NULL;
gchar* synctex_fwd = NULL; gchar* synctex_fwd = NULL;
#endif
gchar* mode = NULL; gchar* mode = NULL;
bool forkback = false; bool forkback = false;
bool print_version = false; bool print_version = false;
int page_number = ZATHURA_PAGE_NUMBER_UNSPECIFIED; int page_number = ZATHURA_PAGE_NUMBER_UNSPECIFIED;
#ifdef WITH_SYNCTEX #ifdef WITH_SYNCTEX
int synctex_pid = -1; int synctex_pid = -1;
#endif #endif
#ifdef GDK_WINDOWING_X11
Window embed = 0; Window embed = 0;
#endif
GOptionEntry entries[] = { GOptionEntry entries[] = {
#ifdef GDK_WINDOWING_X11 #ifdef GDK_WINDOWING_X11
@ -185,20 +182,29 @@ main(int argc, char* argv[])
} }
g_option_context_free(context); g_option_context_free(context);
int ret = 0;
set_log_level(loglevel); set_log_level(loglevel);
#ifdef WITH_SYNCTEX #ifdef WITH_SYNCTEX
/* handle synctex forward synchronization */ /* handle synctex forward synchronization */
if (synctex_fwd != NULL) { if (synctex_fwd != NULL) {
if (argc != 2) { if (argc != 2) {
girara_error("Too many arguments or missing filename while running with --synctex-forward"); girara_error("Too many arguments or missing filename while running with "
return -1; "--synctex-forward");
ret = -1;
goto free_and_ret;
} }
const int ret = run_synctex_forward(synctex_fwd, argv[1], synctex_pid); ret = run_synctex_forward(synctex_fwd, argv[1], synctex_pid);
if (ret != 0) { if (ret > 0) {
/* Error or instance found */ /* Instance found. */
return ret; ret = 0;
goto free_and_ret;
}
else if (ret < 0) {
/* Error occurred. */
ret = -1;
goto free_and_ret;
} }
girara_debug("No instance found. Starting new one."); girara_debug("No instance found. Starting new one.");
@ -206,42 +212,62 @@ main(int argc, char* argv[])
#endif #endif
/* check mode */ /* check mode */
if (mode != NULL && g_strcmp0(mode, "presentation") != 0 && g_strcmp0(mode, "fullscreen") != 0) { if (mode != NULL && g_strcmp0(mode, "presentation") != 0 &&
g_strcmp0(mode, "fullscreen") != 0) {
girara_error("Invalid argument for --mode: %s", mode); girara_error("Invalid argument for --mode: %s", mode);
return -1; ret = -1;
goto free_and_ret;
} }
size_t file_idx = argc > 1 ? 1 : 0; /* g_option_context_parse has some funny (documented) behavior:
* * for "-- a b c" you get no -- in argv
* * for "-- --" you get -- in argv twice
* * for "-- -a" you get -- in argv
*
* So if there is one -- in argv, we need to ignore it. */
const bool has_double_dash = argc > 1 && g_strcmp0(argv[1], "--") == 0;
const int file_idx_base = has_double_dash ? 2 : 1;
int file_idx = argc > file_idx_base ? file_idx_base : 0;
/* Fork instances for other files. */ /* Fork instances for other files. */
if (print_version == false && argc > 2) { if (print_version == false && argc > file_idx_base + 1) {
for (int idx = 2; idx < argc; ++idx) { for (int idx = file_idx_base + 1; idx < argc; ++idx) {
const pid_t pid = fork(); const pid_t pid = fork();
if (pid == 0) { /* child */ if (pid == 0) { /* child */
file_idx = idx; file_idx = idx;
if (setsid() == -1) { if (setsid() == -1) {
girara_error("Could not start new process group: %s", strerror(errno)); girara_error("Could not start new process group: %s",
return -1; strerror(errno));
ret = -1;
goto free_and_ret;
} }
} else if (pid < 0) { /* error */ break;
}
else if (pid < 0) { /* error */
girara_error("Could not fork: %s", strerror(errno)); girara_error("Could not fork: %s", strerror(errno));
return -1; ret = -1;
goto free_and_ret;
} }
} }
} }
/* Fork into the background if the user really wants to ... */ /* Fork into the background if the user really wants to ... */
if (print_version == false && forkback == true && file_idx < 2) { if (print_version == false && forkback == true &&
file_idx < file_idx_base + 1) {
const pid_t pid = fork(); const pid_t pid = fork();
if (pid > 0) { /* parent */ if (pid > 0) { /* parent */
return 0; goto free_and_ret;
} else if (pid < 0) { /* error */ }
else if (pid < 0) { /* error */
girara_error("Could not fork: %s", strerror(errno)); girara_error("Could not fork: %s", strerror(errno));
return -1; ret = -1;
goto free_and_ret;
} }
if (setsid() == -1) { if (setsid() == -1) {
girara_error("Could not start new process group: %s", strerror(errno)); girara_error("Could not start new process group: %s", strerror(errno));
return -1; ret = -1;
goto free_and_ret;
} }
} }
@ -250,14 +276,11 @@ main(int argc, char* argv[])
/* Create zathura session */ /* Create zathura session */
zathura_t* zathura = init_zathura(config_dir, data_dir, cache_dir, zathura_t* zathura = init_zathura(config_dir, data_dir, cache_dir,
#ifdef GDK_WINDOWING_X11 plugin_path, argv, synctex_editor, embed);
plugin_path, argv, synctex_editor, embed);
#else
plugin_path, argv, synctex_editor);
#endif
if (zathura == NULL) { if (zathura == NULL) {
girara_error("Could not initialize zathura."); girara_error("Could not initialize zathura.");
return -1; ret = -1;
goto free_and_ret;
} }
/* Print version */ /* Print version */
@ -269,7 +292,7 @@ main(int argc, char* argv[])
} }
zathura_free(zathura); zathura_free(zathura);
return 0; goto free_and_ret;
} }
/* open document if passed */ /* open document if passed */
@ -277,11 +300,8 @@ main(int argc, char* argv[])
if (page_number > 0) { if (page_number > 0) {
--page_number; --page_number;
} }
#ifdef WITH_SYNCTEX document_open_idle(zathura, argv[file_idx], password, page_number, mode,
document_open_idle(zathura, argv[file_idx], password, page_number, mode, synctex_fwd); synctex_fwd);
#else
document_open_idle(zathura, argv[file_idx], password, page_number, mode, NULL);
#endif
} }
/* run zathura */ /* run zathura */
@ -290,5 +310,16 @@ main(int argc, char* argv[])
/* free zathura */ /* free zathura */
zathura_free(zathura); zathura_free(zathura);
return 0; free_and_ret:
g_free(config_dir);
g_free(data_dir);
g_free(cache_dir);
g_free(plugin_path);
g_free(loglevel);
g_free(password);
g_free(synctex_editor);
g_free(synctex_fwd);
g_free(mode);
return ret;
} }

View file

@ -16,7 +16,7 @@ typedef struct zathura_mark_s zathura_mark_t;
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_mark_add(girara_session_t* session, girara_argument_t* argument, bool sc_mark_add(girara_session_t* session, girara_argument_t* argument,
girara_event_t* event, unsigned int t); girara_event_t* event, unsigned int t);
@ -28,7 +28,7 @@ bool sc_mark_add(girara_session_t* session, girara_argument_t* argument,
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_mark_evaluate(girara_session_t* session, girara_argument_t* argument, bool sc_mark_evaluate(girara_session_t* session, girara_argument_t* argument,
girara_event_t* event, unsigned int t); girara_event_t* event, unsigned int t);
@ -38,7 +38,7 @@ bool sc_mark_evaluate(girara_session_t* session, girara_argument_t* argument,
* *
* @param session The girara session * @param session The girara session
* @param argument_list Argument list * @param argument_list Argument list
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool cmd_marks_add(girara_session_t* session, girara_list_t* argument_list); bool cmd_marks_add(girara_session_t* session, girara_list_t* argument_list);
@ -47,7 +47,7 @@ bool cmd_marks_add(girara_session_t* session, girara_list_t* argument_list);
* *
* @param session The girara session * @param session The girara session
* @param argument_list Argument list * @param argument_list Argument list
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool cmd_marks_delete(girara_session_t* session, girara_list_t* argument_list); bool cmd_marks_delete(girara_session_t* session, girara_list_t* argument_list);

View file

@ -75,7 +75,7 @@ void zathura_page_widget_clear_rectangles(ZathuraPage* widget);
* *
* @param widget the widget * @param widget the widget
* @param index Index of the link * @param index Index of the link
* @return Link object or NULL if an error occured * @return Link object or NULL if an error occurred
*/ */
zathura_link_t* zathura_page_widget_link_get(ZathuraPage* widget, unsigned int index); zathura_link_t* zathura_page_widget_link_get(ZathuraPage* widget, unsigned int index);
/** /**

View file

@ -14,7 +14,7 @@
* @param document The document * @param document The document
* @param index Page number * @param index Page number
* @param error Optional error * @param error Optional error
* @return Page object or NULL if an error occured * @return Page object or NULL if an error occurred
*/ */
zathura_page_t* zathura_page_new(zathura_document_t* document, unsigned int zathura_page_t* zathura_page_new(zathura_document_t* document, unsigned int
index, zathura_error_t* error); index, zathura_error_t* error);
@ -23,7 +23,7 @@ zathura_page_t* zathura_page_new(zathura_document_t* document, unsigned int
* Frees the page object * Frees the page object
* *
* @param page The page object * @param page The page object
* @return ZATHURA_ERROR_OK when no error occured, otherwise see * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
* zathura_error_t * zathura_error_t
*/ */
zathura_error_t zathura_page_free(zathura_page_t* page); zathura_error_t zathura_page_free(zathura_page_t* page);
@ -33,7 +33,7 @@ zathura_error_t zathura_page_free(zathura_page_t* page);
* *
* @param page The page object * @param page The page object
* @return The associated document * @return The associated document
* @return NULL if an error occured * @return NULL if an error occurred
*/ */
zathura_document_t* zathura_page_get_document(zathura_page_t* page); zathura_document_t* zathura_page_get_document(zathura_page_t* page);
@ -50,7 +50,7 @@ unsigned int zathura_page_get_index(zathura_page_t* page);
* *
* @param page The page object * @param page The page object
* @return Width of the page * @return Width of the page
* @return -1 If an error occured * @return -1 If an error occurred
*/ */
double zathura_page_get_width(zathura_page_t* page); double zathura_page_get_width(zathura_page_t* page);
@ -67,7 +67,7 @@ void zathura_page_set_width(zathura_page_t* page, double width);
* *
* @param page The page object * @param page The page object
* @return Height of the page * @return Height of the page
* @return -1 If an error occured * @return -1 If an error occurred
*/ */
double zathura_page_get_height(zathura_page_t* page); double zathura_page_get_height(zathura_page_t* page);
@ -118,7 +118,7 @@ void zathura_page_set_data(zathura_page_t* page, void* data);
* @param page The page object * @param page The page object
* @param text Search item * @param text Search item
* @param error Set to an error value (see \ref zathura_error_t) if an * @param error Set to an error value (see \ref zathura_error_t) if an
* error occured * error occurred
* @return List of results * @return List of results
*/ */
girara_list_t* zathura_page_search_text(zathura_page_t* page, const char* text, zathura_error_t* error); girara_list_t* zathura_page_search_text(zathura_page_t* page, const char* text, zathura_error_t* error);
@ -128,7 +128,7 @@ girara_list_t* zathura_page_search_text(zathura_page_t* page, const char* text,
* *
* @param page The page object * @param page The page object
* @param error Set to an error value (see \ref zathura_error_t) if an * @param error Set to an error value (see \ref zathura_error_t) if an
* error occured * error occurred
* @return List of links * @return List of links
*/ */
girara_list_t* zathura_page_links_get(zathura_page_t* page, zathura_error_t* error); girara_list_t* zathura_page_links_get(zathura_page_t* page, zathura_error_t* error);
@ -137,7 +137,7 @@ girara_list_t* zathura_page_links_get(zathura_page_t* page, zathura_error_t* err
* Free page links * Free page links
* *
* @param list List of links * @param list List of links
* @return ZATHURA_ERROR_OK when no error occured, otherwise see * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
* zathura_error_t * zathura_error_t
*/ */
zathura_error_t zathura_page_links_free(girara_list_t* list); zathura_error_t zathura_page_links_free(girara_list_t* list);
@ -147,7 +147,7 @@ zathura_error_t zathura_page_links_free(girara_list_t* list);
* *
* @param page The page object * @param page The page object
* @param error Set to an error value (see \ref zathura_error_t) if an * @param error Set to an error value (see \ref zathura_error_t) if an
* error occured * error occurred
* @return List of form fields * @return List of form fields
*/ */
girara_list_t* zathura_page_form_fields_get(zathura_page_t* page, zathura_error_t* error); girara_list_t* zathura_page_form_fields_get(zathura_page_t* page, zathura_error_t* error);
@ -156,7 +156,7 @@ girara_list_t* zathura_page_form_fields_get(zathura_page_t* page, zathura_error_
* Free list of form fields * Free list of form fields
* *
* @param list List of form fields * @param list List of form fields
* @return ZATHURA_ERROR_OK when no error occured, otherwise see * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
* zathura_error_t * zathura_error_t
*/ */
zathura_error_t zathura_page_form_fields_free(girara_list_t* list); zathura_error_t zathura_page_form_fields_free(girara_list_t* list);
@ -166,8 +166,8 @@ zathura_error_t zathura_page_form_fields_free(girara_list_t* list);
* *
* @param page Page * @param page Page
* @param error Set to an error value (see \ref zathura_error_t) if an * @param error Set to an error value (see \ref zathura_error_t) if an
* error occured * error occurred
* @return List of images or NULL if an error occured * @return List of images or NULL if an error occurred
*/ */
girara_list_t* zathura_page_images_get(zathura_page_t* page, zathura_error_t* error); girara_list_t* zathura_page_images_get(zathura_page_t* page, zathura_error_t* error);
@ -177,8 +177,8 @@ girara_list_t* zathura_page_images_get(zathura_page_t* page, zathura_error_t* er
* @param page Page * @param page Page
* @param image Image identifier * @param image Image identifier
* @param error Set to an error value (see \ref zathura_error_t) if an * @param error Set to an error value (see \ref zathura_error_t) if an
* error occured * error occurred
* @return The cairo image surface or NULL if an error occured * @return The cairo image surface or NULL if an error occurred
*/ */
cairo_surface_t* zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_error_t* error); cairo_surface_t* zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_error_t* error);
@ -187,7 +187,7 @@ cairo_surface_t* zathura_page_image_get_cairo(zathura_page_t* page, zathura_imag
* @param page Page * @param page Page
* @param rectangle Selection * @param rectangle Selection
* @param error Set to an error value (see \ref zathura_error_t) if an error * @param error Set to an error value (see \ref zathura_error_t) if an error
* occured * occurred
* @return The selected text (needs to be deallocated with g_free) * @return The selected text (needs to be deallocated with g_free)
*/ */
char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_error_t* error); char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_error_t* error);
@ -198,7 +198,7 @@ char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle,
* @param page The page object * @param page The page object
* @param cairo Cairo object * @param cairo Cairo object
* @param printing render for printing * @param printing render for printing
* @return ZATHURA_ERROR_OK when no error occured, otherwise see * @return ZATHURA_ERROR_OK when no error occurred, otherwise see
* zathura_error_t * zathura_error_t
*/ */
zathura_error_t zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing); zathura_error_t zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing);

View file

@ -27,7 +27,7 @@ typedef struct zathura_plugin_version_s {
/** /**
* Creates a new instance of the plugin manager * Creates a new instance of the plugin manager
* *
* @return A plugin manager object or NULL if an error occured * @return A plugin manager object or NULL if an error occurred
*/ */
zathura_plugin_manager_t* zathura_plugin_manager_new(void); zathura_plugin_manager_t* zathura_plugin_manager_new(void);

View file

@ -55,7 +55,7 @@ bool zathura_renderer_recolor_enabled(ZathuraRenderer* renderer);
/** /**
* Enable/disable recoloring. * Enable/disable recoloring.
* @param renderer a renderer object * @param renderer a renderer object
* @param enable wheter to enable or disable recoloring * @param enable whether to enable or disable recoloring
*/ */
void zathura_renderer_enable_recolor(ZathuraRenderer* renderer, bool enable); void zathura_renderer_enable_recolor(ZathuraRenderer* renderer, bool enable);
/** /**
@ -67,7 +67,7 @@ bool zathura_renderer_recolor_hue_enabled(ZathuraRenderer* renderer);
/** /**
* Enable/disable preservation of hue while recoloring. * Enable/disable preservation of hue while recoloring.
* @param renderer a renderer object * @param renderer a renderer object
* @param enable wheter to enable or disable hue preservation * @param enable whether to enable or disable hue preservation
*/ */
void zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer, void zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer,
bool enable); bool enable);

View file

@ -12,7 +12,7 @@
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_abort(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_abort(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -23,7 +23,7 @@ bool sc_abort(girara_session_t* session, girara_argument_t* argument, girara_eve
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_adjust_window(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_adjust_window(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -34,7 +34,7 @@ bool sc_adjust_window(girara_session_t* session, girara_argument_t* argument, gi
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_change_mode(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_change_mode(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -45,7 +45,7 @@ bool sc_change_mode(girara_session_t* session, girara_argument_t* argument, gira
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_display_link(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_display_link(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -56,8 +56,8 @@ bool sc_display_link(girara_session_t* session, girara_argument_t* argument, gir
* @param argument The argument * @param argument The argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true No error occured * @return true No error occurred
* @return false An error occured (abort execution) * @return false An error occurred (abort execution)
*/ */
bool sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -68,7 +68,7 @@ bool sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, g
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_follow(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_follow(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -79,7 +79,7 @@ bool sc_follow(girara_session_t* session, girara_argument_t* argument, girara_ev
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_goto(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_goto(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -90,7 +90,7 @@ bool sc_goto(girara_session_t* session, girara_argument_t* argument, girara_even
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -101,7 +101,7 @@ bool sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, gir
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -112,7 +112,7 @@ bool sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girar
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_navigate(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_navigate(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -123,7 +123,7 @@ bool sc_navigate(girara_session_t* session, girara_argument_t* argument, girara_
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_print(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_print(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -134,7 +134,7 @@ bool sc_print(girara_session_t* session, girara_argument_t* argument, girara_eve
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_recolor(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_recolor(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -145,7 +145,7 @@ bool sc_recolor(girara_session_t* session, girara_argument_t* argument, girara_e
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_reload(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_reload(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -156,7 +156,7 @@ bool sc_reload(girara_session_t* session, girara_argument_t* argument, girara_ev
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_rotate(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_rotate(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -167,7 +167,7 @@ bool sc_rotate(girara_session_t* session, girara_argument_t* argument, girara_ev
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_scroll(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_scroll(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -178,7 +178,7 @@ bool sc_scroll(girara_session_t* session, girara_argument_t* argument, girara_ev
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_jumplist(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_jumplist(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -189,7 +189,7 @@ bool sc_jumplist(girara_session_t* session, girara_argument_t* argument, girara_
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_bisect(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_bisect(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -200,7 +200,7 @@ bool sc_bisect(girara_session_t* session, girara_argument_t* argument, girara_ev
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_search(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_search(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -211,7 +211,7 @@ bool sc_search(girara_session_t* session, girara_argument_t* argument, girara_ev
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_navigate_index(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_navigate_index(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -222,7 +222,7 @@ bool sc_navigate_index(girara_session_t* session, girara_argument_t* argument, g
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_toggle_index(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_toggle_index(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -233,7 +233,7 @@ bool sc_toggle_index(girara_session_t* session, girara_argument_t* argument, gir
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_toggle_page_mode(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_toggle_page_mode(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -244,7 +244,7 @@ bool sc_toggle_page_mode(girara_session_t* session, girara_argument_t* argument,
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -255,7 +255,7 @@ bool sc_toggle_fullscreen(girara_session_t* session, girara_argument_t* argument
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_toggle_presentation(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_toggle_presentation(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -266,7 +266,7 @@ bool sc_toggle_presentation(girara_session_t* session, girara_argument_t* argume
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_quit(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_quit(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
@ -277,7 +277,7 @@ bool sc_quit(girara_session_t* session, girara_argument_t* argument, girara_even
* @param argument The used argument * @param argument The used argument
* @param event Girara event * @param event Girara event
* @param t Number of executions * @param t Number of executions
* @return true if no error occured otherwise false * @return true if no error occurred otherwise false
*/ */
bool sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t); bool sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);

View file

@ -45,8 +45,8 @@ typedef struct zathura_dbus_s ZathuraDbus;
*/ */
typedef enum zathura_plugin_error_e typedef enum zathura_plugin_error_e
{ {
ZATHURA_ERROR_OK, /**< No error occured */ ZATHURA_ERROR_OK, /**< No error occurred */
ZATHURA_ERROR_UNKNOWN, /**< An unknown error occured */ ZATHURA_ERROR_UNKNOWN, /**< An unknown error occurred */
ZATHURA_ERROR_OUT_OF_MEMORY, /**< Out of memory */ ZATHURA_ERROR_OUT_OF_MEMORY, /**< Out of memory */
ZATHURA_ERROR_NOT_IMPLEMENTED, /**< The called function has not been implemented */ ZATHURA_ERROR_NOT_IMPLEMENTED, /**< The called function has not been implemented */
ZATHURA_ERROR_INVALID_ARGUMENTS, /**< Invalid arguments have been passed */ ZATHURA_ERROR_INVALID_ARGUMENTS, /**< Invalid arguments have been passed */
@ -109,7 +109,7 @@ typedef enum zathura_adjust_mode_e
* *
* @param width Width of the image stored in the buffer * @param width Width of the image stored in the buffer
* @param height Height of the image stored in the buffer * @param height Height of the image stored in the buffer
* @return Image buffer or NULL if an error occured * @return Image buffer or NULL if an error occurred
*/ */
zathura_image_buffer_t* zathura_image_buffer_create(unsigned int width, unsigned int height); zathura_image_buffer_t* zathura_image_buffer_create(unsigned int width, unsigned int height);
@ -148,7 +148,7 @@ typedef struct zathura_image_s
typedef enum zathura_link_type_e typedef enum zathura_link_type_e
{ {
ZATHURA_LINK_INVALID, /**< Invalid type */ ZATHURA_LINK_INVALID, /**< Invalid type */
ZATHURA_LINK_NONE, /**< No action */ ZATHURA_LINK_NONE, /**< No action */
ZATHURA_LINK_GOTO_DEST, /**< Links to a page */ ZATHURA_LINK_GOTO_DEST, /**< Links to a page */
ZATHURA_LINK_GOTO_REMOTE, /**< Links to a page */ ZATHURA_LINK_GOTO_REMOTE, /**< Links to a page */
ZATHURA_LINK_URI, /**< Links to an external source */ ZATHURA_LINK_URI, /**< Links to an external source */
@ -158,15 +158,15 @@ typedef enum zathura_link_type_e
typedef enum zathura_link_destination_type_e typedef enum zathura_link_destination_type_e
{ {
ZATHURA_LINK_DESTINATION_UNKNOWN, ZATHURA_LINK_DESTINATION_UNKNOWN,
ZATHURA_LINK_DESTINATION_XYZ, ZATHURA_LINK_DESTINATION_XYZ,
ZATHURA_LINK_DESTINATION_FIT, ZATHURA_LINK_DESTINATION_FIT,
ZATHURA_LINK_DESTINATION_FITH, ZATHURA_LINK_DESTINATION_FITH,
ZATHURA_LINK_DESTINATION_FITV, ZATHURA_LINK_DESTINATION_FITV,
ZATHURA_LINK_DESTINATION_FITR, ZATHURA_LINK_DESTINATION_FITR,
ZATHURA_LINK_DESTINATION_FITB, ZATHURA_LINK_DESTINATION_FITB,
ZATHURA_LINK_DESTINATION_FITBH, ZATHURA_LINK_DESTINATION_FITBH,
ZATHURA_LINK_DESTINATION_FITBV ZATHURA_LINK_DESTINATION_FITBV
} zathura_link_destination_type_t; } zathura_link_destination_type_t;
typedef struct zathura_link_target_s typedef struct zathura_link_target_s
@ -232,7 +232,7 @@ void zathura_index_element_free(zathura_index_element_t* index);
* Creates a list that should be used to store \ref * Creates a list that should be used to store \ref
* zathura_document_information_entry_t entries * zathura_document_information_entry_t entries
* *
* @return A list or NULL if an error occured * @return A list or NULL if an error occurred
*/ */
girara_list_t* zathura_document_information_entry_list_new(); girara_list_t* zathura_document_information_entry_list_new();
@ -242,7 +242,7 @@ girara_list_t* zathura_document_information_entry_list_new();
* @param type The type * @param type The type
* @param value The value * @param value The value
* *
* @return A new entry or NULL if an error occured * @return A new entry or NULL if an error occurred
*/ */
zathura_document_information_entry_t* zathura_document_information_entry_t*
zathura_document_information_entry_new(zathura_document_information_type_t zathura_document_information_entry_new(zathura_document_information_type_t
@ -255,4 +255,9 @@ zathura_document_information_entry_new(zathura_document_information_type_t
*/ */
void zathura_document_information_entry_free(zathura_document_information_entry_t* entry); void zathura_document_information_entry_free(zathura_document_information_entry_t* entry);
/**
* Context for MIME type detection
*/
typedef struct zathura_content_type_context_s zathura_content_type_context_t;
#endif // TYPES_H #endif // TYPES_H

View file

@ -52,13 +52,13 @@ file_valid_extension(zathura_t* zathura, const char* path)
return false; return false;
} }
const gchar* content_type = guess_content_type(path); char* content_type = zathura_content_type_guess(zathura->content_type_context, path);
if (content_type == NULL) { if (content_type == NULL) {
return false; return false;
} }
zathura_plugin_t* plugin = zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type); zathura_plugin_t* plugin = zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type);
g_free((void*)content_type); g_free(content_type);
return (plugin == NULL) ? false : true; return (plugin == NULL) ? false : true;
} }

View file

@ -28,7 +28,7 @@ typedef struct page_offset_s
bool file_valid_extension(zathura_t* zathura, const char* path); bool file_valid_extension(zathura_t* zathura, const char* path);
/** /**
* Generates the document index based upon the list retreived from the document * Generates the document index based upon the list retrieved from the document
* object. * object.
* *
* @param model The tree model * @param model The tree model
@ -64,7 +64,7 @@ zathura_rectangle_t recalc_rectangle(zathura_page_t* page, zathura_rectangle_t r
* @param zathura The zathura instance * @param zathura The zathura instance
* @param page The page object * @param page The page object
* @return The page widget of the page * @return The page widget of the page
* @return NULL if an error occured * @return NULL if an error occurred
*/ */
GtkWidget* zathura_page_get_widget(zathura_t* zathura, zathura_page_t* page); GtkWidget* zathura_page_get_widget(zathura_t* zathura, zathura_page_t* page);

View file

@ -5,7 +5,6 @@
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
@ -21,6 +20,7 @@
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
#include <glib-unix.h> #include <glib-unix.h>
#include <gio/gunixinputstream.h>
#endif #endif
#include "bookmarks.h" #include "bookmarks.h"
@ -43,6 +43,7 @@
#include "dbus-interface.h" #include "dbus-interface.h"
#include "css-definitions.h" #include "css-definitions.h"
#include "synctex.h" #include "synctex.h"
#include "content-type.h"
typedef struct zathura_document_info_s { typedef struct zathura_document_info_s {
zathura_t* zathura; zathura_t* zathura;
@ -93,7 +94,8 @@ zathura_create(void)
} }
/* UI */ /* UI */
if ((zathura->ui.session = girara_session_create()) == NULL) { zathura->ui.session = girara_session_create();
if (zathura->ui.session == NULL) {
goto error_out; goto error_out;
} }
@ -102,6 +104,9 @@ zathura_create(void)
zathura->signals.sigterm = g_unix_signal_add(SIGTERM, zathura_signal_sigterm, zathura); zathura->signals.sigterm = g_unix_signal_add(SIGTERM, zathura_signal_sigterm, zathura);
#endif #endif
/* MIME type detection */
zathura->content_type_context = zathura_content_type_new();
zathura->ui.session->global.data = zathura; zathura->ui.session->global.data = zathura;
return zathura; return zathura;
@ -113,32 +118,27 @@ error_out:
return NULL; return NULL;
} }
bool static void
zathura_init(zathura_t* zathura) create_directories(zathura_t* zathura)
{ {
if (zathura == NULL) { static const unsigned int mode = 0711;
return false;
if (g_mkdir_with_parents(zathura->config.config_dir, mode) == -1) {
girara_error("Could not create '%s': %s", zathura->config.config_dir,
strerror(errno));
} }
/* create zathura (config/data) directory */ if (g_mkdir_with_parents(zathura->config.data_dir, mode) == -1) {
if (g_mkdir_with_parents(zathura->config.config_dir, 0771) == -1) { girara_error("Could not create '%s': %s", zathura->config.data_dir,
girara_error("Could not create '%s': %s", zathura->config.config_dir, strerror(errno)); strerror(errno));
} }
}
if (g_mkdir_with_parents(zathura->config.data_dir, 0771) == -1) { static bool
girara_error("Could not create '%s': %s", zathura->config.data_dir, strerror(errno)); init_ui(zathura_t* zathura)
} {
/* load plugins */
zathura_plugin_manager_load(zathura->plugins.manager);
/* configuration */
config_load_default(zathura);
config_load_files(zathura);
/* UI */
if (girara_session_init(zathura->ui.session, "zathura") == false) { if (girara_session_init(zathura->ui.session, "zathura") == false) {
goto error_free; return false;
} }
/* girara events */ /* girara events */
@ -146,16 +146,9 @@ zathura_init(zathura_t* zathura)
zathura->ui.session->events.unknown_command = cb_unknown_command; zathura->ui.session->events.unknown_command = cb_unknown_command;
/* zathura signals */ /* zathura signals */
zathura->signals.refresh_view = g_signal_new("refresh-view", zathura->signals.refresh_view = g_signal_new(
GTK_TYPE_WIDGET, "refresh-view", GTK_TYPE_WIDGET, G_SIGNAL_RUN_LAST, 0, NULL, NULL,
G_SIGNAL_RUN_LAST, g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_POINTER);
0,
NULL,
NULL,
g_cclosure_marshal_generic,
G_TYPE_NONE,
1,
G_TYPE_POINTER);
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view), "refresh-view", g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view), "refresh-view",
G_CALLBACK(cb_refresh_view), zathura); G_CALLBACK(cb_refresh_view), zathura);
@ -165,28 +158,29 @@ zathura_init(zathura_t* zathura)
gtk_grid_set_row_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE); gtk_grid_set_row_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE);
gtk_grid_set_column_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE); gtk_grid_set_column_homogeneous(GTK_GRID(zathura->ui.page_widget), TRUE);
if (zathura->ui.page_widget == NULL) { if (zathura->ui.page_widget == NULL) {
goto error_free; return false;
} }
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "size-allocate", G_CALLBACK(cb_view_resized), zathura); g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "size-allocate",
G_CALLBACK(cb_view_resized), zathura);
GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment( GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment(
GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
/* Connect hadjustment signals */ /* Connect hadjustment signals */
g_signal_connect(G_OBJECT(hadjustment), "value-changed", g_signal_connect(G_OBJECT(hadjustment), "value-changed",
G_CALLBACK(cb_view_hadjustment_value_changed), zathura); G_CALLBACK(cb_view_hadjustment_value_changed), zathura);
g_signal_connect(G_OBJECT(hadjustment), "changed", g_signal_connect(G_OBJECT(hadjustment), "changed",
G_CALLBACK(cb_view_hadjustment_changed), zathura); G_CALLBACK(cb_view_hadjustment_changed), zathura);
GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment( GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment(
GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
/* Connect vadjustment signals */ /* Connect vadjustment signals */
g_signal_connect(G_OBJECT(vadjustment), "value-changed", g_signal_connect(G_OBJECT(vadjustment), "value-changed",
G_CALLBACK(cb_view_vadjustment_value_changed), zathura); G_CALLBACK(cb_view_vadjustment_value_changed), zathura);
g_signal_connect(G_OBJECT(vadjustment), "changed", g_signal_connect(G_OBJECT(vadjustment), "changed",
G_CALLBACK(cb_view_vadjustment_changed), zathura); G_CALLBACK(cb_view_vadjustment_changed), zathura);
/* page view alignment */ /* page view alignment */
gtk_widget_set_halign(zathura->ui.page_widget, GTK_ALIGN_CENTER); gtk_widget_set_halign(zathura->ui.page_widget, GTK_ALIGN_CENTER);
@ -200,66 +194,39 @@ zathura_init(zathura_t* zathura)
gtk_widget_show(zathura->ui.page_widget); gtk_widget_show(zathura->ui.page_widget);
/* statusbar */ /* statusbar */
zathura->ui.statusbar.file = girara_statusbar_item_add(zathura->ui.session, TRUE, TRUE, TRUE, NULL); zathura->ui.statusbar.file =
girara_statusbar_item_add(zathura->ui.session, TRUE, TRUE, TRUE, NULL);
if (zathura->ui.statusbar.file == NULL) { if (zathura->ui.statusbar.file == NULL) {
goto error_free; return false;
} }
zathura->ui.statusbar.buffer = girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL); zathura->ui.statusbar.buffer =
girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL);
if (zathura->ui.statusbar.buffer == NULL) { if (zathura->ui.statusbar.buffer == NULL) {
goto error_free; return false;
} }
zathura->ui.statusbar.page_number = girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL); zathura->ui.statusbar.page_number =
girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL);
if (zathura->ui.statusbar.page_number == NULL) { if (zathura->ui.statusbar.page_number == NULL) {
goto error_free; return false;
} }
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, _("[No name]")); girara_statusbar_item_set_text(zathura->ui.session,
zathura->ui.statusbar.file, _("[No name]"));
/* signals */ /* signals */
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), zathura); g_signal_connect(G_OBJECT(zathura->ui.session->gtk.window), "destroy",
G_CALLBACK(cb_destroy), zathura);
/* database */ return true;
char* database = NULL; }
girara_setting_get(zathura->ui.session, "database", &database);
if (g_strcmp0(database, "plain") == 0) { static void
girara_debug("Using plain database backend."); init_css(zathura_t* zathura)
zathura->database = zathura_plaindatabase_new(zathura->config.data_dir); {
#ifdef WITH_SQLITE GiraraTemplate* csstemplate =
} else if (g_strcmp0(database, "sqlite") == 0) { girara_session_get_template(zathura->ui.session);
girara_debug("Using sqlite database backend.");
char* tmp = g_build_filename(zathura->config.data_dir, "bookmarks.sqlite", NULL);
zathura->database = zathura_sqldatabase_new(tmp);
g_free(tmp);
#endif
} else if (g_strcmp0(database, "null") != 0) {
girara_error("Database backend '%s' is not supported.", database);
}
if (zathura->database == NULL && g_strcmp0(database, "null") != 0) {
girara_error("Unable to initialize database. Bookmarks won't be available.");
} else {
g_object_set(G_OBJECT(zathura->ui.session->command_history), "io", zathura->database, NULL);
}
g_free(database);
/* bookmarks */
zathura->bookmarks.bookmarks = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
(girara_free_function_t) zathura_bookmark_free);
/* jumplist */
int jumplist_size = 20;
girara_setting_get(zathura->ui.session, "jumplist-size", &jumplist_size);
zathura->jumplist.max_size = jumplist_size < 0 ? 0 : jumplist_size;
zathura->jumplist.list = NULL;
zathura->jumplist.size = 0;
zathura->jumplist.cur = NULL;
/* CSS for index mode */
GiraraTemplate* csstemplate = girara_session_get_template(zathura->ui.session);
static const char* index_settings[] = { static const char* index_settings[] = {
"index-fg", "index-fg",
@ -271,8 +238,8 @@ zathura_init(zathura_t* zathura)
for (size_t s = 0; s < LENGTH(index_settings); ++s) { for (size_t s = 0; s < LENGTH(index_settings); ++s) {
girara_template_add_variable(csstemplate, index_settings[s]); girara_template_add_variable(csstemplate, index_settings[s]);
char* tmp_value = NULL; char* tmp_value = NULL;
GdkRGBA rgba = { 0, 0, 0, 0 }; GdkRGBA rgba = {0, 0, 0, 0};
girara_setting_get(zathura->ui.session, index_settings[s], &tmp_value); girara_setting_get(zathura->ui.session, index_settings[s], &tmp_value);
if (tmp_value != NULL) { if (tmp_value != NULL) {
gdk_rgba_parse(&rgba, tmp_value); gdk_rgba_parse(&rgba, tmp_value);
@ -280,24 +247,111 @@ zathura_init(zathura_t* zathura)
} }
char* color = gdk_rgba_to_string(&rgba); char* color = gdk_rgba_to_string(&rgba);
girara_template_set_variable_value(csstemplate, girara_template_set_variable_value(csstemplate, index_settings[s], color);
index_settings[s], color);
g_free(color); g_free(color);
} }
char* css = g_strdup_printf("%s\n%s", girara_template_get_base(csstemplate), CSS_TEMPLATE_INDEX); char* css = g_strdup_printf("%s\n%s", girara_template_get_base(csstemplate),
CSS_TEMPLATE_INDEX);
girara_template_set_base(csstemplate, css); girara_template_set_base(csstemplate, css);
g_free(css); g_free(css);
}
/* Shortcut helpers */ static void
init_database(zathura_t* zathura)
{
char* database = NULL;
girara_setting_get(zathura->ui.session, "database", &database);
if (g_strcmp0(database, "plain") == 0) {
girara_debug("Using plain database backend.");
zathura->database = zathura_plaindatabase_new(zathura->config.data_dir);
#ifdef WITH_SQLITE
} else if (g_strcmp0(database, "sqlite") == 0) {
girara_debug("Using sqlite database backend.");
char* tmp =
g_build_filename(zathura->config.data_dir, "bookmarks.sqlite", NULL);
zathura->database = zathura_sqldatabase_new(tmp);
g_free(tmp);
#endif
} else if (g_strcmp0(database, "null") != 0) {
girara_error("Database backend '%s' is not supported.", database);
}
if (zathura->database == NULL && g_strcmp0(database, "null") != 0) {
girara_error(
"Unable to initialize database. Bookmarks won't be available.");
}
else {
g_object_set(G_OBJECT(zathura->ui.session->command_history), "io",
zathura->database, NULL);
}
g_free(database);
}
static void
init_jumplist(zathura_t* zathura)
{
int jumplist_size = 20;
girara_setting_get(zathura->ui.session, "jumplist-size", &jumplist_size);
zathura->jumplist.max_size = jumplist_size < 0 ? 0 : jumplist_size;
zathura->jumplist.list = NULL;
zathura->jumplist.size = 0;
zathura->jumplist.cur = NULL;
}
static void
init_shortcut_helpers(zathura_t* zathura)
{
zathura->shortcut.mouse.x = 0; zathura->shortcut.mouse.x = 0;
zathura->shortcut.mouse.y = 0; zathura->shortcut.mouse.y = 0;
zathura->shortcut.toggle_page_mode.pages = 2; zathura->shortcut.toggle_page_mode.pages = 2;
zathura->shortcut.toggle_presentation_mode.pages = 1; zathura->shortcut.toggle_presentation_mode.pages = 1;
zathura->shortcut.toggle_presentation_mode.first_page_column_list = NULL; zathura->shortcut.toggle_presentation_mode.first_page_column_list = NULL;
zathura->shortcut.toggle_presentation_mode.zoom = 1.0; zathura->shortcut.toggle_presentation_mode.zoom = 1.0;
}
bool
zathura_init(zathura_t* zathura)
{
if (zathura == NULL) {
return false;
}
/* create zathura (config/data) directory */
create_directories(zathura);
/* load plugins */
zathura_plugin_manager_load(zathura->plugins.manager);
/* configuration */
config_load_default(zathura);
config_load_files(zathura);
/* UI */
if (!init_ui(zathura)) {
goto error_free;
}
/* database */
init_database(zathura);
/* bookmarks */
zathura->bookmarks.bookmarks = girara_sorted_list_new2(
(girara_compare_function_t)zathura_bookmarks_compare,
(girara_free_function_t)zathura_bookmark_free);
/* jumplist */
init_jumplist(zathura);
/* CSS for index mode */
init_css(zathura);
/* Shortcut helpers */
init_shortcut_helpers(zathura);
/* Start D-Bus service */ /* Start D-Bus service */
bool dbus = true; bool dbus = true;
@ -326,6 +380,16 @@ zathura_free(zathura_t* zathura)
document_close(zathura, false); document_close(zathura, false);
/* MIME type detection */
zathura_content_type_free(zathura->content_type_context);
#ifdef G_OS_UNIX
if (zathura->signals.sigterm > 0) {
g_source_remove(zathura->signals.sigterm);
zathura->signals.sigterm = 0;
}
#endif
/* stop D-Bus */ /* stop D-Bus */
if (zathura->dbus != NULL) { if (zathura->dbus != NULL) {
g_object_unref(zathura->dbus); g_object_unref(zathura->dbus);
@ -337,7 +401,9 @@ zathura_free(zathura_t* zathura)
} }
/* shortcut */ /* shortcut */
g_free(zathura->shortcut.toggle_presentation_mode.first_page_column_list); if (zathura->shortcut.toggle_presentation_mode.first_page_column_list != NULL) {
g_free(zathura->shortcut.toggle_presentation_mode.first_page_column_list);
}
/* stdin support */ /* stdin support */
if (zathura->stdin_support.file != NULL) { if (zathura->stdin_support.file != NULL) {
@ -466,6 +532,7 @@ zathura_set_argv(zathura_t* zathura, char** argv)
zathura->global.arguments = argv; zathura->global.arguments = argv;
} }
#ifdef G_OS_UNIX
static gchar* static gchar*
prepare_document_open_from_stdin(const char* path) prepare_document_open_from_stdin(const char* path)
{ {
@ -483,58 +550,60 @@ prepare_document_open_from_stdin(const char* path)
return NULL; return NULL;
} }
GError* error = NULL; if (infileno == -1) {
gchar* file = NULL; girara_error("Can not read from file descriptor.");
gint handle = g_file_open_tmp("zathura.stdin.XXXXXX", &file, &error); return NULL;
if (handle == -1) { }
GInputStream* input_stream = g_unix_input_stream_new(infileno, false);
if (input_stream == NULL) {
girara_error("Can not read from file descriptor.");
return NULL;
}
GFileIOStream* iostream = NULL;
GError* error = NULL;
GFile* tmpfile = g_file_new_tmp("zathura.stdin.XXXXXX", &iostream, &error);
if (tmpfile == NULL) {
if (error != NULL) { if (error != NULL) {
girara_error("Can not create temporary file: %s", error->message); girara_error("Can not create temporary file: %s", error->message);
g_error_free(error); g_error_free(error);
} }
g_object_unref(input_stream);
return NULL; return NULL;
} }
// read and dump to temporary file const ssize_t count = g_output_stream_splice(
if (infileno == -1) { g_io_stream_get_output_stream(G_IO_STREAM(iostream)), input_stream,
girara_error("Can not read from file descriptor."); G_OUTPUT_STREAM_SPLICE_NONE, NULL, &error);
close(handle); g_object_unref(input_stream);
g_unlink(file); g_object_unref(iostream);
g_free(file); if (count == -1) {
return NULL; if (error != NULL) {
} girara_error("Can not write to temporary file: %s", error->message);
g_error_free(error);
char buffer[BUFSIZ];
ssize_t count = 0;
while ((count = read(infileno, buffer, BUFSIZ)) > 0) {
if (write(handle, buffer, count) != count) {
girara_error("Can not write to temporary file: %s", file);
close(handle);
g_unlink(file);
g_free(file);
return NULL;
} }
} g_file_delete(tmpfile, NULL, NULL);
g_object_unref(tmpfile);
close(handle);
if (count != 0) {
girara_error("Can not read from file descriptor.");
g_unlink(file);
g_free(file);
return NULL; return NULL;
} }
char* file = g_file_get_path(tmpfile);
g_object_unref(tmpfile);
return file; return file;
} }
#endif
static gchar* static gchar*
prepare_document_open_from_gfile(GFile* source) prepare_document_open_from_gfile(GFile* source)
{ {
gchar* file = NULL; gchar* file = NULL;
GFileIOStream* iostream = NULL; GFileIOStream* iostream = NULL;
GError* error = NULL; GError* error = NULL;
GFile *tmpfile = g_file_new_tmp("zathura.gio.XXXXXX", &iostream, &error); GFile* tmpfile = g_file_new_tmp("zathura.gio.XXXXXX", &iostream, &error);
if (tmpfile == NULL) { if (tmpfile == NULL) {
if (error != NULL) { if (error != NULL) {
girara_error("Can not create temporary file: %s", error->message); girara_error("Can not create temporary file: %s", error->message);
@ -543,7 +612,8 @@ prepare_document_open_from_gfile(GFile* source)
return NULL; return NULL;
} }
gboolean rc = g_file_copy(source, tmpfile, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error); gboolean rc = g_file_copy(source, tmpfile, G_FILE_COPY_OVERWRITE, NULL, NULL,
NULL, &error);
if (rc == FALSE) { if (rc == FALSE) {
if (error != NULL) { if (error != NULL) {
girara_error("Can not copy to temporary file: %s", error->message); girara_error("Can not copy to temporary file: %s", error->message);
@ -572,7 +642,9 @@ document_info_open(gpointer data)
char* file = NULL; char* file = NULL;
if (g_strcmp0(document_info->path, "-") == 0 || if (g_strcmp0(document_info->path, "-") == 0 ||
g_str_has_prefix(document_info->path, "/proc/self/fd/") == true) { g_str_has_prefix(document_info->path, "/proc/self/fd/") == true) {
#ifdef G_OS_UNIX
file = prepare_document_open_from_stdin(document_info->path); file = prepare_document_open_from_stdin(document_info->path);
#endif
if (file == NULL) { if (file == NULL) {
girara_notify(document_info->zathura->ui.session, GIRARA_ERROR, girara_notify(document_info->zathura->ui.session, GIRARA_ERROR,
_("Could not read file from stdin and write it to a temporary file.")); _("Could not read file from stdin and write it to a temporary file."));
@ -695,7 +767,7 @@ document_open(zathura_t* zathura, const char* path, const char* uri, const char*
gchar* file_uri = NULL; gchar* file_uri = NULL;
zathura_error_t error = ZATHURA_ERROR_OK; zathura_error_t error = ZATHURA_ERROR_OK;
zathura_document_t* document = zathura_document_open(zathura->plugins.manager, path, uri, password, &error); zathura_document_t* document = zathura_document_open(zathura, path, uri, password, &error);
if (document == NULL) { if (document == NULL) {
if (error == ZATHURA_ERROR_INVALID_PASSWORD) { if (error == ZATHURA_ERROR_INVALID_PASSWORD) {
@ -870,7 +942,7 @@ document_open(zathura_t* zathura, const char* path, const char* uri, const char*
} }
/* set up recolor info in ZathuraRenderer */ /* set up recolor info in ZathuraRenderer */
char* recolor_dark = NULL; char* recolor_dark = NULL;
char* recolor_light = NULL; char* recolor_light = NULL;
girara_setting_get(zathura->ui.session, "recolor-darkcolor", &recolor_dark); girara_setting_get(zathura->ui.session, "recolor-darkcolor", &recolor_dark);
girara_setting_get(zathura->ui.session, "recolor-lightcolor", &recolor_light); girara_setting_get(zathura->ui.session, "recolor-lightcolor", &recolor_light);
@ -1413,10 +1485,10 @@ adjust_view(zathura_t* zathura)
if (adjust_mode == ZATHURA_ADJUST_WIDTH || if (adjust_mode == ZATHURA_ADJUST_WIDTH ||
(adjust_mode == ZATHURA_ADJUST_BESTFIT && page_ratio < view_ratio)) { (adjust_mode == ZATHURA_ADJUST_BESTFIT && page_ratio < view_ratio)) {
newscale = scale * (double)view_width / (double)document_width; newscale *= (double)view_width / (double)document_width;
} else if (adjust_mode == ZATHURA_ADJUST_BESTFIT) { } else if (adjust_mode == ZATHURA_ADJUST_BESTFIT) {
newscale = scale * (double)view_height / (double)cell_height; newscale *= (double)view_height / (double)cell_height;
} else { } else {
goto error_ret; goto error_ret;
@ -1428,8 +1500,8 @@ adjust_view(zathura_t* zathura)
zathura_document_get_cell_size(zathura->document, &new_cell_height, &new_cell_width); zathura_document_get_cell_size(zathura->document, &new_cell_height, &new_cell_width);
/* if the change in scale changes page cell dimensions by at least one pixel, render */ /* if the change in scale changes page cell dimensions by at least one pixel, render */
if (abs(new_cell_width - cell_width) > 1 || if (abs((int)new_cell_width - (int)cell_width) > 1 ||
abs(new_cell_height - cell_height) > 1) { abs((int)new_cell_height - (int)cell_height) > 1) {
render_all(zathura); render_all(zathura);
refresh_view(zathura); refresh_view(zathura);

View file

@ -6,7 +6,9 @@
#include <stdbool.h> #include <stdbool.h>
#include <girara/types.h> #include <girara/types.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#ifdef GDK_WINDOWING_X11
#include <gtk/gtkx.h> #include <gtk/gtkx.h>
#endif
#include "macros.h" #include "macros.h"
#include "types.h" #include "types.h"
@ -222,6 +224,11 @@ struct zathura_s
double zoom; double zoom;
} toggle_presentation_mode; } toggle_presentation_mode;
} shortcut; } shortcut;
/**
* Context for MIME type detection
*/
zathura_content_type_context_t* content_type_context;
}; };
/** /**
@ -304,7 +311,7 @@ void zathura_set_argv(zathura_t* zathura, char** argv);
* @param password The password of the file * @param password The password of the file
* @param page_number Open given page number * @param page_number Open given page number
* *
* @return If no error occured true, otherwise false, is returned. * @return If no error occurred true, otherwise false, is returned.
*/ */
bool document_open(zathura_t* zathura, const char* path, const char* uri, const char* password, bool document_open(zathura_t* zathura, const char* path, const char* uri, const char* password,
int page_number); int page_number);
@ -317,7 +324,7 @@ bool document_open(zathura_t* zathura, const char* path, const char* uri, const
* @param password The password of the file * @param password The password of the file
* @param synctex Open at the given SyncTeX string * @param synctex Open at the given SyncTeX string
* *
* @return If no error occured true, otherwise false, is returned. * @return If no error occurred true, otherwise false, is returned.
*/ */
bool document_open_synctex(zathura_t* zathura, const char* path, const char* uri, bool document_open_synctex(zathura_t* zathura, const char* path, const char* uri,
const char* password, const char* synctex); const char* password, const char* synctex);
@ -343,7 +350,7 @@ void document_open_idle(zathura_t* zathura, const char* path,
* @param path The path * @param path The path
* @param overwrite Overwrite existing file * @param overwrite Overwrite existing file
* *
* @return If no error occured true, otherwise false, is returned. * @return If no error occurred true, otherwise false, is returned.
*/ */
bool document_save(zathura_t* zathura, const char* path, bool overwrite); bool document_save(zathura_t* zathura, const char* path, bool overwrite);
@ -352,7 +359,7 @@ bool document_save(zathura_t* zathura, const char* path, bool overwrite);
* *
* @param zathura The zathura session * @param zathura The zathura session
* @param keep_monitor Set to true if monitor should be kept (sc_reload) * @param keep_monitor Set to true if monitor should be kept (sc_reload)
* @return If no error occured true, otherwise false, is returned. * @return If no error occurred true, otherwise false, is returned.
*/ */
bool document_close(zathura_t* zathura, bool keep_monitor); bool document_close(zathura_t* zathura, bool keep_monitor);
@ -361,7 +368,7 @@ bool document_close(zathura_t* zathura, bool keep_monitor);
* *
* @param zathura The zathura session * @param zathura The zathura session
* @param page_id The id of the page that should be set * @param page_id The id of the page that should be set
* @return If no error occured true, otherwise false, is returned. * @return If no error occurred true, otherwise false, is returned.
*/ */
bool page_set(zathura_t* zathura, unsigned int page_id); bool page_set(zathura_t* zathura, unsigned int page_id);
@ -371,7 +378,7 @@ bool page_set(zathura_t* zathura, unsigned int page_id);
* @param zathura Zathura session * @param zathura Zathura session
* @param position_x X coordinate * @param position_x X coordinate
* @param position_y Y coordinate * @param position_y Y coordinate
* @return If no error occured true, otherwise false, is returned. * @return If no error occurred true, otherwise false, is returned.
*/ */
bool position_set(zathura_t* zathura, double position_x, double position_y); bool position_set(zathura_t* zathura, double position_x, double position_y);