-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feenkcom/gtoolkit#3849] introduce webview events
- Loading branch information
Showing
16 changed files
with
597 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Class { | ||
#name : #GtNativeWebViewEvent, | ||
#superclass : #GtBoxerValueBox, | ||
#category : #'GToolkit-WebView-Bindings' | ||
} | ||
|
||
{ #category : #'library path' } | ||
GtNativeWebViewEvent class >> ffiLibrary [ | ||
^ GtWebViewLibrary uniqueInstance | ||
] | ||
|
||
{ #category : #'private - ffi' } | ||
GtNativeWebViewEvent class >> primRelease: aHandle [ | ||
|
||
"Plain pointers must be deleted using delete(), all users must implement a specific method" | ||
self ffiCall: #(void webview_event_release(void* aHandle)) | ||
] | ||
|
||
{ #category : #converting } | ||
GtNativeWebViewEvent >> asWebViewEvent [ | ||
^ self subclassResponsibility | ||
] | ||
|
||
{ #category : #accessing } | ||
GtNativeWebViewEvent >> eventType [ | ||
^ self ffiCall: #(GtNativeWebViewEventType webview_event_get_type(self)) | ||
] | ||
|
||
{ #category : #'private - ffi' } | ||
GtNativeWebViewEvent >> primIntoInnerEvent [ | ||
^ self ffiCall: #(void* webview_event_into_inner(self)) | ||
] | ||
|
||
{ #category : #accessing } | ||
GtNativeWebViewEvent >> webViewId [ | ||
^ self subclassResponsibility | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Class { | ||
#name : #GtNativeWebViewEventHandler, | ||
#superclass : #GtBoxerValueBox, | ||
#category : #'GToolkit-WebView-Bindings' | ||
} | ||
|
||
{ #category : #'library path' } | ||
GtNativeWebViewEventHandler class >> ffiLibrary [ | ||
^ GtWebViewLibrary uniqueInstance | ||
] | ||
|
||
{ #category : #'private - ffi' } | ||
GtNativeWebViewEventHandler class >> primCreate: aSemaphoreIndex signaller: aSemaphoreSignaller [ | ||
self ffiCall: #(void* webview_events_handler_new(size_t aSemaphoreIndex, void* aSemaphoreSignaller)) | ||
] | ||
|
||
{ #category : #'private - ffi' } | ||
GtNativeWebViewEventHandler class >> primRelease: aHandle [ | ||
|
||
"Plain pointers must be deleted using delete(), all users must implement a specific method" | ||
self ffiCall: #(void webview_events_handler_release(void* aHandle)) | ||
] | ||
|
||
{ #category : #'instance creation' } | ||
GtNativeWebViewEventHandler class >> semaphoreIndex: aSemaphoreIndex signaller: aSemaphoreSignaller [ | ||
^ self fromNativeHandle: (self primCreate: aSemaphoreIndex signaller: aSemaphoreSignaller) | ||
] | ||
|
||
{ #category : #initialization } | ||
GtNativeWebViewEventHandler >> pollEvent [ | ||
| anEventAddress availableEventTypes | | ||
|
||
anEventAddress := self primPollEvent. | ||
anEventAddress isNull ifTrue: [ ^ nil ]. | ||
|
||
availableEventTypes := { | ||
GtNativeWebViewEventType Navigation -> GtNativeWebViewNavigationEvent. | ||
GtNativeWebViewEventType PageLoad -> GtNativeWebViewPageLoadEvent. | ||
GtNativeWebViewEventType Request -> GtNativeWebViewRequestEvent. | ||
} asDictionary. | ||
|
||
^ GtNativeWebViewEvent | ||
fromNativeHandle: anEventAddress | ||
during: [ :anAbstractEvent | | ||
| anEventType | | ||
anEventType := anAbstractEvent eventType. | ||
availableEventTypes | ||
at: anEventType | ||
ifPresent: [ :anEventClass | anEventClass fromNativeHandle: anAbstractEvent primIntoInnerEvent ] | ||
ifAbsent: [ GtNativeWebViewUnknownEvent new ] ] | ||
] | ||
|
||
{ #category : #'private - ffi' } | ||
GtNativeWebViewEventHandler >> primPollEvent [ | ||
^ self ffiCall: #(void* webview_events_handler_pop_event(self)) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
Class { | ||
#name : #GtNativeWebViewEventType, | ||
#superclass : #FFIExternalEnumeration, | ||
#classVars : [ | ||
'Navigation', | ||
'PageLoad', | ||
'Request', | ||
'Unknown' | ||
], | ||
#category : #'GToolkit-WebView-Bindings' | ||
} | ||
|
||
{ #category : #'accessing enum' } | ||
GtNativeWebViewEventType class >> Navigation [ | ||
"This method was automatically generated" | ||
^ Navigation | ||
] | ||
|
||
{ #category : #'accessing enum' } | ||
GtNativeWebViewEventType class >> PageLoad [ | ||
"This method was automatically generated" | ||
^ PageLoad | ||
] | ||
|
||
{ #category : #'accessing enum' } | ||
GtNativeWebViewEventType class >> Request [ | ||
"This method was automatically generated" | ||
^ Request | ||
] | ||
|
||
{ #category : #'accessing enum' } | ||
GtNativeWebViewEventType class >> Unknown [ | ||
"This method was automatically generated" | ||
^ Unknown | ||
] | ||
|
||
{ #category : #'class initialization' } | ||
GtNativeWebViewEventType class >> enumDecl [ | ||
"Auto generated declarations" | ||
|
||
^ #( | ||
Unknown 0 | ||
Request 1 | ||
Navigation 2 | ||
PageLoad 3 | ||
) | ||
] | ||
|
||
{ #category : #'class initialization' } | ||
GtNativeWebViewEventType class >> initialize [ | ||
"Auto-generated class initialisation" | ||
|
||
self initializeEnumeration. | ||
Author | ||
useAuthor: 'UFFI' | ||
during: [ self rebuildEnumAccessors ] | ||
] |
27 changes: 27 additions & 0 deletions
27
src/GToolkit-WebView/GtNativeWebViewNavigationEvent.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Class { | ||
#name : #GtNativeWebViewNavigationEvent, | ||
#superclass : #GtNativeWebViewEvent, | ||
#category : #'GToolkit-WebView-Bindings' | ||
} | ||
|
||
{ #category : #'private - ffi' } | ||
GtNativeWebViewNavigationEvent class >> primRelease: aHandle [ | ||
|
||
"Plain pointers must be deleted using delete(), all users must implement a specific method" | ||
self ffiCall: #(void webview_navigation_event_release(void* aHandle)) | ||
] | ||
|
||
{ #category : #converting } | ||
GtNativeWebViewNavigationEvent >> asWebViewEvent [ | ||
^ GtWebViewNavigationEvent new | ||
] | ||
|
||
{ #category : #accessing } | ||
GtNativeWebViewNavigationEvent >> eventType [ | ||
^ GtNativeWebViewEventType Navigation | ||
] | ||
|
||
{ #category : #accessing } | ||
GtNativeWebViewNavigationEvent >> webViewId [ | ||
^ self ffiCall: #(uint64 webview_navigation_event_get_id(self)) | ||
] |
27 changes: 27 additions & 0 deletions
27
src/GToolkit-WebView/GtNativeWebViewPageLoadEvent.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Class { | ||
#name : #GtNativeWebViewPageLoadEvent, | ||
#superclass : #GtNativeWebViewEvent, | ||
#category : #'GToolkit-WebView-Bindings' | ||
} | ||
|
||
{ #category : #'private - ffi' } | ||
GtNativeWebViewPageLoadEvent class >> primRelease: aHandle [ | ||
|
||
"Plain pointers must be deleted using delete(), all users must implement a specific method" | ||
self ffiCall: #(void webview_page_load_event_release(void* aHandle)) | ||
] | ||
|
||
{ #category : #converting } | ||
GtNativeWebViewPageLoadEvent >> asWebViewEvent [ | ||
^ GtWebViewPageLoadEvent new | ||
] | ||
|
||
{ #category : #accessing } | ||
GtNativeWebViewPageLoadEvent >> eventType [ | ||
^ GtNativeWebViewEventType PageLoad | ||
] | ||
|
||
{ #category : #accessing } | ||
GtNativeWebViewPageLoadEvent >> webViewId [ | ||
^ self ffiCall: #(uint64 webview_page_load_event_get_id(self)) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Class { | ||
#name : #GtNativeWebViewRequestEvent, | ||
#superclass : #GtNativeWebViewEvent, | ||
#category : #'GToolkit-WebView-Bindings' | ||
} | ||
|
||
{ #category : #'private - ffi' } | ||
GtNativeWebViewRequestEvent class >> primRelease: aHandle [ | ||
|
||
"Plain pointers must be deleted using delete(), all users must implement a specific method" | ||
self ffiCall: #(void webview_request_event_release(void* aHandle)) | ||
] | ||
|
||
{ #category : #converting } | ||
GtNativeWebViewRequestEvent >> asWebViewEvent [ | ||
^ GtWebViewIpcMessage new | ||
content: self content | ||
] | ||
|
||
{ #category : #accessing } | ||
GtNativeWebViewRequestEvent >> content [ | ||
<return: #String> | ||
|
||
^ self ffiLibrary getStringFrom: [ :aStringBox | self primGetContent: aStringBox ] | ||
] | ||
|
||
{ #category : #accessing } | ||
GtNativeWebViewRequestEvent >> eventType [ | ||
^ GtNativeWebViewEventType Request | ||
] | ||
|
||
{ #category : #'private - ffi' } | ||
GtNativeWebViewRequestEvent >> primGetContent: aStringBox [ | ||
self ffiCall: #(void webview_request_event_get_content(self, void* aStringBox)) | ||
] | ||
|
||
{ #category : #accessing } | ||
GtNativeWebViewRequestEvent >> webViewId [ | ||
^ self ffiCall: #(uint64 webview_request_event_get_id(self)) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Class { | ||
#name : #GtNativeWebViewUnknownEvent, | ||
#superclass : #GtNativeWebViewEvent, | ||
#category : #'GToolkit-WebView-Bindings' | ||
} | ||
|
||
{ #category : #'private - ffi' } | ||
GtNativeWebViewUnknownEvent class >> primRelease: aHandle [ | ||
] | ||
|
||
{ #category : #converting } | ||
GtNativeWebViewUnknownEvent >> asWebViewEvent [ | ||
^ self shouldNotImplement | ||
] | ||
|
||
{ #category : #accessing } | ||
GtNativeWebViewUnknownEvent >> webViewId [ | ||
^ 0 | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.