]> spindle.queued.net Git - midori/commitdiff
Add print support via javascript
authorChristian Dywan <christian@twotoasts.de>
Sun, 1 Jun 2008 09:43:55 +0000 (11:43 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 1 Jun 2008 09:43:55 +0000 (11:43 +0200)
src/midori-browser.c

index 61f3c7dfb7e6fea0cf96e2981cb8c4a7aeb39986..a7084dcd5cd67d60ae69c5cec283d4b51dd3dc72 100644 (file)
@@ -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, "<Ctrl>p",
-   "hm?", NULL/*G_CALLBACK (_action_print_activate)*/ },
+   "hm?", G_CALLBACK (_action_print_activate) },
  { "Quit", GTK_STOCK_QUIT,
    NULL, "<Ctrl>q",
    N_("Quit the application"), G_CALLBACK (_action_quit_activate) },