From 193fb5dcc8a0ba3775342c29eef64d1283acce88 Mon Sep 17 00:00:00 2001
From: Daniel Carl <danielcarl@gmx.de>
Date: Mon, 10 Apr 2017 00:14:18 +0200
Subject: [PATCH] Open print dialog on :hardcopy.

---
 src/ex.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/ex.c b/src/ex.c
index 46f02a7..6818ba1 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -829,7 +829,15 @@ static void ex_eval_javascript_finished(GObject *object,
 
 static VbCmdResult ex_hardcopy(Client *c, const ExArg *arg)
 {
-    webkit_web_view_run_javascript(c->webview, "window.print();", NULL, NULL, NULL);
+    WebKitPrintOperation *op   = webkit_print_operation_new(c->webview);
+    GtkPrintSettings *settings = gtk_print_settings_new();
+
+    gtk_print_settings_set(settings, GTK_PRINT_SETTINGS_OUTPUT_BASENAME, c->state.title);
+    webkit_print_operation_set_print_settings(op, settings);
+    webkit_print_operation_run_dialog(op, NULL);
+    g_object_unref(op);
+    g_object_unref(settings);
+
     return CMD_SUCCESS;
 }
 
-- 
2.20.1