mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 15:56:00 +01:00
Remove forward declarations
This commit is contained in:
parent
3a68be9a9b
commit
a8cb8d396b
1 changed files with 53 additions and 65 deletions
118
zathura/print.c
118
zathura/print.c
|
@ -10,71 +10,6 @@
|
||||||
#include <girara/session.h>
|
#include <girara/session.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
|
||||||
static void cb_print_draw_page(GtkPrintOperation* print_operation,
|
|
||||||
GtkPrintContext* context, gint page_number,
|
|
||||||
zathura_t* zathura);
|
|
||||||
static void cb_print_end(GtkPrintOperation* print_operation, GtkPrintContext*
|
|
||||||
context, zathura_t* zathura);
|
|
||||||
static void cb_print_request_page_setup(GtkPrintOperation* print_operation,
|
|
||||||
GtkPrintContext* context,
|
|
||||||
gint page_number, GtkPageSetup* setup,
|
|
||||||
zathura_t* zathura);
|
|
||||||
static void cb_print_done(GtkPrintOperation* operation,
|
|
||||||
GtkPrintOperationResult result, zathura_t* zathura);
|
|
||||||
|
|
||||||
void
|
|
||||||
print(zathura_t* zathura)
|
|
||||||
{
|
|
||||||
g_return_if_fail(zathura != NULL);
|
|
||||||
g_return_if_fail(zathura->document != NULL);
|
|
||||||
|
|
||||||
GtkPrintOperation* print_operation = gtk_print_operation_new();
|
|
||||||
|
|
||||||
/* print operation settings */
|
|
||||||
gtk_print_operation_set_job_name(print_operation, zathura_document_get_path(zathura->document));
|
|
||||||
gtk_print_operation_set_allow_async(print_operation, TRUE);
|
|
||||||
gtk_print_operation_set_n_pages(print_operation, zathura_document_get_number_of_pages(zathura->document));
|
|
||||||
gtk_print_operation_set_current_page(print_operation, zathura_document_get_current_page_number(zathura->document));
|
|
||||||
gtk_print_operation_set_use_full_page(print_operation, TRUE);
|
|
||||||
|
|
||||||
if (zathura->print.settings != NULL) {
|
|
||||||
gtk_print_operation_set_print_settings(print_operation,
|
|
||||||
zathura->print.settings);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (zathura->print.page_setup != NULL) {
|
|
||||||
gtk_print_operation_set_default_page_setup(print_operation,
|
|
||||||
zathura->print.page_setup);
|
|
||||||
}
|
|
||||||
gtk_print_operation_set_embed_page_setup(print_operation, TRUE);
|
|
||||||
|
|
||||||
/* print operation signals */
|
|
||||||
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);
|
|
||||||
g_signal_connect(print_operation, "request-page-setup", G_CALLBACK(cb_print_request_page_setup), zathura);
|
|
||||||
|
|
||||||
/* print */
|
|
||||||
GError* error = NULL;
|
|
||||||
GtkPrintOperationResult result = gtk_print_operation_run(print_operation,
|
|
||||||
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
|
|
||||||
GTK_WINDOW(zathura->ui.session->gtk.window), &error);
|
|
||||||
|
|
||||||
if (result == GTK_PRINT_OPERATION_RESULT_ERROR) {
|
|
||||||
girara_notify(zathura->ui.session, GIRARA_ERROR, _("Printing failed: %s"),
|
|
||||||
error->message);
|
|
||||||
g_error_free(error);
|
|
||||||
} else if (result == GTK_PRINT_OPERATION_RESULT_APPLY) {
|
|
||||||
g_clear_object(&zathura->print.settings);
|
|
||||||
g_clear_object(&zathura->print.page_setup);
|
|
||||||
|
|
||||||
/* save previous settings */
|
|
||||||
zathura->print.settings = g_object_ref(gtk_print_operation_get_print_settings(print_operation));
|
|
||||||
zathura->print.page_setup = g_object_ref(gtk_print_operation_get_default_page_setup(print_operation));
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref(print_operation);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cb_print_end(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
|
cb_print_end(GtkPrintOperation* UNUSED(print_operation), GtkPrintContext*
|
||||||
UNUSED(context), zathura_t* zathura)
|
UNUSED(context), zathura_t* zathura)
|
||||||
|
@ -215,3 +150,56 @@ cb_print_request_page_setup(GtkPrintOperation* UNUSED(print_operation),
|
||||||
gtk_page_setup_set_orientation(setup, GTK_PAGE_ORIENTATION_PORTRAIT);
|
gtk_page_setup_set_orientation(setup, GTK_PAGE_ORIENTATION_PORTRAIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print(zathura_t* zathura)
|
||||||
|
{
|
||||||
|
g_return_if_fail(zathura != NULL);
|
||||||
|
g_return_if_fail(zathura->document != NULL);
|
||||||
|
|
||||||
|
GtkPrintOperation* print_operation = gtk_print_operation_new();
|
||||||
|
|
||||||
|
/* print operation settings */
|
||||||
|
gtk_print_operation_set_job_name(print_operation, zathura_document_get_path(zathura->document));
|
||||||
|
gtk_print_operation_set_allow_async(print_operation, TRUE);
|
||||||
|
gtk_print_operation_set_n_pages(print_operation, zathura_document_get_number_of_pages(zathura->document));
|
||||||
|
gtk_print_operation_set_current_page(print_operation, zathura_document_get_current_page_number(zathura->document));
|
||||||
|
gtk_print_operation_set_use_full_page(print_operation, TRUE);
|
||||||
|
|
||||||
|
if (zathura->print.settings != NULL) {
|
||||||
|
gtk_print_operation_set_print_settings(print_operation,
|
||||||
|
zathura->print.settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zathura->print.page_setup != NULL) {
|
||||||
|
gtk_print_operation_set_default_page_setup(print_operation,
|
||||||
|
zathura->print.page_setup);
|
||||||
|
}
|
||||||
|
gtk_print_operation_set_embed_page_setup(print_operation, TRUE);
|
||||||
|
|
||||||
|
/* print operation signals */
|
||||||
|
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);
|
||||||
|
g_signal_connect(print_operation, "request-page-setup", G_CALLBACK(cb_print_request_page_setup), zathura);
|
||||||
|
|
||||||
|
/* print */
|
||||||
|
GError* error = NULL;
|
||||||
|
GtkPrintOperationResult result = gtk_print_operation_run(print_operation,
|
||||||
|
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
|
||||||
|
GTK_WINDOW(zathura->ui.session->gtk.window), &error);
|
||||||
|
|
||||||
|
if (result == GTK_PRINT_OPERATION_RESULT_ERROR) {
|
||||||
|
girara_notify(zathura->ui.session, GIRARA_ERROR, _("Printing failed: %s"),
|
||||||
|
error->message);
|
||||||
|
g_error_free(error);
|
||||||
|
} else if (result == GTK_PRINT_OPERATION_RESULT_APPLY) {
|
||||||
|
g_clear_object(&zathura->print.settings);
|
||||||
|
g_clear_object(&zathura->print.page_setup);
|
||||||
|
|
||||||
|
/* save previous settings */
|
||||||
|
zathura->print.settings = g_object_ref(gtk_print_operation_get_print_settings(print_operation));
|
||||||
|
zathura->print.page_setup = g_object_ref(gtk_print_operation_get_default_page_setup(print_operation));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref(print_operation);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue