mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 10:16:01 +01:00
djvu support rotation
This commit is contained in:
parent
ace7e41a17
commit
19637bcd54
2 changed files with 55 additions and 13 deletions
|
@ -243,17 +243,39 @@ djvu_page_render(zathura_page_t* page)
|
||||||
page_width, page_height, 3 * page_width, NULL, NULL);
|
page_width, page_height, 3 * page_width, NULL, NULL);
|
||||||
|
|
||||||
if(!pixbuf) {
|
if(!pixbuf) {
|
||||||
free(buffer);
|
goto error_free;
|
||||||
g_object_unref(pixbuf);
|
}
|
||||||
goto error_out;
|
|
||||||
|
/* rotate page */
|
||||||
|
if(Zathura.document->rotate != 0) {
|
||||||
|
GdkPixbufRotation angle = GDK_PIXBUF_ROTATE_NONE;
|
||||||
|
|
||||||
|
switch(Zathura.document->rotate) {
|
||||||
|
case 90:
|
||||||
|
angle = GDK_PIXBUF_ROTATE_CLOCKWISE;
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
angle = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
|
||||||
|
break;
|
||||||
|
case 270:
|
||||||
|
angle = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
goto error_free;
|
||||||
|
}
|
||||||
|
|
||||||
|
GdkPixbuf* pixbuf_temp = gdk_pixbuf_rotate_simple(pixbuf, Zathura.document->rotate);
|
||||||
|
if(!pixbuf_temp) {
|
||||||
|
goto error_free;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixbuf = pixbuf_temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget* image = gtk_image_new();
|
GtkWidget* image = gtk_image_new();
|
||||||
|
|
||||||
if(!image) {
|
if(!image) {
|
||||||
free(buffer);
|
goto error_free;
|
||||||
g_object_unref(pixbuf);
|
|
||||||
goto error_out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf);
|
gtk_image_set_from_pixbuf(GTK_IMAGE(image), pixbuf);
|
||||||
|
@ -261,6 +283,11 @@ djvu_page_render(zathura_page_t* page)
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
|
||||||
|
error_free:
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
g_object_unref(pixbuf);
|
||||||
|
|
||||||
error_out:
|
error_out:
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
29
zathura.c
29
zathura.c
|
@ -101,6 +101,26 @@ document_close()
|
||||||
return true;
|
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
|
bool
|
||||||
page_set(unsigned int page_id)
|
page_set(unsigned int page_id)
|
||||||
{
|
{
|
||||||
|
@ -114,12 +134,12 @@ page_set(unsigned int page_id)
|
||||||
|
|
||||||
/* render page */
|
/* render page */
|
||||||
zathura_page_t* page = zathura_page_get(Zathura.document, page_id);
|
zathura_page_t* page = zathura_page_get(Zathura.document, page_id);
|
||||||
|
|
||||||
if(!page) {
|
if(!page) {
|
||||||
goto error_out;
|
goto error_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget* image = zathura_page_render(page);
|
if(!page_render(page)) {
|
||||||
if(!image) {
|
|
||||||
zathura_page_free(page);
|
zathura_page_free(page);
|
||||||
fprintf(stderr, "error: rendering failed\n");
|
fprintf(stderr, "error: rendering failed\n");
|
||||||
goto error_out;
|
goto error_out;
|
||||||
|
@ -127,11 +147,6 @@ page_set(unsigned int page_id)
|
||||||
|
|
||||||
zathura_page_free(page);
|
zathura_page_free(page);
|
||||||
|
|
||||||
/* draw new rendered page */
|
|
||||||
if(!girara_set_view(Zathura.UI.session, image)) {
|
|
||||||
goto error_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* update page number */
|
/* update page number */
|
||||||
Zathura.document->current_page_number = page_id;
|
Zathura.document->current_page_number = page_id;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue