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))
all: options ${PROJECT} po build-manpages
girara-version-check:
ifneq ($(GIRARA_VERSION_CHECK), 0)
$(error "The minimum required version of girara is ${GIRARA_MIN_VERSION}")
endif
$(QUIET)touch girara-version-check
# pkg-config based version checks
.version-checks/%:
$(QUIET)test $($(*)_VERSION_CHECK) -eq 0 || \
pkg-config --atleast-version $($(*)_MIN_VERSION) $($(*)_PKG_CONFIG_NAME) || ( \
echo "The minium required version of $(*) is $($(*)_MIN_VERSION)" && \
false \
)
@mkdir -p .version-checks
$(QUIET)touch $@
options:
@echo ${PROJECT} build options:
......@@ -56,11 +60,11 @@ options:
@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}/' | \
sed 's/ZVABI/${ZATHURA_ABI_VERSION}/' > version.h
$(QUIET)sed -e 's/ZVMAJOR/${ZATHURA_VERSION_MAJOR}/' \
-e 's/ZVMINOR/${ZATHURA_VERSION_MINOR}/' \
-e 's/ZVREV/${ZATHURA_VERSION_REV}/' \
-e 's/ZVAPI/${ZATHURA_API_VERSION}/' \
-e 's/ZVABI/${ZATHURA_ABI_VERSION}/' version.h.in > version.h
%.o: %.c
$(ECHO) CC $<
......@@ -72,8 +76,8 @@ version.h: version.h.in config.mk
@mkdir -p .depend
$(QUIET)${CC} -c ${CPPFLAGS} ${CFLAGS} ${DFLAGS} -o $@ $< -MMD -MF .depend/$@.dep
${OBJECTS}: config.mk version.h girara-version-check
${DOBJECTS}: config.mk version.h girara-version-check
${OBJECTS} ${DOBJECTS}: config.mk version.h \
.version-checks/GIRARA .version-checks/GLIB .version-checks/GTK
${PROJECT}: ${OBJECTS}
$(ECHO) CC -o $@
......@@ -83,7 +87,7 @@ clean:
$(QUIET)rm -rf ${PROJECT} ${OBJECTS} ${PROJECT}-${VERSION}.tar.gz \
${DOBJECTS} ${PROJECT}-debug .depend ${PROJECT}.pc doc version.h \
*gcda *gcno $(PROJECT).info gcov *.tmp \
girara-version-check
.version-checks
ifneq "$(wildcard ${RSTTOMAN})" ""
$(QUIET)rm -f zathura.1 zathurarc.5
endif
......
......@@ -5,7 +5,8 @@ girara user interface library and several document libraries.
Requirements
------------
gtk2 (>= 2.28)
gtk2 (>= 2.18) or gtk3
glib (>= 2.28)
girara
sqlite3 (optional, >= 3.5.9)
check (for tests)
......@@ -36,8 +37,13 @@ To build and install zathura:
make install
Uninstall:
----------
Uninstall
---------
To delete zathura from your system, just type:
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 @@
#include "adjustment.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*
zathura_adjustment_clone(GtkAdjustment* adjustment)
......
......@@ -4,8 +4,73 @@
#define ZATHURA_ADJUSTMENT_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
* 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)
g_return_val_if_fail(zathura && zathura->document && zathura->bookmarks.bookmarks, 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 y = zathura_adjustment_get_ratio(gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view)));
double position_x = zathura_document_get_position_x(zathura->document);
double position_y = zathura_document_get_position_y(zathura->document);
zathura_bookmark_t* old = zathura_bookmark_get(zathura, id);
if (old != NULL) {
old->page = page;
old->x = x;
old->y = y;
old->x = position_x;
old->y = position_y;
if (zathura->database != NULL) {
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)
bookmark->id = g_strdup(id);
bookmark->page = page;
bookmark->x = x;
bookmark->y = y;
bookmark->x = position_x;
bookmark->y = position_y;
girara_list_append(zathura->bookmarks.bookmarks, bookmark);
if (zathura->database != NULL) {
......
......@@ -8,6 +8,7 @@
#include <gtk/gtk.h>
#include <string.h>
#include <glib/gi18n.h>
#include <math.h>
#include "callbacks.h"
#include "links.h"
......@@ -48,119 +49,95 @@ cb_buffer_changed(girara_session_t* session)
}
}
void
cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpointer data)
{
zathura_t* zathura = data;
if (zathura == NULL || zathura->document == NULL || zathura->ui.page_widget == NULL) {
return;
}
GtkAdjustment* view_vadjustment = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
GtkAdjustment* view_hadjustment = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
static void
update_visible_pages(zathura_t* zathura) {
const unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
/* current adjustment values */
GdkRectangle view_rect = {
.x = 0,
.y = 0,
.width = gtk_adjustment_get_page_size(view_hadjustment),
.height = gtk_adjustment_get_page_size(view_vadjustment)
};
int page_padding = 1;
girara_setting_get(zathura->ui.session, "page-padding", &page_padding);
GdkRectangle center = {
.x = (view_rect.width + 1) / 2,
.y = (view_rect.height + 1) / 2,
.width = (2 * page_padding) + 1,
.height = (2 * page_padding) + 1
};
unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
double scale = zathura_document_get_scale(zathura->document);
bool updated = false;
/* find page that fits */
for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) {
zathura_page_t* page = zathura_document_get_page(zathura->document, page_id);
GdkRectangle page_rect = {
.width = zathura_page_get_width(page) * scale,
.height = zathura_page_get_height(page) * scale
};
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
gtk_widget_translate_coordinates(page_widget,
zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y);
ZathuraPage* zathura_page_widget = ZATHURA_PAGE(page_widget);
if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) {
if (page_is_visible(zathura->document, page_id) == true) {
/* make page visible */
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
&& gdk_rectangle_intersect(&center, &page_rect, NULL) == TRUE) {
zathura_document_set_current_page_number(zathura->document, page_id);
updated = true;
zathura_page_widget_update_view_time(zathura_page_widget);
zathura_renderer_page_cache_add(zathura->sync.render_thread, zathura_page_get_index(page));
}
} else {
zathura_page_set_visibility(page, false);
/* if the page is not visible and not cached, but still has a surface, we
* need to get rid of the surface */
if (zathura_page_widget_have_surface(ZATHURA_PAGE(page_widget)) == true &&
zathura_page_cache_is_cached(zathura, zathura_page_get_index(page)) == false) {
zathura_page_widget_update_surface(ZATHURA_PAGE(page_widget), NULL);
/* make page invisible */
if (zathura_page_get_visibility(page) == true) {
zathura_page_set_visibility(page, false);
/* If a page becomes invisible, abort the render request. */
zathura_page_widget_abort_render_request(zathura_page_widget);
}
/* reset current search result */
girara_list_t* results = NULL;
g_object_get(page_widget, "search-results", &results, NULL);
if (results != NULL) {
g_object_set(page_widget, "search-current", 0, NULL);
}
}
}
}
void
cb_view_hadjustment_value_changed(GtkAdjustment* adjustment, gpointer data)
{
zathura_t* zathura = data;
if (zathura == NULL || zathura->document == NULL) {
return;
}
/* Do nothing in index mode */
if (girara_mode_get(zathura->ui.session) == zathura->modes.index) {
return;
}
update_visible_pages(zathura);
double position_x = zathura_adjustment_get_ratio(adjustment);
double position_y = zathura_document_get_position_y(zathura->document);
unsigned int page_id = position_to_page_number(zathura->document, position_x, position_y);
zathura_document_set_position_x(zathura->document, position_x);
zathura_document_set_position_y(zathura->document, position_y);
zathura_document_set_current_page_number(zathura->document, page_id);
statusbar_page_number_update(zathura);
}
void
cb_view_hadjustment_changed(GtkAdjustment* adjustment, gpointer data)
cb_view_vadjustment_value_changed(GtkAdjustment* adjustment, gpointer data)
{
zathura_t* zathura = data;
g_return_if_fail(zathura != NULL);
if (zathura == NULL || zathura->document == NULL) {
return;
}
zathura_adjust_mode_t adjust_mode =
zathura_document_get_adjust_mode(zathura->document);
/* Do nothing in index mode */
if (girara_mode_get(zathura->ui.session) == zathura->modes.index) {
return;
}
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;
}
update_visible_pages(zathura);
ratio = zathura_adjustment_get_ratio(zathura->ui.hadjustment);
zathura_adjustment_set_value_from_ratio(adjustment, ratio);
break;
}
double position_x = zathura_document_get_position_x(zathura->document);
double position_y = zathura_adjustment_get_ratio(adjustment);
unsigned int page_id = position_to_page_number(zathura->document, position_x, position_y);
zathura_document_set_position_x(zathura->document, position_x);
zathura_document_set_position_y(zathura->document, position_y);
zathura_document_set_current_page_number(zathura->document, page_id);
statusbar_page_number_update(zathura);
}
void
cb_view_vadjustment_changed(GtkAdjustment* adjustment, gpointer data)
cb_view_hadjustment_changed(GtkAdjustment* adjustment, gpointer data)
{
zathura_t* zathura = data;
g_return_if_fail(zathura != NULL);
......@@ -168,93 +145,99 @@ cb_view_vadjustment_changed(GtkAdjustment* adjustment, gpointer data)
zathura_adjust_mode_t adjust_mode =
zathura_document_get_adjust_mode(zathura->document);
/* Do nothing in index mode */
if (girara_mode_get(zathura->ui.session) == zathura->modes.index) {
return;
}
/* Don't scroll we're focusing the inputbar. */
if (adjust_mode == ZATHURA_ADJUST_INPUTBAR) {
return;
}
double ratio = zathura_adjustment_get_ratio(zathura->ui.vadjustment);
/* save the viewport size */
unsigned int view_width = (unsigned int)floor(gtk_adjustment_get_page_size(adjustment));
zathura_document_set_viewport_width(zathura->document, view_width);
/* reset the adjustment, in case bounds have changed */
double ratio = zathura_document_get_position_x(zathura->document);
zathura_adjustment_set_value_from_ratio(adjustment, ratio);
}
void
cb_adjustment_track_value(GtkAdjustment* adjustment, gpointer data)
cb_view_vadjustment_changed(GtkAdjustment* adjustment, gpointer data)
{
GtkAdjustment* tracker = 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 = 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)) {
/* Do nothing in index mode */
if (girara_mode_get(zathura->ui.session) == zathura->modes.index) {
return;
}
gdouble value = gtk_adjustment_get_value(adjustment);
gtk_adjustment_set_value(tracker, value);
}
/* Don't scroll we're focusing the inputbar. */
if (adjust_mode == ZATHURA_ADJUST_INPUTBAR) {
return;
}
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);
/* save the viewport size */
unsigned int view_height = (unsigned int)floor(gtk_adjustment_get_page_size(adjustment));
zathura_document_set_viewport_height(zathura->document, view_height);
/* reset the adjustment, in case bounds have changed */
double ratio = zathura_document_get_position_y(zathura->document);
zathura_adjustment_set_value_from_ratio(adjustment, ratio);
}
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_refresh_view(GtkWidget* GIRARA_UNUSED(view), gpointer data)
{
g_return_if_fail(value != NULL);
g_return_if_fail(session != NULL);
g_return_if_fail(session->global.data != NULL);
zathura_t* zathura = session->global.data;
int pages_per_row = *(int*) value;
zathura_t* zathura = data;
if (zathura == NULL || zathura->document == NULL) {
return;
}
if (pages_per_row < 1) {
pages_per_row = 1;
unsigned int page_id = zathura_document_get_current_page_number(zathura->document);
zathura_page_t* page = zathura_document_get_page(zathura->document, page_id);
if (page == NULL) {
return;
}
unsigned int first_page_column = 1;
girara_setting_get(session, "first-page-column", &first_page_column);
GtkAdjustment* vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
GtkAdjustment* hadj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(zathura->ui.session->gtk.view));
page_widget_set_mode(zathura, pages_per_row, first_page_column);
double position_x = zathura_document_get_position_x(zathura->document);
double position_y = zathura_document_get_position_y(zathura->document);
if (zathura->document != NULL) {
unsigned int current_page = zathura_document_get_current_page_number(zathura->document);
page_set_delayed(zathura, current_page);
}
zathura_adjustment_set_value_from_ratio(vadj, position_y);
zathura_adjustment_set_value_from_ratio(hadj, position_x);
statusbar_page_number_update(zathura);
}
void
cb_first_page_column_value_changed(girara_session_t* session, const char* UNUSED(name), girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
cb_page_layout_value_changed(girara_session_t* session, const char* UNUSED(name), girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
{
g_return_if_fail(value != NULL);
g_return_if_fail(session != NULL);
g_return_if_fail(session->global.data != NULL);
zathura_t* zathura = session->global.data;
int first_page_column = *(int*) value;
if (first_page_column < 1) {
first_page_column = 1;
}
unsigned int pages_per_row = 1;
girara_setting_get(session, "pages-per-row", &pages_per_row);
page_widget_set_mode(zathura, pages_per_row, first_page_column);
unsigned int first_page_column = 1;
girara_setting_get(session, "first-page-column", &first_page_column);
if (zathura->document != NULL) {
unsigned int current_page = zathura_document_get_current_page_number(zathura->document);
page_set_delayed(zathura, current_page);
}
unsigned int page_padding = 1;
girara_setting_get(zathura->ui.session, "page-padding", &page_padding);
page_widget_set_mode(zathura, page_padding, pages_per_row, first_page_column);
zathura_document_set_page_layout(zathura->document, page_padding, pages_per_row, first_page_column);
}
void
......@@ -367,6 +350,13 @@ cb_sc_display_link(GtkEntry* entry, girara_session_t* session)
return handle_link(entry, session, ZATHURA_LINK_ACTION_DISPLAY);
}
static gboolean
file_monitor_reload(void* data)
{
sc_reload((girara_session_t*) data, NULL, NULL, 0);
return FALSE;
}
void
cb_file_monitor(GFileMonitor* monitor, GFile* file, GFile* UNUSED(other_file), GFileMonitorEvent event, girara_session_t* session)
{
......@@ -377,9 +367,7 @@ cb_file_monitor(GFileMonitor* monitor, GFile* file, GFile* UNUSED(other_file), G
switch (event) {
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
case G_FILE_MONITOR_EVENT_CREATED:
gdk_threads_enter();
sc_reload(session, NULL, NULL, 0);
gdk_threads_leave();
g_main_context_invoke(NULL, file_monitor_reload, session);
break;
default:
return;
......@@ -457,23 +445,19 @@ error_ret:
}
bool
cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* allocation, zathura_t* zathura)
cb_view_resized(GtkWidget* UNUSED(widget), GtkAllocation* UNUSED(allocation), zathura_t* zathura)
{
if (zathura == NULL || zathura->document == NULL) {
return false;
}
static int height = -1;
static int width = -1;
/* adjust the scale according to settings. If nothing needs to be resized,
it does not trigger the resize event.
/* adjust only if the allocation changed */
if (width != allocation->width || height != allocation->height) {
girara_argument_t argument = { zathura_document_get_adjust_mode(zathura->document), NULL };
sc_adjust_window(zathura->ui.session, &argument, NULL, 0);
width = allocation->width;
height = allocation->height;
}
The right viewport size is already in the document object, due to a
previous call to adjustment_changed. We don't want to use the allocation in
here, because we would have to subtract scrollbars, etc. */
adjust_view(zathura);