Back to Seed Clases

WebKit


Classes

Interfaces

Structs

Unions

Enums

GObject.Object
parent-child marker WebKit.ViewportAttributes

Class WebKit.ViewportAttributes

Import line: WebKit = imports.gi.WebKit;
GIR File: WebKit-3.0.gir
C documentation: WebKitViewportAttributes
Class : ViewportAttributes
Extends: GObject.Object
WebKitViewportAttributes offers the viewport properties to user agents to
control the viewport layout. It contains the viewport size, initial scale with limits,
and information about whether a user is able to scale the contents in the viewport.
This makes a web page fit the device screen.
The WebKitWebView::viewport-attributes-changed signal will be emitted with WebKitViewportAttributes
when the viewport attributes are updated in the case of loading web pages contain
the viewport properties and calling webkit_viewport_attributes_recompute.
If the device size, available size, desktop width, or device DPI needs to be changed due to
a consequence of an explicit browser request (caused by screen rotation, resizing, or similar reasons),
You should call webkit_viewport_attributes_recompute to recompute the viewport properties and
override those values in the handler of WebKitWebView::viewport-attributes-recompute-requested signal.
For more information on the viewport properties, refer to the Safari reference library at
http://developer.apple.com/safari/library/documentation/appleapplications/reference/safarihtmlref/articles/metatags.html

/* Connect to the viewport-attributes-changes signal */
WebKitViewportAttributes* attributes = webkit_web_view_get_viewport_attributes (web_view);
g_signal_connect (web_view, "viewport-attributes-recompute-requested", G_CALLBACK (viewport_recompute_cb), window);
g_signal_connect (web_view, "viewport-attributes-changed", G_CALLBACK (viewport_changed_cb), window);
g_signal_connect (attributes, "notify::valid", G_CALLBACK (viewport_valid_changed_cb), web_view);
/* Handle the viewport-attributes-recompute-requested signal to override the device width */
static void
viewport_recompute_cb (WebKitWebView* web_view, WebKitViewportAttributes* attributes, GtkWidget* window)
{
int override_available_width = 480;
g_object_set (G_OBJECT(attributes), "available-width", override_available_width, NULL);
}
/* Handle the viewport-attributes-changed signal to recompute the initial scale factor */
static void
viewport_changed_cb (WebKitWebView* web_view, WebKitViewportAttributes* attributes, gpointer data)
{
gfloat initialScale;
g_object_get (G_OBJECT (atributes), "initial-scale-factor", &initialScale, NULL);
webkit_web_view_set_zoom_level (web_view, initialScale);
}
/* Handle the notify::valid signal to initialize the zoom level */
static void
viewport_valid_changed_cb (WebKitViewportAttributes* attributes, GParamSpec* pspec, WebKitWebView* web_view)
{
gboolean is_valid;
g_object_get (attributes, "valid", &is_valid, NULL);
if (!is_valid)
webkit_web_view_set_zoom_level (web_view, 1.0);
}
Properties
Properties Defined By
Methods / Constructors
Method / Constructor Defined By
Events
None
Used by These Methods / Signals / Properties
Class / Namespace Method / Signal / Properties
WebKit.WebView
Property
viewport_attributes : WebKit.ViewportAttributes read only
The associated WebKitViewportAttributes instance.
WebKit.WebView
Signal
viewport_attributes_changed (WebView self, ViewportAttributes object) : none
WebKit.WebView
Signal
viewport_attributes_recompute_requested (WebView self, ViewportAttributes object) : none
WebKit.WebView
Method
get_viewport_attributes () : WebKit.ViewportAttributes
Obtains the WebKitViewportAttributes associated with the
WebKitWebView.
Documentation generated by Introspection Doc Generator Loosely Based on JsDoc Toolkit on Sat Apr 16 2011 17:18:02 GMT+0800 (HKT)