Commit 02f64675 authored by Moritz Lipp's avatar Moritz Lipp

Moved render function

parent a819cf51
......@@ -6,6 +6,7 @@
#include <gtk/gtk.h>
#include "zathura.h"
#include "render.h"
#include "ft/document.h"
gboolean
......@@ -61,44 +62,7 @@ cb_view_vadjustment_value_changed(GtkAdjustment *adjustment, gpointer data)
|| ( (begin <= lower) && (end >= lower) && (end <= upper) ) /* end of the page is in viewport */
|| ( (begin >= lower) && (end >= upper) && (begin <= upper) ) /* begin of the page is in viewport */
) {
/* render page */
GtkWidget* image = zathura_page_render(page);
if(!image) {
printf("error: rendering failed\n");
return;
}
/* add new page */
GList* list = gtk_container_get_children(GTK_CONTAINER(Zathura.UI.page_view));
GtkWidget* widget = (GtkWidget*) g_list_nth_data(list, page_id);
g_list_free(list);
if(widget) {
/* child packaging information */
gboolean expand;
gboolean fill;
guint padding;
GtkPackType pack_type;
gtk_box_query_child_packing(GTK_BOX(Zathura.UI.page_view), widget, &expand, &fill, &padding, &pack_type);
/* delete old widget */
gtk_container_remove(GTK_CONTAINER(Zathura.UI.page_view), widget);
/* add new widget */
gtk_box_pack_start(GTK_BOX(Zathura.UI.page_view), image, TRUE, TRUE, 0);
/* set old packaging values */
gtk_box_set_child_packing(GTK_BOX(Zathura.UI.page_view), image, expand, fill, padding, pack_type);
/* reorder child */
gtk_box_reorder_child(GTK_BOX(Zathura.UI.page_view), image, page_id);
} else {
printf("error: page container does not exist\n");
g_object_unref(image);
return;
}
page_render(Zathura.document->pages[page_id]);
}
}
}
#include "render.h"
#include "zathura.h"
bool page_render(zathura_page_t* page)
{
GtkWidget* image = zathura_page_render(page);
if(!image) {
printf("error: rendering failed\n");
return false;
}
/* add new page */
GList* list = gtk_container_get_children(GTK_CONTAINER(Zathura.UI.page_view));
GtkWidget* widget = (GtkWidget*) g_list_nth_data(list, page->number);
g_list_free(list);
if(!widget) {
printf("error: page container does not exist\n");
g_object_unref(image);
return false;
}
/* child packaging information */
gboolean expand;
gboolean fill;
guint padding;
GtkPackType pack_type;
gtk_box_query_child_packing(GTK_BOX(Zathura.UI.page_view), widget, &expand, &fill, &padding, &pack_type);
/* delete old widget */
gtk_container_remove(GTK_CONTAINER(Zathura.UI.page_view), widget);
/* add new widget */
gtk_box_pack_start(GTK_BOX(Zathura.UI.page_view), image, TRUE, TRUE, 0);
/* set old packaging values */
gtk_box_set_child_packing(GTK_BOX(Zathura.UI.page_view), image, expand, fill, padding, pack_type);
/* reorder child */
gtk_box_reorder_child(GTK_BOX(Zathura.UI.page_view), image, page->number);
return true;
}
/* See LICENSE file for license and copyright information */
#include <stdbool.h>
#include "ft/document.h"
bool page_render(zathura_page_t* page);
......@@ -145,26 +145,6 @@ document_close()
return true;
}
bool
page_render(zathura_page_t* page)
{
GtkWidget* image = zathura_page_render(page);
if(!image) {
goto error_out;
}
/* draw new rendered page */
if(!girara_set_view(Zathura.UI.session, image)) {
goto error_out;
}
return true;
error_out:
return false;
}
bool
page_set(unsigned int page_id)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment