Class WebInspector
- All Implemented Interfaces:
Proxy
The WebKit Inspector is a graphical tool to inspect and change the
content of a WebKitWebView
. It also includes an interactive
JavaScript debugger. Using this class one can get a GtkWidget
which can be embedded into an application to show the inspector.
The inspector is available when the WebKitSettings
of the
WebKitWebView
has set the WebKitSettings
:enable-developer-extras
to true, otherwise no inspector is available.
// Enable the developer extras
WebKitSettings *settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW(my_webview));
g_object_set (G_OBJECT(settings), "enable-developer-extras", TRUE, NULL);
// Load some data or reload to be able to inspect the page
webkit_web_view_load_uri (WEBKIT_WEB_VIEW(my_webview), "http://www.gnome.org");
// Show the inspector
WebKitWebInspector *inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW(my_webview));
webkit_web_inspector_show (WEBKIT_WEB_INSPECTOR(inspector));
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Functional interface declaration of theAttachCallback
callback.static interface
Functional interface declaration of theBringToFrontCallback
callback.static class
WebInspector.Builder<B extends WebInspector.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theClosedCallback
callback.static interface
Functional interface declaration of theDetachCallback
callback.static interface
Functional interface declaration of theOpenWindowCallback
callback.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionWebInspector
(MemorySegment address) Create a WebInspector proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected WebInspector
asParent()
Returns this instance as if it were its parent type.void
attach()
Request this WebInspector to be attached.static WebInspector.Builder
<? extends WebInspector.Builder> builder()
AWebInspector.Builder
object constructs aWebInspector
with the specified properties.void
close()
Request this WebInspector to be closed.void
detach()
Request this WebInspector to be detached.boolean
Emits the "attach" signal.boolean
Emits the "bring-to-front" signal.void
Emits the "closed" signal.boolean
Emits the "detach" signal.boolean
Emits the "open-window" signal.int
Get the height that the inspector view when attached.boolean
Whether the this WebInspector can be attached to the same window that contains the inspected view.Get the URI that is currently being inspected.static Type
getType()
Get the GType of the WebInspector classGet theWebKitWebViewBase
used to display the inspector.boolean
Whether the this WebInspector view is currently attached to the same window that contains the inspected view.onAttach
(WebInspector.AttachCallback handler) Emitted when the inspector is requested to be attached to the window where the inspected web view is.Emitted when the inspector should be shown.onClosed
(WebInspector.ClosedCallback handler) Emitted when the inspector page is closed.onDetach
(WebInspector.DetachCallback handler) Emitted when the inspector is requested to be detached from the window it is currently attached to.Emitted when the inspector is requested to open in a separate window.void
show()
Request this WebInspector to be shown.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
WebInspector
Create a WebInspector proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
attach
public void attach()Request this WebInspector to be attached.The signal
WebKitWebInspector
::attach will be emitted. If the inspector is already attached it does nothing. -
close
public void close()Request this WebInspector to be closed. -
detach
public void detach()Request this WebInspector to be detached.The signal
WebKitWebInspector
::detach will be emitted. If the inspector is already detached it does nothing. -
getAttachedHeight
public int getAttachedHeight()Get the height that the inspector view when attached.Get the height that the inspector view should have when it's attached. If the inspector view is not attached this returns 0.
- Returns:
- the height of the inspector view when attached
-
getCanAttach
public boolean getCanAttach()Whether the this WebInspector can be attached to the same window that contains the inspected view.- Returns:
true
if there is enough room for the inspector view inside the window that contains the inspected view, orfalse
otherwise.
-
getInspectedUri
Get the URI that is currently being inspected.This can be
null
if nothing has been loaded yet in the inspected view, if the inspector has been closed or when inspected view was loaded from a HTML string instead of a URI.- Returns:
- the URI that is currently being inspected or
null
-
getWebView
Get theWebKitWebViewBase
used to display the inspector.This might be
null
if the inspector hasn't been loaded yet, or it has been closed.- Returns:
- the
WebKitWebViewBase
used to display the inspector ornull
-
isAttached
public boolean isAttached()Whether the this WebInspector view is currently attached to the same window that contains the inspected view.- Returns:
true
if this WebInspector is currently attached orfalse
otherwise
-
show
public void show()Request this WebInspector to be shown. -
onAttach
Emitted when the inspector is requested to be attached to the window where the inspected web view is. If this signal is not handled the inspector view will be automatically attached to the inspected view, so you only need to handle this signal if you want to attach the inspector view yourself (for example, to add the inspector view to a browser tab).To prevent the inspector view from being attached you can connect to this signal and simply return
true
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitAttach
public boolean emitAttach()Emits the "attach" signal. SeeonAttach(org.gnome.webkit.WebInspector.AttachCallback)
. -
onBringToFront
public SignalConnection<WebInspector.BringToFrontCallback> onBringToFront(WebInspector.BringToFrontCallback handler) Emitted when the inspector should be shown.If the inspector is not attached the inspector window should be shown on top of any other windows. If the inspector is attached the inspector view should be made visible. For example, if the inspector view is attached using a tab in a browser window, the browser window should be raised and the tab containing the inspector view should be the active one. In both cases, if this signal is not handled, the default implementation calls gtk_window_present() on the current toplevel
GtkWindow
of the inspector view.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitBringToFront
public boolean emitBringToFront()Emits the "bring-to-front" signal. SeeonBringToFront(org.gnome.webkit.WebInspector.BringToFrontCallback)
. -
onClosed
Emitted when the inspector page is closed. If you are using your own inspector window, you should connect to this signal and destroy your window.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitClosed
public void emitClosed()Emits the "closed" signal. SeeonClosed(org.gnome.webkit.WebInspector.ClosedCallback)
. -
onDetach
Emitted when the inspector is requested to be detached from the window it is currently attached to. The inspector is detached when the inspector page is about to be closed, and this signal is emitted right beforeWebKitWebInspector
::closed, or when the user clicks on the detach button in the inspector view to show the inspector in a separate window. In this case the signalWebKitWebInspector
::open-window is emitted after this one.To prevent the inspector view from being detached you can connect to this signal and simply return
true
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitDetach
public boolean emitDetach()Emits the "detach" signal. SeeonDetach(org.gnome.webkit.WebInspector.DetachCallback)
. -
onOpenWindow
public SignalConnection<WebInspector.OpenWindowCallback> onOpenWindow(WebInspector.OpenWindowCallback handler) Emitted when the inspector is requested to open in a separate window. If this signal is not handled, aGtkWindow
with the inspector will be created and shown, so you only need to handle this signal if you want to use your own window. This signal is emitted afterWebKitWebInspector
::detach to show the inspector in a separate window after being detached.To prevent the inspector from being shown you can connect to this signal and simply return
true
- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitOpenWindow
public boolean emitOpenWindow()Emits the "open-window" signal. SeeonOpenWindow(org.gnome.webkit.WebInspector.OpenWindowCallback)
. -
builder
AWebInspector.Builder
object constructs aWebInspector
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withWebInspector.Builder.build()
.
-