Documentation and refinement
This commit is contained in:
@@ -317,6 +317,9 @@
|
|||||||
(let* ((ini (new ini% [file 'web-racket-example1]))
|
(let* ((ini (new ini% [file 'web-racket-example1]))
|
||||||
(context (new wv-context% [base-path cur-dir] [ini ini]))
|
(context (new wv-context% [base-path cur-dir] [ini ini]))
|
||||||
(window (new example-1-window%
|
(window (new example-1-window%
|
||||||
[wv-context context]))
|
[wv-context context]
|
||||||
|
[title "This is an example1 window"]
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
window))
|
window))
|
||||||
|
|||||||
@@ -110,8 +110,9 @@
|
|||||||
|
|
||||||
wv-context-base-url
|
wv-context-base-url
|
||||||
wv-win-window-nr
|
wv-win-window-nr
|
||||||
|
wv-context?
|
||||||
|
|
||||||
test
|
;test
|
||||||
)
|
)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
[file-getter (webview-standard-file-getter base-path)]
|
[file-getter (webview-standard-file-getter base-path)]
|
||||||
[context-js (λ () "")]
|
[context-js (λ () "")]
|
||||||
[boilerplate-js (webview-default-boilerplate-js context-js)]
|
[boilerplate-js (webview-default-boilerplate-js context-js)]
|
||||||
[ini (error "You need to provide a 'ini' file settings interface for settings, e.g. simple-ini")]
|
[ini (error "You need to provide a 'ini' file settings interface for settings, e.g. simple-ini/class")]
|
||||||
)
|
)
|
||||||
|
|
||||||
(define wv-context #f)
|
(define wv-context #f)
|
||||||
|
|||||||
@@ -31,6 +31,9 @@
|
|||||||
(define/public (clone context)
|
(define/public (clone context)
|
||||||
(new wv-settings% [ini ini] [wv-context context]))
|
(new wv-settings% [ini ini] [wv-context context]))
|
||||||
|
|
||||||
|
(define/public (context)
|
||||||
|
wv-context)
|
||||||
|
|
||||||
(super-new)
|
(super-new)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -57,9 +57,10 @@
|
|||||||
[height #f]
|
[height #f]
|
||||||
[x #f]
|
[x #f]
|
||||||
[y #f]
|
[y #f]
|
||||||
[wv #f]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(define wv #f)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Administration
|
;; Administration
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
@@ -304,6 +305,9 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(define/public (set-title! title)
|
||||||
|
(webview-set-title! wv title))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Files / Directories
|
;; Files / Directories
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
@@ -418,14 +422,16 @@
|
|||||||
;; Create window
|
;; Create window
|
||||||
(write (list wv-context html-path event-handler parent))
|
(write (list wv-context html-path event-handler parent))
|
||||||
(newline)
|
(newline)
|
||||||
(set! wv (webview-create
|
(let ((wv-parent (if (eq? parent #f) #f (hash-ref (send parent info) 'wv))))
|
||||||
(send wv-context context)
|
(set! wv (webview-create
|
||||||
html-path
|
(send wv-context context)
|
||||||
event-handler
|
html-path
|
||||||
#:parent (if (eq? parent #f)
|
event-handler
|
||||||
#f
|
#:parent wv-parent)))
|
||||||
(get-field wv parent))))
|
|
||||||
|
|
||||||
|
;; Set title
|
||||||
|
(send this set-title! title)
|
||||||
|
|
||||||
;; Move and resize window to settings
|
;; Move and resize window to settings
|
||||||
(send this init-size)
|
(send this init-size)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -17,78 +17,28 @@ uint64_t current_ms() {
|
|||||||
// Main C Interface
|
// Main C Interface
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//static int pipefd[2];
|
|
||||||
//static bool started = false;
|
|
||||||
//static pid_t webview_process;
|
|
||||||
//static bool cannot_fork_or_pipe = false;
|
|
||||||
|
|
||||||
Rktwebview_qt *handler = nullptr;
|
Rktwebview_qt *handler = nullptr;
|
||||||
|
|
||||||
void destroyApp()
|
|
||||||
{
|
|
||||||
if (handler != nullptr) {
|
|
||||||
QCoreApplication *app = QApplication::instance();
|
|
||||||
if (app != nullptr) {
|
|
||||||
app->exit(0);
|
|
||||||
delete app;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void rkt_webview_cleanup()
|
void rkt_webview_cleanup()
|
||||||
{
|
{
|
||||||
if (handler != nullptr) {
|
if (handler != nullptr) {
|
||||||
|
// Does nothing.
|
||||||
rkt_webview_process_events(100);
|
// See QTBUG-145033
|
||||||
|
// QtWebEngine cannot be started as part of QApplication more than once in an application run.
|
||||||
//QTimer app_quit;
|
|
||||||
//QObject::connect(&app_quit, &QTimer::timeout, handler->app(), &QApplication::quit, Qt::ConnectionType::QueuedConnection);
|
|
||||||
|
|
||||||
//app_quit.setSingleShot(true);
|
|
||||||
//app_quit.start(250);
|
|
||||||
|
|
||||||
//handler->app()->exec();
|
|
||||||
|
|
||||||
//fprintf(stderr, "cleanup: handler = %p\n", handler);
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// Do not delete the QApplication, although it will result in QThreadStorage warnings.
|
|
||||||
// If the app is deleted, QtWebEngineProfileBuilder->createProfile will memory corrupt.
|
|
||||||
//handler->deleteApp();
|
|
||||||
|
|
||||||
//delete handler;
|
|
||||||
//handler = nullptr;
|
|
||||||
|
|
||||||
//fprintf(stderr, "cleanup: handler = %p\n", handler);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void rkt_webview_init()
|
void rkt_webview_init()
|
||||||
{
|
{
|
||||||
if (handler == nullptr) {
|
if (handler == nullptr) {
|
||||||
//fprintf(stderr, "init: handler = %p\n", handler);
|
|
||||||
handler = new Rktwebview_qt();
|
handler = new Rktwebview_qt();
|
||||||
//fprintf(stderr, "init: handler = %p\n", handler);
|
|
||||||
atexit(destroyApp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handler->app() == nullptr) {
|
if (handler->app() == nullptr) {
|
||||||
handler->initApp();
|
handler->initApp();
|
||||||
|
|
||||||
//QTimer app_exit;
|
|
||||||
//QObject::connect(&app_exit, &QTimer::timeout, handler->app(), []() {
|
|
||||||
// handler->app()->exit(0);
|
|
||||||
//}, Qt::ConnectionType::QueuedConnection);
|
|
||||||
|
|
||||||
//app_exit.setSingleShot(true);
|
|
||||||
//app_exit.start(250);
|
|
||||||
|
|
||||||
//QApplication *a = handler->app();
|
|
||||||
//a->exec();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
rkt_wv_context_t rkt_webview_new_context(const char *boilerplate_js, const char *optional_server_cert_pem)
|
rkt_wv_context_t rkt_webview_new_context(const char *boilerplate_js, const char *optional_server_cert_pem)
|
||||||
{
|
{
|
||||||
rkt_webview_init();
|
rkt_webview_init();
|
||||||
|
|||||||
@@ -9,113 +9,61 @@
|
|||||||
racket/file)
|
racket/file)
|
||||||
)
|
)
|
||||||
|
|
||||||
@defmodule[wv-settings]
|
@defmodule[racket-webview]
|
||||||
|
|
||||||
@title{Object-Oriented Interface: @racket[wv-settings%]}
|
@title{Object-Oriented Interface: @racket[wv-settings%]}
|
||||||
@author[@author+email["Hans Dijkema" "hans@dijkewijk.nl"]]
|
@author[@author+email["Hans Dijkema" "hans@dijkewijk.nl"]]
|
||||||
|
|
||||||
@defclass[wv-settings% object% ()]{
|
@defclass[wv-settings% object% ()]{
|
||||||
|
|
||||||
An OO wrapper around a settings backend implementing the
|
An OO wrapper around a settings backend implementing, e.g. @racket[simple-ini/class].
|
||||||
@racket[simple-ini/class] interface.
|
|
||||||
|
|
||||||
A @racket[wv-settings%] object represents a view on one settings section.
|
A @racket[wv-settings%] object represents a view on one settings section.
|
||||||
The supplied @racket[wv-context] value is used as the section identifier for
|
The supplied @racket[wv-context] value is used as the section identifier for
|
||||||
context-local settings.
|
context-local settings. The class delegates all actual storage operations to the supplied
|
||||||
|
|
||||||
The class delegates all actual storage operations to the supplied
|
|
||||||
@racket[ini] object.
|
@racket[ini] object.
|
||||||
|
|
||||||
@defconstructor[([ini object?]
|
@defconstructor[([ini object?]
|
||||||
[wv-context any/c])]{
|
[wv-context symbol?])]{
|
||||||
Creates a new settings object.
|
Creates a new settings object. The @racket[ini] argument is the backing settings object.
|
||||||
|
|
||||||
The @racket[ini] argument is the backing settings object.
|
|
||||||
|
|
||||||
The @racket[wv-context] argument is used as the section identifier for
|
The @racket[wv-context] argument is used as the section identifier for
|
||||||
context-local settings.
|
context-local settings. The class assumes that @racket[ini] supports methods compatible with:
|
||||||
|
|
||||||
The class assumes that @racket[ini] supports methods compatible with:
|
|
||||||
|
|
||||||
@itemlist[#:style 'compact
|
@itemlist[#:style 'compact
|
||||||
@item{@racket[(send ini get section key)]}
|
@item{@racket[(send ini get section key)]}
|
||||||
@item{@racket[(send ini get section key default)]}
|
@item{@racket[(send ini get section key default)]}
|
||||||
@item{@racket[(send ini set! section key value)]}
|
@item{@racket[(send ini set! section key value)]}
|
||||||
]
|
]
|
||||||
|
|
||||||
In typical use, @racket[ini] is an instance of a class from
|
|
||||||
@racket[simple-ini/class].
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@defmethod*[([(get [key any/c]) any/c]
|
@defmethod*[([(get [key symbol?]) any/c]
|
||||||
[(get [key any/c] [default-value any/c]) any/c])]{
|
[(get [key symbol?] [default-value any/c]) any/c])]{
|
||||||
Returns the value associated with @racket[key] in the current section.
|
Returns the value associated with @racket[key] in the current section.
|
||||||
|
Returns @tt{default-value} (when supplied) if the key is not found.
|
||||||
Without a default value, this method delegates to:
|
|
||||||
|
|
||||||
@racketblock[
|
|
||||||
(send ini get wv-context key)
|
|
||||||
]
|
|
||||||
|
|
||||||
With a default value, it delegates to:
|
|
||||||
|
|
||||||
@racketblock[
|
|
||||||
(send ini get wv-context key default-value)
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@defmethod*[([(set! [key any/c] [value any/c]) this])]{
|
@defmethod*[([(set! [key symbol?] [value any/c]) this])]{
|
||||||
Stores @racket[value] under @racket[key] in the current section.
|
Stores @racket[value] under @racket[key] in the current section.
|
||||||
|
|
||||||
This method delegates to:
|
|
||||||
|
|
||||||
@racketblock[
|
|
||||||
(send ini set! wv-context key value)
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@defmethod*[([(get/global [key any/c]) any/c]
|
@defmethod*[([(get/global [key symbol?]) any/c]
|
||||||
[(get/global [key any/c] [default-value any/c]) any/c])]{
|
[(get/global [key symbol?] [default-value any/c]) any/c])]{
|
||||||
Returns the value associated with @racket[key] in the global section.
|
Returns the value associated with @racket[key] in the global section.
|
||||||
|
This method delegates to @tt{(send ini get 'global key default-value)}.
|
||||||
Without a default value, this method delegates to:
|
|
||||||
|
|
||||||
@racketblock[
|
|
||||||
(send ini get 'global key)
|
|
||||||
]
|
|
||||||
|
|
||||||
With a default value, it delegates to:
|
|
||||||
|
|
||||||
@racketblock[
|
|
||||||
(send ini get 'global key default-value)
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@defmethod*[([(set/global! [key any/c] [value any/c]) this])]{
|
@defmethod*[([(set/global! [key symbol?] [value any/c]) this])]{
|
||||||
Stores @racket[value] under @racket[key] in the global section.
|
Stores @racket[value] under @racket[key] in the global section.
|
||||||
|
Delegates to @tt{(send ini set! 'global key value)}.
|
||||||
This method delegates to:
|
|
||||||
|
|
||||||
@racketblock[
|
|
||||||
(send ini set! 'global key value)
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@defmethod*[([(clone [context any/c]) (is-a?/c wv-settings%)])]{
|
@defmethod*[([(clone [context any/c]) (is-a?/c wv-settings%)])]{
|
||||||
Creates a new @racket[wv-settings%] object using the same
|
Creates a new @racket[wv-settings%] object using the same
|
||||||
@racket[ini] backend but another section identifier.
|
@racket[ini] backend but with another section identifier.
|
||||||
|
|
||||||
This method is equivalent to:
|
|
||||||
|
|
||||||
@racketblock[
|
|
||||||
(new wv-settings% [ini ini] [wv-context context])
|
|
||||||
]
|
|
||||||
|
|
||||||
It is intended to support cheap creation of per-section settings views.
|
It is intended to support cheap creation of per-section settings views.
|
||||||
}
|
}
|
||||||
|
|
||||||
@defmethod*[([(context) any/c])]{
|
@defmethod*[([(context) symbol?])]{
|
||||||
Returns the section identifier associated with this settings object.
|
Returns the section identifier associated with this settings object.
|
||||||
}
|
}
|
||||||
|
|
||||||
} ; end class
|
}
|
||||||
Reference in New Issue
Block a user