diff --git a/CHANGELOG.md b/CHANGELOG.md index abb62d2..c7520f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,28 @@ --- +## 0.0.1.0 + +### Added + +- + +### Changed + +- Updated webview + - Commit + - 24af6cb9b33b3a10dce44188aec0c1646247d830 + - Removes objective-c + - https://github.com/zserge/webview/pull/181 +- Updated logo + +### Removed + +- Objective-c requirement for macOS +- Cocoa framework requirement for macOS + +--- + ## 0.0.0.0 ### Added diff --git a/README.md b/README.md index 3b5d750..08c9e44 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![webviewhs logo](https://i.imgur.com/MOmkahs.png) +![webviewhs logo](https://i.imgur.com/yohrYgX.png) # What is webviewhs? diff --git a/deps/webview/webview.h b/deps/webview/webview.h index 29671fc..73dbabc 100644 --- a/deps/webview/webview.h +++ b/deps/webview/webview.h @@ -74,14 +74,14 @@ struct webview_priv { RECT saved_rect; }; #elif defined(WEBVIEW_COCOA) -#import -#import -#import +#include +#include +#include struct webview_priv { - NSAutoreleasePool *pool; - NSWindow *window; - WebView *webview; + id pool; + id window; + id webview; id windowDelegate; int should_exit; }; @@ -442,8 +442,8 @@ WEBVIEW_API void webview_dialog(struct webview *w, static void webview_eval_finished(GObject *object, GAsyncResult *result, gpointer userdata) { - (void) object; - (void) result; + (void)object; + (void)result; struct webview *w = (struct webview *)userdata; w->priv.js_busy = 0; } @@ -523,7 +523,9 @@ typedef struct { _IOleInPlaceFrameEx frame; } _IOleInPlaceSiteEx; -typedef struct { IDocHostUIHandler ui; } _IDocHostUIHandlerEx; +typedef struct { + IDocHostUIHandler ui; +} _IDocHostUIHandlerEx; typedef struct { IOleClientSite client; @@ -1430,7 +1432,7 @@ WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen) { WEBVIEW_API void webview_set_color(struct webview *w, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { HBRUSH brush = CreateSolidBrush(RGB(r, g, b)); - SetClassLongPtr(w->priv.hwnd, GCLP_HBRBACKGROUND, (LONG_PTR)brush); + SetClassLongPtr(w->priv.hwnd, GCLP_HBRBACKGROUND, (LONG_PTR)brush); } /* These are missing parts from MinGW */ @@ -1611,209 +1613,491 @@ WEBVIEW_API void webview_print_log(const char *s) { OutputDebugString(s); } #endif /* WEBVIEW_WINAPI */ #if defined(WEBVIEW_COCOA) -#if (!defined MAC_OS_X_VERSION_10_12) || \ - MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 -#define NSAlertStyleWarning NSWarningAlertStyle -#define NSAlertStyleCritical NSCriticalAlertStyle -#define NSWindowStyleMaskResizable NSResizableWindowMask -#define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask -#define NSWindowStyleMaskTitled NSTitledWindowMask -#define NSWindowStyleMaskClosable NSClosableWindowMask -#define NSWindowStyleMaskFullScreen NSFullScreenWindowMask -#define NSEventMaskAny NSAnyEventMask -#define NSEventModifierFlagCommand NSCommandKeyMask -#define NSEventModifierFlagOption NSAlternateKeyMask -#define NSAlertStyleInformational NSInformationalAlertStyle -#endif /* MAC_OS_X_VERSION_10_12 */ -#if (!defined MAC_OS_X_VERSION_10_13) || \ - MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13 -#define NSModalResponseOK NSFileHandlingPanelOKButton -#endif /* MAC_OS_X_VERSION_10_12, MAC_OS_X_VERSION_10_13 */ +#define NSAlertStyleWarning 0 +#define NSAlertStyleCritical 2 +#define NSWindowStyleMaskResizable 8 +#define NSWindowStyleMaskMiniaturizable 4 +#define NSWindowStyleMaskTitled 1 +#define NSWindowStyleMaskClosable 2 +#define NSWindowStyleMaskFullScreen (1 << 14) +#define NSViewWidthSizable 2 +#define NSViewHeightSizable 16 +#define NSBackingStoreBuffered 2 +#define NSEventMaskAny ULONG_MAX +#define NSEventModifierFlagCommand (1 << 20) +#define NSEventModifierFlagOption (1 << 19) +#define NSAlertStyleInformational 1 +#define NSAlertFirstButtonReturn 1000 +#define WKNavigationActionPolicyDownload 2 +#define NSModalResponseOK 1 +#define WKNavigationActionPolicyDownload 2 +#define WKNavigationResponsePolicyAllow 1 +#define WKUserScriptInjectionTimeAtDocumentStart 0 +#define NSApplicationActivationPolicyRegular 0 + +static id get_nsstring(const char *c_str) { + return objc_msgSend((id)objc_getClass("NSString"), + sel_registerName("stringWithUTF8String:"), c_str); +} + +static id create_menu_item(id title, const char *action, const char *key) { + id item = + objc_msgSend((id)objc_getClass("NSMenuItem"), sel_registerName("alloc")); + objc_msgSend(item, sel_registerName("initWithTitle:action:keyEquivalent:"), + title, sel_registerName(action), get_nsstring(key)); + objc_msgSend(item, sel_registerName("autorelease")); + + return item; +} + static void webview_window_will_close(id self, SEL cmd, id notification) { struct webview *w = (struct webview *)objc_getAssociatedObject(self, "webview"); webview_terminate(w); } -static BOOL webview_is_selector_excluded_from_web_script(id self, SEL cmd, - SEL selector) { - return selector != @selector(invoke:); -} - -static NSString *webview_webscript_name_for_selector(id self, SEL cmd, - SEL selector) { - return selector == @selector(invoke:) ? @"invoke" : nil; -} - -static void webview_did_clear_window_object(id self, SEL cmd, id webview, - id script, id frame) { - [script setValue:self forKey:@"external"]; -} - -static void webview_external_invoke(id self, SEL cmd, id arg) { +static void webview_external_invoke(id self, SEL cmd, id contentController, + id message) { struct webview *w = - (struct webview *)objc_getAssociatedObject(self, "webview"); + (struct webview *)objc_getAssociatedObject(contentController, "webview"); if (w == NULL || w->external_invoke_cb == NULL) { return; } - if ([arg isKindOfClass:[NSString class]] == NO) { - return; + + w->external_invoke_cb(w, (const char *)objc_msgSend( + objc_msgSend(message, sel_registerName("body")), + sel_registerName("UTF8String"))); +} + +static void run_open_panel(id self, SEL cmd, id webView, id parameters, + id frame, void (^completionHandler)(id)) { + + id openPanel = objc_msgSend((id)objc_getClass("NSOpenPanel"), + sel_registerName("openPanel")); + + objc_msgSend( + openPanel, sel_registerName("setAllowsMultipleSelection:"), + objc_msgSend(parameters, sel_registerName("allowsMultipleSelection"))); + + objc_msgSend(openPanel, sel_registerName("setCanChooseFiles:"), 1); + objc_msgSend( + openPanel, sel_registerName("beginWithCompletionHandler:"), ^(id result) { + if (result == (id)NSModalResponseOK) { + completionHandler(objc_msgSend(openPanel, sel_registerName("URLs"))); + } else { + completionHandler(nil); + } + }); +} + +static void run_save_panel(id self, SEL cmd, id download, id filename, + void (^completionHandler)(int allowOverwrite, + id destination)) { + id savePanel = objc_msgSend((id)objc_getClass("NSSavePanel"), + sel_registerName("savePanel")); + objc_msgSend(savePanel, sel_registerName("setCanCreateDirectories:"), 1); + objc_msgSend(savePanel, sel_registerName("setNameFieldStringValue:"), + filename); + objc_msgSend(savePanel, sel_registerName("beginWithCompletionHandler:"), + ^(id result) { + if (result == (id)NSModalResponseOK) { + id url = objc_msgSend(savePanel, sel_registerName("URL")); + id path = objc_msgSend(url, sel_registerName("path")); + completionHandler(1, path); + } else { + completionHandler(NO, nil); + } + }); +} + +static void run_confirmation_panel(id self, SEL cmd, id webView, id message, + id frame, void (^completionHandler)(bool)) { + + id alert = + objc_msgSend((id)objc_getClass("NSAlert"), sel_registerName("new")); + objc_msgSend(alert, sel_registerName("setIcon:"), + objc_msgSend((id)objc_getClass("NSImage"), + sel_registerName("imageNamed:"), + get_nsstring("NSCaution"))); + objc_msgSend(alert, sel_registerName("setShowsHelp:"), 0); + objc_msgSend(alert, sel_registerName("setInformativeText:"), message); + objc_msgSend(alert, sel_registerName("addButtonWithTitle:"), + get_nsstring("OK")); + objc_msgSend(alert, sel_registerName("addButtonWithTitle:"), + get_nsstring("Cancel")); + if (objc_msgSend(alert, sel_registerName("runModal")) == + (id)NSAlertFirstButtonReturn) { + completionHandler(true); + } else { + completionHandler(false); + } + objc_msgSend(alert, sel_registerName("release")); +} + +static void run_alert_panel(id self, SEL cmd, id webView, id message, id frame, + void (^completionHandler)(void)) { + id alert = + objc_msgSend((id)objc_getClass("NSAlert"), sel_registerName("new")); + objc_msgSend(alert, sel_registerName("setIcon:"), + objc_msgSend((id)objc_getClass("NSImage"), + sel_registerName("imageNamed:"), + get_nsstring("NSCaution"))); + objc_msgSend(alert, sel_registerName("setShowsHelp:"), 0); + objc_msgSend(alert, sel_registerName("setInformativeText:"), message); + objc_msgSend(alert, sel_registerName("addButtonWithTitle:"), + get_nsstring("OK")); + objc_msgSend(alert, sel_registerName("runModal")); + objc_msgSend(alert, sel_registerName("release")); + completionHandler(); +} + +static void download_failed(id self, SEL cmd, id download, id error) { + printf("%s", + (const char *)objc_msgSend( + objc_msgSend(error, sel_registerName("localizedDescription")), + sel_registerName("UTF8String"))); +} + +static void make_nav_policy_decision(id self, SEL cmd, id webView, id response, + void (^decisionHandler)(int)) { + if (objc_msgSend(response, sel_registerName("canShowMIMEType")) == 0) { + decisionHandler(WKNavigationActionPolicyDownload); + } else { + decisionHandler(WKNavigationResponsePolicyAllow); } - w->external_invoke_cb(w, [(NSString *)(arg)UTF8String]); } WEBVIEW_API int webview_init(struct webview *w) { - w->priv.pool = [[NSAutoreleasePool alloc] init]; - [NSApplication sharedApplication]; - - Class webViewDelegateClass = - objc_allocateClassPair([NSObject class], "WebViewDelegate", 0); - class_addMethod(webViewDelegateClass, sel_registerName("windowWillClose:"), - (IMP)webview_window_will_close, "v@:@"); - class_addMethod(object_getClass(webViewDelegateClass), - sel_registerName("isSelectorExcludedFromWebScript:"), - (IMP)webview_is_selector_excluded_from_web_script, "c@::"); - class_addMethod(object_getClass(webViewDelegateClass), - sel_registerName("webScriptNameForSelector:"), - (IMP)webview_webscript_name_for_selector, "c@::"); - class_addMethod(webViewDelegateClass, - sel_registerName("webView:didClearWindowObject:forFrame:"), - (IMP)webview_did_clear_window_object, "v@:@@@"); - class_addMethod(webViewDelegateClass, sel_registerName("invoke:"), - (IMP)webview_external_invoke, "v@:@"); - objc_registerClassPair(webViewDelegateClass); - - w->priv.windowDelegate = [[webViewDelegateClass alloc] init]; + w->priv.pool = objc_msgSend((id)objc_getClass("NSAutoreleasePool"), + sel_registerName("new")); + objc_msgSend((id)objc_getClass("NSApplication"), + sel_registerName("sharedApplication")); + + Class __WKScriptMessageHandler = objc_allocateClassPair( + objc_getClass("NSObject"), "__WKScriptMessageHandler", 0); + class_addMethod( + __WKScriptMessageHandler, + sel_registerName("userContentController:didReceiveScriptMessage:"), + (IMP)webview_external_invoke, "v@:@@"); + objc_registerClassPair(__WKScriptMessageHandler); + + id scriptMessageHandler = + objc_msgSend((id)__WKScriptMessageHandler, sel_registerName("new")); + + /*** + _WKDownloadDelegate is an undocumented/private protocol with methods called + from WKNavigationDelegate + References: + https://github.com/WebKit/webkit/blob/master/Source/WebKit/UIProcess/API/Cocoa/_WKDownload.h + https://github.com/WebKit/webkit/blob/master/Source/WebKit/UIProcess/API/Cocoa/_WKDownloadDelegate.h + https://github.com/WebKit/webkit/blob/master/Tools/TestWebKitAPI/Tests/WebKitCocoa/Download.mm + ***/ + + Class __WKDownloadDelegate = objc_allocateClassPair( + objc_getClass("NSObject"), "__WKDownloadDelegate", 0); + class_addMethod( + __WKDownloadDelegate, + sel_registerName("_download:decideDestinationWithSuggestedFilename:" + "completionHandler:"), + (IMP)run_save_panel, "v@:@@?"); + class_addMethod(__WKDownloadDelegate, + sel_registerName("_download:didFailWithError:"), + (IMP)download_failed, "v@:@@"); + objc_registerClassPair(__WKDownloadDelegate); + id downloadDelegate = + objc_msgSend((id)__WKDownloadDelegate, sel_registerName("new")); + + Class __WKPreferences = objc_allocateClassPair(objc_getClass("WKPreferences"), + "__WKPreferences", 0); + objc_property_attribute_t type = {"T", "c"}; + objc_property_attribute_t ownership = {"N", ""}; + objc_property_attribute_t attrs[] = {type, ownership}; + class_replaceProperty(__WKPreferences, "developerExtrasEnabled", attrs, 2); + objc_registerClassPair(__WKPreferences); + id wkPref = objc_msgSend((id)__WKPreferences, sel_registerName("new")); + objc_msgSend(wkPref, sel_registerName("setValue:forKey:"), + objc_msgSend((id)objc_getClass("NSNumber"), + sel_registerName("numberWithBool:"), !!w->debug), + objc_msgSend((id)objc_getClass("NSString"), + sel_registerName("stringWithUTF8String:"), + "developerExtrasEnabled")); + + id userController = objc_msgSend((id)objc_getClass("WKUserContentController"), + sel_registerName("new")); + objc_setAssociatedObject(userController, "webview", (id)(w), + OBJC_ASSOCIATION_ASSIGN); + objc_msgSend( + userController, sel_registerName("addScriptMessageHandler:name:"), + scriptMessageHandler, + objc_msgSend((id)objc_getClass("NSString"), + sel_registerName("stringWithUTF8String:"), "invoke")); + + /*** + In order to maintain compatibility with the other 'webviews' we need to + override window.external.invoke to call + webkit.messageHandlers.invoke.postMessage + ***/ + + id windowExternalOverrideScript = objc_msgSend( + (id)objc_getClass("WKUserScript"), sel_registerName("alloc")); + objc_msgSend( + windowExternalOverrideScript, + sel_registerName("initWithSource:injectionTime:forMainFrameOnly:"), + get_nsstring("window.external = this; invoke = function(arg){ " + "webkit.messageHandlers.invoke.postMessage(arg); };"), + WKUserScriptInjectionTimeAtDocumentStart, 0); + + objc_msgSend(userController, sel_registerName("addUserScript:"), + windowExternalOverrideScript); + + id config = objc_msgSend((id)objc_getClass("WKWebViewConfiguration"), + sel_registerName("new")); + id processPool = objc_msgSend(config, sel_registerName("processPool")); + objc_msgSend(processPool, sel_registerName("_setDownloadDelegate:"), + downloadDelegate); + objc_msgSend(config, sel_registerName("setProcessPool:"), processPool); + objc_msgSend(config, sel_registerName("setUserContentController:"), + userController); + objc_msgSend(config, sel_registerName("setPreferences:"), wkPref); + + Class __NSWindowDelegate = objc_allocateClassPair(objc_getClass("NSObject"), + "__NSWindowDelegate", 0); + class_addProtocol(__NSWindowDelegate, objc_getProtocol("NSWindowDelegate")); + class_replaceMethod(__NSWindowDelegate, sel_registerName("windowWillClose:"), + (IMP)webview_window_will_close, "v@:@"); + objc_registerClassPair(__NSWindowDelegate); + + w->priv.windowDelegate = + objc_msgSend((id)__NSWindowDelegate, sel_registerName("new")); + objc_setAssociatedObject(w->priv.windowDelegate, "webview", (id)(w), OBJC_ASSOCIATION_ASSIGN); - NSString *nsTitle = [NSString stringWithUTF8String:w->title]; - NSRect r = NSMakeRect(0, 0, w->width, w->height); - NSUInteger style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | - NSWindowStyleMaskMiniaturizable; + id nsTitle = + objc_msgSend((id)objc_getClass("NSString"), + sel_registerName("stringWithUTF8String:"), w->title); + + CGRect r = CGRectMake(0, 0, w->width, w->height); + + unsigned int style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | + NSWindowStyleMaskMiniaturizable; if (w->resizable) { style = style | NSWindowStyleMaskResizable; } - w->priv.window = [[NSWindow alloc] initWithContentRect:r - styleMask:style - backing:NSBackingStoreBuffered - defer:NO]; - [w->priv.window autorelease]; - [w->priv.window setTitle:nsTitle]; - [w->priv.window setDelegate:w->priv.windowDelegate]; - [w->priv.window center]; - - [[NSUserDefaults standardUserDefaults] setBool:!!w->debug - forKey:@"WebKitDeveloperExtras"]; - [[NSUserDefaults standardUserDefaults] synchronize]; + + w->priv.window = + objc_msgSend((id)objc_getClass("NSWindow"), sel_registerName("alloc")); + objc_msgSend(w->priv.window, + sel_registerName("initWithContentRect:styleMask:backing:defer:"), + r, style, NSBackingStoreBuffered, 0); + + objc_msgSend(w->priv.window, sel_registerName("autorelease")); + objc_msgSend(w->priv.window, sel_registerName("setTitle:"), nsTitle); + objc_msgSend(w->priv.window, sel_registerName("setDelegate:"), + w->priv.windowDelegate); + objc_msgSend(w->priv.window, sel_registerName("center")); + + Class __WKUIDelegate = + objc_allocateClassPair(objc_getClass("NSObject"), "__WKUIDelegate", 0); + class_addProtocol(__WKUIDelegate, objc_getProtocol("WKUIDelegate")); + class_addMethod(__WKUIDelegate, + sel_registerName("webView:runOpenPanelWithParameters:" + "initiatedByFrame:completionHandler:"), + (IMP)run_open_panel, "v@:@@@?"); + class_addMethod(__WKUIDelegate, + sel_registerName("webView:runJavaScriptAlertPanelWithMessage:" + "initiatedByFrame:completionHandler:"), + (IMP)run_alert_panel, "v@:@@@?"); + class_addMethod( + __WKUIDelegate, + sel_registerName("webView:runJavaScriptConfirmPanelWithMessage:" + "initiatedByFrame:completionHandler:"), + (IMP)run_confirmation_panel, "v@:@@@?"); + objc_registerClassPair(__WKUIDelegate); + id uiDel = objc_msgSend((id)__WKUIDelegate, sel_registerName("new")); + + Class __WKNavigationDelegate = objc_allocateClassPair( + objc_getClass("NSObject"), "__WKNavigationDelegate", 0); + class_addProtocol(__WKNavigationDelegate, + objc_getProtocol("WKNavigationDelegate")); + class_addMethod( + __WKNavigationDelegate, + sel_registerName( + "webView:decidePolicyForNavigationResponse:decisionHandler:"), + (IMP)make_nav_policy_decision, "v@:@@?"); + objc_registerClassPair(__WKNavigationDelegate); + id navDel = objc_msgSend((id)__WKNavigationDelegate, sel_registerName("new")); + w->priv.webview = - [[WebView alloc] initWithFrame:r frameName:@"WebView" groupName:nil]; - NSURL *nsURL = [NSURL - URLWithString:[NSString stringWithUTF8String:webview_check_url(w->url)]]; - [[w->priv.webview mainFrame] loadRequest:[NSURLRequest requestWithURL:nsURL]]; - - [w->priv.webview setAutoresizesSubviews:YES]; - [w->priv.webview - setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; - w->priv.webview.frameLoadDelegate = w->priv.windowDelegate; - [[w->priv.window contentView] addSubview:w->priv.webview]; - [w->priv.window orderFrontRegardless]; - - [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; - [NSApp finishLaunching]; - [NSApp activateIgnoringOtherApps:YES]; - - NSMenu *menubar = [[[NSMenu alloc] initWithTitle:@""] autorelease]; - - NSString *appName = [[NSProcessInfo processInfo] processName]; - NSMenuItem *appMenuItem = - [[[NSMenuItem alloc] initWithTitle:appName action:NULL keyEquivalent:@""] - autorelease]; - NSMenu *appMenu = [[[NSMenu alloc] initWithTitle:appName] autorelease]; - [appMenuItem setSubmenu:appMenu]; - [menubar addItem:appMenuItem]; - - NSString *title = [@"Hide " stringByAppendingString:appName]; - NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title - action:@selector(hide:) - keyEquivalent:@"h"] autorelease]; - [appMenu addItem:item]; - item = [[[NSMenuItem alloc] initWithTitle:@"Hide Others" - action:@selector(hideOtherApplications:) - keyEquivalent:@"h"] autorelease]; - [item setKeyEquivalentModifierMask:(NSEventModifierFlagOption | - NSEventModifierFlagCommand)]; - [appMenu addItem:item]; - item = [[[NSMenuItem alloc] initWithTitle:@"Show All" - action:@selector(unhideAllApplications:) - keyEquivalent:@""] autorelease]; - [appMenu addItem:item]; - [appMenu addItem:[NSMenuItem separatorItem]]; - - title = [@"Quit " stringByAppendingString:appName]; - item = [[[NSMenuItem alloc] initWithTitle:title - action:@selector(terminate:) - keyEquivalent:@"q"] autorelease]; - [appMenu addItem:item]; - - [NSApp setMainMenu:menubar]; + objc_msgSend((id)objc_getClass("WKWebView"), sel_registerName("alloc")); + objc_msgSend(w->priv.webview, + sel_registerName("initWithFrame:configuration:"), r, config); + objc_msgSend(w->priv.webview, sel_registerName("setUIDelegate:"), uiDel); + objc_msgSend(w->priv.webview, sel_registerName("setNavigationDelegate:"), + navDel); + + id nsURL = objc_msgSend((id)objc_getClass("NSURL"), + sel_registerName("URLWithString:"), + get_nsstring(webview_check_url(w->url))); + + objc_msgSend(w->priv.webview, sel_registerName("loadRequest:"), + objc_msgSend((id)objc_getClass("NSURLRequest"), + sel_registerName("requestWithURL:"), nsURL)); + objc_msgSend(w->priv.webview, sel_registerName("setAutoresizesSubviews:"), 1); + objc_msgSend(w->priv.webview, sel_registerName("setAutoresizingMask:"), + (NSViewWidthSizable | NSViewHeightSizable)); + objc_msgSend(objc_msgSend(w->priv.window, sel_registerName("contentView")), + sel_registerName("addSubview:"), w->priv.webview); + objc_msgSend(w->priv.window, sel_registerName("orderFrontRegardless")); + + objc_msgSend(objc_msgSend((id)objc_getClass("NSApplication"), + sel_registerName("sharedApplication")), + sel_registerName("setActivationPolicy:"), + NSApplicationActivationPolicyRegular); + + objc_msgSend(objc_msgSend((id)objc_getClass("NSApplication"), + sel_registerName("sharedApplication")), + sel_registerName("finishLaunching")); + + objc_msgSend(objc_msgSend((id)objc_getClass("NSApplication"), + sel_registerName("sharedApplication")), + sel_registerName("activateIgnoringOtherApps:"), 1); + + id menubar = + objc_msgSend((id)objc_getClass("NSMenu"), sel_registerName("alloc")); + objc_msgSend(menubar, sel_registerName("initWithTitle:"), get_nsstring("")); + objc_msgSend(menubar, sel_registerName("autorelease")); + + id appName = objc_msgSend(objc_msgSend((id)objc_getClass("NSProcessInfo"), + sel_registerName("processInfo")), + sel_registerName("processName")); + + id appMenuItem = + objc_msgSend((id)objc_getClass("NSMenuItem"), sel_registerName("alloc")); + objc_msgSend(appMenuItem, + sel_registerName("initWithTitle:action:keyEquivalent:"), appName, + NULL, get_nsstring("")); + + id appMenu = + objc_msgSend((id)objc_getClass("NSMenu"), sel_registerName("alloc")); + objc_msgSend(appMenu, sel_registerName("initWithTitle:"), appName); + objc_msgSend(appMenu, sel_registerName("autorelease")); + + objc_msgSend(appMenuItem, sel_registerName("setSubmenu:"), appMenu); + objc_msgSend(menubar, sel_registerName("addItem:"), appMenuItem); + + id title = + objc_msgSend(get_nsstring("Hide "), + sel_registerName("stringByAppendingString:"), appName); + id item = create_menu_item(title, "hide:", "h"); + objc_msgSend(appMenu, sel_registerName("addItem:"), item); + + item = create_menu_item(get_nsstring("Hide Others"), + "hideOtherApplications:", "h"); + objc_msgSend(item, sel_registerName("setKeyEquivalentModifierMask:"), + (NSEventModifierFlagOption | NSEventModifierFlagCommand)); + objc_msgSend(appMenu, sel_registerName("addItem:"), item); + + item = + create_menu_item(get_nsstring("Show All"), "unhideAllApplications:", ""); + objc_msgSend(appMenu, sel_registerName("addItem:"), item); + + objc_msgSend(appMenu, sel_registerName("addItem:"), + objc_msgSend((id)objc_getClass("NSMenuItem"), + sel_registerName("separatorItem"))); + + title = objc_msgSend(get_nsstring("Quit "), + sel_registerName("stringByAppendingString:"), appName); + item = create_menu_item(title, "terminate:", "q"); + objc_msgSend(appMenu, sel_registerName("addItem:"), item); + + objc_msgSend(objc_msgSend((id)objc_getClass("NSApplication"), + sel_registerName("sharedApplication")), + sel_registerName("setMainMenu:"), menubar); w->priv.should_exit = 0; return 0; } WEBVIEW_API int webview_loop(struct webview *w, int blocking) { - NSDate *until = (blocking ? [NSDate distantFuture] : [NSDate distantPast]); - NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny - untilDate:until - inMode:NSDefaultRunLoopMode - dequeue:YES]; + id until = (blocking ? objc_msgSend((id)objc_getClass("NSDate"), + sel_registerName("distantFuture")) + : objc_msgSend((id)objc_getClass("NSDate"), + sel_registerName("distantPast"))); + + id event = objc_msgSend( + objc_msgSend((id)objc_getClass("NSApplication"), + sel_registerName("sharedApplication")), + sel_registerName("nextEventMatchingMask:untilDate:inMode:dequeue:"), + ULONG_MAX, until, + objc_msgSend((id)objc_getClass("NSString"), + sel_registerName("stringWithUTF8String:"), + "kCFRunLoopDefaultMode"), + true); + if (event) { - [NSApp sendEvent:event]; + objc_msgSend(objc_msgSend((id)objc_getClass("NSApplication"), + sel_registerName("sharedApplication")), + sel_registerName("sendEvent:"), event); } + return w->priv.should_exit; } WEBVIEW_API int webview_eval(struct webview *w, const char *js) { - NSString *nsJS = [NSString stringWithUTF8String:js]; - [[w->priv.webview windowScriptObject] evaluateWebScript:nsJS]; + objc_msgSend(w->priv.webview, + sel_registerName("evaluateJavaScript:completionHandler:"), + get_nsstring(js), NULL); + return 0; } WEBVIEW_API void webview_set_title(struct webview *w, const char *title) { - NSString *nsTitle = [NSString stringWithUTF8String:title]; - [w->priv.window setTitle:nsTitle]; + objc_msgSend(w->priv.window, sel_registerName( + /* Start David Lettier Edit */ + "setTitle:" + /* End David Lettier Edit */ + ), + get_nsstring(title)); } WEBVIEW_API void webview_set_fullscreen(struct webview *w, int fullscreen) { - int b = ((([w->priv.window styleMask] & NSWindowStyleMaskFullScreen) == + unsigned long windowStyleMask = (unsigned long)objc_msgSend( + w->priv.window, sel_registerName("styleMask")); + int b = (((windowStyleMask & NSWindowStyleMaskFullScreen) == NSWindowStyleMaskFullScreen) ? 1 : 0); if (b != fullscreen) { - [w->priv.window toggleFullScreen:nil]; + objc_msgSend(w->priv.window, sel_registerName("toggleFullScreen:"), NULL); } } WEBVIEW_API void webview_set_color(struct webview *w, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { - [w->priv.window setBackgroundColor:[NSColor colorWithRed:(CGFloat)r / 255.0 - green:(CGFloat)g / 255.0 - blue:(CGFloat)b / 255.0 - alpha:(CGFloat)a / 255.0]]; + + id color = objc_msgSend((id)objc_getClass("NSColor"), + sel_registerName("colorWithRed:green:blue:alpha:"), + (float)r / 255.0, (float)g / 255.0, (float)b / 255.0, + (float)a / 255.0); + + objc_msgSend(w->priv.window, sel_registerName("setBackgroundColor:"), color); + if (0.5 >= ((r / 255.0 * 299.0) + (g / 255.0 * 587.0) + (b / 255.0 * 114.0)) / 1000.0) { - [w->priv.window - setAppearance:[NSAppearance - appearanceNamed:NSAppearanceNameVibrantDark]]; + objc_msgSend(w->priv.window, sel_registerName("setAppearance:"), + objc_msgSend((id)objc_getClass("NSAppearance"), + sel_registerName("appearanceNamed:"), + get_nsstring("NSAppearanceNameVibrantDark"))); } else { - [w->priv.window - setAppearance:[NSAppearance - appearanceNamed:NSAppearanceNameVibrantLight]]; + objc_msgSend(w->priv.window, sel_registerName("setAppearance:"), + objc_msgSend((id)objc_getClass("NSAppearance"), + sel_registerName("appearanceNamed:"), + get_nsstring("NSAppearanceNameVibrantLight"))); } - [w->priv.window setOpaque:NO]; - [w->priv.window setTitlebarAppearsTransparent:YES]; - [w->priv.webview setDrawsBackground:NO]; + objc_msgSend(w->priv.window, sel_registerName("setOpaque:"), 0); + objc_msgSend(w->priv.window, + sel_registerName("setTitlebarAppearsTransparent:"), 1); } WEBVIEW_API void webview_dialog(struct webview *w, @@ -1822,57 +2106,76 @@ WEBVIEW_API void webview_dialog(struct webview *w, char *result, size_t resultsz) { if (dlgtype == WEBVIEW_DIALOG_TYPE_OPEN || dlgtype == WEBVIEW_DIALOG_TYPE_SAVE) { - NSSavePanel *panel; + id panel = (id)objc_getClass("NSSavePanel"); if (dlgtype == WEBVIEW_DIALOG_TYPE_OPEN) { - NSOpenPanel *openPanel = [NSOpenPanel openPanel]; + id openPanel = objc_msgSend((id)objc_getClass("NSOpenPanel"), + sel_registerName("openPanel")); if (flags & WEBVIEW_DIALOG_FLAG_DIRECTORY) { - [openPanel setCanChooseFiles:NO]; - [openPanel setCanChooseDirectories:YES]; + objc_msgSend(openPanel, sel_registerName("setCanChooseFiles:"), 0); + objc_msgSend(openPanel, sel_registerName("setCanChooseDirectories:"), + 1); } else { - [openPanel setCanChooseFiles:YES]; - [openPanel setCanChooseDirectories:NO]; + objc_msgSend(openPanel, sel_registerName("setCanChooseFiles:"), 1); + objc_msgSend(openPanel, sel_registerName("setCanChooseDirectories:"), + 0); } - [openPanel setResolvesAliases:NO]; - [openPanel setAllowsMultipleSelection:NO]; + objc_msgSend(openPanel, sel_registerName("setResolvesAliases:"), 0); + objc_msgSend(openPanel, sel_registerName("setAllowsMultipleSelection:"), + 0); panel = openPanel; } else { - panel = [NSSavePanel savePanel]; + panel = objc_msgSend((id)objc_getClass("NSSavePanel"), + sel_registerName("savePanel")); } - [panel setCanCreateDirectories:YES]; - [panel setShowsHiddenFiles:YES]; - [panel setExtensionHidden:NO]; - [panel setCanSelectHiddenExtension:NO]; - [panel setTreatsFilePackagesAsDirectories:YES]; - [panel beginSheetModalForWindow:w->priv.window - completionHandler:^(NSInteger result) { - [NSApp stopModalWithCode:result]; - }]; - if ([NSApp runModalForWindow:panel] == NSModalResponseOK) { - const char *filename = [[[panel URL] path] UTF8String]; + + objc_msgSend(panel, sel_registerName("setCanCreateDirectories:"), 1); + objc_msgSend(panel, sel_registerName("setShowsHiddenFiles:"), 1); + objc_msgSend(panel, sel_registerName("setExtensionHidden:"), 0); + objc_msgSend(panel, sel_registerName("setCanSelectHiddenExtension:"), 0); + objc_msgSend(panel, sel_registerName("setTreatsFilePackagesAsDirectories:"), + 1); + objc_msgSend( + panel, sel_registerName("beginSheetModalForWindow:completionHandler:"), + w->priv.window, ^(id result) { + objc_msgSend(objc_msgSend((id)objc_getClass("NSApplication"), + sel_registerName("sharedApplication")), + sel_registerName("stopModalWithCode:"), result); + }); + + if (objc_msgSend(objc_msgSend((id)objc_getClass("NSApplication"), + sel_registerName("sharedApplication")), + sel_registerName("runModalForWindow:"), + panel) == (id)NSModalResponseOK) { + id url = objc_msgSend(panel, sel_registerName("URL")); + id path = objc_msgSend(url, sel_registerName("path")); + const char *filename = + (const char *)objc_msgSend(path, sel_registerName("UTF8String")); strlcpy(result, filename, resultsz); } } else if (dlgtype == WEBVIEW_DIALOG_TYPE_ALERT) { - NSAlert *a = [NSAlert new]; + id a = objc_msgSend((id)objc_getClass("NSAlert"), sel_registerName("new")); switch (flags & WEBVIEW_DIALOG_FLAG_ALERT_MASK) { case WEBVIEW_DIALOG_FLAG_INFO: - [a setAlertStyle:NSAlertStyleInformational]; + objc_msgSend(a, sel_registerName("setAlertStyle:"), + NSAlertStyleInformational); break; case WEBVIEW_DIALOG_FLAG_WARNING: - NSLog(@"warning"); - [a setAlertStyle:NSAlertStyleWarning]; + printf("Warning\n"); + objc_msgSend(a, sel_registerName("setAlertStyle:"), NSAlertStyleWarning); break; case WEBVIEW_DIALOG_FLAG_ERROR: - NSLog(@"error"); - [a setAlertStyle:NSAlertStyleCritical]; + printf("Error\n"); + objc_msgSend(a, sel_registerName("setAlertStyle:"), NSAlertStyleCritical); break; } - [a setShowsHelp:NO]; - [a setShowsSuppressionButton:NO]; - [a setMessageText:[NSString stringWithUTF8String:title]]; - [a setInformativeText:[NSString stringWithUTF8String:arg]]; - [a addButtonWithTitle:@"OK"]; - [a runModal]; - [a release]; + objc_msgSend(a, sel_registerName("setShowsHelp:"), 0); + objc_msgSend(a, sel_registerName("setShowsSuppressionButton:"), 0); + objc_msgSend(a, sel_registerName("setMessageText:"), get_nsstring(title)); + objc_msgSend(a, sel_registerName("setInformativeText:"), get_nsstring(arg)); + objc_msgSend(a, sel_registerName("addButtonWithTitle:"), + get_nsstring("OK")); + objc_msgSend(a, sel_registerName("runModal")); + objc_msgSend(a, sel_registerName("release")); } } @@ -1895,8 +2198,14 @@ WEBVIEW_API void webview_dispatch(struct webview *w, webview_dispatch_fn fn, WEBVIEW_API void webview_terminate(struct webview *w) { w->priv.should_exit = 1; } -WEBVIEW_API void webview_exit(struct webview *w) { [NSApp terminate:NSApp]; } -WEBVIEW_API void webview_print_log(const char *s) { NSLog(@"%s", s); } + +WEBVIEW_API void webview_exit(struct webview *w) { + id app = objc_msgSend((id)objc_getClass("NSApplication"), + sel_registerName("sharedApplication")); + objc_msgSend(app, sel_registerName("terminate:"), app); +} + +WEBVIEW_API void webview_print_log(const char *s) { printf("%s\n", s); } #endif /* WEBVIEW_COCOA */ diff --git a/docs/Graphics-UI-Webviewhs.html b/docs/Graphics-UI-Webviewhs.html index 1d4cdc2..5d5dedd 100644 --- a/docs/Graphics-UI-Webviewhs.html +++ b/docs/Graphics-UI-Webviewhs.html @@ -1,7 +1,7 @@ Graphics.UI.Webviewhs

