5 #include "display-gtk.h"
7 static void draw_page(GtkPrintOperation *operation,
8 GtkPrintContext *context,
15 struct graphics_context gc = { .printer = 1 };
17 cr = gtk_print_context_get_cairo_context(context);
20 layout=gtk_print_context_create_pango_layout(context);
22 w = gtk_print_context_get_width(context);
23 h = gtk_print_context_get_height(context);
25 /* Do the profile on the top half of the page.. */
27 plot(&gc, w, h/2, current_dive);
29 pango_cairo_show_layout(cr,layout);
30 g_object_unref(layout);
33 static void begin_print(GtkPrintOperation *operation, gpointer user_data)
37 static GtkPrintSettings *settings = NULL;
41 GtkPrintOperation *print;
42 GtkPrintOperationResult res;
44 print = gtk_print_operation_new();
46 gtk_print_operation_set_print_settings(print, settings);
47 gtk_print_operation_set_n_pages(print, 1);
48 g_signal_connect(print, "begin_print", G_CALLBACK(begin_print), NULL);
49 g_signal_connect(print, "draw_page", G_CALLBACK(draw_page), NULL);
50 res = gtk_print_operation_run(print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
51 GTK_WINDOW(main_window), NULL);
52 if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
54 g_object_unref(settings);
55 settings = g_object_ref(gtk_print_operation_get_print_settings(print));
57 g_object_unref(print);