WebKitView.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 15 May 2015 08:19:36 +0100
changeset 35 ee9cb4288e1c
parent 31 035449621a0c
permissions -rw-r--r--
uzbl makefile fixeed.

"{ Package: 'stx:libwebkit' }"

SimpleView subclass:#WebKitView
	instanceVariableNames:'rendererView url title progress link'
	classVariableNames:''
	poolDictionaries:''
	category:'Views-WebKit'
!


!WebKitView class methodsFor:'image specs'!

webKit22x22
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     self webKit22x22 inspect
     ImageEditor openOnClass:self andSelector:#webKit22x22
     Icon flushCachedIcons
    "

    <resource: #image>

    ^Icon
        constantNamed:'WebKitView class webKit22x22'
        ifAbsentPut:[(Depth8Image new) width: 19; height: 21; photometric:(#palette); bitsPerSample:(#(8)); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
????????</O2??????????????????????O?<??????????????????????1;-;Q3,G????????????????J(9^W%9^W(:+??????????=N''%9^W_R)C%Y^W
%<S??????<:W%8@THWZNS"XWWY^)5O????>W%4 OT6F<(V9&X2 "%=+????K%8LHO4-X &-$V5IMFS.&9??\.9TFK3Y@SG&(U5)QKCLM_.WP8JZC@2T-NT%<
19YPI3P#FCB>;^JUR $\D@1,QQ8]AC9YJST<&.3#$!!<B@@(.5,O+A2SUPP,AD)K)9H5_DZ=)6N[01!!O]]7E(LS"M8]>Z" U0F3K*3Q[(.KR_#4]U$-''W,H4Z
ER/R+P;B;;V5,:U ^)V.?<.MZ"A%$S6+0M.92K>"_86U??>2$(5OM4Z /[GIU,>7%H"M]_???8^M#WI''&;W@\:26$86M^O??????"(6H XRK&JSE"X"H[_??
??????=2 XFA XFA XE4P/????????????=\UE9/W$P:????????@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[17 75 132 26 78 143 43 80 116 54 83 115 126 69 47 30 90 160 74 85 86 141 70 48 69 87 109 64 88 114 23 99 162 27 98 174 53 95 137 73 92 114 43 100 134 78 93 110 61 96 133 52 97 157 75 97 101 46 102 137 100 95 77 21 110 173 71 101 116 84 99 104 84 99 128 83 102 124 75 105 120 31 113 183 81 104 131 177 86 39 131 95 86 111 104 57 42 114 165 92 103 127 121 102 59 85 105 139 81 108 129 84 108 135 91 106 135 107 105 109 90 108 131 94 106 142 138 107 35 42 121 185 96 111 129 89 113 140 55 120 179 95 113 136 129 112 49 46 123 187 32 127 190 92 116 143 87 119 145 104 115 139 98 117 140 64 125 166 103 120 102 95 118 147 134 116 53 141 116 42 112 118 109 47 131 176 90 122 148 104 119 149 98 121 150 57 133 191 149 121 40 161 120 16 144 123 40 80 129 171 64 133 179 46 137 194 156 122 26 106 125 148 152 123 35 103 126 155 107 126 149 131 122 128 108 127 150 133 128 68 157 118 103 149 120 114 113 128 146 115 127 151 151 128 37 133 130 74 49 139 236 100 132 159 107 130 159 101 133 160 118 130 142 112 131 154 152 130 47 171 128 14 161 130 24 151 130 54 63 143 188 113 132 156 162 131 25 114 133 157 111 134 163 68 144 196 115 134 158 81 144 160 60 146 204 87 139 194 164 133 28 116 135 159 109 137 171 177 133 22 118 137 161 181 135 0 92 141 203 51 153 210 163 138 31 27 157 245 182 136 0 179 135 25 124 139 157 54 155 212 189 137 0 122 141 165 173 140 26 186 139 0 126 141 159 181 137 37 190 138 2 135 146 92 195 137 6 187 140 3 127 142 160 191 139 4 162 144 44 181 141 18 193 140 0 188 141 5 192 140 6 184 143 3 182 142 20 139 148 88 194 141 0 195 142 0 130 145 164 62 160 217 200 141 0 105 151 182 196 143 0 137 152 91 104 156 149 202 142 0 154 142 142 203 143 0 118 156 127 204 144 0 200 146 0 64 165 215 205 145 2 201 147 1 206 146 4 69 165 223 56 169 225 136 151 170 67 167 217 208 147 7 140 158 102 59 171 227 205 150 8 210 149 12 139 154 173 211 150 14 205 151 27 63 173 229 81 168 240 125 161 182 186 155 66 134 158 200 203 155 29 54 178 240 178 159 67 67 176 233 78 175 226 69 177 234 83 175 213 66 179 228 79 176 227 59 181 243 70 179 235 212 157 35 151 162 176 72 180 236 209 160 35 59 184 240 73 181 237 209 160 45 83 179 230 120 171 209 196 163 67 177 167 92 148 167 179 157 165 173 63 186 242 108 173 241 213 164 50 209 166 49 210 167 50 152 171 183 209 167 59 79 188 238 170 173 120 210 168 67 128 179 216 212 170 69 199 173 88 131 182 220 143 180 214 192 177 109 145 182 216 210 178 95 220 178 77 110 195 241 205 181 102 135 195 232 212 187 108 209 187 120 213 189 116 222 190 112 221 191 119 225 193 115 219 195 121 227 194 110 174 202 225 225 202 135 161 211 237 230 201 135 180 207 231 202 210 219 229 209 153 224 211 173 237 212 138 190 227 249 215 224 232 225 228 224 244 247 243 247 249 246 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255 255]; mask:((ImageMask new) width: 19; height: 21; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@8@@@(@@@?@@A?0@G?<@O?>@O?>@_??@??? ??? ??? ??? ??? ??? ??? _??@_??@O?>@G?<@C?8@@? @') ; yourself); yourself]
! !

!WebKitView class methodsFor:'queries'!

isAvailable

    ^WebKitRenderer isAvailable

    "Created: / 10-06-2011 / 09:58:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!WebKitView class methodsFor:'startup'!

open

    |url webkitView urlView  topView|

    url := 'http://www.webkit.org' asValue.

    topView := StandardSystemView new                ;
                extent:(640 @ 480).
    topView label:'WebKit demo'.

    urlView := EditField in: topView.
    urlView layout: (LayoutFrame fractions:(0 @ 0 corner:1.0 @ 0) offsets:(0 @ 0 corner:0 @ 25)).
    urlView model: url.

    webkitView := self in:topView.
    webkitView layout: (LayoutFrame fractions:(0 @ 0 corner:1.0 @ 1.0) offsets:(0 @ 26 corner:0 @ 0)).
    webkitView url: url.

    topView open.

    ^ webkitView

    "
     WebKitView open
    "

    "Modified: / 16-05-1998 / 16:53:53 / cg"
    "Created: / 03-06-2011 / 09:40:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!WebKitView methodsFor:'accessing'!

rendererView
    ^ rendererView
! !

!WebKitView methodsFor:'accessing - classes'!

rendererClass

    ^WebKitRenderer

    "Created: / 03-06-2011 / 09:38:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!WebKitView methodsFor:'aspects'!

link
    "return/create the 'link' value holder (automatically generated)"

    link isNil ifTrue:[
        link := ValueHolder new.
        link addDependent:self.
    ].
    ^ link
!

link:something
    "set the 'link' value holder (automatically generated)"

    |oldValue newValue|

    link notNil ifTrue:[
        oldValue := link value.
        link removeDependent:self.
    ].
    link := something.
    link notNil ifTrue:[
        link addDependent:self.
    ].
    newValue := link value.
    oldValue ~~ newValue ifTrue:[
        self update:#value with:newValue from:link.
    ].
!

progress
    "return/create the 'progress' value holder (automatically generated)"

    progress isNil ifTrue:[
        progress := ValueHolder new.
        progress addDependent:self.
    ].
    ^ progress
!

progress:something
    "set the 'progress' value holder (automatically generated)"

    |oldValue newValue|

    progress notNil ifTrue:[
        oldValue := progress value.
        progress removeDependent:self.
    ].
    progress := something.
    progress notNil ifTrue:[
        progress addDependent:self.
    ].
    newValue := progress value.
    oldValue ~~ newValue ifTrue:[
        self update:#value with:newValue from:progress.
    ].
!

title
    "return/create the 'title' value holder (automatically generated)"

    title isNil ifTrue:[
        title := ValueHolder new.
    ].
    ^ title
!

title:something
    "set the 'title' value holder (automatically generated)"

    title := something.
!

url
    "return/create the 'url' value holder (automatically generated)"

    url isNil ifTrue:[
        url := ValueHolder new.
        url addDependent:self.
    ].
    ^ url
!

url:something
    "set the 'url' value holder (automatically generated)"

    |oldValue newValue|

    url notNil ifTrue:[
        oldValue := url value.
        url removeDependent:self.
    ].
    url := something.
    url notNil ifTrue:[
        url addDependent:self.
    ].
    newValue := url value.
    newValue ifNil:[url setValue:(newValue := 'about:blank')].
    oldValue ~~ newValue ifTrue:[
        self update:#value with:newValue from:url.
    ].

    "Modified: / 07-06-2011 / 23:03:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!WebKitView methodsFor:'change & update'!

update:aspect with:param from:changedObject
    "Invoked when an object that I depend upon sends a change notification."

    "stub code automatically generated - please change as required"

    (changedObject == url and:[aspect ~~ #valueFromEvent]) ifTrue:[
        self updateUrl.
         ^ self.
    ].
    super update:aspect with:param from:changedObject

    "Modified: / 07-06-2011 / 11:43:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

updateUrl

    | u |
    u := self url value.
    u first == $/ ifTrue:[
        u asFilename exists ifTrue:[
            u := 'file://' , u.
            self url setValue: u.
        ]   
    ].


    renderer setVariable: #uri to: u

    "Created: / 07-06-2011 / 10:18:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!WebKitView methodsFor:'initialization & release'!

initialize
    super initialize.
    renderer := self rendererClass for:self.
    renderer isAvailable ifTrue:[
        "/JV@2011-06-10: TODO: Use different embedding container on
        "/Windows. once supported"
        rendererView := XEmbedContainerView in: self.
        rendererView useWorkaround: #uzbl.
    ] ifFalse:[
        rendererView := Label new label:'WebKitView not (yet) available on this platform.'.
    ].
    rendererView origin: 0.0@0.0 corner: 1.0@1.0.

    "Created: / 02-06-2011 / 23:46:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 20-06-2011 / 11:30:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!WebKitView methodsFor:'realization'!

postRealize
    super postRealize.
    (renderer isAvailable and:[renderer isRunning not]) ifTrue:
        [renderer spawn].

    "Created: / 06-06-2011 / 10:40:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 10-06-2011 / 23:41:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!WebKitView class methodsFor:'documentation'!

version_SVN
    ^ '$Id$'
! !