Interface WebView.LoadChangedCallback

All Superinterfaces:
FunctionPointer
Enclosing class:
WebView
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface WebView.LoadChangedCallback extends FunctionPointer

Functional interface declaration of the LoadChangedCallback callback.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    run(LoadEvent loadEvent)
    Emitted when a load operation in webView changes.
    Creates a native function pointer to the upcall(MemorySegment, int) method.
    default void
    upcall(MemorySegment sourceWebView, int loadEvent)
    The upcall method is called from native code.
  • Method Details

    • run

      void run(LoadEvent loadEvent)

      Emitted when a load operation in webView changes. The signal is always emitted with LoadEvent.STARTED when a new load request is made and LoadEvent.FINISHED when the load finishes successfully or due to an error. When the ongoing load operation fails WebKitWebView::load-failed signal is emitted before WebKitWebView::load-changed is emitted with LoadEvent.FINISHED. If a redirection is received from the server, this signal is emitted with LoadEvent.REDIRECTED after the initial emission with LoadEvent.STARTED and before LoadEvent.COMMITTED. When the page content starts arriving the signal is emitted with LoadEvent.COMMITTED event.

      You can handle this signal and use a switch to track any ongoing load operation.

      static void web_view_load_changed (WebKitWebView  *web_view,
                                         WebKitLoadEvent load_event,
                                         gpointer        user_data)
      {
          switch (load_event) {
          case WEBKIT_LOAD_STARTED:
              // New load, we have now a provisional URI
              provisional_uri = webkit_web_view_get_uri (web_view);
              // Here we could start a spinner or update the
              // location bar with the provisional URI
              break;
          case WEBKIT_LOAD_REDIRECTED:
              redirected_uri = webkit_web_view_get_uri (web_view);
              break;
          case WEBKIT_LOAD_COMMITTED:
              // The load is being performed. Current URI is
              // the final one and it won't change unless a new
              // load is requested or a navigation within the
              // same page is performed
              uri = webkit_web_view_get_uri (web_view);
              break;
          case WEBKIT_LOAD_FINISHED:
              // Load finished, we can now stop the spinner
              break;
          }
      }
      
    • upcall

      default void upcall(MemorySegment sourceWebView, int loadEvent)
      The upcall method is called from native code. The parameters are marshaled and run(LoadEvent) is executed.
    • toCallback

      default MemorySegment toCallback(Arena arena)
      Creates a native function pointer to the upcall(MemorySegment, int) method.
      Specified by:
      toCallback in interface FunctionPointer
      Parameters:
      arena - the arena in which the function pointer is allocated
      Returns:
      the native function pointer