summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Carl <danielcarl@gmx.de>2019-06-15 00:32:46 +0200
committerDaniel Carl <danielcarl@gmx.de>2019-06-15 00:32:46 +0200
commit59ff7b747813b147af63fc038a7cbfa370f319e4 (patch)
treead349a35b58b2f05a3763468432cf1b1378b5bab
parent4527955c8ab4bbef7472ce0e257b0111fdf8302d (diff)
Show error if printing fails #564.
-rw-r--r--src/ex.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/ex.c b/src/ex.c
index d67c05a..2cc96ea 100644
--- a/src/ex.c
+++ b/src/ex.c
@@ -140,6 +140,7 @@ static VbCmdResult ex_eval(Client *c, const ExArg *arg);
static void on_eval_script_finished(GDBusProxy *proxy, GAsyncResult *result, Client *c);
static VbCmdResult ex_clearcache(Client *c, const ExArg *arg);
static VbCmdResult ex_hardcopy(Client *c, const ExArg *arg);
+static void print_failed_cb(WebKitPrintOperation* op, GError *err, Client *c);
static VbCmdResult ex_map(Client *c, const ExArg *arg);
static VbCmdResult ex_unmap(Client *c, const ExArg *arg);
static VbCmdResult ex_normal(Client *c, const ExArg *arg);
@@ -858,12 +859,17 @@ static VbCmdResult ex_clearcache(Client *c, const ExArg *arg)
return CMD_SUCCESS;
}
+/**
+ * Opens the gtk print dialog.
+ */
static VbCmdResult ex_hardcopy(Client *c, const ExArg *arg)
{
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);
+
+ g_signal_connect(op, "failed", G_CALLBACK(print_failed_cb), c);
+
webkit_print_operation_set_print_settings(op, settings);
webkit_print_operation_run_dialog(op, NULL);
g_object_unref(op);
@@ -872,6 +878,14 @@ static VbCmdResult ex_hardcopy(Client *c, const ExArg *arg)
return CMD_SUCCESS;
}
+/**
+ * Callback called when printing failed.
+ */
+static void print_failed_cb(WebKitPrintOperation* op, GError *err, Client *c)
+{
+ vb_echo(c, MSG_ERROR, FALSE, "print failed: %s", err->message);
+}
+
static VbCmdResult ex_map(Client *c, const ExArg *arg)
{
if (!arg->lhs->len || !arg->rhs->len) {