summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorportix <none@none>2013-01-09 23:58:34 +0100
committerportix <none@none>2013-01-09 23:58:34 +0100
commit7066c99ee903da1fa39a3506a1f562fb346cd6d0 (patch)
tree79502b58e990a346f10701a1fd86e72d7ecaf83f /src
parent1d3c857fb1b1c1215065166d9fdb0c6841c9d49f (diff)
downloaddwb-7066c99ee903da1fa39a3506a1f562fb346cd6d0.zip
New command 'print_preview'; new option print-previewer
Diffstat (limited to 'src')
-rw-r--r--src/commands.c24
-rw-r--r--src/commands.h1
-rw-r--r--src/config.h6
3 files changed, 31 insertions, 0 deletions
diff --git a/src/commands.c b/src/commands.c
index 5efeca5f..b8de8ffb 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -661,12 +661,36 @@ commands_print(KeyMap *km, Arg *arg)
WebKitWebFrame *frame = webkit_web_view_get_focused_frame(wv);
if (frame)
{
+ char *print_command = GET_CHAR("print-previewer");
+ if (print_command)
+ g_object_set(gtk_settings_get_default(), "gtk-print-preview-command", print_command, NULL);
+
webkit_web_frame_print(frame);
return STATUS_OK;
}
return STATUS_ERROR;
}/*}}}*/
+DwbStatus
+commands_print_preview(KeyMap *km, Arg *arg)
+{
+ WebKitWebView *wv = commands_get_webview_with_nummod();
+ WebKitWebFrame *frame = webkit_web_view_get_focused_frame(wv);
+ if (frame)
+ {
+ char *print_command = GET_CHAR("print-previewer");
+ if (print_command)
+ g_object_set(gtk_settings_get_default(), "gtk-print-preview-command", print_command, NULL);
+
+ GtkPrintOperation *operation = gtk_print_operation_new();
+ webkit_web_frame_print_full(frame, operation, GTK_PRINT_OPERATION_ACTION_PREVIEW, NULL);
+ g_object_unref(operation);
+ return STATUS_OK;
+ }
+ return STATUS_ERROR;
+}/*}}}*/
+
+
/* commands_web_inspector {{{*/
DwbStatus
commands_web_inspector(KeyMap *km, Arg *arg)
diff --git a/src/commands.h b/src/commands.h
index e09fc7b9..19804d9e 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -97,5 +97,6 @@ DwbStatus commands_download(KeyMap *, Arg *);
DwbStatus commands_toggle_tab(KeyMap *, Arg *);
DwbStatus commands_reload_bookmarks(KeyMap *, Arg *);
DwbStatus commands_reload_quickmarks(KeyMap *, Arg *);
+DwbStatus commands_print_preview(KeyMap *, Arg *);
#endif
diff --git a/src/config.h b/src/config.h
index d44dc60f..81c6cb09 100644
--- a/src/config.h
+++ b/src/config.h
@@ -186,6 +186,7 @@ static KeyValue KEYS[] = {
{ "toggle_tab", { "@Tab@", GDK_CONTROL_MASK, 0 }, },
{ "reload_bookmarks", { NULL, 0, 0 }, },
{ "reload_quickmarks", { NULL, 0, 0 }, },
+ { "print_preview", { NULL, 0, 0 }, },
};
/* FUNCTION_MAP{{{*/
@@ -205,6 +206,9 @@ static FunctionMap FMAP [] = {
{ { "cancel_download", "Cancel a download", }, CP_COMMANDLINE,
(Func)commands_cancel_download, "No download to stop", ALWAYS_SM,
{ .p = NULL }, EP_NONE, { NULL }, },
+ { { "print_preview", "Show a print preview", }, CP_COMMANDLINE,
+ (Func)commands_print_preview, NULL, ALWAYS_SM,
+ { .p = NULL }, EP_NONE, { NULL }, },
{ { "clear_tab", "Clear current tab", }, CP_COMMANDLINE,
(Func)commands_clear_tab, NULL, ALWAYS_SM,
@@ -1164,4 +1168,6 @@ static WebSettings DWB_SETTINGS[] = {
SETTING_GLOBAL, INTEGER, { .i = 250 }, NULL, { 0 }, },
{ { "load-on-focus", "Load uris at the earliest when a tab gets focus", },
SETTING_GLOBAL, BOOLEAN, { .b = false }, NULL, { 0 }, },
+ { { "print-previewer", "Command used for the printing preview", },
+ SETTING_GLOBAL, CHAR, { .p = NULL }, NULL, { 0 }, },
};/*}}}*/