mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 16:53:46 +01:00
Show printing status in statusbar
This commit is contained in:
parent
353297b301
commit
d0819a10e0
58
print.c
58
print.c
@ -1,5 +1,8 @@
|
|||||||
|
/* See LICENSE file for license and copyright information */
|
||||||
|
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
|
#include "render.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
print(zathura_t* zathura)
|
print(zathura_t* zathura)
|
||||||
@ -24,6 +27,7 @@ print(zathura_t* zathura)
|
|||||||
|
|
||||||
/* print operation signals */
|
/* print operation signals */
|
||||||
g_signal_connect(print_operation, "draw-page", G_CALLBACK(cb_print_draw_page), zathura);
|
g_signal_connect(print_operation, "draw-page", G_CALLBACK(cb_print_draw_page), zathura);
|
||||||
|
g_signal_connect(print_operation, "end-print", G_CALLBACK(cb_print_end), zathura);
|
||||||
|
|
||||||
/* print */
|
/* print */
|
||||||
GtkPrintOperationResult result = gtk_print_operation_run(print_operation,
|
GtkPrintOperationResult result = gtk_print_operation_run(print_operation,
|
||||||
@ -41,43 +45,45 @@ print(zathura_t* zathura)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cb_print_begin(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
|
cb_print_end(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
|
||||||
UNUSED(context), zathura_t* UNUSED(zathura))
|
UNUSED(context), zathura_t* zathura)
|
||||||
{
|
{
|
||||||
|
if (zathura == NULL || zathura->ui.session == NULL || zathura->document == NULL
|
||||||
|
|| zathura->document->file_path == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
girara_statusbar_item_set_text(zathura->ui.session,
|
||||||
|
zathura->ui.statusbar.file, zathura->document->file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cb_print_draw_page(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
|
cb_print_draw_page(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
|
||||||
context, gint page_number, zathura_t* zathura)
|
context, gint page_number, zathura_t* zathura)
|
||||||
{
|
{
|
||||||
/* TODO: Implement with cairo */
|
if (context == NULL || zathura == NULL || zathura->document->pages == NULL ||
|
||||||
/*cairo_t* cairo = gtk_print_context_get_cairo_context(context);*/
|
zathura->ui.session == NULL || zathura->ui.statusbar.file == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*girara_info("Printing page %d", page_number);*/
|
/* update statusbar */
|
||||||
|
char* tmp = g_strdup_printf("Printing %d...", page_number);
|
||||||
|
girara_statusbar_item_set_text(zathura->ui.session,
|
||||||
|
zathura->ui.statusbar.file, tmp);
|
||||||
|
g_free(tmp);
|
||||||
|
|
||||||
/*zathura_page_t* page = zathura->document->pages[page_number];*/
|
/* render page */
|
||||||
|
cairo_t* cairo = gtk_print_context_get_cairo_context(context);
|
||||||
|
zathura_page_t* page = zathura->document->pages[page_number];
|
||||||
|
double requested_with = gtk_print_context_get_width(context);
|
||||||
|
double tmp_scale = zathura->document->scale;
|
||||||
|
zathura->document->scale = requested_with / page->width;
|
||||||
|
|
||||||
/*double requested_with = gtk_print_context_get_width(context);*/
|
if (cairo == NULL || page == NULL) {
|
||||||
/*double tmp_scale = zathura->document->scale;*/
|
return;
|
||||||
/*zathura->document->scale = requested_with / page->width;*/
|
}
|
||||||
|
|
||||||
/*g_static_mutex_lock(&(page->lock));*/
|
zathura_page_render(page, cairo);
|
||||||
/*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->document->scale = tmp_scale;
|
||||||
/*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;*/
|
|
||||||
}
|
}
|
||||||
|
10
print.h
10
print.h
@ -23,4 +23,14 @@ void print(zathura_t* zathura);
|
|||||||
void cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext*
|
void cb_print_draw_page(GtkPrintOperation* print_operation, GtkPrintContext*
|
||||||
context, gint page_number, zathura_t* zathura);
|
context, gint page_number, zathura_t* zathura);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emitted after all pages have been rendered
|
||||||
|
*
|
||||||
|
* @param print_operation Print operation
|
||||||
|
* @param context Print context
|
||||||
|
* @param zathura Zathura object
|
||||||
|
*/
|
||||||
|
void cb_print_end(GtkPrintOperation* print_operation, GtkPrintContext* context,
|
||||||
|
zathura_t* zathura);
|
||||||
|
|
||||||
#endif // PRINT_H
|
#endif // PRINT_H
|
||||||
|
Loading…
Reference in New Issue
Block a user