Commit 3d378fda authored by Sebastian Ramacher's avatar Sebastian Ramacher

Imported Upstream version 0.2.3

parent 89f8fc3d
zathura is written by: zathura is written by:
Moritz Lipp <mlq@pwmt.org> Moritz Lipp <mlq@pwmt.org>
Sebastian Ramacher <s.ramacher@gmx.at> Sebastian Ramacher <sebastian+dev@ramacher.at>
Other contributors are (in no particular order): Other contributors are (in no particular order):
...@@ -20,3 +20,7 @@ Roland Schatz <roland.schatz@students.jku.at> ...@@ -20,3 +20,7 @@ Roland Schatz <roland.schatz@students.jku.at>
Abdó Roig-Maranges <abdo.roig@gmail.com> Abdó Roig-Maranges <abdo.roig@gmail.com>
Benoît Knecht <benoit.knecht@gmail.com> Benoît Knecht <benoit.knecht@gmail.com>
Rob Cornish <jrmcornish@gmail.com> Rob Cornish <jrmcornish@gmail.com>
Marwan Tanager <marwan.tngr@gmail.com>
Diego Joss <djego.joss@gmail.com>
Ignas Anikevicius <anikevicius@gmail.com>
oblique
Copyright (c) 2009-2012 pwmt.org Copyright (c) 2009-2013 pwmt.org
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
......
...@@ -17,6 +17,12 @@ else ...@@ -17,6 +17,12 @@ else
SOURCE = $(filter-out database-sqlite.c,$(OSOURCE)) SOURCE = $(filter-out database-sqlite.c,$(OSOURCE))
endif endif
ifneq ($(WITH_MAGIC),0)
INCS += $(MAGIC_INC)
LIBS += $(MAGIC_LIB)
CPPFLAGS += -DWITH_MAGIC
endif
ifneq ($(wildcard ${VALGRIND_SUPPRESSION_FILE}),) ifneq ($(wildcard ${VALGRIND_SUPPRESSION_FILE}),)
VALGRIND_ARGUMENTS += --suppressions=${VALGRIND_SUPPRESSION_FILE} VALGRIND_ARGUMENTS += --suppressions=${VALGRIND_SUPPRESSION_FILE}
endif endif
......
...@@ -7,10 +7,11 @@ Requirements ...@@ -7,10 +7,11 @@ Requirements
------------ ------------
gtk2 (>= 2.28) gtk2 (>= 2.28)
girara girara
sqlite3 (>= 3.5.9) sqlite3 (optional, >= 3.5.9)
check (for tests) check (for tests)
intltool intltool
python-docutils (for man pages) python-docutils (optional, for man pages)
libmagic from file(1) (optional, for mime-type detection)
Please note that you need to have a working pkg-config installation and that the 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 Makefile is only compatible with GNU make. If you don't have a working
...@@ -22,9 +23,15 @@ If it is not installed, the man pages won't be built. ...@@ -22,9 +23,15 @@ 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 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. Please note that sqlite3 WITH_SQLITE=0 and sqlite support won't be available. Please note that sqlite3
with metadata support is required, i.e. sqlite3 has to be built with with meta data support is required, i.e. sqlite3 has to be built with
SQLITE_ENABLE_COLUMN_METADATA defined. SQLITE_ENABLE_COLUMN_METADATA defined.
The use of magic to detect mime types is optional and can be disabled by setting
WITH_MAGIC=0.
If you pass these flags as a command line argument to make, you have to ensure
to pass the same flags when executing the install target.
Installation Installation
------------ ------------
To build and install zathura: To build and install zathura:
......
/* See LICENSE file for license and copyright information */
#include "adjustment.h"
#include "utils.h"
GtkAdjustment*
zathura_adjustment_clone(GtkAdjustment* adjustment)
{
gdouble value = gtk_adjustment_get_value(adjustment);
gdouble lower = gtk_adjustment_get_lower(adjustment);
gdouble upper = gtk_adjustment_get_upper(adjustment);
gdouble step_increment = gtk_adjustment_get_step_increment(adjustment);
gdouble page_increment = gtk_adjustment_get_page_increment(adjustment);
gdouble page_size = gtk_adjustment_get_page_size(adjustment);
return GTK_ADJUSTMENT(gtk_adjustment_new(value, lower, upper, step_increment,
page_increment, page_size));
}
void
zathura_adjustment_set_value(GtkAdjustment* adjustment, gdouble value)
{
gtk_adjustment_set_value(adjustment,
MAX(gtk_adjustment_get_lower(adjustment),
MIN(gtk_adjustment_get_upper(adjustment) -
gtk_adjustment_get_page_size(adjustment),
value)));
}
gdouble
zathura_adjustment_get_ratio(GtkAdjustment* adjustment)
{
gdouble lower = gtk_adjustment_get_lower(adjustment);
gdouble upper = gtk_adjustment_get_upper(adjustment);
gdouble page_size = gtk_adjustment_get_page_size(adjustment);
gdouble value = gtk_adjustment_get_value(adjustment);
return (value - lower + page_size / 2.0) / (upper - lower);
}
void
zathura_adjustment_set_value_from_ratio(GtkAdjustment* adjustment,
gdouble ratio)
{
if (ratio == 0.0) {
return;
}
gdouble lower = gtk_adjustment_get_lower(adjustment);
gdouble upper = gtk_adjustment_get_upper(adjustment);
gdouble page_size = gtk_adjustment_get_page_size(adjustment);
gdouble value = (upper - lower) * ratio + lower - page_size / 2.0;
zathura_adjustment_set_value(adjustment, value);
}
/* See LICENSE file for license and copyright information */
#ifndef ZATHURA_ADJUSTMENT_H
#define ZATHURA_ADJUSTMENT_H
#include <gtk/gtk.h>
/* Clone a GtkAdjustment
*
* Creates a new adjustment with the same value, lower and upper bounds, step
* and page increments and page_size as the original adjustment.
*
* @param adjustment Adjustment instance to be cloned
* @return Pointer to the new adjustment
*/
GtkAdjustment* zathura_adjustment_clone(GtkAdjustment* adjustment);
/**
* Set the adjustment value while enforcing its limits
*
* @param adjustment Adjustment instance
* @param value Adjustment value
*/
void zathura_adjustment_set_value(GtkAdjustment* adjustment, gdouble value);
/**
* Compute the adjustment ratio
*
* That is, the ratio between the length from the lower bound to the middle of
* the slider, and the total length of the scrollbar.
*
* @param adjustment Scrollbar adjustment
* @return Adjustment ratio
*/
gdouble zathura_adjustment_get_ratio(GtkAdjustment* adjustment);
/**
* Set the adjustment value from ratio
*
* The ratio is usually obtained from a previous call to
* zathura_adjustment_get_ratio().
*
* @param adjustment Adjustment instance
* @param ratio Ratio from which the adjustment value will be set
*/
void zathura_adjustment_set_value_from_ratio(GtkAdjustment* adjustment,
gdouble ratio);
#endif /* ZATHURA_ADJUSTMENT_H */
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "shortcuts.h" #include "shortcuts.h"
#include "page-widget.h" #include "page-widget.h"
#include "page.h" #include "page.h"
#include "adjustment.h"
gboolean gboolean
cb_destroy(GtkWidget* UNUSED(widget), zathura_t* zathura) cb_destroy(GtkWidget* UNUSED(widget), zathura_t* zathura)
...@@ -93,7 +94,11 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi ...@@ -93,7 +94,11 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y); zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y);
if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) { if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) {
zathura_page_set_visibility(page, true); if (zathura_page_get_visibility(page) == false) {
zathura_page_set_visibility(page, true);
zathura_page_widget_update_view_time(ZATHURA_PAGE(page_widget));
zathura_page_cache_add(zathura, zathura_page_get_index(page));
}
if (zathura->global.update_page_number == true && updated == false if (zathura->global.update_page_number == true && updated == false
&& gdk_rectangle_intersect(&center, &page_rect, NULL) == TRUE) { && gdk_rectangle_intersect(&center, &page_rect, NULL) == TRUE) {
zathura_document_set_current_page_number(zathura->document, page_id); zathura_document_set_current_page_number(zathura->document, page_id);
...@@ -102,12 +107,93 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi ...@@ -102,12 +107,93 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
} else { } else {
zathura_page_set_visibility(page, false); zathura_page_set_visibility(page, false);
} }
zathura_page_widget_update_view_time(ZATHURA_PAGE(page_widget));
} }
statusbar_page_number_update(zathura); statusbar_page_number_update(zathura);
} }
void
cb_view_hadjustment_changed(GtkAdjustment* adjustment, gpointer data)
{
zathura_t* zathura = data;
g_return_if_fail(zathura != NULL);
zathura_adjust_mode_t adjust_mode =
zathura_document_get_adjust_mode(zathura->document);
gdouble lower, upper, page_size, value, ratio;
bool zoom_center = false;
switch (adjust_mode) {
center:
case ZATHURA_ADJUST_BESTFIT:
case ZATHURA_ADJUST_WIDTH:
lower = gtk_adjustment_get_lower(adjustment);
upper = gtk_adjustment_get_upper(adjustment);
page_size = gtk_adjustment_get_page_size(adjustment);
value = ((upper - lower) - page_size) / 2.0;
zathura_adjustment_set_value(adjustment, value);
break;
default:
girara_setting_get(zathura->ui.session, "zoom-center", &zoom_center);
if (zoom_center) {
goto center;
}
ratio = zathura_adjustment_get_ratio(zathura->ui.hadjustment);
zathura_adjustment_set_value_from_ratio(adjustment, ratio);
break;
}
}
void
cb_view_vadjustment_changed(GtkAdjustment* adjustment, gpointer data)
{
zathura_t* zathura = data;
g_return_if_fail(zathura != NULL);
zathura_adjust_mode_t adjust_mode =
zathura_document_get_adjust_mode(zathura->document);
/* Don't scroll we're focusing the inputbar. */
if (adjust_mode == ZATHURA_ADJUST_INPUTBAR) {
return;
}
double ratio = zathura_adjustment_get_ratio(zathura->ui.vadjustment);
zathura_adjustment_set_value_from_ratio(adjustment, ratio);
}
void
cb_adjustment_track_value(GtkAdjustment* adjustment, gpointer data)
{
GtkAdjustment* tracker = data;
gdouble lower = gtk_adjustment_get_lower(adjustment);
gdouble upper = gtk_adjustment_get_upper(adjustment);
if (lower != gtk_adjustment_get_lower(tracker) ||
upper != gtk_adjustment_get_upper(tracker)) {
return;
}
gdouble value = gtk_adjustment_get_value(adjustment);
gtk_adjustment_set_value(tracker, value);
}
void
cb_adjustment_track_bounds(GtkAdjustment* adjustment, gpointer data)
{
GtkAdjustment* tracker = data;
gdouble value = gtk_adjustment_get_value(adjustment);
gdouble lower = gtk_adjustment_get_lower(adjustment);
gdouble upper = gtk_adjustment_get_upper(adjustment);
gdouble page_size = gtk_adjustment_get_page_size(adjustment);
gtk_adjustment_set_value(tracker, value);
gtk_adjustment_set_lower(tracker, lower);
gtk_adjustment_set_upper(tracker, upper);
gtk_adjustment_set_page_size(tracker, page_size);
}
void void
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)) 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))
{ {
...@@ -340,7 +426,8 @@ cb_password_dialog(GtkEntry* entry, zathura_password_dialog_info_t* dialog) ...@@ -340,7 +426,8 @@ cb_password_dialog(GtkEntry* entry, zathura_password_dialog_info_t* dialog)
} }
/* try to open document again */ /* try to open document again */
if (document_open(dialog->zathura, dialog->path, input) == false) { if (document_open(dialog->zathura, dialog->path, input,
ZATHURA_PAGE_NUMBER_UNSPECIFIED) == false) {
gdk_threads_add_idle(password_dialog, dialog); gdk_threads_add_idle(password_dialog, dialog);
} else { } else {
g_free(dialog->path); g_free(dialog->path);
......
...@@ -35,6 +35,53 @@ void cb_buffer_changed(girara_session_t* session); ...@@ -35,6 +35,53 @@ void cb_buffer_changed(girara_session_t* session);
* @param data NULL * @param data NULL
*/ */
void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data); void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data);
/**
* This function gets called when the bounds or the page_size of the horizontal
* scrollbar change (e.g. when the zoom level is changed).
*
* It adjusts the value of the horizontal scrollbar, possibly based on its
* previous adjustment, stored in the tracking adjustment
* zathura->ui.hadjustment.
*
* @param adjustment The horizontal adjustment of a gtkScrolledWindow
* @param data The zathura instance
*/
void cb_view_hadjustment_changed(GtkAdjustment *adjustment, gpointer data);
/**
* This function gets called when the bounds or the page_size of the vertical
* scrollbar change (e.g. when the zoom level is changed).
*
* It adjusts the value of the vertical scrollbar based on its previous
* adjustment, stored in the tracking adjustment zathura->ui.hadjustment.
*
* @param adjustment The vertical adjustment of a gtkScrolledWindow
* @param data The zathura instance
*/
void cb_view_vadjustment_changed(GtkAdjustment *adjustment, gpointer data);
/* This function gets called when the value of the adjustment changes.
*
* It updates the value of the tracking adjustment, only if the bounds of the
* adjustment have not changed (if they did change,
* cb_adjustment_track_bounds() will take care of updating everything).
*
* @param adjustment The adjustment instance
* @param data The tracking adjustment instance
*/
void cb_adjustment_track_value(GtkAdjustment* adjustment, gpointer data);
/* This function gets called when the bounds or the page_size of the adjustment
* change.
*
* It updates the value, bounds and page_size of the tracking adjustment.
*
* @param adjustment The adjustment instance
* @param data The tracking adjustment instance
*/
void cb_adjustment_track_bounds(GtkAdjustment* adjustment, gpointer data);
/** /**
* This function gets called when the value of the "pages-per-row" * This function gets called when the value of the "pages-per-row"
* variable changes * variable changes
......
...@@ -225,7 +225,9 @@ cmd_open(girara_session_t* session, girara_list_t* argument_list) ...@@ -225,7 +225,9 @@ cmd_open(girara_session_t* session, girara_list_t* argument_list)
document_close(zathura, false); document_close(zathura, false);
} }
document_open(zathura, girara_list_nth(argument_list, 0), (argc == 2) ? girara_list_nth(argument_list, 1) : NULL); document_open(zathura, girara_list_nth(argument_list, 0),
(argc == 2) ? girara_list_nth(argument_list, 1) : NULL,
ZATHURA_PAGE_NUMBER_UNSPECIFIED);
} else { } else {
girara_notify(session, GIRARA_ERROR, _("No arguments given.")); girara_notify(session, GIRARA_ERROR, _("No arguments given."));
return false; return false;
...@@ -531,7 +533,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list) ...@@ -531,7 +533,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list)
} }
/* no argument: take current page as offset */ /* no argument: take current page as offset */
unsigned int page_offset = zathura_document_get_current_page_number(zathura->document); int page_offset = zathura_document_get_current_page_number(zathura->document);
/* retrieve offset from argument */ /* retrieve offset from argument */
if (girara_list_size(argument_list) == 1) { if (girara_list_size(argument_list) == 1) {
...@@ -545,9 +547,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list) ...@@ -545,9 +547,7 @@ cmd_offset(girara_session_t* session, girara_list_t* argument_list)
} }
} }
if (page_offset < zathura_document_get_number_of_pages(zathura->document)) { zathura_document_set_page_offset(zathura->document, page_offset);
zathura_document_set_page_offset(zathura->document, page_offset);
}
return true; return true;
} }
......
...@@ -52,6 +52,10 @@ cb_color_change(girara_session_t* session, const char* name, ...@@ -52,6 +52,10 @@ cb_color_change(girara_session_t* session, const char* name,
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_dark_color)); gdk_color_parse(string_value, &(zathura->ui.colors.recolor_dark_color));
} else if (g_strcmp0(name, "recolor-lightcolor") == 0) { } else if (g_strcmp0(name, "recolor-lightcolor") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color)); gdk_color_parse(string_value, &(zathura->ui.colors.recolor_light_color));
} else if (g_strcmp0(name, "render-loading-bg") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.render_loading_bg));
} else if (g_strcmp0(name, "render-loading-fg") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.render_loading_fg));
} }
render_all(zathura); render_all(zathura);
...@@ -143,7 +147,7 @@ config_load_default(zathura_t* zathura) ...@@ -143,7 +147,7 @@ config_load_default(zathura_t* zathura)
girara_setting_add(gsession, "first-page-column", &int_value, INT, false, _("Column of the first page"),cb_first_page_column_value_changed, NULL); girara_setting_add(gsession, "first-page-column", &int_value, INT, false, _("Column of the first page"),cb_first_page_column_value_changed, NULL);
float_value = 40; float_value = 40;
girara_setting_add(gsession, "scroll-step", &float_value, FLOAT, false, _("Scroll step"), NULL, NULL); girara_setting_add(gsession, "scroll-step", &float_value, FLOAT, false, _("Scroll step"), NULL, NULL);
float_value = -1; float_value = 40;
girara_setting_add(gsession, "scroll-hstep", &float_value, FLOAT, false, _("Horizontal scroll step"), NULL, NULL); girara_setting_add(gsession, "scroll-hstep", &float_value, FLOAT, false, _("Horizontal scroll step"), NULL, NULL);
float_value = 0.0; float_value = 0.0;
girara_setting_add(gsession, "scroll-full-overlap", &float_value, FLOAT, false, _("Full page scroll overlap"), NULL, NULL); girara_setting_add(gsession, "scroll-full-overlap", &float_value, FLOAT, false, _("Full page scroll overlap"), NULL, NULL);
...@@ -151,9 +155,8 @@ config_load_default(zathura_t* zathura) ...@@ -151,9 +155,8 @@ config_load_default(zathura_t* zathura)
girara_setting_add(gsession, "zoom-min", &int_value, INT, false, _("Zoom minimum"), NULL, NULL); girara_setting_add(gsession, "zoom-min", &int_value, INT, false, _("Zoom minimum"), NULL, NULL);
int_value = 1000; int_value = 1000;
girara_setting_add(gsession, "zoom-max", &int_value, INT, false, _("Zoom maximum"), NULL, NULL); girara_setting_add(gsession, "zoom-max", &int_value, INT, false, _("Zoom maximum"), NULL, NULL);
int_value = 20; int_value = ZATHURA_PAGE_CACHE_DEFAULT_SIZE;
girara_setting_add(gsession, "page-store-threshold", &int_value, INT, false, _("Life time (in seconds) of a hidden page"), NULL, NULL); girara_setting_add(gsession, "page-cache-size", &int_value, INT, true, _("Maximum number of pages to keep in the cache"), NULL, NULL);
girara_setting_add(gsession, "page-store-interval", &int_value, INT, true, _("Amount of seconds between each cache purge"), NULL, NULL);
int_value = 20; int_value = 20;
girara_setting_add(gsession, "jumplist-size", &int_value, INT, false, _("Number of positions to remember in the jumplist"), cb_jumplist_change, NULL); girara_setting_add(gsession, "jumplist-size", &int_value, INT, false, _("Number of positions to remember in the jumplist"), cb_jumplist_change, NULL);
...@@ -165,6 +168,10 @@ config_load_default(zathura_t* zathura) ...@@ -165,6 +168,10 @@ config_load_default(zathura_t* zathura)
girara_setting_set(gsession, "highlight-color", "#9FBC00"); 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_add(gsession, "highlight-active-color", NULL, STRING, false, _("Color for highlighting (active)"), cb_color_change, NULL);
girara_setting_set(gsession, "highlight-active-color", "#00BC00"); girara_setting_set(gsession, "highlight-active-color", "#00BC00");
girara_setting_add(gsession, "render-loading-bg", NULL, STRING, false, _("'Loading ...' background color"), cb_color_change, NULL);
girara_setting_set(gsession, "render-loading-bg", "#FFFFFF");
girara_setting_add(gsession, "render-loading-fg", NULL, STRING, false, _("'Loading ...' foreground color"), cb_color_change, NULL);
girara_setting_set(gsession, "render-loading-fg", "#000000");
bool_value = false; bool_value = false;
girara_setting_add(gsession, "recolor", &bool_value, BOOLEAN, false, _("Recolor pages"), cb_setting_recolor_change, NULL); girara_setting_add(gsession, "recolor", &bool_value, BOOLEAN, false, _("Recolor pages"), cb_setting_recolor_change, NULL);
...@@ -179,6 +186,8 @@ config_load_default(zathura_t* zathura) ...@@ -179,6 +186,8 @@ config_load_default(zathura_t* zathura)
bool_value = false; bool_value = false;
girara_setting_add(gsession, "zoom-center", &bool_value, BOOLEAN, false, _("Horizontally centered zoom"), NULL, NULL); girara_setting_add(gsession, "zoom-center", &bool_value, BOOLEAN, false, _("Horizontally centered zoom"), NULL, NULL);
bool_value = true; bool_value = true;
girara_setting_add(gsession, "link-hadjust", &bool_value, BOOLEAN, false, _("Align link target to the left"), NULL, NULL);
bool_value = true;
girara_setting_add(gsession, "search-hadjust", &bool_value, BOOLEAN, false, _("Center result horizontally"), NULL, NULL); girara_setting_add(gsession, "search-hadjust", &bool_value, BOOLEAN, false, _("Center result horizontally"), NULL, NULL);
float_value = 0.5; float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL); girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, _("Transparency for highlighting"), NULL, NULL);
...@@ -200,6 +209,8 @@ config_load_default(zathura_t* zathura) ...@@ -200,6 +209,8 @@ config_load_default(zathura_t* zathura)
bool_value = false; bool_value = false;
girara_setting_add(gsession, "window-title-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the window title"), NULL, NULL); girara_setting_add(gsession, "window-title-basename", &bool_value, BOOLEAN, false, _("Use basename of the file in the window title"), NULL, NULL);
bool_value = false; 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;
girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL); girara_setting_add(gsession, "synctex", &bool_value, BOOLEAN, false, _("Enable synctex support"), NULL, NULL);
/* define default shortcuts */ /* define default shortcuts */
...@@ -244,6 +255,7 @@ config_load_default(zathura_t* zathura) ...@@ -244,6 +255,7 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add(gsession, 0, GDK_KEY_Up, 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_Page_Up, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_Page_Up, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL);
girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_KEY_space, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL); girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_KEY_space, NULL, sc_navigate, FULLSCREEN, PREVIOUS, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_BackSpace, 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_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_j, NULL, sc_navigate_index, INDEX, DOWN, NULL);
...@@ -286,7 +298,8 @@ config_load_default(zathura_t* zathura) ...@@ -286,7 +298,8 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_KEY_space, NULL, sc_scroll, NORMAL, FULL_UP, NULL); girara_shortcut_add(gsession, GDK_SHIFT_MASK, GDK_KEY_space, NULL, sc_scroll, NORMAL, FULL_UP, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_o, NULL, sc_jumplist, NORMAL, BACKWARD, NULL); girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_o, NULL, sc_jumplist, NORMAL, BACKWARD, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_i, NULL, sc_jumplist, NORMAL, FORWARD, NULL); girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_i, NULL, sc_jumplist, NORMAL, FORWARD, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_j, NULL, sc_bisect, NORMAL, FORWARD, NULL);
girara_shortcut_add(gsession, GDK_CONTROL_MASK, GDK_KEY_k, NULL, sc_bisect, NORMAL, BACKWARD, 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, FORWARD, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_N, NULL, sc_search, NORMAL, BACKWARD, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_N, NULL, sc_search, NORMAL, BACKWARD, NULL);
...@@ -299,6 +312,7 @@ config_load_default(zathura_t* zathura) ...@@ -299,6 +312,7 @@ config_load_default(zathura_t* zathura)
girara_shortcut_add(gsession, 0, GDK_KEY_d, NULL, sc_toggle_page_mode, NORMAL, 0, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_d, NULL, sc_toggle_page_mode, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_q, NULL, sc_quit, NORMAL, 0, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_q, NULL, sc_quit, NORMAL, 0, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_q, NULL, sc_quit, FULLSCREEN, 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, NORMAL, ZOOM_IN, NULL);
girara_shortcut_add(gsession, 0, GDK_KEY_KP_Add, NULL, sc_zoom, NORMAL, ZOOM_IN, NULL); girara_shortcut_add(gsession, 0, GDK_KEY_KP_Add, NULL, sc_zoom, NORMAL, ZOOM_IN, NULL);
...@@ -388,6 +402,7 @@ config_load_default(zathura_t* zathura) ...@@ -388,6 +402,7 @@ config_load_default(zathura_t* zathura)
girara_shortcut_mapping_add(gsession, "follow", sc_follow); girara_shortcut_mapping_add(gsession, "follow", sc_follow);
girara_shortcut_mapping_add(gsession, "goto", sc_goto); girara_shortcut_mapping_add(gsession, "goto", sc_goto);
girara_shortcut_mapping_add(gsession, "jumplist", sc_jumplist); girara_shortcut_mapping_add(gsession, "jumplist", sc_jumplist);
girara_shortcut_mapping_add(gsession, "bisect", sc_bisect);
girara_shortcut_mapping_add(gsession, "navigate", sc_navigate); girara_shortcut_mapping_add(gsession, "navigate", sc_navigate);
girara_shortcut_mapping_add(gsession, "navigate_index", sc_navigate_index); girara_shortcut_mapping_add(gsession, "navigate_index", sc_navigate_index);
girara_shortcut_mapping_add(gsession, "print", sc_print); girara_shortcut_mapping_add(gsession, "print", sc_print);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
ZATHURA_VERSION_MAJOR = 0 ZATHURA_VERSION_MAJOR = 0
ZATHURA_VERSION_MINOR = 2 ZATHURA_VERSION_MINOR = 2
ZATHURA_VERSION_REV = 2 ZATHURA_VERSION_REV = 3
# If the API changes, the API version and the ABI version have to be bumped. # If the API changes, the API version and the ABI version have to be bumped.
ZATHURA_API_VERSION = 2 ZATHURA_API_VERSION = 2
# If the ABI breaks for any reason, this has to be bumped. # If the ABI breaks for any reason, this has to be bumped.
...@@ -16,13 +16,17 @@ ZATHURA_GTK_VERSION ?= 2 ...@@ -16,13 +16,17 @@ ZATHURA_GTK_VERSION ?= 2
# minimum required zathura version # minimum required zathura version
# If you want to disable the check, set GIRARA_VERSION_CHECK to 0. # If you want to disable the check, set GIRARA_VERSION_CHECK to 0.
GIRARA_MIN_VERSION = 0.1.5 GIRARA_MIN_VERSION = 0.1.6
GIRARA_VERSION_CHECK ?= $(shell pkg-config --atleast-version=$(GIRARA_MIN_VERSION) girara-gtk${ZATHURA_GTK_VERSION}; echo $$?) GIRARA_VERSION_CHECK ?= $(shell pkg-config --atleast-version=$(GIRARA_MIN_VERSION) girara-gtk${ZATHURA_GTK_VERSION}; echo $$?)
# database # database
# To disable support for the sqlite backend set WITH_SQLITE to 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) WITH_SQLITE ?= $(shell (pkg-config --atleast-version=3.5.9 sqlite3 && echo 1) || echo 0)
# mimetype detection
# To disable support for mimetype detction with libmagic set WITH_MAGIC to 0.
WITH_MAGIC ?= 1
# paths # paths
PREFIX ?= /usr PREFIX ?= /usr
MANPREFIX ?= ${PREFIX}/share/man MANPREFIX ?= ${PREFIX}/share/man
...@@ -56,6 +60,11 @@ SQLITE_INC ?= $(shell pkg-config --cflags sqlite3) ...@@ -56,6 +60,11 @@ SQLITE_INC ?= $(shell pkg-config --cflags sqlite3)
SQLITE_LIB ?= $(shell pkg-config --libs sqlite3) SQLITE_LIB ?= $(shell pkg-config --libs sqlite3)
endif endif
ifneq (${WITH_MAGIC},0)
MAGIC_INC ?=
MAGIC_LIB ?= -lmagic
endif
INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC} INCS = ${GIRARA_INC} ${GTK_INC} ${GTHREAD_INC} ${GMODULE_INC}
LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} -lpthread -lm LIBS = ${GIRARA_LIB} ${GTK_LIB} ${GTHREAD_LIB} ${GMODULE_LIB} -lpthread -lm
......
/* See LICENSE file for license and copyright information */ /* See LICENSE file for license and copyright information */
#define _POSIX_SOURCE #define _POSIX_SOURCE
#define _XOPEN_SOURCE 500
#include <glib.h> #include <glib.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -10,11 +11,13 @@ ...@@ -10,11 +11,13 @@
#include <unistd.h> #include <unistd.h>
#include <girara/utils.h> #include <girara/utils.h>
#include <girara/datastructures.h> #include <girara/datastructures.h>
#include <girara/input-history.h>
#include "database-plain.h" #include "database-plain.h"
#define BOOKMARKS "bookmarks" #define BOOKMARKS "bookmarks"
#define HISTORY "history" #define HISTORY "history"
#define INPUT_HISTORY "input-history"
#define KEY_PAGE "page" #define KEY_PAGE "page"
#define KEY_OFFSET "offset" #define KEY_OFFSET "offset"
...@@ -37,9 +40,11 @@ ...@@ -37,9 +40,11 @@
#endif #endif
static void zathura_database_interface_init(ZathuraDatabaseInterface* iface); static void zathura_database_interface_init(ZathuraDatabaseInterface* iface);
static void io_interface_init(GiraraInputHistoryIOInterface* iface);
G_DEFINE_TYPE_WITH_CODE(ZathuraPlainDatabase, zathura_plaindatabase, G_TYPE_OBJECT, G_DEFINE_TYPE_WITH_CODE(ZathuraPlainDatabase, zathura_plaindatabase, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE(ZATHURA_TYPE_DATABASE, zathura_database_interface_init)) G_IMPLEMENT_INTERFACE(ZATHURA_TYPE_DATABASE, zathura_database_interface_init)
G_IMPLEMENT_INTERFACE(GIRARA_TYPE_INPUT_HISTORY_IO, io_interface_init))
static void plain_finalize(GObject* object); static void plain_finalize(GObject* object);
static bool plain_add_bookmark(zathura_database_t* db, const char* file, static bool plain_add_bookmark(zathura_database_t* db, const char* file,
...@@ -54,6 +59,8 @@ static bool plain_get_fileinfo(zathura_database_t* db, const char* file, ...@@ -54,6 +59,8 @@ static bool plain_get_fileinfo(zathura_database_t* db, const char* file,
zathura_fileinfo_t* file_info); zathura_fileinfo_t* file_info);
static void plain_set_property(GObject* object, guint prop_id, static void plain_set_property(GObject* object, guint prop_id,
const GValue* value, GParamSpec* pspec); const GValue* value, GParamSpec* pspec);
static void plain_io_append(GiraraInputHistoryIO* db, const char*);
static girara_list_t* plain_io_read(GiraraInputHistoryIO* db);
/* forward declaration */ /* forward declaration */
static bool zathura_db_check_file(const char* path); static bool zathura_db_check_file(const char* path);
...@@ -70,6 +77,8 @@ typedef struct zathura_plaindatabase_private_s { ...@@ -70,6 +77,8 @@ typedef struct zathura_plaindatabase_private_s {
char* history_path; char* history_path;
GKeyFile* history; GKeyFile* history;
GFileMonitor* history_monitor; GFileMonitor* history_monitor;
char* input_history_path;
} zathura_plaindatabase_private_t; } zathura_plaindatabase_private_t;
#define ZATHURA_PLAINDATABASE_GET_PRIVATE(obj) \