changeset 2:d5305f9c8dce

Added trivial embedded WebKit.
author Atul Varma <avarma@mozilla.com>
date Sun, 11 Apr 2010 12:38:26 -0700
parents e12920ff751b
children f3501a348031
files Makefile MyApp.m
diffstat 2 files changed, 16 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sun Apr 11 12:06:49 2010 -0700
+++ b/Makefile	Sun Apr 11 12:38:26 2010 -0700
@@ -1,2 +1,2 @@
 all:
-	clang MyApp.m -oMyApp -framework AppKit
+	clang MyApp.m -oMyApp -framework AppKit -framework WebKit
--- a/MyApp.m	Sun Apr 11 12:06:49 2010 -0700
+++ b/MyApp.m	Sun Apr 11 12:38:26 2010 -0700
@@ -1,18 +1,11 @@
 #import <Foundation/NSAutoreleasePool.h>
+#import <Foundation/NSURL.h>
+#import <Foundation/NSURLRequest.h>
 #import <AppKit/NSApplication.h>
 #import <AppKit/NSWindow.h>
-#import <AppKit/NSView.h>
-
-@interface MyView : NSView {
-}
--(void)drawRect:(NSRect)dirtyRect;
-@end
-
-@implementation MyView
--(void)drawRect:(NSRect)dirtyRect {
-  printf("OMG drawRect!\n");
-}
-@end
+#import <WebKit/WebView.h>
+#import <WebKit/WebFrame.h>
+#import <WebKit/WebFrameView.h>
 
 int main(int argc, const char *argv[])
 {
@@ -28,7 +21,16 @@
                                        backing: NSBackingStoreBuffered
                                        defer: YES];
 
-  NSView *view = [[MyView alloc] init];
+  WebView *view = [[WebView alloc] initWithFrame: rect
+                                   frameName: nil
+                                   groupName: nil];
+
+  NSURL *url = [NSURL URLWithString: @"http://127.0.0.1:8000"];
+  NSURLRequest *req = [NSURLRequest requestWithURL: url];
+
+  [view setDrawsBackground: NO];
+  [[[view mainFrame] frameView] setAllowsScrolling: NO];
+  [[view mainFrame] loadRequest: req];
 
   [window setContentView: view];
   [window setLevel: NSScreenSaverWindowLevel];