From 714f7c65f60e2841617cec8405e18b090ebe7cdc Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Sun, 1 Jun 2008 11:43:55 +0200 Subject: [PATCH] Add print support via javascript --- src/midori-browser.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/midori-browser.c b/src/midori-browser.c index 61f3c7df..a7084dcd 100644 --- a/src/midori-browser.c +++ b/src/midori-browser.c @@ -192,7 +192,10 @@ _midori_browser_update_interface (MidoriBrowser* browser) webkit_web_view_can_go_forward (WEBKIT_WEB_VIEW (web_view))); _action_set_sensitive (browser, "Reload", !loading); _action_set_sensitive (browser, "Stop", loading); + _action_set_sensitive (browser, "Print", TRUE); } + else + _action_set_sensitive (browser, "Print", FALSE); GtkAction* action = gtk_action_group_get_action (priv->action_group, "ReloadStop"); @@ -905,6 +908,15 @@ _action_window_close_activate (GtkAction* action, gtk_widget_destroy (GTK_WIDGET (browser)); } +static void +_action_print_activate (GtkAction* action, + MidoriBrowser* browser) +{ + GtkWidget* web_view = midori_browser_get_current_tab (browser); + if (web_view) + webkit_web_view_execute_script (WEBKIT_WEB_VIEW (web_view), "print ();"); +} + static void _action_quit_activate (GtkAction* action, MidoriBrowser* browser) @@ -2191,7 +2203,7 @@ static const GtkActionEntry entries[] = { "hm?", NULL/*G_CALLBACK (_action_print_preview_activate)*/ }, { "Print", GTK_STOCK_PRINT, NULL, "p", - "hm?", NULL/*G_CALLBACK (_action_print_activate)*/ }, + "hm?", G_CALLBACK (_action_print_activate) }, { "Quit", GTK_STOCK_QUIT, NULL, "q", N_("Quit the application"), G_CALLBACK (_action_quit_activate) },