Commit 76b7c88c authored by Sebastian Ramacher's avatar Sebastian Ramacher

Imported Upstream version 0.1.1

parent b533801e
This diff is collapsed.
callbacks.o: callbacks.c /usr/include/glib-2.0/glib/gi18n.h callbacks.h \
document.h zathura.h version.h render.h utils.h shortcuts.h \
page_widget.h
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
page_widget.o: page_widget.c /usr/include/glib-2.0/glib/gi18n.h \
page_widget.h document.h zathura.h version.h render.h callbacks.h \
utils.h shortcuts.h
This diff is collapsed.
render.o: render.c render.h zathura.h callbacks.h document.h version.h \
page_widget.h utils.h
shortcuts.o: shortcuts.c /usr/include/glib-2.0/glib/gi18n.h callbacks.h \
document.h zathura.h version.h shortcuts.h render.h utils.h \
page_widget.h
This diff is collapsed.
zathura.o: zathura.c /usr/include/glib-2.0/glib/gstdio.h \
/usr/include/glib-2.0/glib/gprintf.h /usr/include/glib-2.0/glib/gi18n.h \
bookmarks.h zathura.h callbacks.h document.h version.h config.h \
database-sqlite.h database.h database-plain.h shortcuts.h utils.h \
render.h
......@@ -4,21 +4,25 @@ include config.mk
include common.mk
PROJECT = zathura
SOURCE = $(shell find . -iname "*.c" -a ! -iname "database-*" ! -path "*tests*")
HEADER = $(shell find . -iname "*.h")
OBJECTS = $(patsubst %.c, %.o, $(SOURCE))
DOBJECTS = $(patsubst %.c, %.do, $(SOURCE))
OSOURCE = $(wildcard *.c)
HEADER = $(wildcard *.h)
ifeq (${DATABASE}, sqlite)
ifneq (${WITH_SQLITE},0)
INCS += $(SQLITE_INC)
LIBS += $(SQLITE_LIB)
SOURCE += database-sqlite.c
SOURCE = $(OSOURCE)
CPPFLAGS += -DWITH_SQLITE
else
ifeq (${DATABASE}, plain)
SOURCE += database-plain.c
SOURCE = $(filter-out database-sqlite.c,$(OSOURCE))
endif
ifneq ($(wildcard ${VALGRIND_SUPPRESSION_FILE}),)
VALGRIND_ARGUMENTS += --suppressions=${VALGRIND_SUPPRESSION_FILE}
endif
OBJECTS = $(patsubst %.c, %.o, $(SOURCE))
DOBJECTS = $(patsubst %.c, %.do, $(SOURCE))
all: options ${PROJECT}
options:
......@@ -28,6 +32,12 @@ options:
@echo "DFLAGS = ${DFLAGS}"
@echo "CC = ${CC}"
version.h: version.h.in config.mk
$(QUIET)sed 's/ZVMAJOR/${ZATHURA_VERSION_MAJOR}/' < version.h.in | \
sed 's/ZVMINOR/${ZATHURA_VERSION_MINOR}/' | \
sed 's/ZVREV/${ZATHURA_VERSION_REV}/' | \
sed 's/ZVAPI/${ZATHURA_API_VERSION}/' > version.h
%.o: %.c
$(ECHO) CC $<
@mkdir -p .depend
......@@ -38,11 +48,8 @@ options:
@mkdir -p .depend
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
# force recompilation of database.o if DATABASE has changed
database.o: database-${DATABASE}.o
${OBJECTS}: config.mk
${DOBJECTS}: config.mk
${OBJECTS}: config.mk version.h
${DOBJECTS}: config.mk version.h
${PROJECT}: ${OBJECTS}
$(ECHO) CC -o $@
......@@ -50,8 +57,10 @@ ${PROJECT}: ${OBJECTS}
clean:
$(QUIET)rm -rf ${PROJECT} ${OBJECTS} ${PROJECT}-${VERSION}.tar.gz \
${DOBJECTS} ${PROJECT}-debug .depend ${PROJECT}.pc doc *gcda *gcno $(PROJECT).info gcov
${DOBJECTS} ${PROJECT}-debug .depend ${PROJECT}.pc doc version.h \
*gcda *gcno $(PROJECT).info gcov
$(QUIET)make -C tests clean
$(QUIET)make -C po clean
${PROJECT}-debug: ${DOBJECTS}
$(ECHO) CC -o $@
......@@ -62,17 +71,18 @@ debug: ${PROJECT}-debug
${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 apiversion=${ZATHHRA_API_VERSION} >> ${PROJECT}.pc
$(QUIET)echo includedir=${INCLUDEDIR} >> ${PROJECT}.pc
$(QUIET)echo plugindir=${PLUGINDIR} >> ${PROJECT}.pc
$(QUIET)echo GTK_VERSION=${ZATHURA_GTK_VERSION} >> ${PROJECT}.pc
$(QUIET)cat ${PROJECT}.pc.in >> ${PROJECT}.pc
valgrind: debug
valgrind --tool=memcheck --leak-check=yes --show-reachable=yes \
./${PROJECT}-debug
$(QUIET)G_SLICE=always-malloc G_DEBUG=gc-friendly ${VALGRIND} ${VALGRIND_ARGUMENTS} \
./${PROJECT}-debug
gdb: debug
cgdb ${PROJECT}-debug
$(QUIET)cgdb ${PROJECT}-debug
test: ${OBJECTS}
$(QUIET)make -C tests run
......@@ -80,12 +90,14 @@ test: ${OBJECTS}
dist: clean
$(QUIET)mkdir -p ${PROJECT}-${VERSION}
$(QUIET)mkdir -p ${PROJECT}-${VERSION}/tests
$(QUIET)mkdir -p ${PROJECT}-${VERSION}/po
$(QUIET)cp LICENSE Makefile config.mk common.mk README AUTHORS Doxyfile \
${PROJECT}.1.rst ${PROJECT}rc.5.rst ${SOURCE} ${HEADER} ${PROJECT}.pc.in \
${PROJECT}.desktop \
${PROJECT}.1.rst ${PROJECT}rc.5.rst ${OSOURCE} ${HEADER} ${PROJECT}.pc.in \
${PROJECT}.desktop version.h.in \
${PROJECT}-${VERSION}
$(QUIET)cp tests/Makefile tests/config.mk tests/*.c \
${PROJECT}-${VERSION}/tests
$(QUIET)cp po/Makefile po/*.po ${PROJECT}-${VERSION}/po
$(QUIET)tar -cf ${PROJECT}-${VERSION}.tar ${PROJECT}-${VERSION}
$(QUIET)gzip ${PROJECT}-${VERSION}.tar
$(QUIET)rm -rf ${PROJECT}-${VERSION}
......@@ -94,52 +106,63 @@ doc:
$(QUIET)doxygen Doxyfile
gcov: clean
$(QUIET)CFLAGS="${CFLAGS}-fprofile-arcs -ftest-coverage" LDFLAGS="${LDFLAGS} -fprofile-arcs" ${MAKE} $(PROJECT)
$(QUIET)${MAKE} -C tests
$(QUIET)CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage" LDFLAGS="${LDFLAGS} -fprofile-arcs" ${MAKE} $(PROJECT)
$(QUIET)CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage" LDFLAGS="${LDFLAGS} -fprofile-arcs" ${MAKE} -C tests run
$(QUIET)lcov --directory . --capture --output-file $(PROJECT).info
$(QUIET)genhtml --output-directory gcov $(PROJECT).info
install: all ${PROJECT}.pc
po:
$(QUIET)${MAKE} -C po
update-po:
$(QUIET)${MAKE} -C po update-po
install-headers: ${PROJECT}.pc
$(ECHO) installing header files
$(QUIET)mkdir -p ${DESTDIR}${INCLUDEDIR}/${PROJECT}
$(QUIET)install -m 644 zathura.h document.h version.h ${DESTDIR}${INCLUDEDIR}/${PROJECT}
$(ECHO) installing pkgconfig file
$(QUIET)mkdir -p ${DESTDIR}${LIBDIR}/pkgconfig
$(QUIET)install -m 644 ${PROJECT}.pc ${DESTDIR}${LIBDIR}/pkgconfig
install: all install-headers po
$(ECHO) installing executable file
$(QUIET)mkdir -p ${DESTDIR}${PREFIX}/bin
$(QUIET)install -m 755 ${PROJECT} ${DESTDIR}${PREFIX}/bin
$(ECHO) installing header files
$(QUIET)mkdir -p ${DESTDIR}${PREFIX}/include/${PROJECT}
$(QUIET)cp -f document.h ${DESTDIR}${PREFIX}/include/${PROJECT}
$(QUIET)cp -f zathura.h ${DESTDIR}${PREFIX}/include/${PROJECT}
ifneq "$(wildcard ${RSTTOMAN})" ""
$(ECHO) installing manual pages
$(QUIET)mkdir -p ${DESTDIR}${MANPREFIX}/man1
$(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 ; \
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}${MANPREFIX}/man1 ${DESTDIR}${MANPREFIX}/man5
$(QUIET)sed "s/VERSION/${VERSION}/g" < ${PROJECT}.1.rst > ${PROJECT}-v.1.rst
$(QUIET)${RSTTOMAN} ${PROJECT}-v.1.rst > ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1
$(QUIET)rm ${PROJECT}-v.1.rst
$(QUIET)sed "s/VERSION/${VERSION}/g" < ${PROJECT}rc.5.rst > ${PROJECT}rc-v.5.rst
$(QUIET)${RSTTOMAN} ${PROJECT}rc-v.5.rst > ${DESTDIR}${MANPREFIX}/man5/${PROJECT}rc.5
$(QUIET)rm ${PROJECT}rc-v.5.rst
$(QUIET)chmod 644 ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1
$(QUIET)chmod 644 ${DESTDIR}${MANPREFIX}/man5/${PROJECT}rc.5
endif
$(QUIET)mkdir -p ${DESTDIR}${DESKTOPPREFIX}
$(ECHO) installing desktop file
$(QUIET)install -m 644 ${PROJECT}.desktop ${DESTDIR}${DESKTOPPREFIX}
$(QUIET)chmod 644 ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1
$(ECHO) installing pkgconfig file
$(QUIET)mkdir -p ${DESTDIR}${PREFIX}/lib/pkgconfig
$(QUIET)cp -f ${PROJECT}.pc ${DESTDIR}${PREFIX}/lib/pkgconfig
$(MAKE) -C po install
uninstall-headers:
$(ECHO) removing header files
$(QUIET)rm -rf ${DESTDIR}${INCLUDEDIR}/${PROJECT}
$(ECHO) removing pkgconfig file
$(QUIET)rm -f ${DESTDIR}${LIBDIR}/pkgconfig/${PROJECT}.pc
uninstall:
$(ECHO) removing executable file
$(QUIET)rm -f ${DESTDIR}${PREFIX}/bin/${PROJECT}
$(ECHO) removing header files
$(QUIET)rm -rf ${DESTDIR}${PREFIX}/include/${PROJECT}
$(ECHO) removing manual pages
$(QUIET)rm -f ${DESTDIR}${MANPREFIX}/man1/${PROJECT}.1
$(QUIET)rm -f ${DESTDIR}${MANPREFIX}/man5/${PROJECT}rc.5
$(ECHO) removing desktop file
$(QUIET)rm -f ${DESTDIR}${DESKTOPPREFIX}/${PROJECT}.desktop
$(ECHO) removing pkgconfig file
$(QUIET)rm -f ${DESTDIR}${PREFIX}/lib/pkgconfig/${PROJECT}.pc
$(MAKE) -C po uninstall
-include $(wildcard .depend/*.dep)
.PHONY: all options clean doc debug valgrind gdb dist doc install uninstall test
.PHONY: all options clean doc debug valgrind gdb dist doc install uninstall test \
po install-headers uninstall-headers update-po
......@@ -9,14 +9,18 @@ gtk2 (>= 2.18.6)
girara
sqlite3
check (for tests)
intltool
Please note that you need to have a working pkg-config installation and that the
Makefile is only compatible with GNU make. If you don't have a working
pkg-config installation please set the GTK_INC, GTK_LIB, GIRARA_INC, GIRARA_LIB,
SQLITE_INC and SQLITE_LIB variables accordingly.
And also note that rst2man from python-docutils is needed to build zathurarc.5.
If it is not installed, zathurarc.5 won't be built.
And also note that rst2man from python-docutils is needed to build the man pages.
If it is not installed, the man pages won't be built.
If you don't want to build with support for sqlite databases, you can set
WITH_SQLITE=0 and sqlite support won't be available.
Installation
------------
......
File added
......@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <gtk/gtk.h>
#include <string.h>
#include <glib/gi18n.h>
#include "callbacks.h"
#include "zathura.h"
......@@ -17,8 +18,13 @@
#include "page_widget.h"
gboolean
cb_destroy(GtkWidget* UNUSED(widget), gpointer UNUSED(data))
cb_destroy(GtkWidget* UNUSED(widget), zathura_t* zathura)
{
if (zathura != NULL && zathura->document != NULL) {
zathura_document_free(zathura->document);
zathura->document = NULL;
}
gtk_main_quit();
return TRUE;
}
......@@ -32,8 +38,7 @@ cb_buffer_changed(girara_session_t* session)
zathura_t* zathura = session->global.data;
char* buffer = girara_buffer_get(session);
if (buffer) {
if (buffer != NULL) {
girara_statusbar_item_set_text(session, zathura->ui.statusbar.buffer, buffer);
free(buffer);
} else {
......@@ -45,7 +50,8 @@ void
cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpointer data)
{
zathura_t* zathura = data;
if (!zathura || !zathura->document || !zathura->document->pages || !zathura->ui.page_widget) {
if (zathura == NULL || zathura->document == NULL || zathura->document->pages == NULL
|| zathura->ui.page_widget == NULL) {
return;
}
......@@ -54,10 +60,10 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
GdkRectangle view_rect;
/* get current adjustment values */
view_rect.y = gtk_adjustment_get_value(view_vadjustment);
view_rect.y = 0;
view_rect.height = gtk_adjustment_get_page_size(view_vadjustment);
view_rect.x = gtk_adjustment_get_value(view_hadjustment);
view_rect.width = gtk_adjustment_get_page_size(view_hadjustment);
view_rect.x = 0;
view_rect.width = gtk_adjustment_get_page_size(view_hadjustment);
int page_padding = 1;
girara_setting_get(zathura->ui.session, "page-padding", &page_padding);
......@@ -65,21 +71,17 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
GdkRectangle center;
center.x = view_rect.x + (view_rect.width + 1) / 2;
center.y = view_rect.y + (view_rect.height + 1) / 2;
center.height = center.width = 2*page_padding + 1;
center.height = center.width = (2 * page_padding) + 1;
bool updated = false;
/* find page that fits */
for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; page_id++)
{
for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; page_id++) {
zathura_page_t* page = zathura->document->pages[page_id];
page_offset_t offset;
page_calculate_offset(page, &offset);
GdkRectangle page_rect;
page_rect.x = offset.x;
page_rect.y = offset.y;
page_rect.width = page->width * zathura->document->scale;
gtk_widget_translate_coordinates(page->drawing_area,
zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y);
page_rect.width = page->width * zathura->document->scale;
page_rect.height = page->height * zathura->document->scale;
if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) {
......@@ -133,8 +135,7 @@ cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path,
g_object_get(tree_view, "model", &model, NULL);
if(gtk_tree_model_get_iter(model, &iter, path))
{
if(gtk_tree_model_get_iter(model, &iter, path)) {
zathura_index_element_t* index_element;
gtk_tree_model_get(model, &iter, 2, &index_element, -1);
......@@ -147,7 +148,7 @@ cb_index_row_activated(GtkTreeView* tree_view, GtkTreePath* path,
page_set_delayed(zathura, index_element->target.page_number);
} else if (index_element->type == ZATHURA_LINK_EXTERNAL) {
if (girara_xdg_open(index_element->target.uri) == false) {
girara_notify(zathura->ui.session, GIRARA_ERROR, "Failed to run xdg-open.");
girara_notify(zathura->ui.session, GIRARA_ERROR, _("Failed to run xdg-open."));
}
}
}
......@@ -173,7 +174,7 @@ cb_sc_follow(GtkEntry* entry, girara_session_t* session)
if (eval == true) {
index = atoi(input);
if (index == 0 && g_strcmp0(input, "0") != 0) {
girara_notify(session, GIRARA_WARNING, "Invalid input '%s' given.", input);
girara_notify(session, GIRARA_WARNING, _("Invalid input '%s' given."), input);
eval = false;
}
index = index - 1;
......@@ -207,7 +208,7 @@ cb_sc_follow(GtkEntry* entry, girara_session_t* session)
}
if (eval == true && invalid_index == true) {
girara_notify(session, GIRARA_WARNING, "Invalid index '%s' given.", input);
girara_notify(session, GIRARA_WARNING, _("Invalid index '%s' given."), input);
}
g_free(input);
......@@ -238,10 +239,18 @@ static gboolean
password_dialog(gpointer data)
{
zathura_password_dialog_info_t* dialog = data;
if (dialog != NULL) {
girara_dialog(dialog->zathura->ui.session, "Incorrect password. Enter password:", true, NULL,
(girara_callback_inputbar_activate_t) cb_password_dialog, dialog);
girara_dialog(
dialog->zathura->ui.session,
"Incorrect password. Enter password:",
true,
NULL,
(girara_callback_inputbar_activate_t) cb_password_dialog,
dialog
);
}
return FALSE;
}
......@@ -309,7 +318,8 @@ cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* allocation, zathura_t*
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);
width = allocation->width;
width = allocation->width;
height = allocation->height;
}
......
......@@ -8,15 +8,16 @@
#include <girara/macros.h>
#include "document.h"
#include "zathura.h"
/**
* Quits the current zathura session
*
* @param widget The gtk window of zathura
* @param data NULL
* @param zathura Correspondending zathura session
* @return true if no error occured and the event has been handled
*/
gboolean cb_destroy(GtkWidget* widget, gpointer data);
gboolean cb_destroy(GtkWidget* widget, zathura_t* zathura);
/**
* This function gets called when the buffer of girara changes
......
File added
This diff is collapsed.
File added
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.
File added
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment