release prep

This commit is contained in:
Adam D. Ruppe 2019-12-06 15:48:20 -05:00
parent 1489c4187a
commit b5d037fa56
1 changed files with 90 additions and 102 deletions

View File

@ -52,7 +52,7 @@ void main() {
auto wv = new WebView(true, null); auto wv = new WebView(true, null);
wv.navigate("http://dpldocs.info/"); wv.navigate("http://dpldocs.info/");
wv.setTitle("omg a D webview"); wv.setTitle("omg a D webview");
wv.set_size(500, 500, true); wv.setSize(500, 500, true);
wv.eval("console.log('just testing');"); wv.eval("console.log('just testing');");
wv.run(); wv.run();
} }
@ -99,7 +99,7 @@ class WebView : browser_engine {
/// Returns a native window handle pointer. When using GTK backend the pointer /// Returns a native window handle pointer. When using GTK backend the pointer
/// is GtkWindow pointer, when using Cocoa backend the pointer is NSWindow /// is GtkWindow pointer, when using Cocoa backend the pointer is NSWindow
/// pointer, when using Win32 backend the pointer is HWND pointer. /// pointer, when using Win32 backend the pointer is HWND pointer.
void *get_window() { return m_window; } void* getWindow() { return m_window; }
/// Updates the title of the native window. Must be called from the UI thread. /// Updates the title of the native window. Must be called from the UI thread.
override void setTitle(const char *title) { super.setTitle(title); } override void setTitle(const char *title) { super.setTitle(title); }
@ -249,19 +249,8 @@ version(WEBVIEW_GTK) {
void gtk_widget_set_size_request(GtkWidget*, int, int); void gtk_widget_set_size_request(GtkWidget*, int, int);
} }
//
// ====================================================================
//
// This implementation uses webkit2gtk backend. It requires gtk+3.0 and
// webkit2gtk-4.0 libraries. Proper compiler flags can be retrieved via:
//
// pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.0
//
// ====================================================================
//
private class browser_engine { private class browser_engine {
static extern(C) static extern(C)
void ondestroy (GtkWidget *w, void* arg) { void ondestroy (GtkWidget *w, void* arg) {
(cast(browser_engine) arg).terminate(); (cast(browser_engine) arg).terminate();
@ -315,7 +304,6 @@ private class browser_engine {
gtk_window_set_title(m_window, title); gtk_window_set_title(m_window, title);
} }
/+ /+
void dispatch(std::function<void()> f) { void dispatch(std::function<void()> f) {
g_idle_add_full(G_PRIORITY_HIGH_IDLE, (GSourceFunc)([](void *f) -> int { g_idle_add_full(G_PRIORITY_HIGH_IDLE, (GSourceFunc)([](void *f) -> int {
@ -327,7 +315,7 @@ private class browser_engine {
} }
+/ +/
void set_size(int width, int height, bool resizable) { void setSize(int width, int height, bool resizable) {
gtk_window_set_resizable(m_window, resizable); gtk_window_set_resizable(m_window, resizable);
if (resizable) { if (resizable) {
gtk_window_set_default_size(m_window, width, height); gtk_window_set_default_size(m_window, width, height);
@ -427,7 +415,7 @@ public:
m_window = objc_msgSend( m_window = objc_msgSend(
m_window, "initWithContentRect:styleMask:backing:defer:"_sel, m_window, "initWithContentRect:styleMask:backing:defer:"_sel,
CGRectMake(0, 0, 0, 0), 0, NSBackingStoreBuffered, 0); CGRectMake(0, 0, 0, 0), 0, NSBackingStoreBuffered, 0);
set_size(480, 320, true); setSize(480, 320, true);
} else { } else {
m_window = (id)window; m_window = (id)window;
} }
@ -474,7 +462,7 @@ public:
m_window, "setTitle:"_sel, m_window, "setTitle:"_sel,
objc_msgSend("NSString"_cls, "stringWithUTF8String:"_sel, title)); objc_msgSend("NSString"_cls, "stringWithUTF8String:"_sel, title));
} }
void set_size(int width, int height, bool resizable) { void setSize(int width, int height, bool resizable) {
auto style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | auto style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
NSWindowStyleMaskMiniaturizable; NSWindowStyleMaskMiniaturizable;
if (resizable) { if (resizable) {
@ -601,7 +589,7 @@ protected:
void setTitle(const char *title) { SetWindowText(m_window, title); } void setTitle(const char *title) { SetWindowText(m_window, title); }
void set_size(int width, int height, bool resizable) { void setSize(int width, int height, bool resizable) {
RECT r; RECT r;
r.left = 50; r.left = 50;
r.top = 50; r.top = 50;