Class PrintOperation

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public final class PrintOperation extends GObject

Controls a print operation.

A WebKitPrintOperation controls a print operation in WebKit. With a similar API to GtkPrintOperation, it lets you set the print settings with webkit_print_operation_set_print_settings() or display the print dialog with webkit_print_operation_run_dialog().

  • Constructor Details

    • PrintOperation

      public PrintOperation(MemorySegment address)
      Create a PrintOperation instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • PrintOperation

      public PrintOperation(WebView webView)
      Create a new WebKitPrintOperation to print webView contents.
      Parameters:
      webView - a WebKitWebView
    • PrintOperation

      public PrintOperation()
      Create a new PrintOperation.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the PrintOperation class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected PrintOperation asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getPageSetup

      public PageSetup getPageSetup()

      Return the current page setup of printOperation.

      It returns null until either webkit_print_operation_set_page_setup() or webkit_print_operation_run_dialog() have been called.

      Returns:
      the current GtkPageSetup of printOperation.
    • getPrintSettings

      public PrintSettings getPrintSettings()

      Return the current print settings of printOperation.

      It returns null until either webkit_print_operation_set_print_settings() or webkit_print_operation_run_dialog() have been called.

      Returns:
      the current GtkPrintSettings of printOperation.
    • print

      public void print()

      Start a print operation using current print settings and page setup.

      Start a print operation using current print settings and page setup without showing the print dialog. If either print settings or page setup are not set with webkit_print_operation_set_print_settings() and webkit_print_operation_set_page_setup(), the default options will be used and the print job will be sent to the default printer. The WebKitPrintOperation::finished signal is emitted when the printing operation finishes. If an error occurs while printing the signal WebKitPrintOperation::failed is emitted before WebKitPrintOperation::finished.

      If the app is running in a sandbox, this function only works if printing to a file that is in a location accessible to the sandbox, usually acquired through the File Chooser portal. This function will not work for physical printers when running in a sandbox.

    • runDialog

      public PrintOperationResponse runDialog(@Nullable Window parent)

      Run the print dialog and start printing.

      Run the print dialog and start printing using the options selected by the user. This method returns when the print dialog is closed. If the print dialog is cancelled PrintOperationResponse.CANCEL is returned. If the user clicks on the print button, PrintOperationResponse.PRINT is returned and the print operation starts. In this case, the WebKitPrintOperation::finished signal is emitted when the operation finishes. If an error occurs while printing, the signal WebKitPrintOperation::failed is emitted before WebKitPrintOperation::finished. If the print dialog is not cancelled current print settings and page setup of this PrintOperation are updated with options selected by the user when Print button is pressed in print dialog. You can get the updated print settings and page setup by calling webkit_print_operation_get_print_settings() and webkit_print_operation_get_page_setup() after this method.

      Parameters:
      parent - transient parent of the print dialog
      Returns:
      the WebKitPrintOperationResponse of the print dialog
    • setPageSetup

      public void setPageSetup(PageSetup pageSetup)

      Set the current page setup of printOperation.

      Current page setup is used for the initial values of the print dialog when webkit_print_operation_run_dialog() is called.

      Parameters:
      pageSetup - a GtkPageSetup to set
    • setPrintSettings

      public void setPrintSettings(PrintSettings printSettings)

      Set the current print settings of printOperation.

      Set the current print settings of printOperation. Current print settings are used for the initial values of the print dialog when webkit_print_operation_run_dialog() is called.

      Parameters:
      printSettings - a GtkPrintSettings to set
    • onFailed

      Emitted when an error occurs while printing. The given error, of the domain WEBKIT_PRINT_ERROR, contains further details of the failure. The WebKitPrintOperation::finished signal is emitted after this one.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitFailed

      public void emitFailed(@Nullable GError error)
      Emits the "failed" signal. See onFailed(PrintOperation.FailedCallback).
    • onFinished

      Emitted when the print operation has finished doing everything required for printing.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitFinished

      public void emitFinished()
      Emits the "finished" signal. See onFinished(PrintOperation.FinishedCallback).
    • builder

      public static PrintOperation.Builder<? extends PrintOperation.Builder> builder()
      A PrintOperation.Builder object constructs a PrintOperation with the specified properties. Use the various set...() methods to set properties, and finish construction with PrintOperation.Builder.build().
      Returns:
      the builder object