Changeset 42435 in webkit
- Timestamp:
- Apr 13, 2009 9:26:52 AM (15 years ago)
- Location:
- trunk/WebKit/gtk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/gtk/ChangeLog
r42391 r42435 1 2009-04-13 Gustavo Noronha Silva <gns@gnome.org> 2 3 Reviewed by Holger Freyther. 4 5 https://bugs.webkit.org/show_bug.cgi?id=22898 6 [GTK] need proper API for printing 7 8 Implement proper printing API, using the GTK+ printing API. 9 10 * WebCoreSupport/ChromeClientGtk.cpp: 11 (WebKit::ChromeClient::print): 12 * webkit/webkitprivate.h: 13 * webkit/webkitwebframe.cpp: 14 * webkit/webkitwebframe.h: 15 * webkit/webkitwebview.cpp: 16 1 17 2009-04-10 Gustavo Noronha Silva <gustavo.noronha@collabora.co.uk> 2 18 -
trunk/WebKit/gtk/WebCoreSupport/ChromeClientGtk.cpp
r42251 r42435 405 405 void ChromeClient::print(Frame* frame) 406 406 { 407 webkit_web_frame_print(kit(frame)); 407 WebKitWebFrame* webFrame = kit(frame); 408 gboolean isHandled = false; 409 g_signal_emit_by_name(m_webView, "print-requested", webFrame, &isHandled); 410 411 if (isHandled) 412 return; 413 414 webkit_web_frame_print(webFrame); 408 415 } 409 416 -
trunk/WebKit/gtk/webkit/webkitprivate.h
r41522 r42435 177 177 webkit_web_frame_get_inner_text (WebKitWebFrame* frame); 178 178 179 WEBKIT_API void180 webkit_web_frame_print (WebKitWebFrame* frame);181 182 179 WEBKIT_API gchar* 183 180 webkit_web_frame_dump_render_tree (WebKitWebFrame* frame); -
trunk/WebKit/gtk/webkit/webkitwebframe.cpp
r42251 r42435 7 7 * Copyright (C) 2008 Nuanti Ltd. 8 8 * Copyright (C) 2009 Jan Alonzo <jmalonzo@gmail.com> 9 * Copyright (C) 2009 Gustavo Noronha Silva <gns@gnome.org> 9 10 * 10 11 * This library is free software; you can redistribute it and/or … … 612 613 } 613 614 614 static void begin_print (GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data)615 static void begin_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data) 615 616 { 616 617 PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data); … … 630 631 } 631 632 632 static void draw_page (GtkPrintOperation* op, GtkPrintContext* context, gint page_nr, gpointer user_data)633 static void draw_page_callback(GtkPrintOperation* op, GtkPrintContext* context, gint page_nr, gpointer user_data) 633 634 { 634 635 PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data); … … 640 641 } 641 642 642 static void end_print (GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data)643 static void end_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data) 643 644 { 644 645 PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data); … … 646 647 } 647 648 648 void webkit_web_frame_print(WebKitWebFrame* frame) 649 { 649 /** 650 * webkit_web_frame_print_full: 651 * @frame: a #WebKitWebFrame to be printed 652 * @operation: the #GtkPrintOperation to be carried 653 * @action: the #GtkPrintOperationAction to be performed 654 * @error: #GError for error return 655 * 656 * Prints the given #WebKitFrame, using the given #GtkPrintOperation 657 * and #GtkPrintOperationAction. This function wraps a call to 658 * gtk_print_operation_run() for printing the contents of the 659 * #WebKitWebFrame. 660 * 661 * Since: 1.1.5 662 */ 663 GtkPrintOperationResult webkit_web_frame_print_full(WebKitWebFrame* frame, GtkPrintOperation* operation, GtkPrintOperationAction action, GError** error) 664 { 665 g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), GTK_PRINT_OPERATION_RESULT_ERROR); 666 g_return_val_if_fail(GTK_IS_PRINT_OPERATION(operation), GTK_PRINT_OPERATION_RESULT_ERROR); 667 650 668 GtkWidget* topLevel = gtk_widget_get_toplevel(GTK_WIDGET(webkit_web_frame_get_web_view(frame))); 651 669 if (!GTK_WIDGET_TOPLEVEL(topLevel)) … … 654 672 Frame* coreFrame = core(frame); 655 673 if (!coreFrame) 656 return ;674 return GTK_PRINT_OPERATION_RESULT_ERROR; 657 675 658 676 PrintContext printContext(coreFrame); 659 677 660 GtkPrintOperation* op = gtk_print_operation_new(); 661 g_signal_connect(op, "begin-print", G_CALLBACK(begin_print), &printContext); 662 g_signal_connect(op, "draw-page", G_CALLBACK(draw_page), &printContext); 663 g_signal_connect(op, "end-print", G_CALLBACK(end_print), &printContext); 664 GError *error = NULL; 665 gtk_print_operation_run(op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_WINDOW(topLevel), &error); 666 g_object_unref(op); 678 g_signal_connect(operation, "begin-print", G_CALLBACK(begin_print_callback), &printContext); 679 g_signal_connect(operation, "draw-page", G_CALLBACK(draw_page_callback), &printContext); 680 g_signal_connect(operation, "end-print", G_CALLBACK(end_print_callback), &printContext); 681 682 return gtk_print_operation_run(operation, action, GTK_WINDOW(topLevel), error); 683 } 684 685 /** 686 * webkit_web_frame_print: 687 * @frame: a #WebKitWebFrame 688 * 689 * Prints the given #WebKitFrame, by presenting a print dialog to the 690 * user. If you need more control over the printing process, see 691 * webkit_web_frame_print_full(). 692 * 693 * Since: 1.1.5 694 */ 695 void webkit_web_frame_print(WebKitWebFrame* frame) 696 { 697 g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame)); 698 699 WebKitWebFramePrivate* priv = frame->priv; 700 GtkPrintOperation* operation = gtk_print_operation_new(); 701 GError* error = 0; 702 703 webkit_web_frame_print_full(frame, operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, &error); 704 g_object_unref(operation); 667 705 668 706 if (error) { 669 GtkWidget* dialog = gtk_message_dialog_new(GTK_WINDOW(topLevel), 707 GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(priv->webView)); 708 GtkWidget* dialog = gtk_message_dialog_new(GTK_WIDGET_TOPLEVEL(window) ? GTK_WINDOW(window) : 0, 670 709 GTK_DIALOG_DESTROY_WITH_PARENT, 671 710 GTK_MESSAGE_ERROR, -
trunk/WebKit/gtk/webkit/webkitwebframe.h
r40918 r42435 23 23 24 24 #include <glib-object.h> 25 #include <gtk/gtk.h> 26 25 27 #include <JavaScriptCore/JSBase.h> 26 28 … … 109 111 webkit_web_frame_get_global_context (WebKitWebFrame *frame); 110 112 113 WEBKIT_API GtkPrintOperationResult 114 webkit_web_frame_print_full (WebKitWebFrame *frame, 115 GtkPrintOperation *operation, 116 GtkPrintOperationAction action, 117 GError **error); 118 119 WEBKIT_API void 120 webkit_web_frame_print (WebKitWebFrame *frame); 121 111 122 G_END_DECLS 112 123 -
trunk/WebKit/gtk/webkit/webkitwebview.cpp
r42391 r42435 140 140 DOWNLOAD_REQUESTED, 141 141 MOVE_CURSOR, 142 PRINT_REQUESTED, 142 143 LAST_SIGNAL 143 144 }; … … 1375 1376 G_TYPE_NONE, 1, 1376 1377 GTK_TYPE_MENU); 1378 1379 /** 1380 * WebKitWebView::print-requested 1381 * @web_view: the object in which the signal is emitted 1382 * @web_frame: the frame that is requesting to be printed 1383 * @return: %TRUE if the print request has been handled, %FALSE if 1384 * the default handler should run 1385 * 1386 * Emitted when printing is requested by the frame, usually 1387 * because of a javascript call. When handling this signal you 1388 * should call webkit_web_frame_print_full() or 1389 * webkit_web_frame_print() to do the actual printing. 1390 * 1391 * The default handler will present a print dialog and carry a 1392 * print operation. Notice that this means that if you intend to 1393 * ignore a print request you must connect to this signal, and 1394 * return %TRUE. 1395 * 1396 * Since: 1.1.5 1397 */ 1398 webkit_web_view_signals[PRINT_REQUESTED] = g_signal_new("print-requested", 1399 G_TYPE_FROM_CLASS(webViewClass), 1400 (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), 1401 0, 1402 g_signal_accumulator_true_handled, 1403 NULL, 1404 webkit_marshal_BOOLEAN__OBJECT, 1405 G_TYPE_BOOLEAN, 1, 1406 WEBKIT_TYPE_WEB_FRAME); 1377 1407 1378 1408 webkit_web_view_signals[STATUS_BAR_TEXT_CHANGED] = g_signal_new("status-bar-text-changed",
Note: See TracChangeset
for help on using the changeset viewer.