Update of "Creating Windows"

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.


Artifact ID: c06d25fb4a6c9e4270a7c0f9664bd74d8fa51bd3
Page Name:Creating Windows
Date: 2011-10-02 13:32:15
Original User: murphy
Parent: 3973ed439782cea8f0ff2aa4b1aa74cb7e57d820

Creating Windows

A single procedure is used to control the creation and setup of windows with a WebKit view:

  (make-window URI/CONTENT
               [#:universal-access-from-file-uris? UNIVERSAL-ACCESS-FROM-FILE-URIS?]
               [#:file-access-from-file-uris? FILE-ACCESS-FROM-FILE-URIS?]
               [#:spell-checking? SPELL-CHECKING?]
               [#:clipboard-access? CLIPBOARD-ACCESS?]
               [#:developer-extras? DEVELOPER-EXTRAS?]
               [#:width WIDTH]
               [#:height HEIGHT]
               [#:scrollbar-visible? SCROLLBAR-VISIBLE?]
               [#:status-visible? STATUS-VISIBLE?]
               [#:fullscreen? FULLSCREEN?]
               [#:initialize! INITIALIZE!]
               [#:yield-interval YIELD-INTERVAL]
               [#:timeout TIMEOUT])

The procedure takes the following steps:

  1. A new Gtk+ window is created, which contains a scrolled WebKit view and a status bar.
  2. The WebKit view is initialized using the parameters UNIVERSAL-ACCESS-FROM-FILE-URIS? (default #f), FILE-ACCESS-FROM-FILE-URIS? (default #f), SPELL-CHECKING? (default #t), CLIPBOARD-ACCESS? (default #f) and DEVELOPER-EXTRAS? (default #f). The exact meaning of these parameters is documented in the WebKitGTK+ Reference Manual.
  3. The window around the WebKit view is initialized using the parameters WIDTH (default -1 or "natural" size), HEIGHT (default -1 or "natural" size) and FULLSCREEN? (default #f), the scrollbars around the WebKit view are enabled iff SCROLLBAR-VISIBLE? is true (default #t) and the status bar below the WebKit view is shown iff STATUS-VISIBLE? is true (default #t).
  4. Content is loaded into the WebKit view as specified by URI/CONTENT — if this parameter is a string, it is used as a URI, otherwise it must be a list of the form
    (CONTENT [#:mime-type MIME-TYPE] [#:encoding ENCODING] [#:base-uri BASE-URI])
    where CONTENT is a string and the optional arguments MIME-TYPE (default #f), ENCODING (default #f) and BASE-URI (default #f) determine how the content is interpreted.
  5. It is ensured that the new window becomes visible.
  6. If INITIALIZE! is #f (the default), make-window enters the Gtk+ main loop and waits for the WebKit view to initialize a JavaScript context for its content document. If that happens, the main loop is terminated and make-window returns the wrapped DOM window object of the loaded document. If the TIMEOUT (default #f) expires before that happens, make-window returns #f. The TIMEOUT can be a number of seconds or a SRFI-18 time object. The YIELD-INTERVAL (default 0.5) is passed on to the main loop.
  7. If INITIALIZE! is true, it is applied to the wrapped DOM window object of the loaded document when it becomes available and the main loop is running. make-window simply returns #f in that case without waiting for this condition.

For information how to use the wrapped window object, see Dealing with JavaScript Objects, for information about the Gtk+ main loop see Running the Main Loop.