6 static void draw_page(GtkPrintOperation *operation,
7 GtkPrintContext *context,
14 struct graphics_context gc = { .printer = 1 };
16 cr = gtk_print_context_get_cairo_context(context);
19 layout=gtk_print_context_create_pango_layout(context);
21 w = gtk_print_context_get_width(context);
22 h = gtk_print_context_get_height(context);
24 /* Do the profile on the top half of the page.. */
25 plot(&gc, w, h/2, current_dive);
27 pango_cairo_show_layout(cr,layout);
28 g_object_unref(layout);
31 static void begin_print(GtkPrintOperation *operation, gpointer user_data)
35 static GtkPrintSettings *settings = NULL;
39 GtkPrintOperation *print;
40 GtkPrintOperationResult res;
42 print = gtk_print_operation_new();
44 gtk_print_operation_set_print_settings(print, settings);
45 gtk_print_operation_set_n_pages(print, 1);
46 g_signal_connect(print, "begin_print", G_CALLBACK(begin_print), NULL);
47 g_signal_connect(print, "draw_page", G_CALLBACK(draw_page), NULL);
48 res = gtk_print_operation_run(print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
49 GTK_WINDOW(main_window), NULL);
50 if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
52 g_object_unref(settings);
53 settings = g_object_ref(gtk_print_operation_get_print_settings(print));
55 g_object_unref(print);