Commit 4879edd4 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Imported Upstream version 0.3.0

parent 07fc7eb4
......@@ -25,3 +25,5 @@ Diego Joss <djego.joss@gmail.com>
Ignas Anikevicius <anikevicius@gmail.com>
Kamil Smardzewski <roderyk197@gmail.com>
oblique
Maxime Chéramy <maxime.cheramy@gmail.com>
Alexander Shabalin <shabalyn.a@gmail.com>
......@@ -4,7 +4,7 @@ include config.mk
include colors.mk
include common.mk
OSOURCE = $(filter-out css-definitions.c, $(filter-out dbus-interface-definitions.c, $(wildcard *.c))) $(wildcard synctex/*.c)
OSOURCE = $(filter-out css-definitions.c, $(filter-out dbus-interface-definitions.c, $(wildcard *.c)))
HEADER = $(wildcard *.h) $(wildcard synctex/*.h)
HEADERINST = version.h document.h macros.h page.h types.h plugin-api.h links.h
......@@ -23,6 +23,22 @@ LIBS += $(MAGIC_LIB)
CPPFLAGS += -DWITH_MAGIC
endif
ifneq ($(WITH_SYSTEM_SYNCTEX),0)
INCS += $(SYNCTEX_INC)
LIBS += $(SYNCTEX_LIB)
else
INCS += $(ZLIB_INC)
LIBS += $(ZLIB_LIB)
SOURCE += $(wildcard synctex/*.c)
ifeq (,$(findstring -Isynctex,${CPPFLAGS}))
CPPFLAGS += -Isynctex
endif
ifeq (,$(findstring -DSYNCTEX_VERBOSE=0,${CPPFLAGS}))
CPPFLAGS += -DSYNCTEX_VERBOSE=0
endif
endif
ifneq ($(wildcard ${VALGRIND_SUPPRESSION_FILE}),)
VALGRIND_ARGUMENTS += --suppressions=${VALGRIND_SUPPRESSION_FILE}
endif
......@@ -36,13 +52,6 @@ endif
ifeq (,$(findstring -DLOCALEDIR,${CPPFLAGS}))
CPPFLAGS += -DLOCALEDIR=\"${LOCALEDIR}\"
endif
ifeq (,$(findstring -Isynctex,${CPPFLAGS}))
CPPFLAGS += -Isynctex
endif
ifeq (,$(findstring -DSYNCTEX_VERBOSE=0,${CPPFLAGS}))
CPPFLAGS += -DSYNCTEX_VERBOSE=0
endif
OBJECTS = $(patsubst %.c, %.o, $(SOURCE)) dbus-interface-definitions.o css-definitions.o
DOBJECTS = $(patsubst %.o, %.do, $(OBJECTS))
......@@ -95,7 +104,7 @@ css-definitions.c: data/zathura.css_t
%.do: %.c
$(call colorecho,CC,$<)
@mkdir -p .depend
$(QUIET) mkdir -p $(shell dirname .depend/$@.dep)
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
${OBJECTS} ${DOBJECTS}: config.mk version.h \
......@@ -118,6 +127,8 @@ clean:
version.h.tmp \
dbus-interface-definitions.c \
dbus-interface-definitions.c.tmp \
css-definitions.c \
css-definitions.c.tmp \
*gcda *gcno $(PROJECT).info gcov *.tmp \
.version-checks
$(QUIET)$(MAKE) -C tests clean
......@@ -198,7 +209,12 @@ install-dbus:
$(QUIET)mkdir -m 755 -p $(DESTDIR)$(DBUSINTERFACEDIR)
$(QUIET)install -m 644 data/org.pwmt.zathura.xml $(DESTDIR)$(DBUSINTERFACEDIR)
install: all install-headers install-manpages install-dbus
install-appdata:
$(call colorecho,INSTALL,"AppData file")
$(QUIET)mkdir -m 755 -p $(DESTDIR)$(APPDATAPREFIX)
$(QUIET)install -m 644 data/$(PROJECT).appdata.xml $(DESTDIR)$(APPDATAPREFIX)
install: all install-headers install-manpages install-dbus install-appdata
$(call colorecho,INSTALL,"executeable file")
$(QUIET)mkdir -m 755 -p ${DESTDIR}${PREFIX}/bin
$(QUIET)install -m 755 ${PROJECT} ${DESTDIR}${PREFIX}/bin
......@@ -224,6 +240,8 @@ uninstall: uninstall-headers
$(QUIET)rm -f ${DESTDIR}${DESKTOPPREFIX}/${PROJECT}.desktop
$(call colorecho,UNINSTALL,"D-Bus interface definitions")
$(QUIET)rm -f $(DESTDIR)$(DBUSINTERFACEDIR)/org.pwmt.zathura.xml
$(call colorecho,UNINSTALL,"AppData file")
$(QUIET)rm -f $(DESTDIR)$(APPDATAPREFIX)/$(PROJECT).appdata.xml
$(MAKE) -C po uninstall
-include $(wildcard .depend/*.dep)
......
......@@ -20,6 +20,8 @@
#include "page-widget.h"
#include "page.h"
#include "adjustment.h"
#include "synctex.h"
#include "dbus-interface.h"
gboolean
cb_destroy(GtkWidget* UNUSED(widget), zathura_t* zathura)
......@@ -49,7 +51,7 @@ cb_buffer_changed(girara_session_t* session)
}
}
static void
void
update_visible_pages(zathura_t* zathura)
{
const unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
......@@ -508,6 +510,23 @@ cb_setting_recolor_keep_hue_change(girara_session_t* session, const char* name,
}
}
void
cb_setting_recolor_keep_reverse_video_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;
const bool bool_value = *((bool*) value);
if (zathura->sync.render_thread != NULL && zathura_renderer_recolor_reverse_video_enabled(zathura->sync.render_thread) != bool_value) {
zathura_renderer_enable_recolor_reverse_video(zathura->sync.render_thread, bool_value);
render_all(zathura);
}
}
bool
cb_unknown_command(girara_session_t* session, const char* input)
......@@ -556,13 +575,18 @@ cb_page_widget_text_selected(ZathuraPage* page, const char* text, void* data)
if (selection != NULL) {
gtk_clipboard_set_text(gtk_clipboard_get(*selection), text, -1);
char* stripped_text = g_strdelimit(g_strdup(text), "\n\t\r\n", ' ');
char* escaped_text = g_markup_printf_escaped(
_("Copied selected text to clipboard: %s"), stripped_text);
g_free(stripped_text);
bool notification = true;
girara_setting_get(zathura->ui.session, "selection-notification", &notification);
if (notification == true) {
char* stripped_text = g_strdelimit(g_strdup(text), "\n\t\r\n", ' ');
char* escaped_text = g_markup_printf_escaped(
_("Copied selected text to clipboard: %s"), stripped_text);
g_free(stripped_text);
girara_notify(zathura->ui.session, GIRARA_INFO, "%s", escaped_text);
g_free(escaped_text);
girara_notify(zathura->ui.session, GIRARA_INFO, "%s", escaped_text);
g_free(escaped_text);
}
}
g_free(selection);
......@@ -597,3 +621,38 @@ cb_page_widget_link(ZathuraPage* page, void* data)
gdk_window_set_cursor(window, cursor);
g_object_unref(cursor);
}
void
cb_page_widget_scaled_button_release(ZathuraPage* page_widget, GdkEventButton* event,
void* data)
{
if (event->button != 1 || !(event->state & GDK_CONTROL_MASK)) {
return;
}
zathura_t* zathura = data;
bool synctex = false;
girara_setting_get(zathura->ui.session, "synctex", &synctex);
if (synctex == false) {
return;
}
zathura_page_t* page = zathura_page_widget_get_page(page_widget);
if (zathura->dbus != NULL) {
zathura_dbus_edit(zathura->dbus, zathura_page_get_index(page), event->x, event->y);
}
char* editor = NULL;
girara_setting_get(zathura->ui.session, "synctex-editor-command", &editor);
if (editor == NULL || *editor == '\0') {
g_free(editor);
return;
}
synctex_edit(editor, page, event->x, event->y);
g_free(editor);
}
......@@ -176,6 +176,17 @@ void cb_setting_recolor_change(girara_session_t* session, const char* name,
void cb_setting_recolor_keep_hue_change(girara_session_t* session, const char* name,
girara_setting_type_t type, void* value, void* data);
/**
* Emitted when the 'recolor-reverse-video' setting is changed
*
* @param session Girara session
* @param name Name of the setting ("recolor")
* @param type Type of the setting (BOOLEAN)
* @param value New value
* @param data Custom data
*/
void cb_setting_recolor_keep_reverse_video_change(girara_session_t* session,
const char* name, girara_setting_type_t type, void* value, void* data);
/**
* Unknown command handler which is used to handle the strict numeric goto
......@@ -200,8 +211,14 @@ void cb_page_widget_text_selected(ZathuraPage* page, const char* text,
void cb_page_widget_image_selected(ZathuraPage* page, GdkPixbuf* pixbuf,
void* data);
void cb_page_widget_scaled_button_release(ZathuraPage* page,
GdkEventButton* event, void* data);
void
cb_page_widget_link(ZathuraPage* page, void* data);
void
update_visible_pages(zathura_t* zathura);
#endif // CALLBACKS_H
......@@ -10,6 +10,7 @@ COLOR_NORMAL = `$(TPUT) sgr0`
COLOR_ACTION = `$(TPUT) bold``$(TPUT) setaf 3`
COLOR_COMMENT = `$(TPUT) bold``$(TPUT) setaf 2`
COLOR_BRACKET = `$(TPUT) setaf 4`
CC += -fdiagnostics-color=always
define colorecho
@echo $(COLOR_BRACKET)" ["$(COLOR_ACTION)$1$(COLOR_BRACKET)"] "$(COLOR_COMMENT)$2$(COLOR_BRACKET) $(COLOR_NORMAL)
endef
......
......@@ -523,10 +523,16 @@ cmd_exec(girara_session_t* session, girara_list_t* argument_list)
const char* path = zathura_document_get_path(zathura->document);
GIRARA_LIST_FOREACH(argument_list, char*, iter, value)
char* r = girara_replace_substring(value, "$FILE", path);
if (r != NULL) {
girara_list_iterator_set(iter, r);
}
char* r = girara_replace_substring(value, "$FILE", path);
if (r != NULL) {
char* s = girara_replace_substring(r, "%", path);
g_free(r);
if (s != NULL) {
girara_list_iterator_set(iter, s);
}
}
GIRARA_LIST_FOREACH_END(argument_list, char*, iter, value);
}
......
......@@ -31,10 +31,12 @@ cb_jumplist_change(girara_session_t* session, const char* name,
g_return_if_fail(name != NULL);
zathura_t* zathura = session->global.data;
if (*(int *)value < 0) {
const int* ivalue = value;
if (*ivalue < 0) {
zathura->jumplist.max_size = 0;
} else {
zathura->jumplist.max_size = *(int *)value;
zathura->jumplist.max_size = *ivalue;
}
if (zathura->jumplist.list != NULL && zathura->jumplist.size != 0) {
......@@ -184,6 +186,8 @@ config_load_default(zathura_t* zathura)
bool_value = false;
girara_setting_add(gsession, "recolor-keephue", &bool_value, BOOLEAN, false, _("When recoloring keep original hue and adjust lightness only"), cb_setting_recolor_keep_hue_change, NULL);
bool_value = false;
girara_setting_add(gsession, "recolor-reverse-video", &bool_value, BOOLEAN, false, _("When recoloring keep original image colors"), cb_setting_recolor_keep_reverse_video_change, NULL);
bool_value = false;
girara_setting_add(gsession, "scroll-wrap", &bool_value, BOOLEAN, false, _("Wrap scrolling"), NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "scroll-page-aware", &bool_value, BOOLEAN, false, _("Page aware scrolling"), NULL, NULL);
......@@ -221,12 +225,16 @@ config_load_default(zathura_t* zathura)
girara_setting_add(gsession, "window-title-page", &bool_value, BOOLEAN, false, _("Display the page number in the window title"), NULL, NULL);
bool_value = false;
girara_setting_add(gsession, "statusbar-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the statusbar"), NULL, NULL);
bool_value = false;
bool_value = true;
girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL);
string_value = "";
girara_setting_add(gsession, "synctex-editor-command", string_value, STRING, false, _("Synctex editor command"), NULL, NULL);
bool_value = true;
girara_setting_add(gsession, "dbus-service", &bool_value, BOOLEAN, false, _("Enable D-Bus service"), NULL, NULL);
string_value = "primary";
girara_setting_add(gsession, "selection-clipboard", string_value, STRING, false, _("The clipboard into which mouse-selected data will be written"), NULL, NULL);
bool_value = true;
girara_setting_add(gsession, "selection-notification", &bool_value, BOOLEAN, false, _("Enable notification after selecting text"), NULL, NULL);
#define DEFAULT_SHORTCUTS(mode) \
girara_shortcut_add(gsession, 0, GDK_KEY_a, NULL, sc_adjust_window, (mode), ZATHURA_ADJUST_BESTFIT, NULL); \
......@@ -315,16 +323,18 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add(gsession, 0, 0, "zZ", sc_zoom, (mode), ZOOM_SPECIFIC, NULL);
#define DEFAULT_MOUSE_EVENTS(mode) \
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_SCROLL_UP, UP, NULL); \
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL); \
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_SCROLL_LEFT, LEFT, NULL); \
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_SCROLL_RIGHT, RIGHT, NULL); \
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_SCROLL_UP, UP, NULL); \
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL); \
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_SCROLL_LEFT, LEFT, NULL); \
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_SCROLL_RIGHT, RIGHT, NULL); \
girara_mouse_event_add(gsession, 0, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_SCROLL_BIDIRECTIONAL, BIDIRECTIONAL, NULL); \
\
girara_mouse_event_add(gsession, GDK_SHIFT_MASK, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_SCROLL_UP, LEFT, NULL); \
girara_mouse_event_add(gsession, GDK_SHIFT_MASK, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_SCROLL_DOWN, RIGHT, NULL); \
\
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, (mode), GIRARA_EVENT_SCROLL_UP, UP, NULL); \
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, (mode), GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL); \
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, (mode), GIRARA_EVENT_SCROLL_UP, UP, NULL); \
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, (mode), GIRARA_EVENT_SCROLL_DOWN, DOWN, NULL); \
girara_mouse_event_add(gsession, GDK_CONTROL_MASK, 0, sc_mouse_zoom, (mode), GIRARA_EVENT_SCROLL_BIDIRECTIONAL, BIDIRECTIONAL, NULL); \
girara_mouse_event_add(gsession, 0, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, (mode), GIRARA_EVENT_BUTTON_PRESS, 0, NULL); \
girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, GIRARA_MOUSE_BUTTON2, sc_mouse_scroll, (mode), GIRARA_EVENT_BUTTON_RELEASE, 0, NULL); \
girara_mouse_event_add(gsession, GDK_BUTTON2_MASK, 0, sc_mouse_scroll, (mode), GIRARA_EVENT_MOTION_NOTIFY, 0, NULL); \
......@@ -416,6 +426,7 @@ config_load_default(zathura_t* zathura)
girara_inputbar_command_add(gsession, "close", NULL, cmd_close, NULL, _("Close current file"));
girara_inputbar_command_add(gsession, "info", NULL, cmd_info, NULL, _("Show file information"));
girara_inputbar_command_add(gsession, "exec", NULL, cmd_exec, NULL, _("Execute a command"));
girara_inputbar_command_add(gsession, "!", NULL, cmd_exec, NULL, _("Execute a command")); /* like vim */
girara_inputbar_command_add(gsession, "help", NULL, cmd_help, NULL, _("Show help"));
girara_inputbar_command_add(gsession, "open", "o", cmd_open, cc_open, _("Open document"));
girara_inputbar_command_add(gsession, "quit", "q", cmd_quit, NULL, _("Close zathura"));
......
......@@ -5,8 +5,8 @@
PROJECT = zathura
ZATHURA_VERSION_MAJOR = 0
ZATHURA_VERSION_MINOR = 2
ZATHURA_VERSION_REV = 9
ZATHURA_VERSION_MINOR = 3
ZATHURA_VERSION_REV = 0
# If the API changes, the API version and the ABI version have to be bumped.
ZATHURA_API_VERSION = 2
# If the ABI breaks for any reason, this has to be bumped.
......@@ -18,7 +18,7 @@ VERSION = ${ZATHURA_VERSION_MAJOR}.${ZATHURA_VERSION_MINOR}.${ZATHURA_VERSION_RE
# girara
GIRARA_VERSION_CHECK ?= 1
GIRARA_MIN_VERSION = 0.2.2
GIRARA_MIN_VERSION = 0.2.3
GIRARA_PKG_CONFIG_NAME = girara-gtk3
# glib
GLIB_VERSION_CHECK ?= 1
......@@ -33,6 +33,10 @@ GTK_PKG_CONFIG_NAME = gtk+-3.0
# To disable support for the sqlite backend set WITH_SQLITE to 0.
WITH_SQLITE ?= $(shell (pkg-config --atleast-version=3.5.9 sqlite3 && echo 1) || echo 0)
# synctex
# To use the embedded copy of the syntex parser set WITH_SYSTEM_SYNCTEX to 0.
WITH_SYSTEM_SYNCTEX ?= $(shell (pkg-config synctex && echo 1) || echo 0)
# mimetype detection
# To disable support for mimetype detction with libmagic set WITH_MAGIC to 0.
WITH_MAGIC ?= 1
......@@ -41,6 +45,7 @@ WITH_MAGIC ?= 1
PREFIX ?= /usr
MANPREFIX ?= ${PREFIX}/share/man
DESKTOPPREFIX ?= ${PREFIX}/share/applications
APPDATAPREFIX ?= ${PREFIX}/share/appdata
LIBDIR ?= ${PREFIX}/lib
INCLUDEDIR ?= ${PREFIX}/include
DBUSINTERFACEDIR ?= ${PREFIX}/share/dbus-1/interfaces
......@@ -77,11 +82,16 @@ MAGIC_INC ?=
MAGIC_LIB ?= -lmagic
endif
ifneq ($(WITH_SYSTEM_SYNCTEX),0)
SYNCTEX_INC ?= $(shell pkg-config --cflags synctex)
SYNCTEX_LIB ?= $(shell pkg-config --libs synctex)
else
ZLIB_INC ?= $(shell pkg-config --cflags zlib)
ZLIB_LIB ?= $(shell pkg-config --libs zlib)
endif
INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC} ${GLIB_INC} $(ZLIB_INC)
LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} ${GLIB_LIB} $(ZLIB_LIB) -lpthread -lm
INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC} ${GLIB_INC}
LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} ${GLIB_LIB} -lpthread -lm
# flags
CFLAGS += -std=c99 -pedantic -Wall -Wno-format-zero-length -Wextra $(INCS)
......
/* See LICENSE file for license and copyright information */
#define _BSD_SOURCE
#define _DEFAULT_SOURCE
#define _XOPEN_SOURCE 700
#include "content-type.h"
......
......@@ -3,6 +3,13 @@
#ifndef ZATHURA_CONTENT_TYPE_H
#define ZATHURA_CONTENT_TYPE_H
/**
* "Guess" the content type of a file. Various methods are tried depending on
* the available libraries.
*
* @param path file name
* @return content type of path
*/
const char* guess_content_type(const char* path);
#endif
......@@ -28,5 +28,11 @@
<property type='s' name='filename' access='read' />
<property type='u' name='pagenumber' access='read' />
<property type='u' name='numberofpages' access='read' />
<!-- Open editor with given input file at line and column. -->
<signal name='Edit'>
<arg type='s' name='input' direction='out' />
<arg type='u' name='line' direction='out' />
<arg type='u' name='column' direction='out' />
</signal>
</interface>
</node>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2014 pwmt.org -->
<application>
<id type="desktop">zathura.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>Zlib</project_license>
<description>
<p>
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. zathura makes it
possible to completely view and navigate through documents without using a
mouse.
</p>
<p>
Other features include:
<ul>
<li>SyncTeX forward and backward synchronization support.</li>
<li>Quickmarks and bookmarks.</li>
<li>Automatic document reloading.</li>
</ul>
</p>
</description>
<url type="homepage">http://pwmt.org/projects/zathura</url>
<screenshots>
<screenshot type="default">http://pwmt.org/projects/zathura/img/zathura-cover.png</screenshot>
<screenshot>http://pwmt.org/projects/zathura/img/zathura-completion.png</screenshot>
<screenshot>http://pwmt.org/projects/zathura/img/zathura-follow.png</screenshot>
<screenshot>http://pwmt.org/projects/zathura/img/zathura-bookmarks.png</screenshot>
</screenshots>
<updatecontact>zathura@lists.pwmt.org</updatecontact>
</application>
......@@ -7,6 +7,7 @@
#include <string.h>
#include "database-sqlite.h"
#include "utils.h"
static void zathura_database_interface_init(ZathuraDatabaseInterface* iface);
static void io_interface_init(GiraraInputHistoryIOInterface* iface);
......@@ -126,6 +127,7 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
"vadj_ratio FLOAT,"
"PRIMARY KEY(file, id));";
/* ceate jumplist table */
static const char SQL_JUMPLIST_INIT[] =
"CREATE TABLE IF NOT EXISTS jumplist ("
"id INTEGER PRIMARY KEY AUTOINCREMENT,"
......@@ -156,6 +158,13 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
"line TEXT,"
"PRIMARY KEY(line));";
static const char* ALL_INIT[] = {
SQL_BOOKMARK_INIT,
SQL_JUMPLIST_INIT,
SQL_FILEINFO_INIT,
SQL_HISTORY_INIT
};
/* update fileinfo table (part 1) */
static const char SQL_FILEINFO_ALTER[] =
"ALTER TABLE fileinfo ADD COLUMN pages_per_row INTEGER;"
......@@ -178,28 +187,12 @@ sqlite_db_init(ZathuraSQLDatabase* db, const char* path)
}
/* create tables if they don't exist */
if (sqlite3_exec(session, SQL_BOOKMARK_INIT, NULL, 0, NULL) != SQLITE_OK) {
girara_error("Failed to initialize database: %s\n", path);
sqlite3_close(session);
return;
}
if (sqlite3_exec(session, SQL_JUMPLIST_INIT, NULL, 0, NULL) != SQLITE_OK) {
girara_error("Failed to initialize database: %s\n", path);
sqlite3_close(session);
return;
}
if (sqlite3_exec(session, SQL_FILEINFO_INIT, NULL, 0, NULL) != SQLITE_OK) {
girara_error("Failed to initialize database: %s\n", path);
sqlite3_close(session);
return;
}
if (sqlite3_exec(session, SQL_HISTORY_INIT, NULL, 0, NULL) != SQLITE_OK) {
girara_error("Failed to initialize database: %s\n", path);
sqlite3_close(session);
return;
for (size_t s = 0; s < LENGTH(ALL_INIT); ++s) {
if (sqlite3_exec(session, ALL_INIT[s], NULL, 0, NULL) != SQLITE_OK) {
girara_error("Failed to initialize database: %s\n", path);
sqlite3_close(session);
return;
}
}
/* check existing tables for missing columns */
......@@ -388,7 +381,7 @@ sqlite_load_bookmarks(zathura_database_t* db, const char* file)
girara_list_t* result = girara_sorted_list_new2((girara_compare_function_t) zathura_bookmarks_compare,
(girara_free_function_t) zathura_bookmark_free);
if (result != NULL) {
if (result == NULL) {
sqlite3_finalize(stmt);
return NULL;
}
......@@ -403,11 +396,8 @@ sqlite_load_bookmarks(zathura_database_t* db, const char* file)
bookmark->page = sqlite3_column_int(stmt, 1);
bookmark->x = sqlite3_column_double(stmt, 2);
bookmark->y = sqlite3_column_double(stmt, 3);
if (bookmark->page > 1) {
bookmark->x = bookmark->x == 0.0 ? DBL_MIN : bookmark->x;
bookmark->y = bookmark->y == 0.0 ? DBL_MIN : bookmark->y;
}
bookmark->x = bookmark->x <= 0.0 ? DBL_MIN : bookmark->x;
bookmark->y = bookmark->y <= 0.0 ? DBL_MIN : bookmark->y;
girara_list_append(result, bookmark);
}
......@@ -686,3 +676,4 @@ sqlite_io_read(GiraraInputHistoryIO* db)
sqlite3_finalize(stmt);
return list;
}
......@@ -82,11 +82,24 @@ zathura_dbus_init(ZathuraDbus* dbus)
priv->registration_id = 0;
}
static void
gdbus_connection_closed(GDBusConnection* UNUSED(connection),
gboolean UNUSED(remote_peer_vanished), GError* error, void* UNUSED(data))
{
if (error != NULL) {
girara_debug("D-Bus connection closed: %s", error->message);
}
}
static void
bus_acquired(GDBusConnection* connection, const gchar* name, void* data)
{
girara_debug("Bus acquired at '%s'.", name);
/* register callback for GDBusConnection's closed signal */
g_signal_connect(G_OBJECT(connection), "closed",
G_CALLBACK(gdbus_connection_closed), NULL);
ZathuraDbus* dbus = data;
private_t* priv = GET_PRIVATE(dbus);
......@@ -150,6 +163,33 @@ zathura_dbus_new(zathura_t* zathura)
return dbus;
}
void
zathura_dbus_edit(ZathuraDbus* edit, unsigned int page, unsigned int x, unsigned int y) {
private_t* priv = GET_PRIVATE(edit);
const char* filename = zathura_document_get_path(priv->zathura->document);
char* input_file = NULL;
unsigned int line = 0;
unsigned int column = 0;
if (synctex_get_input_line_column(filename, page, x, y, &input_file, &line,
&column) == false) {
return;
}
GError* error = NULL;
g_dbus_connection_emit_signal(priv->connection, NULL, DBUS_OBJPATH,
DBUS_INTERFACE, "Edit", g_variant_new("(suu)", input_file, x, y), &error);
g_free(input_file);
if (error != NULL) {
girara_debug("Failed to emit 'Edit' signal: %s", error->message);
g_error_free(error);
}
}
/* D-Bus handler */
static void
......
......@@ -41,6 +41,16 @@ GType zathura_dbus_get_type(void);
ZathuraDbus* zathura_dbus_new(zathura_t* zathura);
/**
* Emit the 'Edit' signal on the D-Bus connection.
*
* @param dbus ZathuraDbus instance
* @param page page
* @param x x coordinate
* @param y y coordinate
*/
void zathura_dbus_edit(ZathuraDbus* dbus, unsigned int page, unsigned int x, unsigned int y);
/**
* Look for zathura instance having filename open and cause it to open give page
* and highlight rectangles on the given page
......
.\" Man page generated from reStructuredText.
.
.TH "ZATHURA" "1" "June 25, 2014" "0.2.7" "zathura"
.TH "ZATHURA" "1" "October 16, 2014" "0.2.7" "zathura"
.SH NAME
zathura \- a document viewer
.
......@@ -34,6 +34,11 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.sp
zathura [\-e XID] [\-c PATH] [\-d PATH] [\-p PATH] [\-w PASSWORD] [\-p NUMBER]
[\-\-fork] [\-l LEVEL] [\-s] [\-x CMD] [\-\-synctex\-forward INPUT] <files>
.SH DESCRIPTION
.sp
\fBzathura\fP displays the given files. If a single hyphen\-minus (\-) is given as
file name, the content will be read from the standard input. If no files are
given, an empty \fBzathura\fP instance launches.
.SH OPTIONS
.INDENT 0.0
.TP
......@@ -62,14 +67,12 @@ of the document, \-1 being the last page.
.BI \-l\fP,\fB \-\-debug\fB= level
Set log debug level (debug, info, warning, error)
.TP
.B \-s\fP,\fB \-\-synctex
Enables synctex support
.TP
.BI \-x\fP,\fB \-\-synctex\-editor\-command\fB= command
Set the synctex editor command
Set the synctex editor command. Overrides the synctex\-editor\-command setting.
.TP
.BI \-\-synctex\-forward\fB= input
Jump to the given position. The switch expects the same format as specified for synctex\(aqs view \-i.
Jump to the given position. The switch expects the same format as specified
for synctex\(aqs view \-i.
.TP
.B \-\-fork
Fork into background
......@@ -337,12 +340,13 @@ description please consult zathurarc(5).
.sp
Both synctex forward and backwards synchronization are supported by zathura, To
enable synctex forward synchronization, please look at the \fI\-\-syntex\fP and
\fI\-\-synctex\-editor\fP options. To support synctex backwards synchronization,
zathura provides a D\-Bus interface that can be called by the editor. For
convince zathura also knows how to parse the output of the \fIsynctex view\fP
command. It is enough to pass the arguments to \fIsynctex view\fP\(aqs \fI\-i\fP option to
zathura via \fI\-\-syntex\-forward\fP and zathura will pass the information to the
correct instance.
\fI\-\-synctex\-editor\fP options. zathura will also emit a signal via the D\-Bus
interface. To support synctex backwards synchronization, zathura provides a
D\-Bus interface that can be called by the editor. For convince zathura also
knows how to parse the output of the \fIsynctex view\fP command. It is enough to
pass the arguments to \fIsynctex view\fP\(aqs \fI\-i\fP option to zathura via
\fI\-\-syntex\-forward\fP and zathura will pass the information to the correct
instance.
.SH KNOWN BUGS
.sp
If GDK_NATIVE_WINDOWS is enabled you will experience problems with large
......
.\" Man page generated from reStructuredText.
.
.TH "ZATHURARC" "5" "June 25, 2014" "0.2.7" "zathura"
.TH "ZATHURARC" "5" "October 16, 2014" "0.2.7" "zathura"
.SH NAME
zathurarc \- a document viewer
.
......@@ -967,6 +967,15 @@ Value type: String
.IP \(bu 2
Default value: #000000
.UNINDENT
.SS recolor\-reverse\-video
.sp
Defines if original image colors should be kept while recoloring.
.INDENT 0.0
.IP \(bu 2
Value type: Boolean
.IP \(bu 2
Default value: false
.UNINDENT
.SS render\-loading
.sp
Defines if the "Loading..." text should be displayed if a page is rendered.
......@@ -1040,6 +1049,15 @@ Value type: Boolean
.IP \(bu 2
Default value: false
.UNINDENT
.SS smooth\-scroll
.sp
Defines if scrolling via touchpad should be smooth(only available with gtk >= 3.4).
.INDENT 0.0
.IP \(bu 2
Value type: Boolean
.IP \(bu 2
Default value: false
.UNINDENT
.SS link\-zoom
.sp
En/Disables the ability of changing zoom when following links.
......@@ -1102,7 +1120,7 @@ En/Disables horizontally centered zooming.
.IP \(bu 2
Value type: Boolean
.IP \(bu 2
Default value: False
Default value: false
.UNINDENT
.SS zoom\-max
.sp
......@@ -1144,9 +1162,36 @@ Value type: String
.IP \(bu 2
Default value: primary
.UNINDENT
.SS selection\-notification
.sp
Defines if a notification should be displayed after selecting text.
.INDENT 0.0
.IP \(bu 2
Value type: Boolean
.IP \(bu 2
Default value: true