Merge branch 'develop'

This commit is contained in:
Sebastian Ramacher 2012-02-21 21:59:20 +01:00
commit c659361a43
27 changed files with 896 additions and 674 deletions

1
.gitignore vendored
View file

@ -11,3 +11,4 @@ zathura.pc
*.gcno
*.gcda
gcov/
*.swp

12
AUTHORS Normal file
View file

@ -0,0 +1,12 @@
zathura is written by:
Moritz Lipp <mlq@pwmt.org>
Sebastian Ramacher <s.ramacher@gmx.at>
Other contributors are (in alphabetical order):
Pavel Borzenkov <pavel.borzenkov@gmail.com>
Ivan Sichmann Freitas <ivansichfreitas@gmail.com>
int3 <jezreel@gmail.com>
karottenreibe <k@rottenrei.be>
Johannes Meng <j@jmeng.de>

View file

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

View file

@ -63,6 +63,8 @@ ${PROJECT}.pc: ${PROJECT}.pc.in config.mk
$(QUIET)echo project=${PROJECT} > ${PROJECT}.pc
$(QUIET)echo version=${VERSION} >> ${PROJECT}.pc
$(QUIET)echo includedir=${PREFIX}/include >> ${PROJECT}.pc
$(QUIET)echo plugindir=${PLUGINDIR} >> ${PROJECT}.pc
$(QUIET)echo GTK_VERSION=${ZATHURA_GTK_VERSION} >> ${PROJECT}.pc
$(QUIET)cat ${PROJECT}.pc.in >> ${PROJECT}.pc
valgrind: debug
@ -72,19 +74,22 @@ valgrind: debug
gdb: debug
cgdb ${PROJECT}-debug
tests: ${OBJECTS}
$(QUIET)make -C tests
test: ${OBJECTS}
$(QUIET)make -C tests run
dist: clean
$(QUIET)mkdir -p ${PROJECT}-${VERSION}
$(QUIET)cp -R LICENSE Makefile config.mk common.mk README Doxyfile \
${PROJECT}.1 ${SOURCE} ${HEADER} ${PROJECT}.pc.in tests \
$(QUIET)mkdir -p ${PROJECT}-${VERSION}/tests
$(QUIET)cp LICENSE Makefile config.mk common.mk README AUTHORS Doxyfile \
${PROJECT}.1.rst ${PROJECT}rc.5.rst ${SOURCE} ${HEADER} ${PROJECT}.pc.in \
${PROJECT}-${VERSION}
$(QUIET)cp Makefile config.mk tests/*.c \
${PROJECT}-${VERSION}/tests
$(QUIET)tar -cf ${PROJECT}-${VERSION}.tar ${PROJECT}-${VERSION}
$(QUIET)gzip ${PROJECT}-${VERSION}.tar
$(QUIET)rm -rf ${PROJECT}-${VERSION}
doc: clean
doc:
$(QUIET)doxygen Doxyfile
gcov: clean
@ -103,10 +108,15 @@ install: all ${PROJECT}.pc
$(QUIET)cp -f zathura.h ${DESTDIR}${PREFIX}/include/${PROJECT}
$(ECHO) installing manual pages
$(QUIET)mkdir -p ${DESTDIR}${MANPREFIX}/man1
$(QUIET)sed "s/VERSION/${VERSION}/g" < ${PROJECT}.1 > ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1
$(QUIET)if which rst2man > /dev/null ; then \
mkdir -p ${DESTDIR}${MANPREFIX}/man1 ; \
sed "s/VERSION/${VERSION}/g" < ${PROJECT}.1.rst > ${PROJECT}-v.1.rst ; \
rst2man ${PROJECT}-v.1.rst > ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1 ; \
rm -f ${PROJECT}-v.1.rst ; \
mkdir -p ${DESTDIR}${MANPREFIX}/man5 ; \
rst2man ${PROJECT}rc.5.rst > ${DESTDIR}${MANPREFIX}/man5/${PROJECT}rc.5 ; \
sed "s/VERSION/${VERSION}/g" < ${PROJECT}rc.5.rst > ${PROJECT}rc-v.5.rst ; \
rst2man ${PROJECT}rc-v.5.rst > ${DESTDIR}${MANPREFIX}/man5/${PROJECT}rc.5 ; \
rm -f ${PROJECT}rc-v.5.rst ; \
fi
$(QUIET)mkdir -p ${DESTDIR}${DESKTOPPREFIX}
$(ECHO) installing desktop file
@ -131,4 +141,4 @@ uninstall:
-include $(wildcard .depend/*.dep)
.PHONY: all options clean doc debug valgrind gdb dist doc install uninstall tests
.PHONY: all options clean doc debug valgrind gdb dist doc install uninstall test

View file

@ -32,8 +32,9 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page)
bookmark->id = g_strdup(id);
bookmark->page = page;
girara_list_append(zathura->bookmarks.bookmarks, bookmark);
if (zathura->database) {
if (!zathura_db_add_bookmark(zathura->database, zathura->document->file_path, bookmark)) {
if (zathura->database != NULL) {
if (zathura_db_add_bookmark(zathura->database, zathura->document->file_path, bookmark) == false) {
girara_warning("Failed to add bookmark to database.");
}
}
@ -48,15 +49,16 @@ zathura_bookmark_remove(zathura_t* zathura, const gchar* id)
g_return_val_if_fail(id, false);
zathura_bookmark_t* bookmark = zathura_bookmark_get(zathura, id);
if (!bookmark) {
if (bookmark == NULL) {
return false;
}
if (zathura->database) {
if (!zathura_db_remove_bookmark(zathura->database, zathura->document->file_path, bookmark->id)) {
if (zathura->database != NULL) {
if (zathura_db_remove_bookmark(zathura->database, zathura->document->file_path, bookmark->id) == false) {
girara_warning("Failed to remove bookmark from database.");
}
}
girara_list_remove(zathura->bookmarks.bookmarks, bookmark);
return true;
@ -74,7 +76,7 @@ zathura_bookmark_get(zathura_t* zathura, const gchar* id)
void
zathura_bookmark_free(zathura_bookmark_t* bookmark)
{
if (!bookmark) {
if (bookmark == NULL) {
return;
}
@ -86,17 +88,19 @@ bool
zathura_bookmarks_load(zathura_t* zathura, const gchar* file) {
g_return_val_if_fail(zathura, false);
g_return_val_if_fail(file, false);
if (zathura->database == NULL) {
return false;
}
girara_list_t* bookmarks = zathura_db_load_bookmarks(zathura->database, file);
if (!bookmarks) {
if (bookmarks == NULL) {
return false;
}
girara_list_free(zathura->bookmarks.bookmarks);
zathura->bookmarks.bookmarks = bookmarks;
return true;
}
@ -106,9 +110,11 @@ zathura_bookmarks_compare(zathura_bookmark_t* lhs, zathura_bookmark_t* rhs)
if (lhs == NULL && rhs == NULL) {
return 0;
}
if (lhs == NULL) {
return -1;
}
if (rhs == NULL) {
return 1;
}

View file

@ -97,18 +97,25 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
}
void
cb_pages_per_row_value_changed(girara_session_t* UNUSED(session), const char* UNUSED(name), girara_setting_type_t UNUSED(type), void* value, void* data)
cb_pages_per_row_value_changed(girara_session_t* session, const char* UNUSED(name), girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
{
g_return_if_fail(value != NULL);
g_return_if_fail(session != NULL);
g_return_if_fail(session->global.data != NULL);
zathura_t* zathura = session->global.data;
int pages_per_row = *(int*) value;
zathura_t* zathura = data;
if (pages_per_row < 1) {
pages_per_row = 1;
}
page_widget_set_mode(zathura, pages_per_row);
if (zathura->document != NULL) {
unsigned int current_page = zathura->document->current_page_number;
page_set_delayed(zathura, current_page);
}
}
void
@ -214,11 +221,16 @@ cb_file_monitor(GFileMonitor* monitor, GFile* file, GFile* UNUSED(other_file), G
g_return_if_fail(file != NULL);
g_return_if_fail(session != NULL);
if (event != G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT) {
switch (event) {
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
case G_FILE_MONITOR_EVENT_CREATED:
gdk_threads_enter();
sc_reload(session, NULL, NULL, 0);
gdk_threads_leave();
break;
default:
return;
}
sc_reload(session, NULL, NULL, 0);
}
static gboolean
@ -256,13 +268,13 @@ cb_password_dialog(GtkEntry* entry, zathura_password_dialog_info_t* dialog)
g_free(input);
}
g_idle_add(password_dialog, dialog);
gdk_threads_add_idle(password_dialog, dialog);
return false;
}
/* try to open document again */
if (document_open(dialog->zathura, dialog->path, input) == false) {
g_idle_add(password_dialog, dialog);
gdk_threads_add_idle(password_dialog, dialog);
} else {
g_free(dialog->path);
free(dialog);
@ -283,14 +295,22 @@ error_ret:
}
bool
cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* UNUSED(allocation), zathura_t* zathura)
cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* allocation, zathura_t* zathura)
{
if (zathura == NULL || zathura->document == NULL) {
return false;
}
static int height = -1;
static int width = -1;
/* adjust only if the allocation changed */
if (width != allocation->width || height != allocation->height) {
girara_argument_t argument = { zathura->document->adjust_mode, NULL };
sc_adjust_window(zathura->ui.session, &argument, NULL, 0);
return true;
width = allocation->width;
height = allocation->height;
}
return false;
}

View file

@ -116,7 +116,7 @@ cmd_close(girara_session_t* session, girara_list_t* UNUSED(argument_list))
return true;
}
document_close(zathura);
document_close(zathura, false);
return true;
}
@ -157,11 +157,6 @@ cmd_info(girara_session_t* session, girara_list_t* UNUSED(argument_list))
char* tmp = zathura_document_meta_get(zathura->document, meta_fields[i].field, NULL);
if (tmp != NULL) {
char* text = g_strdup_printf("<b>%s:</b> %s\n", meta_fields[i].name, tmp);
if (text == NULL) {
g_free(tmp);
return true;
}
g_string_append(string, text);
g_free(text);
@ -198,8 +193,8 @@ cmd_open(girara_session_t* session, girara_list_t* argument_list)
girara_notify(session, GIRARA_ERROR, "Too many arguments.");
return false;
} else if (argc >= 1) {
if (zathura->document) {
document_close(zathura);
if (zathura->document != NULL) {
document_close(zathura, false);
}
document_open(zathura, girara_list_nth(argument_list, 0), (argc == 2) ? girara_list_nth(argument_list, 1) : NULL);
@ -286,6 +281,8 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
}
bool firsthit = true;
zathura_plugin_error_t error = ZATHURA_PLUGIN_ERROR_OK;
for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; ++page_id) {
zathura_page_t* page = zathura->document->pages[(page_id + zathura->document->current_page_number) % zathura->document->number_of_pages];
if (page == NULL) {
@ -294,12 +291,17 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
g_object_set(page->drawing_area, "draw-links", FALSE, NULL);
girara_list_t* result = zathura_page_search_text(page, input, NULL);
girara_list_t* result = zathura_page_search_text(page, input, &error);
if (result == NULL || girara_list_size(result) == 0) {
girara_list_free(result);
g_object_set(page->drawing_area, "search-results", NULL, NULL);
if (error == ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED) {
break;
} else {
continue;
}
}
g_object_set(page->drawing_area, "search-results", result, NULL);
if (firsthit == true) {
@ -333,13 +335,19 @@ cmd_export(girara_session_t* session, girara_list_t* argument_list)
const char* attachment_name = girara_list_nth(argument_list, 0);
const char* file_name = girara_list_nth(argument_list, 1);
if (file_name == NULL || attachment_name == NULL) {
return false;
}
char* file_name2 = girara_fix_path(file_name);
if (!zathura_document_attachment_save(zathura->document, attachment_name, file_name)) {
if (zathura_document_attachment_save(zathura->document, attachment_name, file_name) == false) {
girara_notify(session, GIRARA_ERROR, "Couldn't write attachment '%s' to '%s'.", attachment_name, file_name);
} else {
girara_notify(session, GIRARA_INFO, "Wrote attachment '%s' to '%s'.", attachment_name, file_name2);
}
g_free(file_name2);
return true;
}

View file

@ -11,6 +11,7 @@
#include "utils.h"
#include <girara/session.h>
#include <girara/settings.h>
#include <girara/completion.h>
#include <girara/utils.h>
#include <girara/datastructures.h>
@ -29,6 +30,10 @@ compare_case_insensitive(const char* str1, const char* str2)
static girara_list_t*
list_files(zathura_t* zathura, const char* current_path, const char* current_file, int current_file_length, bool is_dir)
{
if (zathura == NULL || zathura->ui.session == NULL || current_path == NULL) {
return NULL;
}
/* read directory */
GDir* dir = g_dir_open(current_path, 0, NULL);
if (dir == NULL) {
@ -38,6 +43,9 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil
girara_list_t* res = girara_sorted_list_new2((girara_compare_function_t)compare_case_insensitive,
(girara_free_function_t)g_free);
bool show_hidden = false;
girara_setting_get(zathura->ui.session, "show-hidden", &show_hidden);
/* read files */
char* name = NULL;
while ((name = (char*) g_dir_read_name(dir)) != NULL) {
@ -45,20 +53,26 @@ list_files(zathura_t* zathura, const char* current_path, const char* current_fil
if (e_name == NULL) {
goto error_free;
}
int e_length = strlen(e_name);
if ((current_file_length > e_length) || strncmp(current_file, e_name,
current_file_length)) {
if (show_hidden == false && e_name[0] == '.') {
g_free(e_name);
continue;
}
char* full_path = g_strdup_printf("%s%s%s", current_path, is_dir ? "" : "/", e_name);
if (full_path == NULL) {
if ((current_file_length > e_length) || strncmp(current_file, e_name, current_file_length)) {
g_free(e_name);
goto error_free;
continue;
}
char* tmp = "/";
if (is_dir == true || g_strcmp0(current_path, "/") == 0) {
tmp = "";
};
char* full_path = g_strdup_printf("%s%s%s", current_path, tmp, e_name);
if (g_file_test(full_path, G_FILE_TEST_IS_DIR) == true) {
char* tmp_path = full_path;
full_path = g_strdup_printf("%s/", full_path);
@ -120,9 +134,6 @@ cc_open(girara_session_t* session, const char* input)
}
char* tmp_path = g_strdup_printf("%s/%s", cwd, path);
if (tmp_path == NULL) {
goto error_free;
}
g_free(path);
path = tmp_path;
@ -132,10 +143,6 @@ cc_open(girara_session_t* session, const char* input)
bool is_dir = (path[strlen(path) - 1] == '/') ? true : false;
if ((g_file_test(path, G_FILE_TEST_IS_DIR) == TRUE) && !is_dir) {
char* tmp_path = g_strdup_printf("%s/", path);
if (tmp_path == NULL) {
goto error_free;
}
g_free(path);
path = tmp_path;
is_dir = true;

221
config.c
View file

@ -12,6 +12,31 @@
#include <girara/shortcuts.h>
#include <girara/config.h>
#include <girara/commands.h>
#include <girara/gtk2-compat.h>
static void
cb_color_change(girara_session_t* session, const char* name, girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
{
g_return_if_fail(value != NULL);
g_return_if_fail(session != NULL);
g_return_if_fail(session->global.data != NULL);
g_return_if_fail(name != NULL);
zathura_t* zathura = session->global.data;
char* string_value = (char*) value;
if (g_strcmp0(name, "highlight-color") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color));
} else if (g_strcmp0(name, "highlight-active-active") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color_active));
} else if (g_strcmp0(name, "recolor-darkcolor") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_dark_color));
} else if (g_strcmp0(name, "recolor-lightcolor") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color));
}
/* TODO: cause a redraw here? */
}
void
config_load_default(zathura_t* zathura)
@ -45,103 +70,141 @@ config_load_default(zathura_t* zathura)
int_value = 1;
girara_setting_add(gsession, "page-padding", &int_value, INT, true, "Padding between pages", NULL, NULL);
int_value = 1;
girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, "Number of pages per row", cb_pages_per_row_value_changed, zathura);
girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, "Number of pages per row", cb_pages_per_row_value_changed, NULL);
float_value = 40;
girara_setting_add(gsession, "scroll-step", &float_value, FLOAT, false, "Scroll step", NULL, NULL);
int_value = 10;
girara_setting_add(gsession, "zoom-min", &int_value, INT, false, "Zoom minimum", NULL, NULL);
int_value = 1000;
girara_setting_add(gsession, "zoom-max", &int_value, INT, false, "Zoom maximum", NULL, NULL);
string_value = "#FFFFFF";
girara_setting_add(gsession, "recolor-darkcolor", string_value, STRING, false, "Recoloring (dark color)", NULL, NULL);
string_value = "#000000";
girara_setting_add(gsession, "recolor-lightcolor", string_value, STRING, false, "Recoloring (light color)", NULL, NULL);
girara_setting_add(gsession, "recolor-darkcolor", NULL, STRING, false, "Recoloring (dark color)", cb_color_change, NULL);
girara_setting_set(gsession, "recolor-darkcolor", "#FFFFFF");
girara_setting_add(gsession, "recolor-lightcolor", NULL, STRING, false, "Recoloring (light color)", cb_color_change, NULL);
girara_setting_set(gsession, "recolor-lightcolor", "#000000");
girara_setting_add(gsession, "highlight-color", NULL, STRING, false, "Color for highlighting", cb_color_change, NULL);
girara_setting_set(gsession, "highlight-color", "#9FBC00");
girara_setting_add(gsession, "highlight-active-color", NULL, STRING, false, "Color for highlighting (active)", cb_color_change, NULL);
girara_setting_set(gsession, "highlight-active-color", "#00BC00");
string_value = "#9FBC00";
girara_setting_add(gsession, "highlight-color", string_value, STRING, false, "Color for highlighting", NULL, NULL);
float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, "Transparency for highlighting", NULL, NULL);
bool_value = true;
girara_setting_add(gsession, "render-loading", &bool_value, BOOLEAN, false, "Render 'Loading ...'", NULL, NULL);
int_value = ADJUST_BESTFIT;
girara_setting_add(gsession, "adjust-open", &int_value, INT, false, "Adjust to when opening file", NULL, NULL);
string_value = "best-fit";
girara_setting_add(gsession, "adjust-open", string_value, STRING, false, "Adjust to when opening file", NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "show-hidden", &bool_value, BOOLEAN, false, "Show hidden files and directories", NULL, NULL);
/* define default shortcuts */
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_c, NULL, sc_abort, 0, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_Escape, NULL, sc_abort, 0, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_a, NULL, sc_adjust_window, NORMAL, ADJUST_BESTFIT, NULL);
girara_shortcut_add(gsession, 0, GDK_s, NULL, sc_adjust_window, NORMAL, ADJUST_WIDTH, NULL);
girara_shortcut_add(gsession, 0, GDK_i, NULL, sc_change_mode, NORMAL, INSERT, NULL);
girara_shortcut_add(gsession, 0, GDK_m, NULL, sc_change_mode, NORMAL, ADD_MARKER, NULL);
girara_shortcut_add(gsession, 0, GDK_apostrophe, NULL, sc_change_mode, NORMAL, EVAL_MARKER, NULL);
girara_shortcut_add(gsession, 0, GDK_slash, NULL, girara_sc_focus_inputbar, NORMAL, 0, &("/"));
girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_slash, NULL, girara_sc_focus_inputbar, NORMAL, 0, &("/"));
girara_shortcut_add(gsession, 0, GDK_question, NULL, girara_sc_focus_inputbar, NORMAL, 0, &("?"));
girara_shortcut_add(gsession, 0, GDK_colon, NULL, girara_sc_focus_inputbar, NORMAL, 0, &(":"));
girara_shortcut_add(gsession, 0, GDK_o, NULL, girara_sc_focus_inputbar, NORMAL, 0, &(":open "));
girara_shortcut_add(gsession, 0, GDK_O, NULL, girara_sc_focus_inputbar, NORMAL, APPEND_FILEPATH, &(":open "));
girara_shortcut_add(gsession, 0, GDK_f, NULL, sc_follow, NORMAL, 0, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_c, NULL, sc_abort, 0, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Escape, NULL, sc_abort, 0, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_a, NULL, sc_adjust_window, NORMAL, ADJUST_BESTFIT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_s, NULL, sc_adjust_window, NORMAL, ADJUST_WIDTH, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_m, NULL, sc_change_mode, NORMAL, ADD_MARKER, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_apostrophe, NULL, sc_change_mode, NORMAL, EVAL_MARKER, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_slash, NULL, sc_focus_inputbar, NORMAL, 0, &("/"));
girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_KEY_slash, NULL, sc_focus_inputbar, NORMAL, 0, &("/"));
girara_shortcut_add(gsession, 0, GDK_KEY_question, NULL, sc_focus_inputbar, NORMAL, 0, &("?"));
girara_shortcut_add(gsession, 0, GDK_KEY_colon, NULL, sc_focus_inputbar, NORMAL, 0, &(":"));
girara_shortcut_add(gsession, 0, GDK_KEY_o, NULL, sc_focus_inputbar, NORMAL, 0, &(":open "));
girara_shortcut_add(gsession, 0, GDK_KEY_O, NULL, sc_focus_inputbar, NORMAL, APPEND_FILEPATH, &(":open "));
girara_shortcut_add(gsession, 0, GDK_KEY_f, NULL, sc_follow, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, 0, "gg", sc_goto, NORMAL, TOP, NULL);
girara_shortcut_add(gsession, 0, 0, "gg", sc_goto, FULLSCREEN, TOP, NULL);
girara_shortcut_add(gsession, 0, 0, "G", sc_goto, NORMAL, BOTTOM, NULL);
girara_shortcut_add(gsession, 0, 0, "G", sc_goto, FULLSCREEN, BOTTOM, NULL);
girara_shortcut_add(gsession, 0, GDK_J, NULL, sc_navigate, NORMAL, NEXT, NULL);
girara_shortcut_add(gsession, 0, GDK_K, NULL, sc_navigate, NORMAL, PREVIOUS, NULL);
girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_Right, NULL, sc_navigate, NORMAL, NEXT, NULL);
girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_Left, NULL, sc_navigate, NORMAL, PREVIOUS, NULL);
girara_shortcut_add(gsession, 0, GDK_Left, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL);
girara_shortcut_add(gsession, 0, GDK_Up, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL);
girara_shortcut_add(gsession, 0, GDK_Down, NULL, sc_navigate, FULLSCREEN, NEXT, NULL);
girara_shortcut_add(gsession, 0, GDK_Right, NULL, sc_navigate, FULLSCREEN, NEXT, NULL);
girara_shortcut_add(gsession, 0, GDK_k, NULL, sc_navigate_index, INDEX, UP, NULL);
girara_shortcut_add(gsession, 0, GDK_j, NULL, sc_navigate_index, INDEX, DOWN, NULL);
girara_shortcut_add(gsession, 0, GDK_h, NULL, sc_navigate_index, INDEX, COLLAPSE, NULL);
girara_shortcut_add(gsession, 0, GDK_l, NULL, sc_navigate_index, INDEX, EXPAND, NULL);
girara_shortcut_add(gsession, 0, GDK_space, NULL, sc_navigate_index, INDEX, SELECT, NULL);
girara_shortcut_add(gsession, 0, GDK_Return, NULL, sc_navigate_index, INDEX, SELECT, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_i, NULL, sc_recolor, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_R, NULL, sc_reload, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_r, NULL, sc_rotate, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_h, NULL, sc_scroll, NORMAL, LEFT, NULL);
girara_shortcut_add(gsession, 0, GDK_j, NULL, sc_scroll, NORMAL, DOWN, NULL);
girara_shortcut_add(gsession, 0, GDK_k, NULL, sc_scroll, NORMAL, UP, NULL);
girara_shortcut_add(gsession, 0, GDK_l, NULL, sc_scroll, NORMAL, RIGHT, NULL);
girara_shortcut_add(gsession, 0, GDK_Left, NULL, sc_scroll, NORMAL, LEFT, NULL);
girara_shortcut_add(gsession, 0, GDK_Up, NULL, sc_scroll, NORMAL, UP, NULL);
girara_shortcut_add(gsession, 0, GDK_Down, NULL, sc_scroll, NORMAL, DOWN, NULL);
girara_shortcut_add(gsession, 0, GDK_Right, NULL, sc_scroll, NORMAL, RIGHT, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_d, NULL, sc_scroll, NORMAL, HALF_DOWN, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_u, NULL, sc_scroll, NORMAL, HALF_UP, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_f, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_b, NULL, sc_scroll, NORMAL, FULL_UP, NULL);
girara_shortcut_add(gsession, 0, GDK_space, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL);
girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_space, NULL, sc_scroll, NORMAL, FULL_UP, NULL);
girara_shortcut_add(gsession, 0, GDK_n, NULL, sc_search, NORMAL, FORWARD, NULL);
girara_shortcut_add(gsession, 0, GDK_N, NULL, sc_search, NORMAL, BACKWARD, NULL);
girara_shortcut_add(gsession, 0, GDK_Tab, NULL, sc_toggle_index, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_Tab, NULL, sc_toggle_index, INDEX, 0, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_m, NULL, girara_sc_toggle_inputbar, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_F5, NULL, sc_toggle_fullscreen, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_F5, NULL, sc_toggle_fullscreen, FULLSCREEN, 0, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_n, NULL, girara_sc_toggle_statusbar, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_q, NULL, sc_quit, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_plus, NULL, sc_zoom, NORMAL, ZOOM_IN, NULL);
girara_shortcut_add(gsession, 0, GDK_plus, NULL, sc_zoom, FULLSCREEN, ZOOM_IN, NULL);
girara_shortcut_add(gsession, 0, GDK_minus, NULL, sc_zoom, NORMAL, ZOOM_OUT, NULL);
girara_shortcut_add(gsession, 0, GDK_minus, NULL, sc_zoom, FULLSCREEN, ZOOM_OUT, NULL);
girara_shortcut_add(gsession, 0, GDK_equal, NULL, sc_zoom, NORMAL, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, GDK_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_J, NULL, sc_navigate, NORMAL, NEXT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_K, NULL, sc_navigate, NORMAL, PREVIOUS, NULL);
girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_KEY_Right, NULL, sc_navigate, NORMAL, NEXT, NULL);
girara_shortcut_add(gsession, GDK_MOD1_MASK, GDK_KEY_Left, NULL, sc_navigate, NORMAL, PREVIOUS, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Page_Down, NULL, sc_navigate, NORMAL, NEXT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Page_Up, NULL, sc_navigate, NORMAL, PREVIOUS, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_J, NULL, sc_navigate, FULLSCREEN, NEXT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_K, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Left, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Up, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Down, NULL, sc_navigate, FULLSCREEN, NEXT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Right, NULL, sc_navigate, FULLSCREEN, NEXT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Page_Down, NULL, sc_navigate, FULLSCREEN, NEXT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Page_Up, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_k, NULL, sc_navigate_index, INDEX, UP, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_j, NULL, sc_navigate_index, INDEX, DOWN, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_h, NULL, sc_navigate_index, INDEX, COLLAPSE, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_l, NULL, sc_navigate_index, INDEX, EXPAND, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_L, NULL, sc_navigate_index, INDEX, EXPAND_ALL, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_H, NULL, sc_navigate_index, INDEX, COLLAPSE_ALL, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Up, NULL, sc_navigate_index, INDEX, UP, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Down, NULL, sc_navigate_index, INDEX, DOWN, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Left, NULL, sc_navigate_index, INDEX, COLLAPSE, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Right, NULL, sc_navigate_index, INDEX, EXPAND, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_space, NULL, sc_navigate_index, INDEX, SELECT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Return, NULL, sc_navigate_index, INDEX, SELECT, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_i, NULL, sc_recolor, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_R, NULL, sc_reload, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_r, NULL, sc_rotate, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_h, NULL, sc_scroll, NORMAL, LEFT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_j, NULL, sc_scroll, NORMAL, DOWN, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_k, NULL, sc_scroll, NORMAL, UP, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_l, NULL, sc_scroll, NORMAL, RIGHT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Left, NULL, sc_scroll, NORMAL, LEFT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Up, NULL, sc_scroll, NORMAL, UP, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Down, NULL, sc_scroll, NORMAL, DOWN, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Right, NULL, sc_scroll, NORMAL, RIGHT, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_d, NULL, sc_scroll, NORMAL, HALF_DOWN, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_u, NULL, sc_scroll, NORMAL, HALF_UP, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_f, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_b, NULL, sc_scroll, NORMAL, FULL_UP, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_space, NULL, sc_scroll, NORMAL, FULL_DOWN, NULL);
girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_KEY_space, NULL, sc_scroll, NORMAL, FULL_UP, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_n, NULL, sc_search, NORMAL, FORWARD, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_N, NULL, sc_search, NORMAL, BACKWARD, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Tab, NULL, sc_toggle_index, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_Tab, NULL, sc_toggle_index, INDEX, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_F5, NULL, sc_toggle_fullscreen, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_F5, NULL, sc_toggle_fullscreen, FULLSCREEN, 0, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_n, NULL, girara_sc_toggle_statusbar, NORMAL, 0, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_m, NULL, girara_sc_toggle_inputbar, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_q, NULL, sc_quit, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_plus, NULL, sc_zoom, NORMAL, ZOOM_IN, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_plus, NULL, sc_zoom, FULLSCREEN, ZOOM_IN, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_minus, NULL, sc_zoom, NORMAL, ZOOM_OUT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_minus, NULL, sc_zoom, FULLSCREEN, ZOOM_OUT, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, NORMAL, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, 0, "zI", sc_zoom, NORMAL, ZOOM_IN, NULL);
girara_shortcut_add(gsession, 0, 0, "zI", sc_zoom, FULLSCREEN, ZOOM_IN, NULL);
girara_shortcut_add(gsession, 0, 0, "zO", sc_zoom, NORMAL, ZOOM_OUT, NULL);
girara_shortcut_add(gsession, 0, 0, "zO", sc_zoom, FULLSCREEN, ZOOM_OUT, NULL);
girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, NORMAL, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, 0, "z0", sc_zoom, FULLSCREEN, ZOOM_ORIGINAL, NULL);
girara_shortcut_add(gsession, 0, GDK_equal, NULL, sc_zoom, NORMAL, ZOOM_SPECIFIC, NULL);
girara_shortcut_add(gsession, 0, GDK_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_SPECIFIC, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, NORMAL, ZOOM_SPECIFIC, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_equal, NULL, sc_zoom, FULLSCREEN, ZOOM_SPECIFIC, NULL);
/* mouse events */
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL, 0, NULL);
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL, 0, NULL);
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL, 0, NULL);
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL, 0, NULL);
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL_UP, UP, NULL);
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL_UP, UP, NULL);
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL);
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, FULLSCREEN, GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL);
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL_UP, UP, NULL);
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL_UP, UP, NULL);
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, NORMAL, GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL);
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, FULLSCREEN, GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL);
girara_mouse_event_add(gsession, 0, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, NORMAL, GIRARA_EVENT_BUTTON_PRESS, 0, NULL);
girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, NORMAL, GIRARA_EVENT_BUTTON_RELEASE, 0, NULL);
girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, 0, sc_mouse_scroll, NORMAL, GIRARA_EVENT_MOTION_NOTIFY, 0, NULL);
@ -168,7 +231,7 @@ config_load_default(zathura_t* zathura)
girara_shortcut_mapping_add(gsession, "change_mode", sc_change_mode);
girara_shortcut_mapping_add(gsession, "follow", sc_follow);
girara_shortcut_mapping_add(gsession, "goto", sc_goto);
girara_shortcut_mapping_add(gsession, "index_navigate", sc_navigate_index);
girara_shortcut_mapping_add(gsession, "navigate_index", sc_navigate_index);
girara_shortcut_mapping_add(gsession, "navigate", sc_navigate);
girara_shortcut_mapping_add(gsession, "quit", sc_quit);
girara_shortcut_mapping_add(gsession, "recolor", sc_recolor);
@ -185,7 +248,11 @@ config_load_default(zathura_t* zathura)
/* add argument mappings */
girara_argument_mapping_add(gsession, "bottom", BOTTOM);
girara_argument_mapping_add(gsession, "default", DEFAULT);
girara_argument_mapping_add(gsession, "collapse", COLLAPSE);
girara_argument_mapping_add(gsession, "collapse-all", COLLAPSE_ALL);
girara_argument_mapping_add(gsession, "down", DOWN);
girara_argument_mapping_add(gsession, "expand", EXPAND);
girara_argument_mapping_add(gsession, "expand-all", EXPAND_ALL);
girara_argument_mapping_add(gsession, "full-down", FULL_DOWN);
girara_argument_mapping_add(gsession, "full-up", FULL_UP);
girara_argument_mapping_add(gsession, "half-down", HALF_DOWN);
@ -206,7 +273,7 @@ config_load_default(zathura_t* zathura)
void
config_load_file(zathura_t* zathura, char* path)
{
if (zathura == NULL) {
if (zathura == NULL || path == NULL) {
return;
}

View file

@ -3,6 +3,9 @@
VERSION = 0.0.8.1
# the GTK version to use
ZATHURA_GTK_VERSION ?= 2
# paths
PREFIX ?= /usr
MANPREFIX ?= ${PREFIX}/share/man
@ -13,11 +16,11 @@ PLUGINDIR ?= ${PREFIX}/lib/zathura
# libs
# set this to 0 if you don't need to link against dl
GTK_INC ?= $(shell pkg-config --cflags gtk+-2.0)
GTK_LIB ?= $(shell pkg-config --libs gtk+-2.0 gthread-2.0)
GTK_INC ?= $(shell pkg-config --cflags gtk+-${ZATHURA_GTK_VERSION}.0)
GTK_LIB ?= $(shell pkg-config --libs gtk+-${ZATHURA_GTK_VERSION}.0 gthread-2.0)
GIRARA_INC ?= $(shell pkg-config --cflags girara-gtk2)
GIRARA_LIB ?= $(shell pkg-config --libs girara-gtk2)
GIRARA_INC ?= $(shell pkg-config --cflags girara-gtk${ZATHURA_GTK_VERSION})
GIRARA_LIB ?= $(shell pkg-config --libs girara-gtk${ZATHURA_GTK_VERSION})
SQLITE_INC ?= $(shell pkg-config --cflags sqlite3)
SQLITE_LIB ?= $(shell pkg-config --libs sqlite3)

View file

@ -234,9 +234,6 @@ zathura_db_set_fileinfo(zathura_database_t* db, const char* file, unsigned int
}
char* tmp = g_strdup_printf("%f", scale);
if (tmp == NULL) {
return false;
}
g_key_file_set_integer(db->history, file, KEY_PAGE, page);
g_key_file_set_integer(db->history, file, KEY_OFFSET, offset);

View file

@ -216,8 +216,6 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password
return NULL;
}
char* file_uri = NULL;
/* determine real path */
long path_max;
#ifdef PATH_MAX
@ -328,39 +326,24 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password
document->pages[page_id] = page;
}
/* install file monitor */
file_uri = g_filename_to_uri(real_path, NULL, NULL);
if (file_uri == NULL) {
goto error_free;
}
document->file_monitor.file = g_file_new_for_uri(file_uri);
if (document->file_monitor.file == NULL) {
goto error_free;
}
document->file_monitor.monitor = g_file_monitor_file(document->file_monitor.file, G_FILE_MONITOR_NONE, NULL, NULL);
if (document->file_monitor.monitor == NULL) {
goto error_free;
}
g_signal_connect(G_OBJECT(document->file_monitor.monitor), "changed", G_CALLBACK(cb_file_monitor), zathura->ui.session);
/* apply open adjustment */
int adjust_open = ADJUST_BESTFIT;
girara_setting_get(zathura->ui.session, "adjust-open", &adjust_open);
g_free(file_uri);
char* adjust_open = "best-fit";
document->adjust_mode = ADJUST_BESTFIT;
if (girara_setting_get(zathura->ui.session, "adjust-open", &(adjust_open)) == true) {
if (g_strcmp0(adjust_open, "best-fit") == 0) {
document->adjust_mode = ADJUST_BESTFIT;
} else if (g_strcmp0(adjust_open, "width") == 0) {
document->adjust_mode = ADJUST_WIDTH;
} else {
document->adjust_mode = ADJUST_NONE;
}
g_free(adjust_open);
}
return document;
error_free:
if (file_uri != NULL) {
g_free(file_uri);
}
free(real_path);
if (document != NULL && document->pages != NULL) {
@ -378,7 +361,7 @@ error_free:
zathura_plugin_error_t
zathura_document_free(zathura_document_t* document)
{
if (document == NULL) {
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
return false;
}
@ -393,6 +376,7 @@ zathura_document_free(zathura_document_t* document)
/* free document */
bool r = true;
if (document->functions.document_free == NULL) {
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
} else {
r = document->functions.document_free(document);
@ -410,11 +394,12 @@ zathura_document_free(zathura_document_t* document)
zathura_plugin_error_t
zathura_document_save_as(zathura_document_t* document, const char* path)
{
if (document == NULL || path == NULL) {
if (document == NULL || path == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
return false;
}
if (document->functions.document_save_as == NULL) {
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
return false;
}
@ -425,11 +410,12 @@ zathura_document_save_as(zathura_document_t* document, const char* path)
girara_tree_node_t*
zathura_document_index_generate(zathura_document_t* document, zathura_plugin_error_t* error)
{
if (document == NULL) {
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
return NULL;
}
if (document->functions.document_index_generate == NULL) {
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
return NULL;
}
@ -440,11 +426,12 @@ zathura_document_index_generate(zathura_document_t* document, zathura_plugin_err
girara_list_t*
zathura_document_attachments_get(zathura_document_t* document, zathura_plugin_error_t* error)
{
if (document == NULL) {
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
return NULL;
}
if (document->functions.document_attachments_get == NULL) {
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
return NULL;
}
@ -455,11 +442,13 @@ zathura_document_attachments_get(zathura_document_t* document, zathura_plugin_er
zathura_plugin_error_t
zathura_document_attachment_save(zathura_document_t* document, const char* attachment, const char* file)
{
if (document == NULL) {
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
}
if (document->functions.document_attachment_save == NULL) {
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}
@ -469,9 +458,9 @@ zathura_document_attachment_save(zathura_document_t* document, const char* attac
char*
zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t meta, zathura_plugin_error_t* error)
{
if (document == NULL) {
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
}
return NULL;
}
@ -480,6 +469,8 @@ zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
return NULL;
}
@ -489,12 +480,19 @@ zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t
zathura_page_t*
zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plugin_error_t* error)
{
if (document == NULL) {
if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) {
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
}
return NULL;
}
if (document->functions.page_get == NULL) {
girara_notify(document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}
return NULL;
}
@ -504,6 +502,12 @@ zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plu
page->number = page_id;
page->visible = false;
page->drawing_area = zathura_page_widget_new(page);
if (page->drawing_area == NULL) {
girara_error("couldn't create page widget");
zathura_page_free(page);
return NULL;
}
page->document = document;
unsigned int page_height = 0;
@ -519,13 +523,14 @@ zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plu
zathura_plugin_error_t
zathura_page_free(zathura_page_t* page)
{
if (page == NULL || page->document == NULL) {
return false;
if (page == NULL || page->document == NULL || page->document->zathura == NULL || page->document->zathura->ui.session == NULL) {
return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
}
if (page->document->functions.page_free == NULL) {
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
return false;
return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}
return page->document->functions.page_free(page);
@ -534,12 +539,20 @@ zathura_page_free(zathura_page_t* page)
girara_list_t*
zathura_page_search_text(zathura_page_t* page, const char* text, zathura_plugin_error_t* error)
{
if (page == NULL || page->document == NULL || text == NULL) {
if (page == NULL || page->document == NULL || text == NULL ||
page->document->zathura == NULL || page->document->zathura->ui.session == NULL) {
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
}
return NULL;
}
if (page->document->functions.page_search_text == NULL) {
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}
return NULL;
}
@ -549,12 +562,20 @@ zathura_page_search_text(zathura_page_t* page, const char* text, zathura_plugin_
girara_list_t*
zathura_page_links_get(zathura_page_t* page, zathura_plugin_error_t* error)
{
if (page == NULL || page->document == NULL) {
if (page == NULL || page->document == NULL || page->document->zathura == NULL
|| page->document->zathura->ui.session == NULL) {
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
}
return NULL;
}
if (page->document->functions.page_links_get == NULL) {
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}
return NULL;
}
@ -570,12 +591,20 @@ zathura_page_links_free(girara_list_t* UNUSED(list))
girara_list_t*
zathura_page_form_fields_get(zathura_page_t* page, zathura_plugin_error_t* error)
{
if (page == NULL || page->document == NULL) {
if (page == NULL || page->document == NULL || page->document->zathura == NULL
|| page->document->zathura->ui.session == NULL) {
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
}
return NULL;
}
if (page->document->functions.page_form_fields_get == NULL) {
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}
return NULL;
}
@ -585,42 +614,59 @@ zathura_page_form_fields_get(zathura_page_t* page, zathura_plugin_error_t* error
zathura_plugin_error_t
zathura_page_form_fields_free(girara_list_t* UNUSED(list))
{
return false;
return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}
girara_list_t*
zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error)
{
if (page == NULL || page->document == NULL) {
if (page == NULL || page->document == NULL || page->document->zathura == NULL
|| page->document->zathura->ui.session == NULL) {
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
}
return NULL;
}
if (page->document->functions.page_images_get == NULL) {
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
return false;
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}
return NULL;
}
return page->document->functions.page_images_get(page, error);
}
zathura_plugin_error_t
zathura_page_image_save(zathura_page_t* page, zathura_image_t* image, const char* file)
cairo_surface_t*
zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error)
{
if (page == NULL || page->document == NULL || image == NULL || file == NULL) {
return false;
if (page == NULL || page->document == NULL || image == NULL ||
page->document->zathura == NULL || page->document->zathura->ui.session ==
NULL) {
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
}
return NULL;
}
if (page->document->functions.page_image_save == NULL) {
if (page->document->functions.page_image_get_cairo == NULL) {
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
return false;
if (error != NULL) {
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}
return NULL;
}
return page->document->functions.page_image_save(page, image, file);
return page->document->functions.page_image_get_cairo(page, image, error);
}
char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t* error)
{
if (page == NULL || page->document == NULL) {
if (page == NULL || page->document == NULL || page->document->zathura == NULL || page->document->zathura->ui.session == NULL) {
if (error) {
*error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
}
@ -628,6 +674,7 @@ char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle,
}
if (page->document->functions.page_get_text == NULL) {
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
if (error) {
*error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
@ -641,11 +688,14 @@ char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle,
zathura_plugin_error_t
zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing)
{
if (page == NULL || page->document == NULL || cairo == NULL) {
if (page == NULL || page->document == NULL || cairo == NULL ||
page->document->zathura == NULL || page->document->zathura->ui.session ==
NULL) {
return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS;
}
if (page->document->functions.page_render_cairo == NULL) {
girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, "%s not implemented", __FUNCTION__);
girara_error("%s not implemented", __FUNCTION__);
return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED;
}

View file

@ -271,9 +271,9 @@ struct zathura_document_s
girara_list_t* (*page_images_get)(zathura_page_t* page, zathura_plugin_error_t* error);
/**
* Save image to a file
* Get the image
*/
zathura_plugin_error_t (*page_image_save)(zathura_page_t* page, zathura_image_t* image, const char* file);
cairo_surface_t* (*page_image_get_cairo)(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error);
/**
* Get text for selection
@ -300,14 +300,6 @@ struct zathura_document_s
* Document pages
*/
zathura_page_t** pages;
/**
* File monitor
*/
struct {
GFileMonitor* monitor; /**< File monitor */
GFile* file; /**< File for file monitor */
} file_monitor;
};
/**
@ -477,21 +469,21 @@ zathura_plugin_error_t zathura_page_form_fields_free(girara_list_t* list);
girara_list_t* zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error);
/**
* Save image
* Get image
*
* @param page Page
* @param image The image
* @param file Path to the file
* @return ZATHURA_PLUGIN_ERROR_OK when no error occured, otherwise see
* zathura_plugin_error_t
* @param image Image identifier
* @param error Set to an error value (see \ref zathura_plugin_error_t) if an
* error occured
* @return The cairo image surface or NULL if an error occured
*/
zathura_plugin_error_t zathura_page_image_save(zathura_page_t* page, zathura_image_t* image, const char* file);
cairo_surface_t* zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error);
/**
* Get text for selection
* @param page Page
* @param rectangle Selection
* @error Set to an error value (see \ref zathura_plugin_error_t) if an error
* @param error Set to an error value (see \ref zathura_plugin_error_t) if an error
* occured
* @return The selected text (needs to be deallocated with g_free)
*/

View file

@ -29,7 +29,10 @@ typedef struct zathura_page_widget_private_s {
#define ZATHURA_PAGE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZATHURA_TYPE_PAGE, zathura_page_widget_private_t))
static gboolean zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo);
#if GTK_MAJOR_VERSION == 2
static gboolean zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event);
#endif
static void zathura_page_widget_finalize(GObject* object);
static void zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
static void zathura_page_widget_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec);
@ -61,7 +64,11 @@ zathura_page_widget_class_init(ZathuraPageClass* class)
/* overwrite methods */
GtkWidgetClass* widget_class = GTK_WIDGET_CLASS(class);
#if GTK_MAJOR_VERSION == 3
widget_class->draw = zathura_page_widget_draw;
#else
widget_class->expose_event = zathura_page_widget_expose;
#endif
widget_class->size_allocate = zathura_page_widget_size_allocate;
widget_class->button_press_event = cb_zathura_page_widget_button_press_event;
widget_class->button_release_event = cb_zathura_page_widget_button_release_event;
@ -219,6 +226,7 @@ zathura_page_widget_get_property(GObject* object, guint prop_id, GValue* value,
}
}
#if GTK_MAJOR_VERSION == 2
static gboolean
zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event)
{
@ -232,14 +240,29 @@ zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event)
cairo_rectangle(cairo, event->area.x, event->area.y, event->area.width, event->area.height);
cairo_clip(cairo);
const gboolean ret = zathura_page_widget_draw(widget, cairo);
cairo_destroy(cairo);
return ret;
}
#endif
static gboolean
zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
{
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget);
g_static_mutex_lock(&(priv->lock));
#if GTK_MAJOR_VERSION == 2
const unsigned int page_height = widget->allocation.height;
const unsigned int page_width = widget->allocation.width;
#else
const unsigned int page_height = gtk_widget_get_allocated_height(widget);
const unsigned int page_width = gtk_widget_get_allocated_width(widget);
#endif
if (priv->surface != NULL) {
cairo_save(cairo);
unsigned int page_height = widget->allocation.height;
unsigned int page_width = widget->allocation.width;
switch (priv->page->document->rotate) {
case 90:
cairo_translate(cairo, page_width, 0);
@ -302,10 +325,11 @@ zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event)
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
/* draw position */
GdkColor color = priv->zathura->ui.colors.highlight_color;
if (idx == priv->search_current) {
cairo_set_source_rgba(cairo, 0, color.green, color.blue, transparency);
GdkColor color = priv->zathura->ui.colors.highlight_color_active;
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
} else {
GdkColor color = priv->zathura->ui.colors.highlight_color;
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
}
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
@ -325,7 +349,7 @@ zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event)
} else {
/* set background color */
cairo_set_source_rgb(cairo, 255, 255, 255);
cairo_rectangle(cairo, 0, 0, widget->allocation.width, widget->allocation.height);
cairo_rectangle(cairo, 0, 0, page_width, page_height);
cairo_fill(cairo);
bool render_loading = true;
@ -339,8 +363,8 @@ zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event)
cairo_set_font_size(cairo, 16.0);
cairo_text_extents_t extents;
cairo_text_extents(cairo, text, &extents);
double x = widget->allocation.width * 0.5 - (extents.width * 0.5 + extents.x_bearing);
double y = widget->allocation.height * 0.5 - (extents.height * 0.5 + extents.y_bearing);
double x = page_width * 0.5 - (extents.width * 0.5 + extents.x_bearing);
double y = page_height * 0.5 - (extents.height * 0.5 + extents.y_bearing);
cairo_move_to(cairo, x, y);
cairo_show_text(cairo, text);
}
@ -348,8 +372,6 @@ zathura_page_widget_expose(GtkWidget* widget, GdkEventExpose* event)
/* render real page */
render_page(priv->zathura->sync.render_thread, priv->page);
}
cairo_destroy(cairo);
g_static_mutex_unlock(&(priv->lock));
return FALSE;
}
@ -391,7 +413,11 @@ redraw_rect(ZathuraPage* widget, zathura_rectangle_t* rectangle)
grect.y = rectangle->y1;
grect.width = rectangle->x2 - rectangle->x1;
grect.height = rectangle->y2 - rectangle->y1;
#if (GTK_MAJOR_VERSION == 3)
gtk_widget_queue_draw_area(GTK_WIDGET(widget), grect.x, grect.y, grect.width, grect.height);
#else
gdk_window_invalidate_rect(GTK_WIDGET(widget)->window, &grect, TRUE);
#endif
}
static void

View file

@ -112,7 +112,7 @@ render_free(render_thread_t* render_thread)
}
if (render_thread->list) {
girara_list_free(render_thread->list);
girara_list_clear(render_thread->list);
}
if (render_thread->cond) {
@ -121,6 +121,10 @@ render_free(render_thread_t* render_thread)
g_cond_free(render_thread->cond);
}
if (render_thread->list) {
girara_list_free(render_thread->list);
}
if (render_thread->lock) {
g_mutex_free(render_thread->lock);
}

View file

@ -6,6 +6,7 @@
#include <girara/shortcuts.h>
#include <girara/utils.h>
#include <gtk/gtk.h>
#include <libgen.h>
#include "callbacks.h"
#include "shortcuts.h"
@ -57,6 +58,10 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument,
}
zathura->document->adjust_mode = argument->n;
if (argument->n == ADJUST_NONE) {
/* there is nothing todo */
goto error_ret;
}
/* get window size */
GtkAllocation allocation;
@ -112,6 +117,63 @@ sc_change_mode(girara_session_t* session, girara_argument_t* argument,
return false;
}
bool
sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, girara_event_t* UNUSED(event), unsigned int UNUSED(t))
{
g_return_val_if_fail(session != NULL, false);
g_return_val_if_fail(session->gtk.inputbar_entry != NULL, false);
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
g_return_val_if_fail(argument != NULL, false);
if (gtk_widget_get_visible(GTK_WIDGET(session->gtk.inputbar)) == false) {
gtk_widget_show(GTK_WIDGET(session->gtk.inputbar));
}
if (gtk_widget_get_visible(GTK_WIDGET(session->gtk.notification_area)) == true) {
gtk_widget_hide(GTK_WIDGET(session->gtk.notification_area));
}
gtk_widget_grab_focus(GTK_WIDGET(session->gtk.inputbar_entry));
if (argument->data != NULL) {
gtk_entry_set_text(session->gtk.inputbar_entry, (char*) argument->data);
/* append filepath */
if (argument->n == APPEND_FILEPATH && zathura->document != NULL) {
char* file_path = g_strdup(zathura->document->file_path);
if (file_path == NULL) {
return false;
}
char* path = dirname(file_path);
char* tmp = g_strdup_printf("%s%s/", (char*) argument->data, (g_strcmp0(path, "/") == 0) ? "" : path);
if (tmp == NULL) {
g_free(file_path);
return false;
}
gtk_entry_set_text(session->gtk.inputbar_entry, tmp);
g_free(tmp);
g_free(file_path);
}
/* we save the X clipboard that will be clear by "grab_focus" */
gchar* x_clipboard_text = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY));
gtk_editable_set_position(GTK_EDITABLE(session->gtk.inputbar_entry), -1);
if (x_clipboard_text != NULL) {
/* we reset the X clipboard with saved text */
gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), x_clipboard_text, -1);
g_free(x_clipboard_text);
}
}
return true;
}
bool
sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument),
girara_event_t* UNUSED(event), unsigned int UNUSED(t))
@ -120,7 +182,7 @@ sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument),
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
if (zathura->document == NULL) {
if (zathura->document == NULL || zathura->ui.session == NULL) {
return false;
}
@ -151,7 +213,7 @@ sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument),
/* ask for input */
if (show_links == true) {
girara_dialog(zathura->ui.session, "Follow link:", FALSE, NULL, (girara_callback_inputbar_activate_t) cb_sc_follow, NULL);
girara_dialog(zathura->ui.session, "Follow link:", FALSE, NULL, (girara_callback_inputbar_activate_t) cb_sc_follow, zathura->ui.session);
}
return false;
@ -188,42 +250,36 @@ sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_e
g_return_val_if_fail(argument != NULL, false);
g_return_val_if_fail(event != NULL, false);
static int x = 0;
static int y = 0;
if (zathura->document == NULL) {
return false;
}
/* scroll event */
if (event->type == GIRARA_EVENT_SCROLL) {
switch (event->direction) {
case GIRARA_SCROLL_UP:
argument->n = UP;
break;
case GIRARA_SCROLL_DOWN:
argument->n = DOWN;
break;
case GIRARA_SCROLL_LEFT:
argument->n = LEFT;
break;
case GIRARA_SCROLL_RIGHT:
argument->n = RIGHT;
break;
}
static int x = 0;
static int y = 0;
GtkAdjustment* x_adj = NULL;
GtkAdjustment* y_adj = NULL;
switch (event->type) {
/* scroll */
case GIRARA_EVENT_SCROLL_UP:
case GIRARA_EVENT_SCROLL_DOWN:
case GIRARA_EVENT_SCROLL_LEFT:
case GIRARA_EVENT_SCROLL_RIGHT:
return sc_scroll(session, argument, NULL, t);
} else if (event->type == GIRARA_EVENT_BUTTON_PRESS) {
/* drag */
case GIRARA_EVENT_BUTTON_PRESS:
x = event->x;
y = event->y;
} else if (event->type == GIRARA_EVENT_BUTTON_RELEASE) {
break;
case GIRARA_EVENT_BUTTON_RELEASE:
x = 0;
y = 0;
} else if (event->type == GIRARA_EVENT_MOTION_NOTIFY) {
GtkAdjustment* x_adj =
gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
GtkAdjustment* y_adj =
gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
break;
case GIRARA_EVENT_MOTION_NOTIFY:
x_adj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
y_adj =gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(session->gtk.view));
if (x_adj == NULL || y_adj == NULL) {
return false;
@ -234,6 +290,11 @@ sc_mouse_scroll(girara_session_t* session, girara_argument_t* argument, girara_e
x = event->x;
y = event->y;
break;
/* unhandled events */
default:
break;
}
return false;
@ -253,12 +314,11 @@ sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girara_eve
}
/* scroll event */
if (event->type == GIRARA_EVENT_SCROLL) {
switch (event->direction) {
case GIRARA_SCROLL_UP:
switch (event->type) {
case GIRARA_EVENT_SCROLL_UP:
argument->n = ZOOM_IN;
break;
case GIRARA_SCROLL_DOWN:
case GIRARA_EVENT_SCROLL_DOWN:
argument->n = ZOOM_OUT;
break;
default:
@ -268,9 +328,6 @@ sc_mouse_zoom(girara_session_t* session, girara_argument_t* argument, girara_eve
return sc_zoom(session, argument, NULL, t);
}
return false;
}
bool
sc_navigate(girara_session_t* session, girara_argument_t* argument,
girara_event_t* UNUSED(event), unsigned int t)
@ -318,23 +375,15 @@ sc_reload(girara_session_t* session, girara_argument_t* UNUSED(argument),
g_return_val_if_fail(session->global.data != NULL, false);
zathura_t* zathura = session->global.data;
if (zathura->document == NULL || zathura->document->file_path == NULL) {
if (zathura->file_monitor.file_path == NULL) {
return false;
}
/* save current document path and password */
char* path = g_strdup(zathura->document->file_path);
char* password = zathura->document->password ? g_strdup(zathura->document->password) : NULL;
/* close current document */
document_close(zathura);
document_close(zathura, true);
/* reopen document */
document_open(zathura, path, password);
/* clean up */
g_free(path);
g_free(password);
document_open(zathura, zathura->file_monitor.file_path, zathura->file_monitor.password);
return false;
}
@ -383,22 +432,24 @@ sc_scroll(girara_session_t* session, girara_argument_t* argument,
gdouble view_size = gtk_adjustment_get_page_size(adjustment);
gdouble value = gtk_adjustment_get_value(adjustment);
gdouble max = gtk_adjustment_get_upper(adjustment) - view_size;
unsigned int padding = zathura->global.page_padding;
float scroll_step = 40;
girara_setting_get(session, "scroll-step", &scroll_step);
gdouble new_value;
switch(argument->n) {
case FULL_UP:
new_value = value - view_size;
new_value = value - view_size - padding;
break;
case FULL_DOWN:
new_value = value + view_size;
new_value = value + view_size + padding;
break;
case HALF_UP:
new_value = value - (view_size / 2);
new_value = value - ((view_size + padding) / 2);
break;
case HALF_DOWN:
new_value = value + (view_size / 2);
new_value = value + ((view_size + padding) / 2);
break;
case LEFT:
case UP:
@ -547,14 +598,14 @@ sc_navigate_index(girara_session_t* session, girara_argument_t* argument,
}
break;
case COLLAPSE:
if(!gtk_tree_view_collapse_row(tree_view, path)
if (gtk_tree_view_collapse_row(tree_view, path) == FALSE
&& gtk_tree_path_get_depth(path) > 1) {
gtk_tree_path_up(path);
gtk_tree_view_collapse_row(tree_view, path);
}
break;
case DOWN:
if(gtk_tree_view_row_expanded(tree_view, path)) {
if (gtk_tree_view_row_expanded(tree_view, path) == TRUE) {
gtk_tree_path_down(path);
} else {
do {
@ -572,6 +623,15 @@ sc_navigate_index(girara_session_t* session, girara_argument_t* argument,
gtk_tree_path_down(path);
}
break;
case EXPAND_ALL:
gtk_tree_view_expand_all(tree_view);
break;
case COLLAPSE_ALL:
gtk_tree_view_collapse_all(tree_view);
gtk_tree_path_free(path);
path = gtk_tree_path_new_first();
gtk_tree_view_set_cursor(tree_view, path, NULL, FALSE);
break;
case SELECT:
cb_index_row_activated(tree_view, path, NULL, zathura);
return false;
@ -787,10 +847,18 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
}
/* zoom limitations */
if (zathura->document->scale < 0.1f) {
zathura->document->scale = 0.1f;
} else if (zathura->document->scale > 10.0f) {
zathura->document->scale = 10.0f;
int zoom_min_int = 10;
int zoom_max_int = 1000;
girara_setting_get(session, "zoom-min", &zoom_min_int);
girara_setting_get(session, "zoom-max", &zoom_max_int);
float zoom_min = zoom_min_int * 0.01f;
float zoom_max = zoom_max_int * 0.01f;
if (zathura->document->scale < zoom_min) {
zathura->document->scale = zoom_min;
} else if (zathura->document->scale > zoom_max) {
zathura->document->scale = zoom_max;
}
/* keep position */
@ -805,4 +873,3 @@ sc_zoom(girara_session_t* session, girara_argument_t* argument, girara_event_t*
return false;
}

View file

@ -38,6 +38,18 @@ bool sc_adjust_window(girara_session_t* session, girara_argument_t* argument, gi
*/
bool sc_change_mode(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
/**
* Shortcut function to focus the inputbar
*
* @param session The used girara session
* @param argument The argument
* @param event Girara event
* @param t Number of executions
* @return true No error occured
* @return false An error occured (abort execution)
*/
bool sc_focus_inputbar(girara_session_t* session, girara_argument_t* argument, girara_event_t* event, unsigned int t);
/**
* Follow a link
*

View file

@ -21,7 +21,7 @@ ZSOURCE += ../database-plain.c
endif
endif
all: ${PROJECT} run
all: ${PROJECT}
run: ${PROJECT}
$(QUIET)./${PROJECT}
@ -46,8 +46,8 @@ ${PROJECT}: options ${OBJECTS}
${OBJECTS}: ../config.mk
clean:
$(QUIET)rm -rf ${OBJECTS} ${PROJECT}
$(QUIET)rm -rf ${OBJECTS} ${PROJECT} *.gcno *.gcda
.PHONY: all options clean debug
.PHONY: all options clean debug run
-include $(wildcard .depend/*.dep)

View file

@ -7,7 +7,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "math.h"
#include <math.h>
#include "utils.h"
#include "zathura.h"
@ -263,7 +263,8 @@ recalc_rectangle(zathura_page_t* page, zathura_rectangle_t rectangle)
void
set_adjustment(GtkAdjustment* adjustment, gdouble value)
{
gtk_adjustment_set_value(adjustment, MAX(adjustment->lower, MIN(adjustment->upper - adjustment->page_size, value)));
gtk_adjustment_set_value(adjustment, MAX(gtk_adjustment_get_lower(adjustment),
MIN(gtk_adjustment_get_upper(adjustment) - gtk_adjustment_get_page_size(adjustment), value)));
}
void

View file

@ -74,7 +74,8 @@ void page_calculate_offset(zathura_page_t* page, page_offset_t* offset);
/**
* Rotate a rectangle by 0, 90, 180 or 270 degree
* @param rect the rectangle to rotate
*
* @param rectangle the rectangle to rotate
* @param degree rotation degree
* @param height the height of the enclosing rectangle
* @param width the width of the enclosing rectangle

View file

@ -1,27 +0,0 @@
.TH ZATHURA 1 zathura\-VERSION
.SH NAME
zathura \- a document viewer
.SH SYNOPSIS
.B zathura
.RB [options]
.RB [file]
.RB [password]
.SH DESCRIPTION
zathura is a highly customizable and functional document viewer.
.SH OPTIONS
.TP
.B "-e xid"
Reparents to window specified by xid.
.TP
.B "-c path"
Path to the config directory.
.TP
.B "-d path"
Path to the data directory.
.TP
.B "-p path"
Path to the plugin directory.

153
zathura.1.rst Normal file
View file

@ -0,0 +1,153 @@
=======
zathura
=======
-----------------
a document viewer
-----------------
:Author: pwmt.org
:Date: VERSION
:Manual section: 1
SYNOPOSIS
=========
| zathura [OPTION]...
| zathura [OPTION]... FILE
| zathura [OPTION]... FILE PASSWORD
DESCRIPTION
===========
zathura is a highly customizable and functional document viewer. It provides a
minimalistic and space saving interface as well as an easy usage that mainly
focuses on keyboard interaction.
OPTIONS
=======
-e [xid], --reparent [xid]
Reparents to window specified by xid
-c [path], --config-dir [path]
Path to the config directory
-d [path], --data-dir [path]
Path to the data directory
-p [path], --plugins-dir [path]
Path to the directory containing plugins
--fork
Fork into the background
MOUSE AND KEY BINDINGS
======================
J, K
Go to the next or previous page
h, k, j, l
Scroll to the left, down, up or right direction
Left, Down, Up, Right
Scroll to the left, down, up or right direction
^d, ^u
Scroll a half page down or up
^f, ^b, space, <S-space>
Scroll a full page down or up
gg, G, nG
Goto to the first, the last or to the nth page
^c, Escape
Abort
a, s
Adjust window in best-fit or width mode
/, ?
Search for text
n, N
Search for the next or previous result
o, O
Open document
f
Follow links
\:
Enter command
r
Rotate by 90 degrees
^i
Recolor
R
Reload document
Tab
Show index and switch to **Index mode**
F5
Switch to fullscreen mode
^m
Toggle inputbar
^n
Toggle statusbar
+, -, =
Zoom in, out or to the original size
zI, zO, z0
Zoom in, out or to the original size
n=
Zoom to size n
mX
Set a quickmark to a letter or number X
'X
Goto quickmark saved at letter or number X
q
Quit
Index mode
----------
k, j
Move to upper or lower entry
l
Expand entry
L
Expand all entries
h
Collapse entry
H
Collapse all entries
space, Return
Select and open entry
Mouse bindings
--------------
Scroll
Scroll up or down
^Scroll
Zoom in or out
Hold Button2
Pan the document
Button1
Follow link
COMMANDS
========
bmark
Save a bookmark
bdelete
Delete a bookmark
blist
List bookmarks
close
Close document
info
Show document information
help
Show help page
open, o
Open a document
print
Print document
write, write!
Save document (and force overwriting)
export
Export attachments
CONFIGURATION
=============
The default appearance and behaviour of zathura can be overwritten by modifying
the *zathurarc* file (default path: ~/.config/zathura/zathurarc). For a detailed
description please visit http://pwmt.org/projects/zathura/configuration

140
zathura.c
View file

@ -38,7 +38,12 @@ zathura_t*
zathura_init(int argc, char* argv[])
{
/* parse command line options */
#if (GTK_MAJOR_VERSION == 2)
GdkNativeWindow embed = 0;
#else
Window embed = 0;
#endif
gchar* config_dir = NULL, *data_dir = NULL, *plugin_path = NULL;
bool forkback = false;
GOptionEntry entries[] =
@ -55,7 +60,7 @@ zathura_init(int argc, char* argv[])
g_option_context_add_main_entries(context, entries, NULL);
GError* error = NULL;
if (!g_option_context_parse(context, &argc, &argv, &error))
if (g_option_context_parse(context, &argc, &argv, &error) == false)
{
printf("Error parsing command line arguments: %s\n", error->message);
g_option_context_free(context);
@ -86,7 +91,7 @@ zathura_init(int argc, char* argv[])
zathura->plugins.type_plugin_mapping = girara_list_new2(
(girara_free_function_t)zathura_type_plugin_mapping_free);
if (config_dir) {
if (config_dir != NULL) {
zathura->config.config_dir = g_strdup(config_dir);
} else {
gchar* path = girara_get_xdg_path(XDG_CONFIG);
@ -94,7 +99,7 @@ zathura_init(int argc, char* argv[])
g_free(path);
}
if (data_dir) {
if (data_dir != NULL) {
zathura->config.data_dir = g_strdup(config_dir);
} else {
gchar* path = girara_get_xdg_path(XDG_DATA);
@ -106,7 +111,7 @@ zathura_init(int argc, char* argv[])
g_mkdir_with_parents(zathura->config.config_dir, 0771);
g_mkdir_with_parents(zathura->config.data_dir, 0771);
if (plugin_path) {
if (plugin_path != NULL) {
girara_list_t* paths = girara_split_path_array(plugin_path);
girara_list_merge(zathura->plugins.path, paths);
girara_list_free(paths);
@ -163,6 +168,7 @@ zathura_init(int argc, char* argv[])
/* initialize girara */
zathura->ui.session->gtk.embed = embed;
if (girara_session_init(zathura->ui.session, "zathura") == false) {
goto error_out;
}
@ -172,11 +178,11 @@ zathura_init(int argc, char* argv[])
/* page view */
zathura->ui.page_widget = gtk_table_new(0, 0, TRUE);
if (!zathura->ui.page_widget) {
if (zathura->ui.page_widget == NULL) {
goto error_free;
}
g_signal_connect(G_OBJECT(zathura->ui.session->gtk.view), "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);
/* callbacks */
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
@ -186,7 +192,7 @@ zathura_init(int argc, char* argv[])
/* page view alignment */
zathura->ui.page_widget_alignment = gtk_alignment_new(0.5, 0.5, 0, 0);
if (!zathura->ui.page_widget_alignment) {
if (zathura->ui.page_widget_alignment == NULL) {
goto error_free;
}
gtk_container_add(GTK_CONTAINER(zathura->ui.page_widget_alignment), zathura->ui.page_widget);
@ -205,7 +211,7 @@ zathura_init(int argc, char* argv[])
}
zathura->ui.statusbar.page_number = girara_statusbar_item_add(zathura->ui.session, FALSE, FALSE, FALSE, NULL);
if (!zathura->ui.statusbar.page_number) {
if (zathura->ui.statusbar.page_number == NULL) {
goto error_free;
}
@ -221,28 +227,6 @@ zathura_init(int argc, char* argv[])
gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), zathura->global.page_padding);
gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), zathura->global.page_padding);
/* parse colors */
char* string_value = NULL;
girara_setting_get(zathura->ui.session, "recolor-darkcolor", &string_value);
if (string_value != NULL) {
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_dark_color));
g_free(string_value);
}
string_value = NULL;
girara_setting_get(zathura->ui.session, "recolor-lightcolor", &string_value);
if (string_value != NULL) {
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color));
g_free(string_value);
}
string_value = NULL;
girara_setting_get(zathura->ui.session, "highlight-color", &string_value);
if (string_value != NULL) {
gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color));
g_free(string_value);
}
/* database */
zathura->database = zathura_db_init(zathura->config.data_dir);
if (zathura->database == NULL) {
@ -260,18 +244,18 @@ zathura_init(int argc, char* argv[])
document_info->zathura = zathura;
document_info->path = argv[1];
document_info->password = (argc >= 2) ? argv[2] : NULL;
g_idle_add(document_info_open, document_info);
gdk_threads_add_idle(document_info_open, document_info);
}
return zathura;
error_free:
if (zathura->ui.page_widget) {
if (zathura->ui.page_widget != NULL) {
g_object_unref(zathura->ui.page_widget);
}
if (zathura->ui.page_widget_alignment) {
if (zathura->ui.page_widget_alignment != NULL) {
g_object_unref(zathura->ui.page_widget_alignment);
}
@ -289,7 +273,7 @@ zathura_free(zathura_t* zathura)
return;
}
document_close(zathura);
document_close(zathura, false);
if (zathura->ui.session != NULL) {
girara_session_destroy(zathura->ui.session);
@ -414,16 +398,46 @@ document_info_open(gpointer data)
bool
document_open(zathura_t* zathura, const char* path, const char* password)
{
if (!path) {
if (path == NULL) {
goto error_out;
}
zathura_document_t* document = zathura_document_open(zathura, path, password);
if (!document) {
if (document == NULL) {
goto error_out;
}
/* install file monitor */
gchar* file_uri = g_filename_to_uri(document->file_path, NULL, NULL);
if (file_uri == NULL) {
goto error_free;
}
zathura->file_monitor.file = g_file_new_for_uri(file_uri);
if (zathura->file_monitor.file == NULL) {
goto error_free;
}
zathura->file_monitor.monitor = g_file_monitor_file(zathura->file_monitor.file, G_FILE_MONITOR_NONE, NULL, NULL);
if (zathura->file_monitor.monitor == NULL) {
goto error_free;
}
g_signal_connect(G_OBJECT(zathura->file_monitor.monitor), "changed", G_CALLBACK(cb_file_monitor), zathura->ui.session);
zathura->file_monitor.file_path = g_strdup(document->file_path);
if (zathura->file_monitor.file_path == NULL) {
goto error_free;
}
if (document->password != NULL) {
zathura->file_monitor.password = g_strdup(document->password);
if (zathura->file_monitor.password == NULL) {
goto error_free;
}
}
zathura->document = document;
/* view mode */
@ -436,7 +450,7 @@ document_open(zathura_t* zathura, const char* path, const char* password)
/* threads */
zathura->sync.render_thread = render_init(zathura);
if (!zathura->sync.render_thread) {
if (zathura->sync.render_thread == NULL) {
goto error_free;
}
@ -447,17 +461,21 @@ document_open(zathura_t* zathura, const char* path, const char* password)
}
/* bookmarks */
if (!zathura_bookmarks_load(zathura, zathura->document->file_path)) {
girara_warning("Failed to load bookmarks for %s.\n", zathura->document->file_path);
}
zathura_bookmarks_load(zathura, zathura->document->file_path);
page_set_delayed(zathura, document->current_page_number - 1);
page_set_delayed(zathura, document->current_page_number);
cb_view_vadjustment_value_changed(NULL, zathura);
free(file_uri);
return true;
error_free:
if (file_uri != NULL) {
g_free(file_uri);
}
zathura_document_free(document);
error_out:
@ -473,7 +491,7 @@ document_save(zathura_t* zathura, const char* path, bool overwrite)
g_return_val_if_fail(path, false);
gchar* file_path = girara_fix_path(path);
if (!overwrite && g_file_test(file_path, G_FILE_TEST_EXISTS))
if ((overwrite == false) && g_file_test(file_path, G_FILE_TEST_EXISTS))
{
girara_error("File already exists: %s. Use :write! to overwrite it.", file_path);
g_free(file_path);
@ -488,20 +506,44 @@ document_save(zathura_t* zathura, const char* path, bool overwrite)
static void
remove_page_from_table(GtkWidget* page, gpointer permanent)
{
if (!permanent) {
if (permanent == false) {
g_object_ref(G_OBJECT(page));
}
gtk_container_remove(GTK_CONTAINER(page->parent), page);
gtk_container_remove(GTK_CONTAINER(gtk_widget_get_parent(page)), page);
}
bool
document_close(zathura_t* zathura)
document_close(zathura_t* zathura, bool keep_monitor)
{
if (!zathura->document) {
if (zathura == NULL || zathura->document == NULL) {
return false;
}
/* remove monitor */
if (keep_monitor == false) {
if (zathura->file_monitor.monitor != NULL) {
g_file_monitor_cancel(zathura->file_monitor.monitor);
g_object_unref(zathura->file_monitor.monitor);
zathura->file_monitor.monitor = NULL;
}
if (zathura->file_monitor.file != NULL) {
g_object_unref(zathura->file_monitor.file);
zathura->file_monitor.file = NULL;
}
if (zathura->file_monitor.file_path != NULL) {
g_free(zathura->file_monitor.file_path);
zathura->file_monitor.file_path = NULL;
}
if (zathura->file_monitor.password != NULL) {
g_free(zathura->file_monitor.password);
zathura->file_monitor.password = NULL;
}
}
/* store last seen page */
zathura_db_set_fileinfo(zathura->database, zathura->document->file_path, zathura->document->current_page_number,
/* zathura->document->offset TODO */ 0, zathura->document->scale,
@ -553,7 +595,7 @@ page_set_delayed(zathura_t* zathura, unsigned int page_id)
page_set_delayed_t* p = g_malloc(sizeof(page_set_delayed_t));
p->zathura = zathura;
p->page = page_id;
g_idle_add(page_set_delayed_impl, p);
gdk_threads_add_idle(page_set_delayed_impl, p);
return true;
}
@ -571,10 +613,12 @@ page_set(zathura_t* zathura, unsigned int page_id)
/* render page */
zathura_page_t* page = zathura->document->pages[page_id];
if (!page) {
if (page == NULL) {
goto error_out;
}
zathura->document->current_page_number = page_id;
page_offset_t offset;
page_calculate_offset(page, &offset);

View file

@ -7,4 +7,4 @@ Comment[de]=Ein minimalistischer Dokumenten-Betrachter
Exec=zathura %f
Terminal=false
Categories=Office;Viewer;
MimeType=application/pdf;application/postscript;image/vnd.djvu;
MimeType=application/pdf;application/postscript;application/eps;application/x-eps;image/eps;image/x-eps;image/vnd.djvu;

View file

@ -14,9 +14,9 @@ enum { NEXT, PREVIOUS, LEFT, RIGHT, UP, DOWN, BOTTOM, TOP, HIDE, HIGHLIGHT,
DELETE_LAST_WORD, DELETE_LAST_CHAR, DEFAULT, ERROR, WARNING, NEXT_GROUP,
PREVIOUS_GROUP, ZOOM_IN, ZOOM_OUT, ZOOM_ORIGINAL, ZOOM_SPECIFIC, FORWARD,
BACKWARD, ADJUST_BESTFIT, ADJUST_WIDTH, ADJUST_NONE, CONTINUOUS, DELETE_LAST,
ADD_MARKER, EVAL_MARKER, EXPAND, COLLAPSE, SELECT, GOTO_DEFAULT, GOTO_LABELS,
GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP, FULL_DOWN, NEXT_CHAR, PREVIOUS_CHAR,
DELETE_TO_LINE_START, APPEND_FILEPATH };
ADD_MARKER, EVAL_MARKER, EXPAND, EXPAND_ALL, COLLAPSE_ALL, COLLAPSE, SELECT,
GOTO_DEFAULT, GOTO_LABELS, GOTO_OFFSET, HALF_UP, HALF_DOWN, FULL_UP,
FULL_DOWN, NEXT_CHAR, PREVIOUS_CHAR, DELETE_TO_LINE_START, APPEND_FILEPATH };
/* forward declaration for types from document.h */
struct zathura_document_s;
@ -50,6 +50,7 @@ typedef struct zathura_s
GdkColor recolor_dark_color; /**< Dark color for recoloring */
GdkColor recolor_light_color; /**< Light color for recoloring */
GdkColor highlight_color; /**< Color for highlighting */
GdkColor highlight_color_active; /** Color for highlighting */
} colors;
GtkWidget *page_widget_alignment;
@ -108,6 +109,16 @@ typedef struct zathura_s
zathura_document_t* document; /**< The current document */
zathura_database_t* database; /**< The database */
/**
* File monitor
*/
struct {
GFileMonitor* monitor; /**< File monitor */
GFile* file; /**< File for file monitor */
gchar* file_path; /**< Save file path */
gchar* password; /**< Save password */
} file_monitor;
} zathura_t;
/**
@ -152,9 +163,10 @@ bool document_save(zathura_t* zathura, const char* path, bool overwrite);
* Closes the current opened document
*
* @param zathura The zathura session
* @param keep_monitor Set to true if monitor should be kept (sc_reload)
* @return If no error occured true, otherwise false, is returned.
*/
bool document_close(zathura_t* zathura);
bool document_close(zathura_t* zathura, bool keep_monitor);
/**
* Opens the page with the given number

View file

@ -6,4 +6,4 @@ Description: document viewer
Version: ${version}
URL: http://pwmt.org/projects/zathura
Cflags: ${INC_PATH}
Libs:
Requires.private: girara-gtk${GTK_VERSION} gtk+-${GTK_VERSION}-0

View file

@ -1,272 +1,28 @@
===========
=========
zathurarc
===========
=========
--------------------------
zathura configuration file
--------------------------
:Author: pwmt.org
:Date: 02.02.2012
:Date: VERSION
:Manual section: 5
SYNOPOSIS
=========
SYNOPSIS
========
/etc/zathurarc, $XDG_CONFIG_HOME/zathura/zathurarc
DESCRIPTION
===========
The zathurarc file is a simple plain text file that can be populated with
various commands to change the behaviour and the look of zathura which we are
going to describe in the following subsections. Each line (besides empty lines
and comments (which start with a prepended #)) is evaluated on its own, so it is
not possible to write multiple commands in one single line.
The *zathurarc* file is a simple plain text file that can be populated with
various commands to change the behaviour and the look of zathura.
The following commands can be used:
set - Changing the options
--------------------------
In addition to the build-in :set command zathura offers more options to be
changed and makes those changes permanent. To overwrite an option you just have
to add a line structured like the following:
::
set <option> <new value>
The option field has to be replaced with the name of the option that should be
changed and the new value field has to be replaced with the new value the option
should get. The type of the value can be one of the following:
* INT - An integer number
* FLOAT - A floating point number
* STRING - A character string
* BOOL - A boolean value (“true” for true, “false” for false)
In addition we advice you to check the List of options to get a more detailed
view of the options that can be changed and which values they should be set to.
The following example should give some deeper insight of how the set command can
be used:
::
set option1 5
set option2 2.0
set option3 hello
set option4 hello\ world
set option5 "hello world"
Possible options are:
page-padding
^^^^^^^^^^^^
The page padding defines the gap in pixels between each rendered page and can
not be changed during runtime.
* Value-type: Integer
* Default value: 1
pages-per-row
^^^^^^^^^^^^^
Defines the number of pages that are rendered next to each other in a row.
* Value-type: Integer
* Default value: 1
recolor-dark-color
^^^^^^^^^^^^^^^^^^
Defines the color value that is used to represent dark colors in recoloring mode
* Value-type: String
* Default value: #FFFFFF
recolor-light-color
^^^^^^^^^^^^^^^^^^^
Defines the color value that is used to represent light colors in recoloring mode
* Value-type: String
* Default value: #000000
zoom-step
^^^^^^^^^
Defines the amount of percent that is zoomed in or out on each comand.
* Value-type: Integer
* Default value: 10
map - Mapping a shortcut
------------------------
It is possible to map or remap new key bindings to shortcut functions which
allows a high level of customization. The *:map* command can also be used in
the *zathurarc* file to make those changes permanent::
map [mode] <binding> <shortcut function> <argument>
Mode
^^^^
The *map* command expects several arguments where only the *binding* as well as
the *shortcut-function* argument is required. Since zathura uses several odes it
is possible to map bindings only for a specific mode by passing the *mode*
argument which can take one of the following values:
* normal (default)
* visual
* insert
* index
The brackets around the value are mandatory.
Single key binding
^^^^^^^^^^^^^^^^^^
The (possible) second argument defines the used key binding that should be
mapped to the shortcut function and is structured like the following. On the one
hand it is possible to just assign single letters, numbers or signs to it::
map a shortcut_function
map b shortcut_function
map c shortcut_function
map 1 shortcut_function
map 2 shortcut_function
map 3 shortcut_function
map ! shortcut_function
map ? shortcut_function
Using modifiers
^^^^^^^^^^^^^^^
It is also possible to use modifiers like the *Control* or *Alt* button on the
keyboard. It is possible to use the following modifiers:
* A - *Alt*
* C - *Control*
* S - *Shift*
Now it is required to define the *binding* with the following structure::
map <A-a> shortcut_function
map <C-a> shortcut_function
Special keys
^^^^^^^^^^^^
zathura allows it also to assign keys like the space bar or the tab button which
also have to be written in between angle brackets. The following special keys
are currently available:
========== =================
Identifier Description
========== =================
BackSpace *Back space*
CapsLock *Caps lock*
Esc *Escape*
Down *Arrow down*
Up *Arrow up*
Left *Arrow left*
Right *A7row right*
F1 *F1*
F2 *F2*
F3 *F3*
F4 *F4*
F5 *F5*
F6 *F6*
F7 *F7*
F8 *F8*
F9 *F9*
F10 *F10*
F11 *F11*
F12 *F12*
PageDown *Page Down*
PageUp *Page Up*
Return *Return*
Space *Space*
Super *Windows button*
Tab *Tab*
========== =================
Of course it is possible to combine those special keys with a modifier. The
usage of those keys should be explained by the following examples::
map <Space> shortcut_function
map <C-Space> shortcut_function
Mouse buttons
^^^^^^^^^^^^^
It is also possible to map mouse buttons to shortcuts by using the following
special keys:
========== ================
Identifier Description
========== ================
Button1 *Mouse button 1*
Button2 *Mouse button 2*
Button3 *Mouse button 3*
Button4 *Mouse button 4*
Button5 *Mouse button 5*
========== ================
They can also be combined with modifiers::
map <Button1> shortcut_function
map <C-Button1> shortcut_function
Buffer commands
^^^^^^^^^^^^^^^
If a mapping does not match one of the previous definition but is still a valid
mapping it will be mapped as a buffer command::
map abc quit
map test quit
Shortcut functions
^^^^^^^^^^^^^^^^^^
The following shortcut functions can be mapped:
================= ====================================
Function Description
================= ====================================
abort *Switch back to normal mode*
adjust *Adjust page width*
change_mode *Change current mode*
focus_inputbar *Focus inputbar*
follow *Follow a link*
goto *Go to a certain page*
index_navigate *Navigate through the index*
naviate *Navigate to the next/previous page*
quit *Quit zathura*
recolor *Recolor the pages*
reload *Reload the document*
rotate *Rotate the page*
scroll *Scroll*
search *Search next/previous item*
toggle_fullscreen *Toggle fullscreen*
toggle_index *Show or hide index*
toggle_inputbar *Show or hide inputbar*
toggle_statusbar *Show or hide statusbar*
zoom *Zoom in or out*
================= ====================================
Pass arguments
^^^^^^^^^^^^^^
Some shortcut function require or have optional arguments which influence the
behaviour of them. Those can be passed as the last argument::
map <C-i> zoom in
map <C-o> zoom out
unmap - Removing a shortcut
---------------------------
In addition to mapping or remaping custom key bindings it is possible to remove
existing ones by using the *:unmap* command. The command is used in the
following way (the explanation of the parameters is described in the *map*
section of this document::
unmap [mode] <binding>
EXAMPLE
=======
::
# zathurarc
You can find a detailed description of *zathurarc* on the following website:
http://pwmt.org/projects/zathura/configuration
SEE ALSO
========