mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2025-01-01 07:56:00 +01:00
Allow async printing and calculate scale level
This commit is contained in:
parent
00589a7295
commit
f0d2e71ef9
1 changed files with 33 additions and 14 deletions
47
print.c
47
print.c
|
@ -18,7 +18,7 @@ print(zathura_t* zathura)
|
||||||
gtk_print_operation_set_default_page_setup(print_operation, zathura->print.page_setup);
|
gtk_print_operation_set_default_page_setup(print_operation, zathura->print.page_setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_print_operation_set_show_progress(print_operation, TRUE);
|
gtk_print_operation_set_allow_async(print_operation, TRUE);
|
||||||
gtk_print_operation_set_n_pages(print_operation, zathura->document->number_of_pages);
|
gtk_print_operation_set_n_pages(print_operation, zathura->document->number_of_pages);
|
||||||
gtk_print_operation_set_current_page(print_operation, zathura->document->current_page_number);
|
gtk_print_operation_set_current_page(print_operation, zathura->document->current_page_number);
|
||||||
|
|
||||||
|
@ -40,22 +40,41 @@ print(zathura_t* zathura)
|
||||||
g_object_unref(print_operation);
|
g_object_unref(print_operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cb_print_begin(GtkPrintOperation* print_operation, GtkPrintContext* context, zathura_t* zathura)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext* context, gint page_number, zathura_t* zathura)
|
cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext* context, gint page_number, zathura_t* zathura)
|
||||||
{
|
{
|
||||||
/*cairo_t* cairo = gtk_print_context_get_cairo_context(context);*/
|
cairo_t* cairo = gtk_print_context_get_cairo_context(context);
|
||||||
|
|
||||||
/*zathura_page_t* page = zathura->document->pages[page_number];*/
|
girara_info("Printing page %d", page_number);
|
||||||
/*g_static_mutex_lock(&(page->lock));*/
|
|
||||||
/*zathura_image_buffer_t* image_buffer = zathura_page_render(page);*/
|
|
||||||
/*g_static_mutex_unlock(&(page->lock));*/
|
|
||||||
|
|
||||||
/*for (unsigned int y = 0; y < image_buffer->height; y++) {*/
|
zathura_page_t* page = zathura->document->pages[page_number];
|
||||||
/*unsigned char* src = image_buffer->data + y * image_buffer->rowstride;*/
|
|
||||||
/*for (unsigned int x = 0; x < image_buffer->width; x++) {*/
|
double requested_with = gtk_print_context_get_width(context);
|
||||||
/*cairo_set_source_rgb(cairo, src[0], src[1], src[2]);*/
|
double tmp_scale = zathura->document->scale;
|
||||||
/*cairo_rectangle(cairo, x, y, 1, 1);*/
|
zathura->document->scale = requested_with / page->width;
|
||||||
/*cairo_fill(cairo);*/
|
|
||||||
/*}*/
|
g_static_mutex_lock(&(page->lock));
|
||||||
/*}*/
|
zathura_image_buffer_t* image_buffer = zathura_page_render(page);
|
||||||
|
g_static_mutex_unlock(&(page->lock));
|
||||||
|
|
||||||
|
for (unsigned int y = 0; y < image_buffer->height; y++) {
|
||||||
|
unsigned char* src = image_buffer->data + y * image_buffer->rowstride;
|
||||||
|
for (unsigned int x = 0; x < image_buffer->width; x++) {
|
||||||
|
if (src[0] != 255 && src[1] != 255 && src[2] != 255) {
|
||||||
|
cairo_set_source_rgb(cairo, src[0], src[1], src[2]);
|
||||||
|
cairo_rectangle(cairo, x, y, 1, 1);
|
||||||
|
cairo_fill(cairo);
|
||||||
|
}
|
||||||
|
|
||||||
|
src += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zathura->document->scale = tmp_scale;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue