Unhitch zathura_t from document_t/page_t/plugin_manager_t

This commit is contained in:
Moritz Lipp 2012-04-03 09:02:45 +02:00
parent b458b8c17a
commit 97247f41ca
17 changed files with 173 additions and 166 deletions

View file

@ -82,7 +82,7 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi
zathura_page_t* page = zathura_document_get_page(zathura->document, page_id);
GdkRectangle page_rect;
GtkWidget* page_widget = zathura_page_get_widget(page);
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);
page_rect.width = zathura_page_get_width(page) * scale;
@ -194,7 +194,7 @@ cb_sc_follow(GtkEntry* entry, girara_session_t* session)
continue;
}
GtkWidget* page_widget = zathura_page_get_widget(page);
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
g_object_set(page_widget, "draw-links", FALSE, NULL);
if (eval == true) {

View file

@ -319,7 +319,7 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu
continue;
}
GtkWidget* page_widget = zathura_page_get_widget(page);
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
g_object_set(page_widget, "draw-links", FALSE, NULL);
girara_list_t* result = zathura_page_search_text(page, input, &error);

View file

@ -46,7 +46,6 @@ struct zathura_document_s
unsigned int rotate; /**< Rotation */
void* data; /**< Custom data */
zathura_adjust_mode_t adjust_mode; /**< Adjust mode (best-fit, width) */
zathura_t* zathura; /**< Zathura instance */
unsigned int page_offset; /**< Page offset */
/**
@ -62,7 +61,8 @@ struct zathura_document_s
zathura_document_t*
zathura_document_open(zathura_t* zathura, const char* path, const char* password)
zathura_document_open(zathura_plugin_manager_t* plugin_manager, const char*
path, const char* password, zathura_error_t* error)
{
if (path == NULL) {
return NULL;
@ -104,7 +104,7 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password
return NULL;
}
zathura_plugin_t* plugin = zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type);
zathura_plugin_t* plugin = zathura_plugin_manager_get_plugin(plugin_manager, content_type);
g_free((void*)content_type);
if (plugin == NULL) {
@ -118,7 +118,6 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password
document->password = password;
document->scale = 1.0;
document->plugin = plugin;
document->zathura = zathura;
/* open document */
if (plugin->functions.document_open == NULL) {
@ -126,49 +125,16 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password
goto error_free;
}
zathura_error_t error = plugin->functions.document_open(document);
if (error != ZATHURA_ERROR_OK) {
if (error == ZATHURA_ERROR_INVALID_PASSWORD) {
zathura_password_dialog_info_t* password_dialog_info = malloc(sizeof(zathura_password_dialog_info_t));
if (password_dialog_info != NULL) {
password_dialog_info->path = g_strdup(path);
password_dialog_info->zathura = zathura;
if (path != NULL) {
girara_dialog(zathura->ui.session, "Enter password:", true, NULL,
(girara_callback_inputbar_activate_t) cb_password_dialog, password_dialog_info);
goto error_free;
} else {
free(password_dialog_info);
}
}
goto error_free;
zathura_error_t int_error = plugin->functions.document_open(document);
if (int_error != ZATHURA_ERROR_OK) {
if (error != NULL) {
*error = int_error;
}
girara_error("could not open document\n");
goto error_free;
}
/* read history file */
zathura_db_get_fileinfo(zathura->database, document->file_path,
&document->current_page_number, &document->page_offset, &document->scale,
&document->rotate);
/* check for valid scale value */
if (document->scale <= FLT_EPSILON) {
girara_warning("document info: '%s' has non positive scale", document->file_path);
document->scale = 1;
}
/* check current page number */
if (document->current_page_number > document->number_of_pages) {
girara_warning("document info: '%s' has an invalid page number", document->file_path);
document->current_page_number = 0;
}
/* update statusbar */
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, real_path);
/* read all pages */
document->pages = calloc(document->number_of_pages, sizeof(zathura_page_t*));
if (document->pages == NULL) {
@ -184,27 +150,6 @@ zathura_document_open(zathura_t* zathura, const char* path, const char* password
document->pages[page_id] = page;
}
/* jump to first page if setting enabled */
bool always_first_page = false;
girara_setting_get(zathura->ui.session, "open-first-page", &always_first_page);
if (always_first_page == true) {
document->current_page_number = 0;
}
/* apply open adjustment */
char* adjust_open = "best-fit";
document->adjust_mode = ZATHURA_ADJUST_BESTFIT;
if (girara_setting_get(zathura->ui.session, "adjust-open", &(adjust_open)) == true) {
if (g_strcmp0(adjust_open, "best-fit") == 0) {
document->adjust_mode = ZATHURA_ADJUST_BESTFIT;
} else if (g_strcmp0(adjust_open, "width") == 0) {
document->adjust_mode = ZATHURA_ADJUST_WIDTH;
} else {
document->adjust_mode = ZATHURA_ADJUST_NONE;
}
g_free(adjust_open);
}
return document;
error_free:
@ -611,16 +556,6 @@ guess_type(const char* path)
return out;
}
zathura_t*
zathura_document_get_zathura(zathura_document_t* document)
{
if (document == NULL) {
return NULL;
}
return document->zathura;
}
zathura_plugin_t*
zathura_document_get_plugin(zathura_document_t* document)
{

View file

@ -3,24 +3,24 @@
#ifndef DOCUMENT_H
#define DOCUMENT_H
#include <cairo.h>
#include <gtk/gtk.h>
#include <stdbool.h>
#include <girara/types.h>
#include "zathura.h"
#include "types.h"
#include "page.h"
/**
* Open the document
*
* @param zathura Zathura object
* @param plugin_manager The plugin manager
* @param path Path to the document
* @param password Password of the document or NULL
* @param error Optional error parameter
* @return The document object
*/
zathura_document_t* zathura_document_open(zathura_t* zathura, const char* path,
const char* password);
zathura_document_t* zathura_document_open(zathura_plugin_manager_t*
plugin_manager, const char* path, const char* password, zathura_error_t*
error);
/**
* Free the document

View file

@ -15,15 +15,6 @@ typedef struct zathura_password_dialog_info_s
zathura_t* zathura; /**< Zathura session */
} zathura_password_dialog_info_t;
/**
* Returns the associated zathura instance
* TODO: Separate zathura_t completely from the document
*
* @param document The docment
* @return The associated zathura instance
*/
zathura_t* zathura_document_get_zathura(zathura_document_t* document);
/**
* Returns the associated plugin
*

View file

@ -62,6 +62,7 @@ enum properties_e
{
PROP_0,
PROP_PAGE,
PROP_ZATHURA,
PROP_DRAW_LINKS,
PROP_LINKS_OFFSET,
PROP_LINKS_NUMBER,
@ -98,6 +99,8 @@ zathura_page_widget_class_init(ZathuraPageClass* class)
/* add properties */
g_object_class_install_property(object_class, PROP_PAGE,
g_param_spec_pointer("page", "page", "the page to draw", G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property(object_class, PROP_ZATHURA,
g_param_spec_pointer("zathura", "zathura", "the zathura instance", G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property(object_class, PROP_DRAW_LINKS,
g_param_spec_boolean("draw-links", "draw-links", "Set to true if links should be drawn", FALSE, G_PARAM_WRITABLE));
g_object_class_install_property(object_class, PROP_LINKS_OFFSET,
@ -138,11 +141,11 @@ zathura_page_widget_init(ZathuraPage* widget)
}
GtkWidget*
zathura_page_widget_new(zathura_page_t* page)
zathura_page_widget_new(zathura_t* zathura, zathura_page_t* page)
{
g_return_val_if_fail(page != NULL, NULL);
return g_object_new(ZATHURA_TYPE_PAGE, "page", page, NULL);
return g_object_new(ZATHURA_TYPE_PAGE, "page", page, "zathura", zathura, NULL);
}
static void
@ -173,13 +176,13 @@ zathura_page_widget_set_property(GObject* object, guint prop_id, const GValue* v
{
ZathuraPage* pageview = ZATHURA_PAGE(object);
zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(pageview);
zathura_document_t* document = NULL;
switch (prop_id) {
case PROP_PAGE:
priv->page = g_value_get_pointer(value);
document = zathura_page_get_document(priv->page);
priv->zathura = zathura_document_get_zathura(document);
priv->page = g_value_get_pointer(value);
break;
case PROP_ZATHURA:
priv->zathura = g_value_get_pointer(value);
break;
case PROP_DRAW_LINKS:
priv->draw_links = g_value_get_boolean(value);

View file

@ -45,10 +45,11 @@ struct zathura_page_widget_class_s {
GType zathura_page_widget_get_type(void);
/**
* Create a page view widget.
* @param zathura the zathura instance
* @param page the page to be displayed
* @return a page view widget
*/
GtkWidget* zathura_page_widget_new(zathura_page_t* page);
GtkWidget* zathura_page_widget_new(zathura_t* zathura, zathura_page_t* page);
/**
* Update the widget's surface. This should only be called from the render
* thread.

27
page.c
View file

@ -6,7 +6,6 @@
#include "document.h"
#include "page.h"
#include "page-widget.h"
#include "plugin.h"
#include "utils.h"
#include "internal.h"
@ -18,7 +17,6 @@ struct zathura_page_s {
unsigned int index; /**< Page number */
void* data; /**< Custom data */
bool visible; /**< Page is visible */
GtkWidget* widget; /**< Drawing area */
zathura_document_t* document; /**< Document */
};
@ -38,14 +36,6 @@ zathura_page_new(zathura_document_t* document, unsigned int index, zathura_error
page->index = index;
page->visible = false;
page->document = document;
page->widget = zathura_page_widget_new(page);
if (page->widget == NULL) {
if (error != NULL) {
*error = ZATHURA_ERROR_UNKNOWN;
}
goto error_free;
}
/* init plugin */
zathura_plugin_t* plugin = zathura_document_get_plugin(document);
@ -64,13 +54,6 @@ zathura_page_new(zathura_document_t* document, unsigned int index, zathura_error
goto error_free;
}
/* set widget size */
unsigned int page_height = 0;
unsigned int page_width = 0;
page_calc_height_width(page, &page_height, &page_width, true);
gtk_widget_set_size_request(page->widget, page_width, page_height);
return page;
error_free:
@ -128,16 +111,6 @@ zathura_page_get_index(zathura_page_t* page)
return page->index;
}
GtkWidget*
zathura_page_get_widget(zathura_page_t* page)
{
if (page == NULL) {
return NULL;
}
return page->widget;
}
double
zathura_page_get_width(zathura_page_t* page)
{

11
page.h
View file

@ -4,8 +4,10 @@
#define PAGE_H
#include <girara/datastructures.h>
#include <cairo.h>
#include "document.h"
#include "types.h"
/**
* Get the page object
@ -44,15 +46,6 @@ zathura_document_t* zathura_page_get_document(zathura_page_t* page);
*/
unsigned int zathura_page_get_index(zathura_page_t* page);
/**
* Returns the page widget of the page
*
* @param page The page object
* @return The page widget of the page
* @return NULL if an error occured
*/
GtkWidget* zathura_page_get_widget(zathura_page_t* page);
/**
* Returns the width of the page
*

View file

@ -25,8 +25,6 @@ struct zathura_plugin_s
void* handle; /**< DLL handle */
};
typedef struct zathura_plugin_manager_s zathura_plugin_manager_t;
/**
* Creates a new instance of the plugin manager
*

View file

@ -163,7 +163,7 @@ render(zathura_t* zathura, zathura_page_t* page)
/* update the widget */
gdk_threads_enter();
GtkWidget* widget = zathura_page_get_widget(page);
GtkWidget* widget = zathura_page_get_widget(zathura, page);
zathura_page_widget_update_surface(ZATHURA_PAGE(widget), surface);
gdk_threads_leave();
@ -173,7 +173,7 @@ render(zathura_t* zathura, zathura_page_t* page)
void
render_all(zathura_t* zathura)
{
if (zathura->document == NULL) {
if (zathura == NULL || zathura->document == NULL) {
return;
}
@ -184,7 +184,7 @@ render_all(zathura_t* zathura)
unsigned int page_height = 0, page_width = 0;
page_calc_height_width(page, &page_height, &page_width, true);
GtkWidget* widget = zathura_page_get_widget(page);
GtkWidget* widget = zathura_page_get_widget(zathura, page);
gtk_widget_set_size_request(widget, page_width, page_height);
gtk_widget_queue_resize(widget);
}

View file

@ -51,7 +51,7 @@ sc_abort(girara_session_t* session, girara_argument_t* UNUSED(argument),
continue;
}
g_object_set(zathura_page_get_widget(page), "draw-links", FALSE, NULL);
g_object_set(zathura_page_get_widget(zathura, page), "draw-links", FALSE, NULL);
}
}
@ -238,7 +238,7 @@ sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument),
continue;
}
GtkWidget* page_widget = zathura_page_get_widget(page);
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
g_object_set(page_widget, "search-results", NULL, NULL);
if (zathura_page_get_visibility(page) == true) {
g_object_set(page_widget, "draw-links", TRUE, NULL);
@ -580,7 +580,7 @@ sc_search(girara_session_t* session, girara_argument_t* argument,
continue;
}
GtkWidget* page_widget = zathura_page_get_widget(page);
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
int num_search_results = 0, current = -1;
g_object_get(page_widget, "search-current", &current,
@ -604,7 +604,7 @@ sc_search(girara_session_t* session, girara_argument_t* argument,
int ntmp = cur_page + diff * (page_id + npage_id);
zathura_page_t* npage = zathura_document_get_page(zathura->document, (ntmp + 2*num_pages) % num_pages);
zathura_document_set_current_page_number(zathura->document, zathura_page_get_index(npage));
GtkWidget* npage_page_widget = zathura_page_get_widget(npage);
GtkWidget* npage_page_widget = zathura_page_get_widget(zathura, npage);
g_object_get(npage_page_widget, "search-length", &num_search_results, NULL);
if (num_search_results != 0) {
target_page = npage;
@ -619,14 +619,14 @@ sc_search(girara_session_t* session, girara_argument_t* argument,
if (target_page != NULL) {
girara_list_t* results = NULL;
GtkWidget* page_widget = zathura_page_get_widget(target_page);
GtkWidget* page_widget = zathura_page_get_widget(zathura, target_page);
g_object_set(page_widget, "search-current", target_idx, NULL);
g_object_get(page_widget, "search-results", &results, NULL);
zathura_rectangle_t* rect = girara_list_nth(results, target_idx);
zathura_rectangle_t rectangle = recalc_rectangle(target_page, *rect);
page_offset_t offset;
page_calculate_offset(target_page, &offset);
page_calculate_offset(zathura, target_page, &offset);
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));

View file

@ -5,6 +5,11 @@
#include "zathura.h"
/**
* Plugin manager
*/
typedef struct zathura_plugin_manager_s zathura_plugin_manager_t;
/**
* Error types
*/

20
utils.c
View file

@ -56,7 +56,7 @@ file_valid_extension(zathura_t* zathura, const char* path)
return false;
}
zathura_plugin_t* plugin = zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type);
zathura_plugin_t* plugin = zathura_plugin_manager_get_plugin(zathura->plugins.manager, content_type);
g_free((void*)content_type);
return (plugin == NULL) ? false : true;
@ -167,13 +167,11 @@ document_index_build(GtkTreeModel* model, GtkTreeIter* parent,
}
void
page_calculate_offset(zathura_page_t* page, page_offset_t* offset)
page_calculate_offset(zathura_t* zathura, zathura_page_t* page, page_offset_t* offset)
{
g_return_if_fail(page != NULL);
g_return_if_fail(offset != NULL);
zathura_document_t* document = zathura_page_get_document(page);
zathura_t* zathura = zathura_document_get_zathura(document);
GtkWidget* widget = zathura_page_get_widget(page);
GtkWidget* widget = zathura_page_get_widget(zathura, page);
g_return_if_fail(gtk_widget_translate_coordinates(widget,
zathura->ui.page_widget, 0, 0, &(offset->x), &(offset->y)) == true);
@ -292,3 +290,15 @@ page_calc_height_width(zathura_page_t* page, unsigned int* page_height, unsigned
*page_height = ceil(height * scale);
}
}
GtkWidget*
zathura_page_get_widget(zathura_t* zathura, zathura_page_t* page)
{
if (zathura == NULL || page == NULL || zathura->pages == NULL) {
return NULL;
}
unsigned int page_number = zathura_page_get_index(page);
return zathura->pages[page_number];
}

12
utils.h
View file

@ -58,11 +58,12 @@ void document_index_build(GtkTreeModel* model, GtkTreeIter* parent, girara_tree_
* Calculates the offset of the page to the top of the viewing area as
* well as to the left side of it. The result has to be freed.
*
* @param zathura Zathura session
* @param page The Page
* @param offset Applied offset
* @return The calculated offset or NULL if an error occured
*/
void page_calculate_offset(zathura_page_t* page, page_offset_t* offset);
void page_calculate_offset(zathura_t* zathura, zathura_page_t* page, page_offset_t* offset);
/**
* Rotate a rectangle by 0, 90, 180 or 270 degree
@ -103,5 +104,14 @@ void set_adjustment(GtkAdjustment* adjust, gdouble value);
void
page_calc_height_width(zathura_page_t* page, unsigned int* page_height, unsigned int* page_width, bool rotate);
/**
* Returns the page widget of the page
*
* @param zathura The zathura instance
* @param page The page object
* @return The page widget of the page
* @return NULL if an error occured
*/
GtkWidget* zathura_page_get_widget(zathura_t* zathura, zathura_page_t* page);
#endif // UTILS_H

119
zathura.c
View file

@ -435,18 +435,81 @@ document_info_open(gpointer data)
bool
document_open(zathura_t* zathura, const char* path, const char* password)
{
if (path == NULL) {
if (zathura == NULL || zathura->plugins.manager == NULL || path == NULL) {
goto error_out;
}
zathura_document_t* document = zathura_document_open(zathura, path, password);
zathura_error_t error = ZATHURA_ERROR_OK;
zathura_document_t* document = zathura_document_open(zathura->plugins.manager, path, password, &error);
if (document == NULL) {
if (error == ZATHURA_ERROR_INVALID_PASSWORD) {
zathura_password_dialog_info_t* password_dialog_info = malloc(sizeof(zathura_password_dialog_info_t));
if (password_dialog_info != NULL) {
password_dialog_info->zathura = zathura;
if (path != NULL) {
password_dialog_info->path = g_strdup(path);
girara_dialog(zathura->ui.session, "Enter password:", true, NULL,
(girara_callback_inputbar_activate_t) cb_password_dialog, password_dialog_info);
goto error_out;
} else {
free(password_dialog_info);
}
}
goto error_out;
}
goto error_out;
}
const char* file_path = zathura_document_get_path(document);
unsigned int number_of_pages = zathura_document_get_number_of_pages(document);
unsigned int current_page_number = 0;
double scale = 0;
unsigned int page_offset = 0;
unsigned int rotate = 0;
/* read history file */
zathura_db_get_fileinfo(zathura->database, file_path, &current_page_number,
&page_offset, &scale, &rotate);
/* check for valid scale value */
if (scale <= FLT_EPSILON) {
girara_warning("document info: '%s' has non positive scale", file_path);
zathura_document_set_scale(document, 1);
}
/* check current page number */
if (current_page_number > number_of_pages) {
girara_warning("document info: '%s' has an invalid page number", file_path);
zathura_document_set_current_page_number(document, 0);
}
/* jump to first page if setting enabled */
bool always_first_page = false;
girara_setting_get(zathura->ui.session, "open-first-page", &always_first_page);
if (always_first_page == true) {
zathura_document_set_current_page_number(document, 0);
}
/* apply open adjustment */
char* adjust_open = "best-fit";
zathura_document_set_adjust_mode(document, ZATHURA_ADJUST_BESTFIT);
if (girara_setting_get(zathura->ui.session, "adjust-open", &(adjust_open)) == true) {
if (g_strcmp0(adjust_open, "best-fit") == 0) {
zathura_document_set_adjust_mode(document, ZATHURA_ADJUST_BESTFIT);
} else if (g_strcmp0(adjust_open, "width") == 0) {
zathura_document_set_adjust_mode(document, ZATHURA_ADJUST_WIDTH);
} else {
zathura_document_set_adjust_mode(document, ZATHURA_ADJUST_NONE);
}
g_free(adjust_open);
}
/* update statusbar */
girara_statusbar_item_set_text(zathura->ui.session, zathura->ui.statusbar.file, file_path);
/* install file monitor */
const char* file_path = zathura_document_get_path(document);
gchar* file_uri = g_filename_to_uri(file_path, NULL, NULL);
if (file_uri == NULL) {
goto error_free;
@ -484,6 +547,33 @@ document_open(zathura_t* zathura, const char* path, const char* password)
zathura->document = document;
/* create blank pages */
zathura->pages = calloc(number_of_pages, sizeof(GtkWidget*));
if (zathura->pages == NULL) {
goto error_free;
}
for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) {
zathura_page_t* page = zathura_document_get_page(document, page_id);
if (page == NULL) {
goto error_free;
}
GtkWidget* page_widget = zathura_page_widget_new(zathura, page);
if (page_widget == NULL) {
goto error_free;
}
zathura->pages[page_id] = page_widget;
/* set widget size */
unsigned int page_height = 0;
unsigned int page_width = 0;
page_calc_height_width(page, &page_height, &page_width, true);
gtk_widget_set_size_request(page_widget, page_width, page_height);
}
/* view mode */
int pages_per_row = 1;
girara_setting_get(zathura->ui.session, "pages-per-row", &pages_per_row);
@ -498,16 +588,8 @@ document_open(zathura_t* zathura, const char* path, const char* password)
goto error_free;
}
/* create blank pages */
unsigned int number_of_pages = zathura_document_get_number_of_pages(document);
for (unsigned int page_id = 0; page_id < number_of_pages; page_id++) {
zathura_page_t* page = zathura_document_get_page(document, page_id);
if (page != NULL) {
GtkWidget* page_widget = zathura_page_get_widget(page);
if (page_widget != NULL) {
gtk_widget_realize(page_widget);
}
}
gtk_widget_realize(zathura->pages[page_id]);
}
/* bookmarks */
@ -519,7 +601,7 @@ document_open(zathura_t* zathura, const char* path, const char* password)
/* update title */
girara_set_window_title(zathura->ui.session, file_path);
free(file_uri);
g_free(file_uri);
/* adjust window */
girara_argument_t argument = { zathura_document_get_adjust_mode(document), NULL };
@ -612,11 +694,16 @@ document_close(zathura_t* zathura, bool keep_monitor)
zathura_db_set_fileinfo(zathura->database, path, current_page_number,
page_offset, scale, rotation);
/* release render thread */
render_free(zathura->sync.render_thread);
zathura->sync.render_thread = NULL;
/* remove widgets */
gtk_container_foreach(GTK_CONTAINER(zathura->ui.page_widget), remove_page_from_table, (gpointer)1);
free(zathura->pages);
zathura->pages = NULL;
/* remove document */
zathura_document_free(zathura->document);
zathura->document = NULL;
@ -683,7 +770,7 @@ page_set(zathura_t* zathura, unsigned int page_id)
zathura->global.update_page_number = false;
page_offset_t offset;
page_calculate_offset(page, &offset);
page_calculate_offset(zathura, page, &offset);
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));
@ -740,7 +827,7 @@ page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row)
int y = i / pages_per_row;
zathura_page_t* page = zathura_document_get_page(zathura->document, i);
GtkWidget* page_widget = zathura_page_get_widget(page);
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
gtk_table_attach(GTK_TABLE(zathura->ui.page_widget), page_widget, x, x + 1, y, y + 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
}
@ -764,7 +851,7 @@ gboolean purge_pages(gpointer data)
unsigned int number_of_pages = zathura_document_get_number_of_pages(zathura->document);
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);
GtkWidget* page_widget = zathura_page_get_widget(page);
GtkWidget* page_widget = zathura_page_get_widget(zathura, page);
zathura_page_widget_purge_unused(ZATHURA_PAGE(page_widget), threshold);
}
return TRUE;

View file

@ -104,6 +104,7 @@ typedef struct zathura_s
} stdin_support;
zathura_document_t* document; /**< The current document */
GtkWidget** pages; /**< The page widgets */
zathura_database_t* database; /**< The database */
/**