webviewhs-0.0.0.0: Create native dialogs and windows that run web pages.

Copyright(C) 2018 David Lettier
LicenseBSD3
MaintainerDavid Lettier
Safe HaskellNone
LanguageHaskell2010

Graphics.UI.Webviewhs

Description

webviewhs is a Haskell binding to the webview library created by +

webviewhs-0.0.1.0: Create native dialogs and windows that run web pages.

Copyright(C) 2018 David Lettier
LicenseBSD3
MaintainerDavid Lettier
Safe HaskellNone
LanguageHaskell2010

Graphics.UI.Webviewhs

Description

webviewhs is a Haskell binding to the webview library created by Serge Zaitsev.

According to webview:

[webview is] a tiny cross-platform webview library for C/C++/Golang to build modern cross-platform GUIs.
 It uses Cocoa/WebKit on macOS, gtk-webkit2 on Linux and MSHTML (IE10/11) on Windows.

For more information, see the webview README.

Be sure to explore the provided examples.

Synopsis

Documentation

data WindowParams Source #

Specifies the window creation parameters.

Constructors

WindowParams 

Fields

  • windowParamsTitle :: Text
     
  • windowParamsUri :: Text

    This can be file://, http://, https://, data:text/html, etc.

  • windowParamsWidth :: Int
     
  • windowParamsHeight :: Int
     
  • windowParamsResizable :: Bool
     
  • windowParamsDebuggable :: Bool

    This enables the right click context menu with reload and diff --git a/docs/doc-index.html b/docs/doc-index.html index 2c320e2..75edaf1 100644 --- a/docs/doc-index.html +++ b/docs/doc-index.html @@ -1,4 +1,4 @@ -webviewhs-0.0.0.0: Create native dialogs and windows that run web pages. (Index)

    webviewhs-0.0.0.0: Create native dialogs and windows that run web pages.

    Index

    createWindowGraphics.UI.Webviewhs
    createWindowAndBlockGraphics.UI.Webviewhs
    destroyWindowGraphics.UI.Webviewhs
    dispatchToMainGraphics.UI.Webviewhs
    injectCssGraphics.UI.Webviewhs
    injectCss'Graphics.UI.Webviewhs
    iterateWindowLoopGraphics.UI.Webviewhs
    logGraphics.UI.Webviewhs
    log'Graphics.UI.Webviewhs
    openWindowAlertDialogGraphics.UI.Webviewhs
    runJavaScriptGraphics.UI.Webviewhs
    runJavaScript'Graphics.UI.Webviewhs
    setWindowBackgroundColorGraphics.UI.Webviewhs
    setWindowFullscreenGraphics.UI.Webviewhs
    setWindowTitleGraphics.UI.Webviewhs
    terminateWindowLoopGraphics.UI.Webviewhs
    WindowGraphics.UI.Webviewhs
    WindowAlertDialogTypeGraphics.UI.Webviewhs
    WindowAlertDialogTypeErrorGraphics.UI.Webviewhs
    WindowAlertDialogTypeInfoGraphics.UI.Webviewhs
    WindowAlertDialogTypeWarningGraphics.UI.Webviewhs
    WindowBackgroundColor 
    1 (Type/Class)Graphics.UI.Webviewhs
    2 (Data Constructor)Graphics.UI.Webviewhs
    windowBackgroundColorAlphaGraphics.UI.Webviewhs
    windowBackgroundColorBlueGraphics.UI.Webviewhs
    windowBackgroundColorGreenGraphics.UI.Webviewhs
    windowBackgroundColorRedGraphics.UI.Webviewhs
    WindowParams 
    1 (Type/Class)Graphics.UI.Webviewhs
    2 (Data Constructor)Graphics.UI.Webviewhs
    windowParamsDebuggableGraphics.UI.Webviewhs
    windowParamsHeightGraphics.UI.Webviewhs
    windowParamsResizableGraphics.UI.Webviewhs
    windowParamsTitleGraphics.UI.Webviewhs
    windowParamsUriGraphics.UI.Webviewhs
    windowParamsWidthGraphics.UI.Webviewhs
    withWindowLoopGraphics.UI.Webviewhs
    withWindowOpenDialogGraphics.UI.Webviewhs
    withWindowSaveDialogGraphics.UI.Webviewhs
    \ No newline at end of file +

    webviewhs-0.0.1.0: Create native dialogs and windows that run web pages.

    Index

    createWindowGraphics.UI.Webviewhs
    createWindowAndBlockGraphics.UI.Webviewhs
    destroyWindowGraphics.UI.Webviewhs
    dispatchToMainGraphics.UI.Webviewhs
    injectCssGraphics.UI.Webviewhs
    injectCss'Graphics.UI.Webviewhs
    iterateWindowLoopGraphics.UI.Webviewhs
    logGraphics.UI.Webviewhs
    log'Graphics.UI.Webviewhs
    openWindowAlertDialogGraphics.UI.Webviewhs
    runJavaScriptGraphics.UI.Webviewhs
    runJavaScript'Graphics.UI.Webviewhs
    setWindowBackgroundColorGraphics.UI.Webviewhs
    setWindowFullscreenGraphics.UI.Webviewhs
    setWindowTitleGraphics.UI.Webviewhs
    terminateWindowLoopGraphics.UI.Webviewhs
    WindowGraphics.UI.Webviewhs
    WindowAlertDialogTypeGraphics.UI.Webviewhs
    WindowAlertDialogTypeErrorGraphics.UI.Webviewhs
    WindowAlertDialogTypeInfoGraphics.UI.Webviewhs
    WindowAlertDialogTypeWarningGraphics.UI.Webviewhs
    WindowBackgroundColor 
    1 (Type/Class)Graphics.UI.Webviewhs
    2 (Data Constructor)Graphics.UI.Webviewhs
    windowBackgroundColorAlphaGraphics.UI.Webviewhs
    windowBackgroundColorBlueGraphics.UI.Webviewhs
    windowBackgroundColorGreenGraphics.UI.Webviewhs
    windowBackgroundColorRedGraphics.UI.Webviewhs
    WindowParams 
    1 (Type/Class)Graphics.UI.Webviewhs
    2 (Data Constructor)Graphics.UI.Webviewhs
    windowParamsDebuggableGraphics.UI.Webviewhs
    windowParamsHeightGraphics.UI.Webviewhs
    windowParamsResizableGraphics.UI.Webviewhs
    windowParamsTitleGraphics.UI.Webviewhs
    windowParamsUriGraphics.UI.Webviewhs
    windowParamsWidthGraphics.UI.Webviewhs
    withWindowLoopGraphics.UI.Webviewhs
    withWindowOpenDialogGraphics.UI.Webviewhs
    withWindowSaveDialogGraphics.UI.Webviewhs
    \ No newline at end of file diff --git a/docs/iindex.html b/docs/iindex.html index 2a959f8..4138a6b 100644 --- a/docs/iindex.html +++ b/docs/iindex.html @@ -1,4 +1,4 @@ -webviewhs-0.0.0.0: Create native dialogs and windows that run web pages.

    webviewhs-0.0.0.0: Create native dialogs and windows that run web pages.

    webviewhs-0.0.0.0: Create native dialogs and windows that run web pages.

    Please see the README on GitHub at https://github.com/lettier/webviewhs#readme

    Modules

    \ No newline at end of file +

    webviewhs-0.0.1.0: Create native dialogs and windows that run web pages.

    webviewhs-0.0.1.0: Create native dialogs and windows that run web pages.

    Please see the README on GitHub at https://github.com/lettier/webviewhs#readme

    Modules

    \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 1d4cdc2..5d5dedd 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,7 +1,7 @@ Graphics.UI.Webviewhs

    webviewhs-0.0.0.0: Create native dialogs and windows that run web pages.

    Copyright(C) 2018 David Lettier
    LicenseBSD3
    MaintainerDavid Lettier
    Safe HaskellNone
    LanguageHaskell2010

    Graphics.UI.Webviewhs

    Description

    webviewhs is a Haskell binding to the webview library created by +

    webviewhs-0.0.1.0: Create native dialogs and windows that run web pages.

    Copyright(C) 2018 David Lettier
    LicenseBSD3
    MaintainerDavid Lettier
    Safe HaskellNone
    LanguageHaskell2010

    Graphics.UI.Webviewhs

    Description

    webviewhs is a Haskell binding to the webview library created by Serge Zaitsev.

    According to webview:

    [webview is] a tiny cross-platform webview library for C/C++/Golang to build modern cross-platform GUIs.
     It uses Cocoa/WebKit on macOS, gtk-webkit2 on Linux and MSHTML (IE10/11) on Windows.

    For more information, see the webview README.

    Be sure to explore the provided examples.

    Synopsis

    Documentation

    data WindowParams Source #

    Specifies the window creation parameters.

    Constructors

    WindowParams 

    Fields

    • windowParamsTitle :: Text
       
    • windowParamsUri :: Text

      This can be file://, http://, https://, data:text/html, etc.

    • windowParamsWidth :: Int
       
    • windowParamsHeight :: Int
       
    • windowParamsResizable :: Bool
       
    • windowParamsDebuggable :: Bool

      This enables the right click context menu with reload and diff --git a/docs/src/Graphics.UI.Webviewhs.html b/docs/src/Graphics.UI.Webviewhs.html index 6b0b99a..5761d69 100644 --- a/docs/src/Graphics.UI.Webviewhs.html +++ b/docs/src/Graphics.UI.Webviewhs.html @@ -17,7 +17,7 @@ License : BSD3 Maintainer : David Lettier - ![webviewhs logo](https://i.imgur.com/VeULsQK.png) + ![webviewhs logo](https://i.imgur.com/2yAJALE.png) webviewhs is a Haskell binding to the [webview](https://github.com/zserge/webview) library created by [Serge Zaitsev](https://github.com/zserge). diff --git a/examples/README.md b/examples/README.md index 789393e..138e2fa 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,4 +1,4 @@ -![webviewhs logo](https://i.imgur.com/MOmkahs.png) +![webviewhs logo](https://i.imgur.com/yohrYgX.png) # How do I use webviewhs? diff --git a/logo/webviewhs-logo-0.svg b/logo/webviewhs-logo-0.svg index 817417c..d7f51b2 100644 --- a/logo/webviewhs-logo-0.svg +++ b/logo/webviewhs-logo-0.svg @@ -5,30 +5,30 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" - width="376.46393" - height="427.54068" - viewBox="0 0 376.46392 427.54071" + id="svg8" version="1.1" - id="svg8"> + viewBox="0 0 353.0588 427.54071" + height="427.54068" + width="353.05881"> + width="1.0267404" + x="-0.013370176" + id="filter1139" + style="color-interpolation-filters:sRGB" /> + x="-0.12483822" + width="1.2496763" + y="-0.11552281" + height="1.2310456"> + stdDeviation="14.837282" + id="feGaussianBlur4585" /> - + style="display:inline" + transform="translate(-69.425764,-599.29224)" + id="layer1"> webviewhs + y="957.617" + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:65.08499908px;font-family:'Fira Sans';-inkscape-font-specification:'Fira Sans Bold';fill:#6b8395;fill-opacity:1;stroke-width:0.67373472px">webviewhs + transform="translate(2.5336798e-6,-49.321656)"> + id="path1076" + d="m 346.43908,658.6139 -121.55153,32.56927 c 55.15659,11.42087 73.91045,36.71026 87.88385,102.78518 10.27756,48.40982 18.71989,83.15753 26.71477,109.61464 l 6.95291,-1.86287 z m -6.95291,244.96909 -31.89344,8.5467 c 12.1524,42.84489 24.79187,66.03938 41.21568,90.67101 l 31.62439,-13.86783 c -16.33957,-21.6476 -28.0596,-42.70343 -40.94663,-85.34988 z m -31.89344,8.5467 C 300.42671,886.86497 293.42916,854.778 285.92683,811.50651 l -30.63042,114.63503 z m -52.29632,14.01185 -36.22534,9.70683 -16.98583,57.9798 32.72915,8.97253 z m -36.22534,9.70683 44.79265,-152.8926 h 15.07696 c -8.08992,-37.52472 -21.27382,-55.76531 -59.88516,-63.515 l 5.82887,-28.25602 -121.55156,32.56928 v 243.10624 z m 5.81332,-244.66362 v -0.002 c 0,-2.1e-4 0,2.1e-4 0,0 z" + style="display:inline;opacity:1;fill:#ff5c17;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke markers fill" /> + id="path1078" + d="m 367.50828,679.68231 -100.76091,26.99808 c 24.50202,15.60685 36.39783,41.76841 46.02403,87.28716 13.80813,65.03973 24.30797,105.44156 34.85313,134.14842 l 19.88375,-5.32744 z m -19.88375,248.43366 -32.26697,8.64642 c 9.87303,28.03498 20.48238,46.58808 33.45085,66.03751 l 31.62439,-13.86783 c -12.85735,-17.0342 -22.85285,-33.71469 -32.80827,-60.8161 z m -32.26697,8.64642 c -10.0037,-28.40611 -19.25171,-66.54672 -29.43073,-125.25668 l -38.31768,143.41051 z m -67.74841,18.15383 -37.03099,9.92205 -8.49292,28.9891 32.72915,8.97253 z m -37.03099,9.92205 53.28556,-181.8833 h 15.07696 c -8.08992,-37.52472 -21.27382,-55.76451 -59.88516,-63.5142 v 0 l -94.65349,25.38166 v 243.10614 z m 8.47736,-245.3975 47.69185,-12.76038 c -11.06563,-7.04844 -24.70211,-11.94489 -41.86298,-15.49802 z" + style="display:inline;opacity:0.8;fill:#ffa200;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke markers fill" /> + id="path1080" + d="m 224.88439,691.18237 -5.82887,28.2584 c 16.4262,3.29691 28.79609,9.07662 37.44216,16.70201 l 31.95996,-8.56412 c -13.59093,-19.45718 -32.98189,-30.0624 -63.57325,-36.39629 z m 63.57325,36.39629 c 10.91468,15.62587 18.08996,36.95882 24.31376,66.38889 18.15062,85.49388 30.58928,128.45113 44.924,158.16466 l 30.88209,-8.27448 V 700.75151 Z m 69.23776,224.55355 -32.67689,8.75566 c 7.17443,15.7546 14.93116,28.6262 23.7899,41.91203 l 31.62439,-13.86783 c -8.57435,-11.3598 -15.87164,-22.5683 -22.7374,-36.79986 z m -32.67689,8.75566 C 311.04836,930.21015 299.2894,888.57791 285.92683,811.50571 l -46.00656,172.18436 z m -85.09824,22.8022 -37.83341,10.1373 32.72753,8.97253 z m 16.57741,-247.54729 -111.02645,29.74886 v 243.10616 l 56.61401,-15.17043 61.77848,-210.8724 h 15.07696 c -4.64827,-21.56079 -10.76563,-36.51339 -22.443,-46.81219 z" + style="display:inline;opacity:0.8;fill:#008bff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.8;paint-order:stroke markers fill" /> (C) 2018 David Lettier + id="text871">(C) 2018 DAVID LETTIER diff --git a/makefile b/makefile index 46d9cfa..761c353 100644 --- a/makefile +++ b/makefile @@ -4,7 +4,7 @@ .RECIPEPREFIX != ps -_WEBVIEWHS_VERSION="0.0.0.0" +_WEBVIEWHS_VERSION="0.0.1.0" _STACK=stack --allow-different-user _GHC_VERSION=`$(_STACK) ghc -- --version | sed 's|The Glorious Glasgow Haskell Compilation System, version ||g'` _STACK_PATH_LOCAL_BIN=`$(_STACK) path --local-bin` diff --git a/src/Graphics/UI/Webviewhs.hs b/src/Graphics/UI/Webviewhs.hs index d3b7dec..096923e 100644 --- a/src/Graphics/UI/Webviewhs.hs +++ b/src/Graphics/UI/Webviewhs.hs @@ -17,7 +17,7 @@ License : BSD3 Maintainer : David Lettier - ![webviewhs logo](https://i.imgur.com/VeULsQK.png) + ![webviewhs logo](https://i.imgur.com/2yAJALE.png) webviewhs is a Haskell binding to the [webview](https://github.com/zserge/webview) library created by [Serge Zaitsev](https://github.com/zserge). diff --git a/webviewhs.cabal b/webviewhs.cabal index adaecf3..d967246 100644 --- a/webviewhs.cabal +++ b/webviewhs.cabal @@ -1,5 +1,5 @@ name: webviewhs -version: 0.0.0.0 +version: 0.0.1.0 synopsis: Create native dialogs and windows that run web pages. description: Please see the README on GitHub at category: UI @@ -50,10 +50,10 @@ library cc-options: -DWEBVIEW_GTK=1 -pthread else if os(darwin) - cc-options: -DWEBVIEW_COCOA=1 -ObjC -x objective-c + cc-options: -DWEBVIEW_COCOA=1 else if os(windows) - cc-options: -DWEBVIEW_WINAPI=1 -mwindows + cc-options: -DWEBVIEW_WINAPI=1 -mwindows -std=c99 extra-libraries: ole32 comctl32 oleaut32 uuid if os(linux) pkgconfig-depends: @@ -61,8 +61,7 @@ library , webkit2gtk-4.0 if os(darwin) frameworks: - Cocoa - , Webkit + Webkit ghc-options: -Wall -freverse-errors