diff --git a/callbacks.c b/callbacks.c index b54de6c..fe9bfc1 100644 --- a/callbacks.c +++ b/callbacks.c @@ -16,6 +16,7 @@ #include "utils.h" #include "shortcuts.h" #include "page-widget.h" +#include "page.h" gboolean cb_destroy(GtkWidget* UNUSED(widget), zathura_t* zathura) @@ -79,22 +80,23 @@ cb_view_vadjustment_value_changed(GtkAdjustment* GIRARA_UNUSED(adjustment), gpoi zathura_page_t* page = zathura->document->pages[page_id]; GdkRectangle page_rect; - gtk_widget_translate_coordinates(page->drawing_area, + GtkWidget* page_widget = zathura_page_get_widget(page); + gtk_widget_translate_coordinates(page_widget, zathura->ui.session->gtk.view, 0, 0, &page_rect.x, &page_rect.y); - page_rect.width = page->width * zathura->document->scale; - page_rect.height = page->height * zathura->document->scale; + page_rect.width = zathura_page_get_width(page) * zathura->document->scale; + page_rect.height = zathura_page_get_height(page) * zathura->document->scale; if (gdk_rectangle_intersect(&view_rect, &page_rect, NULL) == TRUE) { - page->visible = true; + zathura_page_set_visibility(page, true); if (zathura->global.update_page_number == true && updated == false && gdk_rectangle_intersect(¢er, &page_rect, NULL) == TRUE) { zathura->document->current_page_number = page_id; updated = true; } } else { - page->visible = false; + zathura_page_set_visibility(page, false); } - zathura_page_widget_update_view_time(ZATHURA_PAGE(page->drawing_area)); + zathura_page_widget_update_view_time(ZATHURA_PAGE(page_widget)); } statusbar_page_number_update(zathura); @@ -185,14 +187,15 @@ cb_sc_follow(GtkEntry* entry, girara_session_t* session) bool invalid_index = true; for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; page_id++) { zathura_page_t* page = zathura->document->pages[page_id]; - if (page == NULL || page->visible == false) { + if (page == NULL || zathura_page_get_visibility(page) == false) { continue; } - g_object_set(page->drawing_area, "draw-links", FALSE, NULL); + GtkWidget* page_widget = zathura_page_get_widget(page); + g_object_set(page_widget, "draw-links", FALSE, NULL); if (eval == true) { - zathura_link_t* link = zathura_page_widget_link_get(ZATHURA_PAGE(page->drawing_area), index); + zathura_link_t* link = zathura_page_widget_link_get(ZATHURA_PAGE(page_widget), index); if (link != NULL) { switch (link->type) { case ZATHURA_LINK_TO_PAGE: diff --git a/commands.c b/commands.c index 47b8427..d81e9ac 100644 --- a/commands.c +++ b/commands.c @@ -14,7 +14,7 @@ #include "document.h" #include "utils.h" #include "page-widget.h" - +#include "page.h" #include #include @@ -310,12 +310,13 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu continue; } - g_object_set(page->drawing_area, "draw-links", FALSE, NULL); + GtkWidget* page_widget = zathura_page_get_widget(page); + g_object_set(page_widget, "draw-links", FALSE, NULL); girara_list_t* result = zathura_page_search_text(page, input, &error); if (result == NULL || girara_list_size(result) == 0) { girara_list_free(result); - g_object_set(page->drawing_area, "search-results", NULL, NULL); + g_object_set(page_widget, "search-results", NULL, NULL); if (error == ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED) { break; @@ -324,12 +325,12 @@ cmd_search(girara_session_t* session, const char* input, girara_argument_t* argu } } - g_object_set(page->drawing_area, "search-results", result, NULL); + g_object_set(page_widget, "search-results", result, NULL); if (firsthit == true) { if (page_id != 0) { - page_set_delayed(zathura, page->number); + page_set_delayed(zathura, zathura_page_get_id(page)); } - g_object_set(page->drawing_area, "search-current", 0, NULL); + g_object_set(page_widget, "search-current", 0, NULL); firsthit = false; } } diff --git a/config.c b/config.c index 47a717f..417cedf 100644 --- a/config.c +++ b/config.c @@ -93,7 +93,7 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "zoom-min", &int_value, INT, false, _("Zoom minimum"), NULL, NULL); int_value = 1000; girara_setting_add(gsession, "zoom-max", &int_value, INT, false, _("Zoom maximum"), NULL, NULL); - int_value = 30; + int_value = 5; girara_setting_add(gsession, "page-store-threshold", &int_value, INT, false, _("Store unvisible pages only for some time (in seconds)"), NULL, NULL); girara_setting_add(gsession, "page-store-interval", &int_value, INT, true, _("Amount of seconds between the checks for invisible pages"), NULL, NULL); diff --git a/document.c b/document.c index 6248b50..d49b97d 100644 --- a/document.c +++ b/document.c @@ -18,6 +18,7 @@ #include "zathura.h" #include "render.h" #include "database.h" +#include "page.h" #include "page-widget.h" #include @@ -550,235 +551,6 @@ zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t return document->functions.document_meta_get(document, meta, error); } -zathura_page_t* -zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plugin_error_t* error) -{ - if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) { - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; - } - return NULL; - } - - if (document->functions.page_get == NULL) { - girara_notify(document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); - girara_error("%s not implemented", __FUNCTION__); - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; - } - return NULL; - } - - zathura_page_t* page = document->functions.page_get(document, page_id, error); - - if (page != NULL) { - page->number = page_id; - page->visible = false; - page->drawing_area = zathura_page_widget_new(page); - if (page->drawing_area == NULL) { - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_UNKNOWN; - } - girara_error("Couldn't create page widget"); - zathura_page_free(page); - return NULL; - } - - page->document = document; - - 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->drawing_area, page_width, page_height); - } - - return page; -} - -zathura_plugin_error_t -zathura_page_free(zathura_page_t* page) -{ - if (page == NULL || page->document == NULL || page->document->zathura == NULL || page->document->zathura->ui.session == NULL) { - return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; - } - - if (page->document->functions.page_free == NULL) { - girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); - girara_error("%s not implemented", __FUNCTION__); - return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; - } - - return page->document->functions.page_free(page); -} - -girara_list_t* -zathura_page_search_text(zathura_page_t* page, const char* text, zathura_plugin_error_t* error) -{ - if (page == NULL || page->document == NULL || text == NULL || - page->document->zathura == NULL || page->document->zathura->ui.session == NULL) { - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; - } - return NULL; - } - - if (page->document->functions.page_search_text == NULL) { - girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); - girara_error("%s not implemented", __FUNCTION__); - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; - } - return NULL; - } - - return page->document->functions.page_search_text(page, text, error); -} - -girara_list_t* -zathura_page_links_get(zathura_page_t* page, zathura_plugin_error_t* error) -{ - if (page == NULL || page->document == NULL || page->document->zathura == NULL - || page->document->zathura->ui.session == NULL) { - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; - } - return NULL; - } - - if (page->document->functions.page_links_get == NULL) { - girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); - girara_error("%s not implemented", __FUNCTION__); - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; - } - return NULL; - } - - return page->document->functions.page_links_get(page, error); -} - -zathura_plugin_error_t -zathura_page_links_free(girara_list_t* UNUSED(list)) -{ - return false; -} - -girara_list_t* -zathura_page_form_fields_get(zathura_page_t* page, zathura_plugin_error_t* error) -{ - if (page == NULL || page->document == NULL || page->document->zathura == NULL - || page->document->zathura->ui.session == NULL) { - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; - } - return NULL; - } - - if (page->document->functions.page_form_fields_get == NULL) { - girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); - girara_error("%s not implemented", __FUNCTION__); - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; - } - return NULL; - } - - return page->document->functions.page_form_fields_get(page, error); -} - -zathura_plugin_error_t -zathura_page_form_fields_free(girara_list_t* UNUSED(list)) -{ - return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; -} - -girara_list_t* -zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error) -{ - if (page == NULL || page->document == NULL || page->document->zathura == NULL - || page->document->zathura->ui.session == NULL) { - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; - } - return NULL; - } - - if (page->document->functions.page_images_get == NULL) { - girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); - girara_error("%s not implemented", __FUNCTION__); - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; - } - return NULL; - } - - return page->document->functions.page_images_get(page, error); -} - -cairo_surface_t* -zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error) -{ - if (page == NULL || page->document == NULL || image == NULL || - page->document->zathura == NULL || page->document->zathura->ui.session == - NULL) { - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; - } - return NULL; - } - - if (page->document->functions.page_image_get_cairo == NULL) { - girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); - girara_error("%s not implemented", __FUNCTION__); - if (error != NULL) { - *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; - } - return NULL; - } - - return page->document->functions.page_image_get_cairo(page, image, error); -} - -char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t* error) -{ - if (page == NULL || page->document == NULL || page->document->zathura == NULL || page->document->zathura->ui.session == NULL) { - if (error) { - *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; - } - return NULL; - } - - if (page->document->functions.page_get_text == NULL) { - girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); - girara_error("%s not implemented", __FUNCTION__); - if (error) { - *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; - } - return NULL; - } - - return page->document->functions.page_get_text(page, rectangle, error); -} - -zathura_plugin_error_t -zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing) -{ - if (page == NULL || page->document == NULL || cairo == NULL || - page->document->zathura == NULL || page->document->zathura->ui.session == - NULL) { - return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; - } - - if (page->document->functions.page_render_cairo == NULL) { - girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); - girara_error("%s not implemented", __FUNCTION__); - return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; - } - - return page->document->functions.page_render_cairo(page, cairo, printing); -} - zathura_index_element_t* zathura_index_element_new(const char* title) { diff --git a/document.h b/document.h index 05c2280..7f1f213 100644 --- a/document.h +++ b/document.h @@ -233,20 +233,6 @@ typedef struct zathura_form_s zathura_form_type_t type; /**< Type */ } zathura_form_t; -/** - * Page - */ -struct zathura_page_s -{ - double height; /**< Page height */ - double width; /**< Page width */ - unsigned int number; /**< Page number */ - zathura_document_t* document; /**< Document */ - void* data; /**< Custom data */ - bool visible; /**< Page is visible */ - GtkWidget* drawing_area; /**< Drawing area */ -}; - /** * Document */ @@ -439,117 +425,6 @@ zathura_plugin_error_t zathura_document_attachment_save(zathura_document_t* docu */ char* zathura_document_meta_get(zathura_document_t* document, zathura_document_meta_t meta, zathura_plugin_error_t* error); -/** - * Get the page object - * - * @param document The document - * @param page_id Page number - * @param error Set to an error value (see \ref zathura_plugin_error_t) if an - * error occured - * @return Page object or NULL if an error occured - */ -zathura_page_t* zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plugin_error_t* error); - -/** - * Frees the page object - * - * @param page The page object - * @return ZATHURA_PLUGIN_ERROR_OK when no error occured, otherwise see - * zathura_plugin_error_t - */ -zathura_plugin_error_t zathura_page_free(zathura_page_t* page); - -/** - * Search page - * - * @param page The page object - * @param text Search item - * @param error Set to an error value (see \ref zathura_plugin_error_t) if an - * error occured - * @return List of results - */ -girara_list_t* zathura_page_search_text(zathura_page_t* page, const char* text, zathura_plugin_error_t* error); - -/** - * Get page links - * - * @param page The page object - * @param error Set to an error value (see \ref zathura_plugin_error_t) if an - * error occured - * @return List of links - */ -girara_list_t* zathura_page_links_get(zathura_page_t* page, zathura_plugin_error_t* error); - -/** - * Free page links - * - * @param list List of links - * @return ZATHURA_PLUGIN_ERROR_OK when no error occured, otherwise see - * zathura_plugin_error_t - */ -zathura_plugin_error_t zathura_page_links_free(girara_list_t* list); - -/** - * Get list of form fields - * - * @param page The page object - * @param error Set to an error value (see \ref zathura_plugin_error_t) if an - * error occured - * @return List of form fields - */ -girara_list_t* zathura_page_form_fields_get(zathura_page_t* page, zathura_plugin_error_t* error); - -/** - * Free list of form fields - * - * @param list List of form fields - * @return ZATHURA_PLUGIN_ERROR_OK when no error occured, otherwise see - * zathura_plugin_error_t - */ -zathura_plugin_error_t zathura_page_form_fields_free(girara_list_t* list); - -/** - * Get list of images - * - * @param page Page - * @param error Set to an error value (see \ref zathura_plugin_error_t) if an - * error occured - * @return List of images or NULL if an error occured - */ -girara_list_t* zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error); - -/** - * Get image - * - * @param page Page - * @param image Image identifier - * @param error Set to an error value (see \ref zathura_plugin_error_t) if an - * error occured - * @return The cairo image surface or NULL if an error occured - */ -cairo_surface_t* zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error); - -/** - * Get text for selection - * @param page Page - * @param rectangle Selection - * @param error Set to an error value (see \ref zathura_plugin_error_t) if an error - * occured - * @return The selected text (needs to be deallocated with g_free) - */ -char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t* error); - -/** - * Render page - * - * @param page The page object - * @param cairo Cairo object - * @param printing render for printing - * @return ZATHURA_PLUGIN_ERROR_OK when no error occured, otherwise see - * zathura_plugin_error_t - */ -zathura_plugin_error_t zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing); - /** * Create new index element * diff --git a/page-widget.c b/page-widget.c index 32cc86d..182bf2a 100644 --- a/page-widget.c +++ b/page-widget.c @@ -8,6 +8,7 @@ #include #include "page-widget.h" +#include "page.h" #include "render.h" #include "utils.h" #include "shortcuts.h" @@ -172,11 +173,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); - priv->zathura = priv->page->document->zathura; + document = zathura_page_get_document(priv->page); + priv->zathura = document->zathura; break; case PROP_DRAW_LINKS: priv->draw_links = g_value_get_boolean(value); @@ -282,6 +285,8 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); g_static_mutex_lock(&(priv->lock)); + zathura_document_t* document = zathura_page_get_document(priv->page); + #if GTK_MAJOR_VERSION == 2 GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); @@ -295,7 +300,7 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) if (priv->surface != NULL) { cairo_save(cairo); - switch (priv->page->document->rotate) { + switch (document->rotate) { case 90: cairo_translate(cairo, page_width, 0); break; @@ -307,8 +312,8 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) break; } - if (priv->page->document->rotate != 0) { - cairo_rotate(cairo, priv->page->document->rotate * G_PI / 180.0); + if (document->rotate != 0) { + cairo_rotate(cairo, document->rotate * G_PI / 180.0); } cairo_set_source_surface(cairo, priv->surface, 0, 0); @@ -524,6 +529,7 @@ cb_zathura_page_widget_button_release_event(GtkWidget* widget, GdkEventButton* b } zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); + zathura_document_t* document = zathura_page_get_document(priv->page); if (priv->selection.y2 == -1 && priv->selection.x2 == -1 ) { /* simple single click */ @@ -541,7 +547,7 @@ cb_zathura_page_widget_button_release_event(GtkWidget* widget, GdkEventButton* b && rect.y1 <= button->y && rect.y2 >= button->y) { switch (link->type) { case ZATHURA_LINK_TO_PAGE: - page_set_delayed(priv->page->document->zathura, link->target.page_number); + page_set_delayed(document->zathura, link->target.page_number); return false; case ZATHURA_LINK_EXTERNAL: girara_xdg_open(link->target.value); @@ -554,10 +560,10 @@ cb_zathura_page_widget_button_release_event(GtkWidget* widget, GdkEventButton* b redraw_rect(ZATHURA_PAGE(widget), &priv->selection); zathura_rectangle_t tmp = priv->selection; - tmp.x1 /= priv->page->document->scale; - tmp.x2 /= priv->page->document->scale; - tmp.y1 /= priv->page->document->scale; - tmp.y2 /= priv->page->document->scale; + tmp.x1 /= document->scale; + tmp.x2 /= document->scale; + tmp.y1 /= document->scale; + tmp.y2 /= document->scale; char* text = zathura_page_get_text(priv->page, tmp, NULL); if (text != NULL) { @@ -566,8 +572,8 @@ cb_zathura_page_widget_button_release_event(GtkWidget* widget, GdkEventButton* b gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), text, -1); - if (priv->page != NULL && priv->page->document != NULL && priv->page->document->zathura != NULL) { - zathura_t* zathura = priv->page->document->zathura; + if (priv->page != NULL && document != NULL && document->zathura != NULL) { + zathura_t* zathura = document->zathura; char* stripped_text = g_strdelimit(g_strdup(text), "\n\t\r\n", ' '); girara_notify(zathura->ui.session, GIRARA_INFO, _("Copied selected text to clipbard: %s"), stripped_text); g_free(stripped_text); @@ -730,7 +736,7 @@ zathura_page_widget_update_view_time(ZathuraPage* widget) g_return_if_fail(ZATHURA_IS_PAGE(widget) == TRUE); zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); - if (priv->page->visible == true) { + if (zathura_page_get_visibility(priv->page) == true) { priv->last_view = g_get_real_time(); } } @@ -740,7 +746,7 @@ zathura_page_widget_purge_unused(ZathuraPage* widget, gint64 threshold) { g_return_if_fail(ZATHURA_IS_PAGE(widget) == TRUE); zathura_page_widget_private_t* priv = ZATHURA_PAGE_GET_PRIVATE(widget); - if (priv->page->visible == true || priv->surface == NULL || threshold <= 0) { + if (zathura_page_get_visibility(priv->page) == true || priv->surface == NULL || threshold <= 0) { return; } diff --git a/page.c b/page.c new file mode 100644 index 0000000..49a206a --- /dev/null +++ b/page.c @@ -0,0 +1,369 @@ +/* See LICENSE file for license and copyright information */ + +#include +#include +#include + +#include "document.h" +#include "page.h" +#include "page-widget.h" +#include "utils.h" + +struct zathura_page_s { + double height; /**< Page height */ + double width; /**< Page width */ + unsigned int id; /**< Page number */ + void* data; /**< Custom data */ + bool visible; /**< Page is visible */ + GtkWidget* widget; /**< Drawing area */ + zathura_document_t* document; /**< Document */ +}; + +zathura_page_t* +zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plugin_error_t* error) +{ + if (document == NULL || document->zathura == NULL || document->zathura->ui.session == NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } + goto error_ret; + } + + zathura_page_t* page = NULL; + + if (document->functions.page_get == NULL) { + if (error != NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); + girara_error("%s not implemented", __FUNCTION__); + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + goto error_ret; + } + + page = document->functions.page_get(document, page_id, error); + + if (page != NULL) { + page->id = page_id; + page->visible = false; + page->document = document; + + page->widget = zathura_page_widget_new(page); + if (page->widget == NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_UNKNOWN; + } + goto error_free; + } + + 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: + + if (page != NULL) { + zathura_page_free(page); + } + +error_ret: + + return NULL; +} + +zathura_plugin_error_t +zathura_page_free(zathura_page_t* page) +{ + if (page == NULL || page->document == NULL || page->document->zathura == NULL || page->document->zathura->ui.session == NULL) { + return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } + + if (page->document->functions.page_free == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); + girara_error("%s not implemented", __FUNCTION__); + return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + + return page->document->functions.page_free(page); +} + +zathura_document_t* +zathura_page_get_document(zathura_page_t* page) +{ + if (page == NULL) { + return NULL; + } + + return page->document; +} + +unsigned int +zathura_page_get_id(zathura_page_t* page) +{ + if (page == NULL) { + return 0; + } + + return page->id; +} + +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) +{ + if (page == NULL) { + return -1; + } + + return page->width; +} + +void +zathura_page_set_width(zathura_page_t* page, double width) +{ + if (page == NULL) { + return; + } + + page->width = width; +} + +double +zathura_page_get_height(zathura_page_t* page) +{ + if (page == NULL) { + return -1; + } + + return page->height; +} + +void +zathura_page_set_height(zathura_page_t* page, double height) +{ + if (page == NULL) { + return; + } + + page->height = height; +} + +bool +zathura_page_get_visibility(zathura_page_t* page) +{ + if (page == NULL) { + return false; + } + + return page->visible; +} + +void +zathura_page_set_visibility(zathura_page_t* page, bool visibility) +{ + if (page == NULL) { + return; + } + + page->visible = visibility; +} + +void* +zathura_page_get_data(zathura_page_t* page) +{ + if (page == NULL) { + return NULL; + } + + return page->data; +} + +void +zathura_page_set_data(zathura_page_t* page, void* data) +{ + if (page == NULL) { + return; + } + + page->data = data; +} + +girara_list_t* +zathura_page_search_text(zathura_page_t* page, const char* text, zathura_plugin_error_t* error) +{ + if (page == NULL || page->document == NULL || text == NULL || + page->document->zathura == NULL || page->document->zathura->ui.session == NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } + return NULL; + } + + if (page->document->functions.page_search_text == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); + girara_error("%s not implemented", __FUNCTION__); + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + return NULL; + } + + return page->document->functions.page_search_text(page, text, error); +} + +girara_list_t* +zathura_page_links_get(zathura_page_t* page, zathura_plugin_error_t* error) +{ + if (page == NULL || page->document == NULL || page->document->zathura == NULL + || page->document->zathura->ui.session == NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } + return NULL; + } + + if (page->document->functions.page_links_get == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); + girara_error("%s not implemented", __FUNCTION__); + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + return NULL; + } + + return page->document->functions.page_links_get(page, error); +} + +zathura_plugin_error_t +zathura_page_links_free(girara_list_t* UNUSED(list)) +{ + return false; +} + +girara_list_t* +zathura_page_form_fields_get(zathura_page_t* page, zathura_plugin_error_t* error) +{ + if (page == NULL || page->document == NULL || page->document->zathura == NULL + || page->document->zathura->ui.session == NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } + return NULL; + } + + if (page->document->functions.page_form_fields_get == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); + girara_error("%s not implemented", __FUNCTION__); + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + return NULL; + } + + return page->document->functions.page_form_fields_get(page, error); +} + +zathura_plugin_error_t +zathura_page_form_fields_free(girara_list_t* UNUSED(list)) +{ + return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; +} + +girara_list_t* +zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error) +{ + if (page == NULL || page->document == NULL || page->document->zathura == NULL + || page->document->zathura->ui.session == NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } + return NULL; + } + + if (page->document->functions.page_images_get == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); + girara_error("%s not implemented", __FUNCTION__); + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + return NULL; + } + + return page->document->functions.page_images_get(page, error); +} + +cairo_surface_t* +zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error) +{ + if (page == NULL || page->document == NULL || image == NULL || + page->document->zathura == NULL || page->document->zathura->ui.session == + NULL) { + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } + return NULL; + } + + if (page->document->functions.page_image_get_cairo == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); + girara_error("%s not implemented", __FUNCTION__); + if (error != NULL) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + return NULL; + } + + return page->document->functions.page_image_get_cairo(page, image, error); +} + +char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t* error) +{ + if (page == NULL || page->document == NULL || page->document->zathura == NULL || page->document->zathura->ui.session == NULL) { + if (error) { + *error = ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } + return NULL; + } + + if (page->document->functions.page_get_text == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); + girara_error("%s not implemented", __FUNCTION__); + if (error) { + *error = ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + return NULL; + } + + return page->document->functions.page_get_text(page, rectangle, error); +} + +zathura_plugin_error_t +zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing) +{ + if (page == NULL || page->document == NULL || cairo == NULL || + page->document->zathura == NULL || page->document->zathura->ui.session == + NULL) { + return ZATHURA_PLUGIN_ERROR_INVALID_ARGUMENTS; + } + + if (page->document->functions.page_render_cairo == NULL) { + girara_notify(page->document->zathura->ui.session, GIRARA_WARNING, _("%s not implemented"), __FUNCTION__); + girara_error("%s not implemented", __FUNCTION__); + return ZATHURA_PLUGIN_ERROR_NOT_IMPLEMENTED; + } + + return page->document->functions.page_render_cairo(page, cairo, printing); +} diff --git a/page.h b/page.h new file mode 100644 index 0000000..b4b429a --- /dev/null +++ b/page.h @@ -0,0 +1,214 @@ +/* See LICENSE file for license and copyright information */ + +#ifndef PAGE_H +#define PAGE_H + +#include + +#include "document.h" + +/** + * Get the page object + * + * @param document The document + * @param id Page number + * @param error Set to an error value (see \ref zathura_plugin_error_t) if an + * error occured + * @return Page object or NULL if an error occured + */ +zathura_page_t* zathura_page_get(zathura_document_t* document, unsigned int page_id, zathura_plugin_error_t* error); + +/** + * Frees the page object + * + * @param page The page object + * @return ZATHURA_PLUGIN_ERROR_OK when no error occured, otherwise see + * zathura_plugin_error_t + */ +zathura_plugin_error_t zathura_page_free(zathura_page_t* page); + +/** + * Returns the associated document + * + * @param page The page object + * @return The associated document + * @return NULL if an error occured + */ +zathura_document_t* zathura_page_get_document(zathura_page_t* page); + +/** + * Returns the set id of the page + * + * @param page The page object + * @return The id of the page + */ +unsigned int zathura_page_get_id(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 + * + * @param page The page object + * @return Width of the page + * @return -1 If an error occured + */ +double zathura_page_get_width(zathura_page_t* page); + +/** + * Sets the new width of the page + * + * @param page The page object + * @param width The new width of the page + */ +void zathura_page_set_width(zathura_page_t* page, double width); + +/** + * Returns the height of the page + * + * @param page The page object + * @return Height of the page + * @return -1 If an error occured + */ +double zathura_page_get_height(zathura_page_t* page); + +/** + * Sets the new height of the page + * + * @param page The page object + * @param height The new height of the page + */ +void zathura_page_set_height(zathura_page_t* page, double height); + +/** + * Returns the visibility of the page + * + * @param page The page object + * @return true if the page is visible + * @return false if the page is hidden + */ +bool zathura_page_get_visibility(zathura_page_t* page); + +/** + * Sets the visibility of the page + * + * @param page The page object + * @param visibility The new visibility value + */ +void zathura_page_set_visibility(zathura_page_t* page, bool visibility); + +/** + * Returns the custom data + * + * @param page The page object + * @return The custom data or NULL + */ +void* zathura_page_get_data(zathura_page_t* page); + +/** + * Sets the custom data + * + * @param page The page object + * @param data The custom data + */ +void zathura_page_set_data(zathura_page_t* page, void* data); + +/** + * Search page + * + * @param page The page object + * @param text Search item + * @param error Set to an error value (see \ref zathura_plugin_error_t) if an + * error occured + * @return List of results + */ +girara_list_t* zathura_page_search_text(zathura_page_t* page, const char* text, zathura_plugin_error_t* error); + +/** + * Get page links + * + * @param page The page object + * @param error Set to an error value (see \ref zathura_plugin_error_t) if an + * error occured + * @return List of links + */ +girara_list_t* zathura_page_links_get(zathura_page_t* page, zathura_plugin_error_t* error); + +/** + * Free page links + * + * @param list List of links + * @return ZATHURA_PLUGIN_ERROR_OK when no error occured, otherwise see + * zathura_plugin_error_t + */ +zathura_plugin_error_t zathura_page_links_free(girara_list_t* list); + +/** + * Get list of form fields + * + * @param page The page object + * @param error Set to an error value (see \ref zathura_plugin_error_t) if an + * error occured + * @return List of form fields + */ +girara_list_t* zathura_page_form_fields_get(zathura_page_t* page, zathura_plugin_error_t* error); + +/** + * Free list of form fields + * + * @param list List of form fields + * @return ZATHURA_PLUGIN_ERROR_OK when no error occured, otherwise see + * zathura_plugin_error_t + */ +zathura_plugin_error_t zathura_page_form_fields_free(girara_list_t* list); + +/** + * Get list of images + * + * @param page Page + * @param error Set to an error value (see \ref zathura_plugin_error_t) if an + * error occured + * @return List of images or NULL if an error occured + */ +girara_list_t* zathura_page_images_get(zathura_page_t* page, zathura_plugin_error_t* error); + +/** + * Get image + * + * @param page Page + * @param image Image identifier + * @param error Set to an error value (see \ref zathura_plugin_error_t) if an + * error occured + * @return The cairo image surface or NULL if an error occured + */ +cairo_surface_t* zathura_page_image_get_cairo(zathura_page_t* page, zathura_image_t* image, zathura_plugin_error_t* error); + +/** + * Get text for selection + * @param page Page + * @param rectangle Selection + * @param error Set to an error value (see \ref zathura_plugin_error_t) if an error + * occured + * @return The selected text (needs to be deallocated with g_free) + */ +char* zathura_page_get_text(zathura_page_t* page, zathura_rectangle_t rectangle, zathura_plugin_error_t* error); + +/** + * Render page + * + * @param page The page object + * @param cairo Cairo object + * @param printing render for printing + * @return ZATHURA_PLUGIN_ERROR_OK when no error occured, otherwise see + * zathura_plugin_error_t + */ +zathura_plugin_error_t zathura_page_render(zathura_page_t* page, cairo_t* cairo, bool printing); + +#endif // PAGE_H diff --git a/print.c b/print.c index e6d683f..4f029e6 100644 --- a/print.c +++ b/print.c @@ -3,6 +3,7 @@ #include "print.h" #include "document.h" #include "render.h" +#include "page.h" #include #include diff --git a/render.c b/render.c index 55fdd5e..6cb7a28 100644 --- a/render.c +++ b/render.c @@ -9,6 +9,7 @@ #include "render.h" #include "zathura.h" #include "document.h" +#include "page.h" #include "page-widget.h" #include "utils.h" @@ -30,7 +31,7 @@ render_job(void* data, void* user_data) } if (render(zathura, page) != true) { - girara_error("Rendering failed (page %d)\n", page->number); + girara_error("Rendering failed (page %d)\n", zathura_page_get_id(page)); } } @@ -161,7 +162,8 @@ render(zathura_t* zathura, zathura_page_t* page) /* update the widget */ gdk_threads_enter(); - zathura_page_widget_update_surface(ZATHURA_PAGE(page->drawing_area), surface); + GtkWidget* widget = zathura_page_get_widget(page); + zathura_page_widget_update_surface(ZATHURA_PAGE(widget), surface); gdk_threads_leave(); return true; @@ -180,7 +182,8 @@ render_all(zathura_t* zathura) unsigned int page_height = 0, page_width = 0; page_calc_height_width(page, &page_height, &page_width, true); - gtk_widget_set_size_request(page->drawing_area, page_width, page_height); - gtk_widget_queue_resize(page->drawing_area); + GtkWidget* widget = zathura_page_get_widget(page); + gtk_widget_set_size_request(widget, page_width, page_height); + gtk_widget_queue_resize(widget); } } diff --git a/shortcuts.c b/shortcuts.c index 42a8244..de04b48 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -15,6 +15,7 @@ #include "zathura.h" #include "render.h" #include "utils.h" +#include "page.h" #include "page-widget.h" static void @@ -44,7 +45,7 @@ sc_abort(girara_session_t* session, girara_argument_t* UNUSED(argument), continue; } - g_object_set(page->drawing_area, "draw-links", FALSE, NULL); + g_object_set(zathura_page_get_widget(page), "draw-links", FALSE, NULL); } } @@ -97,11 +98,11 @@ sc_adjust_window(girara_session_t* session, girara_argument_t* argument, goto error_ret; } - if (page->height > max_height) { - max_height = page->height; + if (zathura_page_get_height(page) > max_height) { + max_height = zathura_page_get_height(page); } - total_width += page->width; + total_width += zathura_page_get_width(page); } if (argument->n == ADJUST_WIDTH) { @@ -212,19 +213,20 @@ sc_follow(girara_session_t* session, girara_argument_t* UNUSED(argument), continue; } - g_object_set(page->drawing_area, "search-results", NULL, NULL); - if (page->visible == true) { - g_object_set(page->drawing_area, "draw-links", TRUE, NULL); + GtkWidget* page_widget = zathura_page_get_widget(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); int number_of_links = 0; - g_object_get(page->drawing_area, "number-of-links", &number_of_links, NULL); + g_object_get(page_widget, "number-of-links", &number_of_links, NULL); if (number_of_links != 0) { show_links = true; } - g_object_set(page->drawing_area, "offset-links", page_offset, NULL); + g_object_set(page_widget, "offset-links", page_offset, NULL); page_offset += number_of_links; } else { - g_object_set(page->drawing_area, "draw-links", FALSE, NULL); + g_object_set(page_widget, "draw-links", FALSE, NULL); } } @@ -547,8 +549,10 @@ sc_search(girara_session_t* session, girara_argument_t* argument, continue; } + GtkWidget* page_widget = zathura_page_get_widget(page); + int num_search_results = 0, current = -1; - g_object_get(page->drawing_area, "search-current", ¤t, + g_object_get(page_widget, "search-current", ¤t, "search-length", &num_search_results, NULL); if (num_search_results == 0 || current == -1) { continue; @@ -563,13 +567,14 @@ sc_search(girara_session_t* session, girara_argument_t* argument, target_idx = current - 1; } else { /* the next result is on a different page */ - g_object_set(page->drawing_area, "search-current", -1, NULL); + g_object_set(page_widget, "search-current", -1, NULL); for (int npage_id = 1; page_id < num_pages; ++npage_id) { int ntmp = cur_page + diff * (page_id + npage_id); zathura_page_t* npage = zathura->document->pages[(ntmp + 2*num_pages) % num_pages]; - zathura->document->current_page_number = npage->number; - g_object_get(npage->drawing_area, "search-length", &num_search_results, NULL); + zathura->document->current_page_number = zathura_page_get_id(npage); + GtkWidget* npage_page_widget = zathura_page_get_widget(npage); + g_object_get(npage_page_widget, "search-length", &num_search_results, NULL); if (num_search_results != 0) { target_page = npage; target_idx = diff == 1 ? 0 : num_search_results - 1; @@ -583,8 +588,9 @@ sc_search(girara_session_t* session, girara_argument_t* argument, if (target_page != NULL) { girara_list_t* results = NULL; - g_object_set(target_page->drawing_area, "search-current", target_idx, NULL); - g_object_get(target_page->drawing_area, "search-results", &results, NULL); + GtkWidget* page_widget = zathura_page_get_widget(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); diff --git a/utils.c b/utils.c index 5c5bcbc..5387f27 100644 --- a/utils.c +++ b/utils.c @@ -12,6 +12,7 @@ #include "utils.h" #include "zathura.h" #include "document.h" +#include "page.h" #include @@ -172,11 +173,13 @@ document_index_build(GtkTreeModel* model, GtkTreeIter* parent, void page_calculate_offset(zathura_page_t* page, page_offset_t* offset) { - g_return_if_fail(page != NULL && page->document != NULL && page->document->zathura != NULL && offset != NULL); - zathura_document_t* document = page->document; + g_return_if_fail(page != NULL); + g_return_if_fail(offset != NULL); + zathura_document_t* document = zathura_page_get_document(page); zathura_t* zathura = document->zathura; + GtkWidget* widget = zathura_page_get_widget(page); - g_return_if_fail(gtk_widget_translate_coordinates(page->drawing_area, + g_return_if_fail(gtk_widget_translate_coordinates(widget, zathura->ui.page_widget, 0, 0, &(offset->x), &(offset->y)) == true); } @@ -215,39 +218,52 @@ zathura_rectangle_t rotate_rectangle(zathura_rectangle_t rectangle, unsigned int zathura_rectangle_t recalc_rectangle(zathura_page_t* page, zathura_rectangle_t rectangle) { - if (page == NULL || page->document == NULL) { - return rectangle; + if (page == NULL) { + goto error_ret; } + zathura_document_t* document = zathura_page_get_document(page); + + if (document == NULL) { + goto error_ret; + } + + double page_height = zathura_page_get_height(page); + double page_width = zathura_page_get_width(page); + zathura_rectangle_t tmp; - switch (page->document->rotate) { + switch (document->rotate) { case 90: - tmp.x1 = (page->height - rectangle.y2) * page->document->scale; - tmp.x2 = (page->height - rectangle.y1) * page->document->scale; - tmp.y1 = rectangle.x1 * page->document->scale; - tmp.y2 = rectangle.x2 * page->document->scale; + tmp.x1 = (page_height - rectangle.y2) * document->scale; + tmp.x2 = (page_height - rectangle.y1) * document->scale; + tmp.y1 = rectangle.x1 * document->scale; + tmp.y2 = rectangle.x2 * document->scale; break; case 180: - tmp.x1 = (page->width - rectangle.x2) * page->document->scale; - tmp.x2 = (page->width - rectangle.x1) * page->document->scale; - tmp.y1 = (page->height - rectangle.y2) * page->document->scale; - tmp.y2 = (page->height - rectangle.y1) * page->document->scale; + tmp.x1 = (page_width - rectangle.x2) * document->scale; + tmp.x2 = (page_width - rectangle.x1) * document->scale; + tmp.y1 = (page_height - rectangle.y2) * document->scale; + tmp.y2 = (page_height - rectangle.y1) * document->scale; break; case 270: - tmp.x1 = rectangle.y1 * page->document->scale; - tmp.x2 = rectangle.y2 * page->document->scale; - tmp.y1 = (page->width - rectangle.x2) * page->document->scale; - tmp.y2 = (page->width - rectangle.x1) * page->document->scale; + tmp.x1 = rectangle.y1 * document->scale; + tmp.x2 = rectangle.y2 * document->scale; + tmp.y1 = (page_width - rectangle.x2) * document->scale; + tmp.y2 = (page_width - rectangle.x1) * document->scale; break; default: - tmp.x1 = rectangle.x1 * page->document->scale; - tmp.x2 = rectangle.x2 * page->document->scale; - tmp.y1 = rectangle.y1 * page->document->scale; - tmp.y2 = rectangle.y2 * page->document->scale; + tmp.x1 = rectangle.x1 * document->scale; + tmp.x2 = rectangle.x2 * document->scale; + tmp.y1 = rectangle.y1 * document->scale; + tmp.y2 = rectangle.y2 * document->scale; } return tmp; + +error_ret: + + return rectangle; } void @@ -262,11 +278,19 @@ page_calc_height_width(zathura_page_t* page, unsigned int* page_height, unsigned { g_return_if_fail(page != NULL && page_height != NULL && page_width != NULL); - if (rotate && page->document->rotate % 180) { - *page_width = ceil(page->height * page->document->scale); - *page_height = ceil(page->width * page->document->scale); + zathura_document_t* document = zathura_page_get_document(page); + if (document == NULL) { + return; + } + + double height = zathura_page_get_height(page); + double width = zathura_page_get_width(page); + + if (rotate && document->rotate % 180) { + *page_width = ceil(height * document->scale); + *page_height = ceil(width * document->scale); } else { - *page_width = ceil(page->width * page->document->scale); - *page_height = ceil(page->height * page->document->scale); + *page_width = ceil(width * document->scale); + *page_height = ceil(height * document->scale); } } diff --git a/zathura.c b/zathura.c index 2b354ec..d838091 100644 --- a/zathura.c +++ b/zathura.c @@ -27,6 +27,7 @@ #include "zathura.h" #include "utils.h" #include "render.h" +#include "page.h" #include "page-widget.h" typedef struct zathura_document_info_s @@ -496,7 +497,12 @@ document_open(zathura_t* zathura, const char* path, const char* password) /* create blank pages */ for (unsigned int page_id = 0; page_id < document->number_of_pages; page_id++) { zathura_page_t* page = document->pages[page_id]; - gtk_widget_realize(page->drawing_area); + if (page != NULL) { + GtkWidget* page_widget = zathura_page_get_widget(page); + if (page_widget != NULL) { + gtk_widget_realize(page_widget); + } + } } /* bookmarks */ @@ -722,7 +728,9 @@ page_widget_set_mode(zathura_t* zathura, unsigned int pages_per_row) { int x = i % pages_per_row; int y = i / pages_per_row; - gtk_table_attach(GTK_TABLE(zathura->ui.page_widget), zathura->document->pages[i]->drawing_area, x, x + 1, y, y + 1, GTK_SHRINK, GTK_SHRINK, 0, 0); + + GtkWidget* page_widget = zathura_page_get_widget(zathura->document->pages[i]); + gtk_table_attach(GTK_TABLE(zathura->ui.page_widget), page_widget, x, x + 1, y, y + 1, GTK_SHRINK, GTK_SHRINK, 0, 0); } gtk_widget_show_all(zathura->ui.page_widget); @@ -744,7 +752,8 @@ gboolean purge_pages(gpointer data) for (unsigned int page_id = 0; page_id < zathura->document->number_of_pages; page_id++) { zathura_page_t* page = zathura->document->pages[page_id]; - zathura_page_widget_purge_unused(ZATHURA_PAGE(page->drawing_area), threshold); + GtkWidget* page_widget = zathura_page_get_widget(page); + zathura_page_widget_purge_unused(ZATHURA_PAGE(page_widget), threshold); } return TRUE; }