cocoawebview 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/cocoawebview/cocoawebview.m +23 -7
- data/lib/cocoawebview/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d00e0e58d1097c2a8038c2f484f3e155fa00c85eae7965f3b859b2fa59f843c
|
4
|
+
data.tar.gz: 683d9b3490e9527f0a7a967fe82f70db6702cc2f402168cc57deabbe98bb5a4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 712d3408b6500ab3e94d138aa285b53fa283eb806dd968cc076ba20354ecf520ecbab286eb3f543d1722f9fab70b8c7676fabe483cecac78d2a15740b356ec7e
|
7
|
+
data.tar.gz: dfbc8a72c65e69bdaeeea9c9ff3c31650b5bf72bd12b4bc692c25b5168512ba174c71936f24004b8a750bc02f3f5524f4cc664ca7ad16edd5eb3f792e512a5c8
|
@@ -10,7 +10,7 @@ NSApplication *application = nil;
|
|
10
10
|
VALUE nsapp_initialize(VALUE self);
|
11
11
|
VALUE nsapp_run(VALUE self);
|
12
12
|
|
13
|
-
VALUE webview_initialize(VALUE self);
|
13
|
+
VALUE webview_initialize(VALUE self, VALUE debug);
|
14
14
|
VALUE webview_show(VALUE self);
|
15
15
|
VALUE webview_hide(VALUE self);
|
16
16
|
VALUE webview_eval(VALUE self, VALUE code);
|
@@ -35,14 +35,16 @@ VALUE webview_eval(VALUE self, VALUE code);
|
|
35
35
|
@interface CocoaWebview : NSWindow {
|
36
36
|
WKWebView *webView;
|
37
37
|
VALUE rb_cocoawebview;
|
38
|
+
BOOL showDevTool;
|
38
39
|
}
|
39
|
-
- (
|
40
|
+
- (void)setDevTool:(BOOL)flag;
|
41
|
+
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag;
|
40
42
|
- (void)eval:(NSString*)code;
|
41
43
|
- (void)setCocoaWebview:(VALUE)view;
|
42
44
|
@end
|
43
45
|
|
44
46
|
@implementation CocoaWebview
|
45
|
-
- (id)initWithFrame:(NSRect)frame{
|
47
|
+
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag {
|
46
48
|
int style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
47
49
|
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskFullSizeContentView;
|
48
50
|
style &= ~NSWindowStyleMaskFullScreen;
|
@@ -51,13 +53,19 @@ VALUE webview_eval(VALUE self, VALUE code);
|
|
51
53
|
backing:NSBackingStoreBuffered
|
52
54
|
defer:NO];
|
53
55
|
if (self) {
|
56
|
+
[self center];
|
54
57
|
[self setTitle:@"My Custom Window"];
|
58
|
+
[self setDevTool:flag];
|
55
59
|
[self setTitlebarAppearsTransparent: YES];
|
56
60
|
[self addWebViewToWindow:self];
|
57
61
|
}
|
58
62
|
return self;
|
59
63
|
}
|
60
64
|
|
65
|
+
- (void)setDevTool:(BOOL)flag {
|
66
|
+
showDevTool = flag;
|
67
|
+
}
|
68
|
+
|
61
69
|
- (void)setCocoaWebview:(VALUE)view {
|
62
70
|
rb_cocoawebview = view;
|
63
71
|
}
|
@@ -76,7 +84,9 @@ VALUE webview_eval(VALUE self, VALUE code);
|
|
76
84
|
|
77
85
|
[[config preferences] setValue:@YES forKey:@"fullScreenEnabled"];
|
78
86
|
|
79
|
-
|
87
|
+
if (showDevTool) {
|
88
|
+
[[config preferences] setValue:@YES forKey:@"developerExtrasEnabled"];
|
89
|
+
}
|
80
90
|
|
81
91
|
[[config preferences] setValue:@YES forKey:@"javaScriptCanAccessClipboard"];
|
82
92
|
|
@@ -134,7 +144,7 @@ Init_cocoawebview(void)
|
|
134
144
|
|
135
145
|
/* CocoaWebview */
|
136
146
|
rb_mCocoaWebviewClass = rb_define_class_under(rb_mCocoawebview, "CocoaWebview", rb_cObject);
|
137
|
-
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize,
|
147
|
+
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 1);
|
138
148
|
rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
|
139
149
|
rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
|
140
150
|
rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
|
@@ -153,9 +163,15 @@ VALUE nsapp_run(VALUE self) {
|
|
153
163
|
[application run];
|
154
164
|
}
|
155
165
|
|
156
|
-
VALUE webview_initialize(VALUE self) {
|
166
|
+
VALUE webview_initialize(VALUE self, VALUE debug) {
|
157
167
|
rb_iv_set(self, "@var", rb_hash_new());
|
158
|
-
|
168
|
+
BOOL flag = NO;
|
169
|
+
if (debug == Qtrue) {
|
170
|
+
flag = YES;
|
171
|
+
} else {
|
172
|
+
flag = NO;
|
173
|
+
}
|
174
|
+
CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag];
|
159
175
|
|
160
176
|
[webview setCocoaWebview:self];
|
161
177
|
|
data/lib/cocoawebview/version.rb
CHANGED