Commit e1a57e34 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Imported Upstream version 0.2.5

parent ed946ca2
...@@ -42,11 +42,15 @@ DOBJECTS = $(patsubst %.c, %.do, $(SOURCE)) ...@@ -42,11 +42,15 @@ DOBJECTS = $(patsubst %.c, %.do, $(SOURCE))
all: options ${PROJECT} po build-manpages all: options ${PROJECT} po build-manpages
girara-version-check: # pkg-config based version checks
ifneq ($(GIRARA_VERSION_CHECK), 0) .version-checks/%:
$(error "The minimum required version of girara is ${GIRARA_MIN_VERSION}") $(QUIET)test $($(*)_VERSION_CHECK) -eq 0 || \
endif pkg-config --atleast-version $($(*)_MIN_VERSION) $($(*)_PKG_CONFIG_NAME) || ( \
$(QUIET)touch girara-version-check echo "The minium required version of $(*) is $($(*)_MIN_VERSION)" && \
false \
)
@mkdir -p .version-checks
$(QUIET)touch $@
options: options:
@echo ${PROJECT} build options: @echo ${PROJECT} build options:
...@@ -56,11 +60,11 @@ options: ...@@ -56,11 +60,11 @@ options:
@echo "CC = ${CC}" @echo "CC = ${CC}"
version.h: version.h.in config.mk version.h: version.h.in config.mk
$(QUIET)sed 's/ZVMAJOR/${ZATHURA_VERSION_MAJOR}/' < version.h.in | \ $(QUIET)sed -e 's/ZVMAJOR/${ZATHURA_VERSION_MAJOR}/' \
sed 's/ZVMINOR/${ZATHURA_VERSION_MINOR}/' | \ -e 's/ZVMINOR/${ZATHURA_VERSION_MINOR}/' \
sed 's/ZVREV/${ZATHURA_VERSION_REV}/' | \ -e 's/ZVREV/${ZATHURA_VERSION_REV}/' \
sed 's/ZVAPI/${ZATHURA_API_VERSION}/' | \ -e 's/ZVAPI/${ZATHURA_API_VERSION}/' \
sed 's/ZVABI/${ZATHURA_ABI_VERSION}/' > version.h -e 's/ZVABI/${ZATHURA_ABI_VERSION}/' version.h.in > version.h
%.o: %.c %.o: %.c
$(ECHO) CC $< $(ECHO) CC $<
...@@ -72,8 +76,8 @@ version.h: version.h.in config.mk ...@@ -72,8 +76,8 @@ version.h: version.h.in config.mk
@mkdir -p .depend @mkdir -p .depend
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep $(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
${OBJECTS}: config.mk version.h girara-version-check ${OBJECTS} ${DOBJECTS}: config.mk version.h \
${DOBJECTS}: config.mk version.h girara-version-check .version-checks/GIRARA .version-checks/GLIB .version-checks/GTK
${PROJECT}: ${OBJECTS} ${PROJECT}: ${OBJECTS}
$(ECHO) CC -o $@ $(ECHO) CC -o $@
...@@ -83,7 +87,7 @@ clean: ...@@ -83,7 +87,7 @@ clean:
$(QUIET)rm -rf ${PROJECT} ${OBJECTS} ${PROJECT}-${VERSION}.tar.gz \ $(QUIET)rm -rf ${PROJECT} ${OBJECTS} ${PROJECT}-${VERSION}.tar.gz \
${DOBJECTS} ${PROJECT}-debug .depend ${PROJECT}.pc doc version.h \ ${DOBJECTS} ${PROJECT}-debug .depend ${PROJECT}.pc doc version.h \
*gcda *gcno $(PROJECT).info gcov *.tmp \ *gcda *gcno $(PROJECT).info gcov *.tmp \
girara-version-check .version-checks
ifneq "$(wildcard ${RSTTOMAN})" "" ifneq "$(wildcard ${RSTTOMAN})" ""
$(QUIET)rm -f zathura.1 zathurarc.5 $(QUIET)rm -f zathura.1 zathurarc.5
endif endif
......
...@@ -5,7 +5,8 @@ girara user interface library and several document libraries. ...@@ -5,7 +5,8 @@ girara user interface library and several document libraries.
Requirements Requirements
------------ ------------
gtk2 (>= 2.28) gtk2 (>= 2.18) or gtk3
glib (>= 2.28)
girara girara
sqlite3 (optional, >= 3.5.9) sqlite3 (optional, >= 3.5.9)
check (for tests) check (for tests)
...@@ -36,8 +37,13 @@ To build and install zathura: ...@@ -36,8 +37,13 @@ To build and install zathura:
make install make install
Uninstall: Uninstall
---------- ---------
To delete zathura from your system, just type: To delete zathura from your system, just type:
make uninstall make uninstall
Bugs
----
Please report bugs at http://bugs.pwmt.org or contact us on our mailing list at
zathura@lists.pwmt.org.
...@@ -2,6 +2,142 @@ ...@@ -2,6 +2,142 @@
#include "adjustment.h" #include "adjustment.h"
#include "utils.h" #include "utils.h"
#include <math.h>
double
page_calc_height_width(zathura_document_t* document, double height, double width,
unsigned int* page_height, unsigned int* page_width, bool rotate)
{
g_return_val_if_fail(document != NULL && page_height != NULL && page_width != NULL, 0.0);
double scale = zathura_document_get_scale(document);
if (rotate && zathura_document_get_rotation(document) % 180) {
*page_width = round(height * scale);
*page_height = round(width * scale);
scale = MAX(*page_width / height, *page_height / width);
} else {
*page_width = round(width * scale);
*page_height = round(height * scale);
scale = MAX(*page_width / width, *page_height / height);
}
return scale;
}
void
page_calc_position(zathura_document_t* document, double x, double y,
double *xn, double *yn) {
g_return_if_fail(document != NULL && xn != NULL && yn != NULL);
unsigned int rot = zathura_document_get_rotation(document);
if (rot == 90) {
*xn = 1 - y;
*yn = x;
}else if (rot == 180) {
*xn = 1 - x;
*yn = 1 - y;
} else if (rot == 270) {
*xn = y;
*yn = 1 - x;
} else {
*xn = x;
*yn = y;
}
}
unsigned int
position_to_page_number(zathura_document_t* document,
double pos_x, double pos_y){
g_return_val_if_fail(document != NULL, 0);
unsigned int doc_width, doc_height;
zathura_document_get_document_size(document, &doc_height, &doc_width);
unsigned int cell_width, cell_height;
zathura_document_get_cell_size(document, &cell_height, &cell_width);
unsigned int c0 = zathura_document_get_first_page_column(document);
unsigned int npag = zathura_document_get_number_of_pages(document);
unsigned int ncol = zathura_document_get_pages_per_row(document);
unsigned int nrow = (npag + c0 - 1 + ncol - 1) / ncol; /* number of rows */
unsigned int pad = zathura_document_get_page_padding(document);
unsigned int col = floor(pos_x * (double)doc_width / (double)(cell_width + pad));
unsigned int row = floor(pos_y * (double)doc_height / (double)(cell_height + pad));
return ncol * (row % nrow) + (col % ncol) - (c0 - 1);
}
void
page_number_to_position(zathura_document_t* document, unsigned int page_number,
double xalign, double yalign, double *pos_x, double *pos_y) {
g_return_if_fail(document != NULL);
unsigned int c0 = zathura_document_get_first_page_column(document);
unsigned int npag = zathura_document_get_number_of_pages(document);
unsigned int ncol = zathura_document_get_pages_per_row(document);
unsigned int nrow = (npag + c0 - 1 + ncol - 1) / ncol; /* number of rows */
/* row and column for page_number indexed from 0 */
unsigned int row = (page_number + c0 - 1) / ncol;
unsigned int col = (page_number + c0 - 1) % ncol;
/* sizes of page cell, viewport and document */
unsigned int cell_height = 0, cell_width = 0;
zathura_document_get_cell_size(document, &cell_height, &cell_width);
unsigned int view_height = 0, view_width = 0;
zathura_document_get_viewport_size(document, &view_height, &view_width);
unsigned int doc_height = 0, doc_width = 0;
zathura_document_get_document_size(document, &doc_height, &doc_width);
/* compute the shift to align to the viewport. If the page fits to viewport, just center it. */
double shift_x = 0.5, shift_y = 0.5;
if (cell_width > view_width) {
shift_x = 0.5 + (xalign - 0.5) * ((double)cell_width - (double)view_width) / (double)cell_width;
}
if (cell_height > view_height) {
shift_y = 0.5 + (yalign - 0.5) * ((double)cell_height - (double)view_height) / (double)cell_height;
}
/* compute the position */
*pos_x = ((double)col + shift_x) / (double)ncol;
*pos_y = ((double)row + shift_y) / (double)nrow;
}
bool
page_is_visible(zathura_document_t *document, unsigned int page_number) {
g_return_val_if_fail(document != NULL, false);
/* position at the center of the viewport */
double pos_x = zathura_document_get_position_x(document);
double pos_y = zathura_document_get_position_y(document);
/* get the center of page page_number */
double page_x, page_y;
page_number_to_position(document, page_number, 0.5, 0.5, &page_x, &page_y);
unsigned int cell_width, cell_height;
zathura_document_get_cell_size(document, &cell_height, &cell_width);
unsigned int doc_width, doc_height;
zathura_document_get_document_size(document, &doc_height, &doc_width);
unsigned int view_width, view_height;
zathura_document_get_viewport_size(document, &view_height, &view_width);
return ( fabs(pos_x - page_x) < 0.5 * (double)(view_width + cell_width) / (double)doc_width &&
fabs(pos_y - page_y) < 0.5 * (double)(view_height + cell_height) / (double)doc_height);
}
GtkAdjustment* GtkAdjustment*
zathura_adjustment_clone(GtkAdjustment* adjustment) zathura_adjustment_clone(GtkAdjustment* adjustment)
......
...@@ -4,8 +4,73 @@ ...@@ -4,8 +4,73 @@
#define ZATHURA_ADJUSTMENT_H #define ZATHURA_ADJUSTMENT_H
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <stdbool.h>
#include "document.h"
/* Clone a GtkAdjustment /**
* Calculate the page size according to the corrent scaling and rotation if
* desired.
*
* @param document the document
* @param height width the original height and width
* @return page_height page_width the scaled and rotated height and width
* @param rotate honor page's rotation
* @return real scale after rounding
*/
double page_calc_height_width(zathura_document_t* document, double height, double width,
unsigned int* page_height, unsigned int* page_width, bool rotate);
/**
* Calculate a page relative position after a rotation. The positions x y are
* relative to a page, i.e. 0=top of page, 1=bottom of page. They are NOT
* relative to the entire document.
*
* @param document the document
* @param x y the x y coordinates on the unrotated page
* @param xn yn the x y coordinates after rotation
*/
void page_calc_position(zathura_document_t* document, double x, double y,
double *xn, double *yn);
/**
* Converts a relative position within the document to a page number.
*
* @param document The document
* @param pos_x pos_y the position relative to the document
* @return page sitting in that position
*/
unsigned int position_to_page_number(zathura_document_t* document,
double pos_x, double pos_y);
/**
* Converts a page number to a position in units relative to the document
*
* We can specify where to aliwn the viewport and the page. For instance, xalign
* = 0 means align them on the left margin, xalign = 0.5 means centered, and
* xalign = 1.0 align them on the right margin.
*
* The return value is the position in in units relative to the document (0=top
* 1=bottom) of the point thet will lie at the center of the viewport.
*
* @param document The document
* @param page_number the given page number
* @param xalign yalign where to align the viewport and the page
* @return pos_x pos_y position that will lie at the center of the viewport.
*/
void page_number_to_position(zathura_document_t* document, unsigned int page_number,
double xalign, double yalign, double *pos_x, double *pos_y);
/**
* Checks whether a given page falls within the viewport
*
* @param document The document
* @param page_number the page number
* @return true if the page intersects the viewport
*/
bool page_is_visible(zathura_document_t *document, unsigned int page_number);
/**
* Clone a GtkAdjustment
* *
* Creates a new adjustment with the same value, lower and upper bounds, step * Creates a new adjustment with the same value, lower and upper bounds, step
* and page increments and page_size as the original adjustment. * and page increments and page_size as the original adjustment.
......
...@@ -25,14 +25,14 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page) ...@@ -25,14 +25,14 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page)
g_return_val_if_fail(zathura && zathura->document && zathura->bookmarks.bookmarks, NULL); g_return_val_if_fail(zathura && zathura->document && zathura->bookmarks.bookmarks, NULL);
g_return_val_if_fail(id, NULL); g_return_val_if_fail(id, NULL);
double x = zathura_adjustment_get_ratio(gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view))); double position_x = zathura_document_get_position_x(zathura->document);
double y = zathura_adjustment_get_ratio(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view))); double position_y = zathura_document_get_position_y(zathura->document);
zathura_bookmark_t* old = zathura_bookmark_get(zathura, id); zathura_bookmark_t* old = zathura_bookmark_get(zathura, id);
if (old != NULL) { if (old != NULL) {
old->page = page; old->page = page;
old->x = x; old->x = position_x;
old->y = y; old->y = position_y;
if (zathura->database != NULL) { if (zathura->database != NULL) {
const char* path = zathura_document_get_path(zathura->document); const char* path = zathura_document_get_path(zathura->document);
...@@ -52,8 +52,8 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page) ...@@ -52,8 +52,8 @@ zathura_bookmark_add(zathura_t* zathura, const gchar* id, unsigned int page)
bookmark->id = g_strdup(id); bookmark->id = g_strdup(id);
bookmark->page = page; bookmark->page = page;
bookmark->x = x; bookmark->x = position_x;
bookmark->y = y; bookmark->y = position_y;
girara_list_append(zathura->bookmarks.bookmarks, bookmark); girara_list_append(zathura->bookmarks.bookmarks, bookmark);
if (zathura->database != NULL) { if (zathura->database != NULL) {
......
This diff is collapsed.
...@@ -27,6 +27,15 @@ gboolean cb_destroy(GtkWidget* widget, zathura_t* zathura); ...@@ -27,6 +27,15 @@ gboolean cb_destroy(GtkWidget* widget, zathura_t* zathura);
*/ */
void cb_buffer_changed(girara_session_t* session); void cb_buffer_changed(girara_session_t* session);
/**
* This function gets called when the value of the horizontal scrollbars
* changes (e.g.: by scrolling, moving to another page)
*
* @param adjustment The hadjustment of the page view
* @param data NULL
*/
void cb_view_hadjustment_value_changed(GtkAdjustment *adjustment, gpointer data);
/** /**
* This function gets called when the value of the vertical scrollbars * This function gets called when the value of the vertical scrollbars
* changes (e.g.: by scrolling, moving to another page) * changes (e.g.: by scrolling, moving to another page)
...@@ -40,9 +49,7 @@ void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data) ...@@ -40,9 +49,7 @@ void cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
* This function gets called when the bounds or the page_size of the horizontal * This function gets called when the bounds or the page_size of the horizontal
* scrollbar change (e.g. when the zoom level is changed). * scrollbar change (e.g. when the zoom level is changed).
* *
* It adjusts the value of the horizontal scrollbar, possibly based on its * It adjusts the value of the horizontal scrollbar
* previous adjustment, stored in the tracking adjustment
* zathura->ui.hadjustment.
* *
* @param adjustment The horizontal adjustment of a gtkScrolledWindow * @param adjustment The horizontal adjustment of a gtkScrolledWindow
* @param data The zathura instance * @param data The zathura instance
...@@ -61,26 +68,16 @@ void cb_view_hadjustment_changed(GtkAdjustment *adjustment, gpointer data); ...@@ -61,26 +68,16 @@ void cb_view_hadjustment_changed(GtkAdjustment *adjustment, gpointer data);
*/ */
void cb_view_vadjustment_changed(GtkAdjustment *adjustment, gpointer data); void cb_view_vadjustment_changed(GtkAdjustment *adjustment, gpointer data);
/* This function gets called when the value of the adjustment changes. /**
* * This function gets called when the program need to refresh the document view.
* 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. * It adjusts the value of the scrollbars, triggering a redraw in the new
* position.
* *
* @param adjustment The adjustment instance * @param view The view GtkWidget
* @param data The tracking adjustment instance * @param data The zathura instance
*/ */
void cb_adjustment_track_bounds(GtkAdjustment* adjustment, gpointer data); void cb_refresh_view(GtkWidget* view, 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"
...@@ -92,19 +89,7 @@ void cb_adjustment_track_bounds(GtkAdjustment* adjustment, gpointer data); ...@@ -92,19 +89,7 @@ void cb_adjustment_track_bounds(GtkAdjustment* adjustment, gpointer data);
* @param value The value * @param value The value
* @param data Custom data * @param data Custom data
*/ */
void cb_pages_per_row_value_changed(girara_session_t* session, const char* name, void cb_page_layout_value_changed(girara_session_t* session, const char* name,
girara_setting_type_t type, void* value, void* data);
/**
* This function gets called when the value of the "first-page-column"
* variable changes
*
* @param session The current girara session
* @param name The name of the row
* @param type The settings type
* @param value The value
* @param data Custom data
*/
void cb_first_page_column_value_changed(girara_session_t* session, const char* name,
girara_setting_type_t type, void* value, void* data); girara_setting_type_t type, void* value, void* data);
/** /**
...@@ -202,4 +187,17 @@ void cb_setting_recolor_keep_hue_change(girara_session_t* session, const char* n ...@@ -202,4 +187,17 @@ void cb_setting_recolor_keep_hue_change(girara_session_t* session, const char* n
*/ */
bool cb_unknown_command(girara_session_t* session, const char* input); bool cb_unknown_command(girara_session_t* session, const char* input);
/**
* Emitted when text has been selected in the page widget
*
* @param widget page view widget
* @param text selected text
* @param data user data
*/
void cb_page_widget_text_selected(ZathuraPage* page, const char* text,
void* data);
void cb_page_widget_image_selected(ZathuraPage* page, GdkPixbuf* pixbuf,
void* data);
#endif // CALLBACKS_H #endif // CALLBACKS_H
...@@ -118,15 +118,9 @@ cmd_bookmark_open(girara_session_t* session, girara_list_t* argument_list) ...@@ -118,15 +118,9 @@ cmd_bookmark_open(girara_session_t* session, girara_list_t* argument_list)
} }
zathura_jumplist_add(zathura); zathura_jumplist_add(zathura);
page_set(zathura, bookmark->page - 1);
if (bookmark->x != DBL_MIN && bookmark->y != DBL_MIN) { if (bookmark->x != DBL_MIN && bookmark->y != DBL_MIN) {
GtkAdjustment* hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)); position_set(zathura, bookmark->x, bookmark->y);
GtkAdjustment* vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
zathura_adjustment_set_value_from_ratio(hadjustment, bookmark->x);
zathura_adjustment_set_value_from_ratio(vadjustment, bookmark->y);
zathura_document_set_current_page_number(zathura->document, bookmark->page - 1);
statusbar_page_number_update(zathura);
} else {
page_set(zathura, bookmark->page - 1);
} }
zathura_jumplist_add(zathura); zathura_jumplist_add(zathura);
...@@ -164,15 +158,15 @@ cmd_info(girara_session_t* session, girara_list_t* UNUSED(argument_list)) ...@@ -164,15 +158,15 @@ cmd_info(girara_session_t* session, girara_list_t* UNUSED(argument_list))
zathura_document_information_type_t field; zathura_document_information_type_t field;
}; };
struct meta_field meta_fields[] = { const struct meta_field meta_fields[] = {
{ "Title", ZATHURA_DOCUMENT_INFORMATION_TITLE }, { _("Title"), ZATHURA_DOCUMENT_INFORMATION_TITLE },
{ "Author", ZATHURA_DOCUMENT_INFORMATION_AUTHOR }, { _("Author"), ZATHURA_DOCUMENT_INFORMATION_AUTHOR },
{ "Subject", ZATHURA_DOCUMENT_INFORMATION_SUBJECT }, { _("Subject"), ZATHURA_DOCUMENT_INFORMATION_SUBJECT },
{ "Keywords", ZATHURA_DOCUMENT_INFORMATION_KEYWORDS }, { _("Keywords"), ZATHURA_DOCUMENT_INFORMATION_KEYWORDS },
{ "Creator", ZATHURA_DOCUMENT_INFORMATION_CREATOR }, { _("Creator"), ZATHURA_DOCUMENT_INFORMATION_CREATOR },
{ "Producer", ZATHURA_DOCUMENT_INFORMATION_PRODUCER }, { _("Producer"), ZATHURA_DOCUMENT_INFORMATION_PRODUCER },
{ "Creation date", ZATHURA_DOCUMENT_INFORMATION_CREATION_DATE }, { _("Creation date"), ZATHURA_DOCUMENT_INFORMATION_CREATION_DATE },
{ "Modiciation date", ZATHURA_DOCUMENT_INFORMATION_MODIFICATION_DATE } { _("Modification date"), ZATHURA_DOCUMENT_INFORMATION_MODIFICATION_DATE }
}; };
girara_list_t* information = zathura_document_get_information(zathura->document, NULL); girara_list_t* information = zathura_document_get_information(zathura->document, NULL);
...@@ -381,9 +375,9 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu ...@@ -381,9 +375,9 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
GtkWidget* page_widget = zathura_page_get_widget(zathura, page); GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
g_object_set(page_widget, "draw-links", FALSE, NULL); g_object_set(page_widget, "draw-links", FALSE, NULL);
render_lock(zathura->sync.render_thread); zathura_renderer_lock(zathura->sync.render_thread);
girara_list_t* result = zathura_page_search_text(page, input, &error); girara_list_t* result = zathura_page_search_text(page, input, &error);
render_unlock(zathura->sync.render_thread); zathura_renderer_unlock(zathura->sync.render_thread);
if (result == NULL || girara_list_size(result) == 0) { if (result == NULL || girara_list_size(result) == 0) {
girara_list_free(result); girara_list_free(result);
......
...@@ -57,9 +57,13 @@ cb_color_change(girara_session_t* session, const char* name, ...@@ -57,9 +57,13 @@ cb_color_change(girara_session_t* session, const char* name,
} else if (g_strcmp0(name, "highlight-active-color") == 0) { } else if (g_strcmp0(name, "highlight-active-color") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color_active)); gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color_active));
} else if (g_strcmp0(name, "recolor-darkcolor") == 0) { } else if (g_strcmp0(name, "recolor-darkcolor") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.recolor_dark_color)); if (zathura->sync.render_thread != NULL) {
zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, NULL, string_value);
}
} 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)); if (zathura->sync.render_thread != NULL) {
zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, string_value, NULL);
}
} else if (g_strcmp0(name, "render-loading-bg") == 0) { } else if (g_strcmp0(name, "render-loading-bg") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.render_loading_bg)); gdk_color_parse(string_value, &(zathura->ui.colors.render_loading_bg));
} else if (g_strcmp0(name, "render-loading-fg") == 0) { } else if (g_strcmp0(name, "render-loading-fg") == 0) {
...@@ -69,27 +73,6 @@ cb_color_change(girara_session_t* session, const char* name, ...@@ -69,27 +73,6 @@ cb_color_change(girara_session_t* session, const char* name,
render_all(zathura); render_all(zathura);
} }
static void
cb_page_padding_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 val = *(int*) value;
if (GTK_IS_TABLE(zathura->ui.page_widget) == TRUE) {
#if (GTK_MAJOR_VERSION == 3)
gtk_grid_set_row_spacing(GTK_GRID(zathura->ui.page_widget), val);
gtk_grid_set_column_spacing(GTK_GRID(zathura->ui.page_widget), val);
#else
gtk_table_set_row_spacings(GTK_TABLE(zathura->ui.page_widget), val);
gtk_table_set_col_spacings(GTK_TABLE(zathura->ui.page_widget), val);
#endif
}
}
static void static void
cb_nohlsearch_changed(girara_session_t* session, const char* UNUSED(name), cb_nohlsearch_changed(girara_session_t* session, const char* UNUSED(name),
girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data)) girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
...@@ -128,6 +111,7 @@ config_load_default(zathura_t* zathura) ...@@ -128,6 +111,7 @@ config_load_default(zathura_t* zathura)
float float_value = 0; float float_value = 0;
bool bool_value = false; bool bool_value = false;
bool inc_search = true; bool inc_search = true;
char* string_value = NULL;
girara_session_t* gsession = zathura->ui.session; girara_session_t* gsession = zathura->ui.session;
/* mode settings */ /* mode settings */
...@@ -144,21 +128,21 @@ config_load_default(zathura_t* zathura) ...@@ -144,21 +128,21 @@ config_load_default(zathura_t* zathura)
girara_mode_set(gsession, zathura->modes.normal); girara_mode_set(gsession, zathura->modes.normal);
/* zathura settings */ /* zathura settings */
girara_setting_add(gsession, "database", "plain", STRING, true, _("Database backend"), NULL, NULL); girara_setting_add(gsession, "database", "plain", STRING, true, _("Database backend"), NULL, NULL);
int_value = 10; int_value = 10;
girara_setting_add(gsession, "zoom-step", &int_value, INT, false, _("Zoom step"), NULL, NULL); girara_setting_add(gsession, "zoom-step", &int_value, INT, false, _("Zoom step"), NULL, NULL);
int_value = 1; int_value = 1;
girara_setting_add(gsession, "page-padding", &int_value, INT, false, _("Padding between pages"), cb_page_padding_changed, NULL); girara_setting_add(gsession, "page-padding", &int_value, INT, false, _("Padding between pages"), cb_page_layout_value_changed, NULL);
int_value = 1; 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, NULL); girara_setting_add(gsession, "pages-per-row", &int_value, INT, false, _("Number of pages per row"), cb_page_layout_value_changed, NULL);
int_value = 1; int_value = 1;
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_page_layout_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 = 40; 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);
int_value = 10; int_value = 10;
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;
...@@ -168,17 +152,15 @@ config_load_default(zathura_t* zathura) ...@@ -168,17 +152,15 @@ config_load_default(zathura_t* zathura)
int_value = 2000; int_value = 2000;
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);
girara_setting_add(gsession, "recolor-darkcolor", NULL, STRING, false, _("Recoloring (dark color)"), cb_color_change, NULL); girara_setting_add(gsession, "recolor-darkcolor", "#FFFFFF", STRING, false, _("Recoloring (dark color)"), cb_color_change, NULL);
girara_setting_set(gsession, "recolor-darkcolor", "#FFFFFF"); girara_setting_add(gsession, "recolor-lightcolor", "#000000", STRING, false, _("Recoloring (light color)"), cb_color_change, NULL);
girara_setting_add(gsession, "recolor-lightcolor", NULL, STRING, false, _("Recoloring (light color)"), cb_color_change, NULL); girara_setting_add(gsession, "highlight-color", NULL, STRING, false, _("Color for highlighting"), 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_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_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_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_add(gsession, "render-loading-fg", NULL, STRING, false, _("'Loading ...' foreground color"), cb_color_change, NULL);
girara_setting_set(gsession, "render-loading-fg", "#000000"); girara_setting_set(gsession, "render-loading-fg", "#000000");
bool_value = false; bool_value = false;
...@@ -196,6 +178,8 @@ config_load_default(zathura_t* zathura) ...@@ -196,6 +178,8 @@ config_load_default(zathura_t* zathura)
bool_value = true; bool_value = true;
girara_setting_add(gsession, "link-hadjust", &bool_value, BOOLEAN, false, _("Align link target to the left"), NULL, NULL); girara_setting_add(gsession, "link-hadjust", &bool_value, BOOLEAN, false, _("Align link target to the left"), NULL, NULL);
bool_value = true; bool_value = true;
girara_setting_add(gsession, "link-zoom", &bool_value, BOOLEAN, false, _("Let zoom be changed when following links"), 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);
...@@ -222,6 +206,8 @@ config_load_default(zathura_t* zathura) ...@@ -222,6 +206,8 @