WebKit2GTK+ Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Implemented Interfaces | Properties | Signals |
struct WebKitWebView; enum WebKitLoadEvent; GtkWidget * webkit_web_view_new (void
); GtkWidget * webkit_web_view_new_with_context (WebKitWebContext *context
); WebKitWebContext * webkit_web_view_get_context (WebKitWebView *web_view
); void webkit_web_view_load_uri (WebKitWebView *web_view
,const gchar *uri
); void webkit_web_view_load_html (WebKitWebView *web_view
,const gchar *content
,const gchar *base_uri
); void webkit_web_view_load_plain_text (WebKitWebView *web_view
,const gchar *plain_text
); void webkit_web_view_load_request (WebKitWebView *web_view
,WebKitURIRequest *request
); void webkit_web_view_replace_content (WebKitWebView *web_view
,const gchar *content
,const gchar *content_uri
,const gchar *base_uri
); gboolean webkit_web_view_can_go_back (WebKitWebView *web_view
); void webkit_web_view_go_back (WebKitWebView *web_view
); gboolean webkit_web_view_can_go_forward (WebKitWebView *web_view
); void webkit_web_view_go_forward (WebKitWebView *web_view
); const gchar * webkit_web_view_get_title (WebKitWebView *web_view
); void webkit_web_view_reload (WebKitWebView *web_view
); void webkit_web_view_reload_bypass_cache (WebKitWebView *web_view
); void webkit_web_view_stop_loading (WebKitWebView *web_view
); gdouble webkit_web_view_get_estimated_load_progress (WebKitWebView *web_view
); const gchar * webkit_web_view_get_custom_charset (WebKitWebView *web_view
); void webkit_web_view_set_custom_charset (WebKitWebView *web_view
,const gchar *charset
); WebKitBackForwardList * webkit_web_view_get_back_forward_list (WebKitWebView *web_view
); void webkit_web_view_go_to_back_forward_list_item (WebKitWebView *web_view
,WebKitBackForwardListItem *list_item
); const gchar * webkit_web_view_get_uri (WebKitWebView *web_view
); void webkit_web_view_set_settings (WebKitWebView *web_view
,WebKitSettings *settings
); WebKitSettings * webkit_web_view_get_settings (WebKitWebView *web_view
); WebKitWindowProperties * webkit_web_view_get_window_properties (WebKitWebView *web_view
); void webkit_web_view_set_zoom_level (WebKitWebView *web_view
,gdouble zoom_level
); gdouble webkit_web_view_get_zoom_level (WebKitWebView *web_view
);
GObject +----GInitiallyUnowned +----GtkWidget +----GtkContainer +----WebKitWebViewBase +----WebKitWebView
"estimated-load-progress" gdouble : Read "title" gchar* : Read "uri" gchar* : Read "web-context" WebKitWebContext* : Read / Write / Construct Only "zoom-level" gdouble : Read / Write
"close" :Run Last
"create" :Run Last
"load-changed" :Run Last
"load-failed" :Run Last
"ready-to-show" :Run Last
"script-alert" :Run Last
"script-confirm" :Run Last
"script-prompt" :Run Last
typedef enum { WEBKIT_LOAD_STARTED, WEBKIT_LOAD_REDIRECTED, WEBKIT_LOAD_COMMITTED, WEBKIT_LOAD_FINISHED } WebKitLoadEvent;
A new load request has been made. No data has been received yet, empty structures have been allocated to perform the load; the load may still fail due to transport issues such as not being able to resolve a name, or connect to a port. | |
A provisional data source received a server redirect. | |
The content started arriving for a page load. The necessary transport requirements are stabilished, and the load is being performed. | |
Load completed. All resources are done loading or there was an error during the load operation. |
GtkWidget * webkit_web_view_new (void
);
Creates a new WebKitWebView with the default WebKitWebContext.
See also webkit_web_view_new_with_context()
.
Returns : |
The newly created WebKitWebView widget |
GtkWidget * webkit_web_view_new_with_context (WebKitWebContext *context
);
Creates a new WebKitWebView with the given WebKitWebContext.
|
the WebKitWebContext to be used by the WebKitWebView |
Returns : |
The newly created WebKitWebView widget |
WebKitWebContext * webkit_web_view_get_context (WebKitWebView *web_view
);
Gets the web context of web_view
.
|
a WebKitWebView |
Returns : |
the WebKitWebContext of the view. [transfer none] |
void webkit_web_view_load_uri (WebKitWebView *web_view
,const gchar *uri
);
Requests loading of the specified URI string. You can monitor the load operation by connecting to "load-changed" signal.
|
a WebKitWebView |
|
an URI string |
void webkit_web_view_load_html (WebKitWebView *web_view
,const gchar *content
,const gchar *base_uri
);
Load the given content
string with the specified base_uri
.
Relative URLs in the content
will be resolved against base_uri
.
When base_uri
is NULL
, it defaults to "about:blank". The mime type
of the document will be "text/html". You can monitor the load operation
by connecting to "load-changed" signal.
|
a WebKitWebView |
|
The HTML string to load |
|
The base URI for relative locations or NULL . [allow-none]
|
void webkit_web_view_load_plain_text (WebKitWebView *web_view
,const gchar *plain_text
);
Load the specified plain_text
string into web_view
. The mime type of
document will be "text/plain". You can monitor the load
operation by connecting to "load-changed" signal.
|
a WebKitWebView |
|
The plain text to load |
void webkit_web_view_load_request (WebKitWebView *web_view
,WebKitURIRequest *request
);
Requests loading of the specified WebKitURIRequest. You can monitor the load operation by connecting to "load-changed" signal.
|
a WebKitWebView |
|
a WebKitURIRequest to load |
void webkit_web_view_replace_content (WebKitWebView *web_view
,const gchar *content
,const gchar *content_uri
,const gchar *base_uri
);
Replace the content of web_view
with content
using content_uri
as page URI.
This allows clients to display page-loading errors in the WebKitWebView itself.
This is typically called from "load-failed" signal. The URI passed in
base_uri
has to be an absolute URI. The mime type of the document will be "text/html".
Signals "load-changed" and "load-failed" are not emitted
when replacing content of a WebKitWebView using this method.
|
a WebKitWebView |
|
the new content to display as the main page of the web_view
|
|
the URI for the page content |
|
the base URI for relative locations or NULL . [allow-none]
|
gboolean webkit_web_view_can_go_back (WebKitWebView *web_view
);
Determines whether web_view
has a previous history item.
|
a WebKitWebView |
Returns : |
TRUE if able to move back or FALSE otherwise. |
void webkit_web_view_go_back (WebKitWebView *web_view
);
Loads the previous history item. You can monitor the load operation by connecting to "load-changed" signal.
|
a WebKitWebView |
gboolean webkit_web_view_can_go_forward (WebKitWebView *web_view
);
Determines whether web_view
has a next history item.
|
a WebKitWebView |
Returns : |
TRUE if able to move forward or FALSE otherwise. |
void webkit_web_view_go_forward (WebKitWebView *web_view
);
Loads the next history item. You can monitor the load operation by connecting to "load-changed" signal.
|
a WebKitWebView |
const gchar * webkit_web_view_get_title (WebKitWebView *web_view
);
Gets the value of the "title" property.
You can connect to notify::title signal of web_view
to
be notified when the title has been received.
|
a WebKitWebView |
Returns : |
The main frame document title of web_view . |
void webkit_web_view_reload (WebKitWebView *web_view
);
Reloads the current contents of web_view
.
See also webkit_web_view_reload_bypass_cache()
.
|
a WebKitWebView |
void webkit_web_view_reload_bypass_cache (WebKitWebView *web_view
);
Reloads the current contents of web_view
without
using any cached data.
|
a WebKitWebView |
void webkit_web_view_stop_loading (WebKitWebView *web_view
);
Stops any ongoing loading operation in web_view
.
This method does nothing if no content is being loaded.
If there is a loading operation in progress, it will be cancelled and
"load-failed" signal will be emitted with
WEBKIT_NETWORK_ERROR_CANCELLED
error.
|
a WebKitWebView |
gdouble webkit_web_view_get_estimated_load_progress
(WebKitWebView *web_view
);
Gets the value of the "estimated-load-progress" property.
You can monitor the estimated progress of a load operation by
connecting to the notify::estimated-load-progress signal of web_view
.
|
a WebKitWebView |
Returns : |
an estimate of the of the percent complete for a document load as a range from 0.0 to 1.0. |
const gchar * webkit_web_view_get_custom_charset (WebKitWebView *web_view
);
Returns the current custom character encoding name of web_view
.
|
a WebKitWebView |
Returns : |
the current custom character encoding name or NULL if no
custom character encoding has been set. |
void webkit_web_view_set_custom_charset (WebKitWebView *web_view
,const gchar *charset
);
Sets the current custom character encoding override of web_view
. The custom
character encoding will override any text encoding detected via HTTP headers or
META tags. Calling this method will stop any current load operation and reload the
current page. Setting the custom character encoding to NULL
removes the character
encoding override.
|
a WebKitWebView |
|
a character encoding name or NULL . [allow-none]
|
WebKitBackForwardList * webkit_web_view_get_back_forward_list
(WebKitWebView *web_view
);
Obtains the WebKitBackForwardList associated with the given WebKitWebView. The WebKitBackForwardList is owned by the WebKitWebView.
|
a WebKitWebView |
Returns : |
the WebKitBackForwardList. [transfer none] |
void webkit_web_view_go_to_back_forward_list_item (WebKitWebView *web_view
,WebKitBackForwardListItem *list_item
);
Loads the specific history item list_item
.
You can monitor the load operation by connecting to
"load-changed" signal.
|
a WebKitWebView |
|
a WebKitBackForwardListItem |
const gchar * webkit_web_view_get_uri (WebKitWebView *web_view
);
Returns the current active URI of web_view
. The active URI might change during
a load operation:
When nothing has been loaded yet on web_view
the active URI is NULL
.
When a new load operation starts the active URI is the requested URI:
If the load operation was started by webkit_web_view_load_uri()
,
the requested URI is the given one.
If the load operation was started by webkit_web_view_load_html()
,
the requested URI is "about:blank".
If the load operation was started by webkit_web_view_go_back()
or
webkit_web_view_go_forward()
, the requested URI is the original URI
of the previous/next item in the WebKitBackForwardList of web_view
.
If the load operation was started by
webkit_web_view_go_to_back_forward_list_item()
, the requested URI
is the opriginal URI of the given WebKitBackForwardListItem.
If there is a server redirection during the load operation,
the active URI is the redirected URI. When the signal
"load-changed" is emitted with WEBKIT_LOAD_REDIRECTED
event, the active URI is already updated to the redirected URI.
When the signal "load-changed" is emitted
with WEBKIT_LOAD_COMMITTED
event, the active URI is the final
one and it will not change unless a new load operation is started
or a navigation action within the same page is performed.
When the page content is replaced using webkit_web_view_replace_content()
,
the active URI is the content_uri provided.
You can monitor the active URI by connecting to the notify::uri
signal of web_view
.
|
a WebKitWebView |
Returns : |
the current active URI of web_view or NULL
if nothing has been loaded yet. |
void webkit_web_view_set_settings (WebKitWebView *web_view
,WebKitSettings *settings
);
Sets the WebKitSettings to be applied to web_view
. The
existing WebKitSettings of web_view
will be replaced by
settings
. New settings are applied immediately on web_view
.
The same WebKitSettings object can be shared
by multiple WebKitWebViews.
|
a WebKitWebView |
|
a WebKitSettings |
WebKitSettings * webkit_web_view_get_settings (WebKitWebView *web_view
);
Gets the WebKitSettings currently applied to web_view
.
If no other WebKitSettings have been explicitly applied to
web_view
with webkit_web_view_set_settings()
, the default
WebKitSettings will be returned. This method always returns
a valid WebKitSettings object.
To modify any of the web_view
settings, you can either create
a new WebKitSettings object with webkit_settings_new()
, setting
the desired preferences, and then replace the existing web_view
settings with webkit_web_view_set_settings()
or get the existing
web_view
settings and update it directly. WebKitSettings objects
can be shared by multiple WebKitWebViews, so modifying
the settings of a WebKitWebView would affect other
WebKitWebViews using the same WebKitSettings.
|
a WebKitWebView |
Returns : |
the WebKitSettings attached to web_view . [transfer none]
|
WebKitWindowProperties * webkit_web_view_get_window_properties
(WebKitWebView *web_view
);
Get the WebKitWindowProperties object containing the properties
that the window containing web_view
should have.
|
a WebKitWebView |
Returns : |
the WebKitWindowProperties of web_view . [transfer none]
|
void webkit_web_view_set_zoom_level (WebKitWebView *web_view
,gdouble zoom_level
);
Set the zoom level of web_view
, i.e. the factor by which the
view contents are scaled with respect to their original size.
|
a WebKitWebView |
|
the zoom level |
gdouble webkit_web_view_get_zoom_level (WebKitWebView *web_view
);
Get the zoom level of web_view
, i.e. the factor by which the
view contents are scaled with respect to their original size.
|
a WebKitWebView |
Returns : |
the current zoom level of web_view
|
"estimated-load-progress"
property "estimated-load-progress" gdouble : Read
An estimate of the percent completion for the current loading operation. This value will range from 0.0 to 1.0 and, once a load completes, will remain at 1.0 until a new load starts, at which point it will be reset to 0.0. The value is an estimate based on the total number of bytes expected to be received for a document, including all its possible subresources and child documents.
Allowed values: [0,1]
Default value: 0
"title"
property "title" gchar* : Read
The main frame document title of this WebKitWebView. If
the title has not been received yet, it will be NULL
.
Default value: NULL
"uri"
property "uri" gchar* : Read
The current active URI of the WebKitWebView.
See webkit_web_view_get_uri()
for more details.
Default value: NULL
"web-context"
property"web-context" WebKitWebContext* : Read / Write / Construct Only
The WebKitWebContext of the view.
"zoom-level"
property "zoom-level" gdouble : Read / Write
The zoom level of the WebKitWebView content.
See webkit_web_view_set_zoom_level()
for more details.
Allowed values: >= 0
Default value: 1
"close"
signalvoid user_function (WebKitWebView *webView,
gpointer user_data) : Run Last
Emitted when closing a WebKitWebView is requested. This occurs when a
call is made from JavaScript's window.close
function.
It is the owner's responsibility to handle this signal to hide or
destroy the WebKitWebView, if necessary.
|
the WebKitWebView on which the signal is emitted |
|
user data set when the signal handler was connected. |
"create"
signalGtkWidget* user_function (WebKitWebView *web_view,
gpointer user_data) : Run Last
Emitted when the creation of a new WebKitWebView is requested. If this signal is handled the signal handler should return the newly created WebKitWebView.
The new WebKitWebView should not be displayed to the user until the "ready-to-show" signal is emitted.
|
the WebKitWebView on which the signal is emitted |
|
user data set when the signal handler was connected. |
Returns : |
a newly allocated WebKitWebView widget
or NULL to propagate the event further. [transfer full]
|
"load-changed"
signalvoid user_function (WebKitWebView *web_view,
WebKitLoadEvent load_event,
gpointer user_data) : Run Last
Emitted when the a load operation in web_view
changes.
The signal is always emitted with WEBKIT_LOAD_STARTED
when a
new load request is made and WEBKIT_LOAD_FINISHED
when the load
finishes successfully or due to an error. When the ongoing load
operation fails "load-failed" signal is emitted
before "load-changed" is emitted with
WEBKIT_LOAD_FINISHED
.
If a redirection is received from the server, this signal is emitted
with WEBKIT_LOAD_REDIRECTED
after the initial emission with
WEBKIT_LOAD_STARTED
and before WEBKIT_LOAD_COMMITTED
.
When the page content starts arriving the signal is emitted with
WEBKIT_LOAD_COMMITTED
event.
You can handle this signal and use a switch to track any ongoing load operation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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; } } |
|
the WebKitWebView on which the signal is emitted |
|
the WebKitLoadEvent |
|
user data set when the signal handler was connected. |
"load-failed"
signalgboolean user_function (WebKitWebView *web_view,
WebKitLoadEvent load_event,
gchar *failing_uri,
gpointer error,
gpointer user_data) : Run Last
Emitted when an error occurs during a load operation.
If the error happened when starting to load data for a page
load_event
will be WEBKIT_LOAD_STARTED
. If it happened while
loading a committed data source load_event
will be WEBKIT_LOAD_COMMITTED
.
Since a load error causes the load operation to finish, the signal
WebKitWebView::load-changed will always be emitted with
WEBKIT_LOAD_FINISHED
event right after this one.
By default, if the signal is not handled, a stock error page will be displayed. You need to handle the signal if you want to provide your own error page.
|
the WebKitWebView on which the signal is emitted |
|
the WebKitLoadEvent of the load operation |
|
the URI that failed to load |
|
the GError that was triggered |
|
user data set when the signal handler was connected. |
"ready-to-show"
signalvoid user_function (WebKitWebView *web_view,
gpointer user_data) : Run Last
Emitted after "create" on the newly created WebKitWebView
when it should be displayed to the user. When this signal is emitted
all the information about how the window should look, including
size, position, whether the location, status and scrollbars
should be displayed, is already set on the WebKitWindowProperties
of web_view
. See also webkit_web_view_get_window_properties()
.
|
the WebKitWebView on which the signal is emitted |
|
user data set when the signal handler was connected. |
"script-alert"
signalgboolean user_function (WebKitWebView *web_view,
gchar *message,
gpointer user_data) : Run Last
Emitted when JavaScript code calls window.alert
. If the
signal is not handled a message dialog with a single Close button will be
shown with the message text.
|
the WebKitWebView on which the signal is emitted |
|
the message text |
|
user data set when the signal handler was connected. |
Returns : |
TRUE to stop other handlers from being invoked for the event.
FALSE to propagate the event further. |
"script-confirm"
signalgboolean user_function (WebKitWebView *web_view,
gchar *message,
gpointer confirmed,
gpointer user_data) : Run Last
Emitted when JavaScript code calls confirm
. If the
signal is not handled a message dialog with OK and Cancel buttons will be
shown with the message text. If OK button is clicked confirmed
will be
set to TRUE
, otherwise it will be FALSE
.
|
the WebKitWebView on which the signal is emitted |
|
the message text |
|
return location for confirm dialog response. [out] |
|
user data set when the signal handler was connected. |
Returns : |
TRUE to stop other handlers from being invoked for the event.
FALSE to propagate the event further. |
"script-prompt"
signalgboolean user_function (WebKitWebView *web_view,
gchar *message,
gchar *text,
gpointer Returns,
gpointer user_data) : Run Last
Emitted when JavaScript code calls prompt
. If the
signal is not handled a message dialog with OK and Cancel buttons and
a text entry will be shown with the message text. If OK button is clicked
text
will contain the text entered by the user, otherwise it will be NULL
.
|
the WebKitWebView on which the signal is emitted |
|
the message text
default (allow-none): the default text |
|
return location for prompt dialog text response. [out] |
|
user data set when the signal handler was connected. |
Returns : |
TRUE to stop other handlers from being invoked for the event.
FALSE to propagate the event further. |