cocoawebview 0.1.1 → 0.1.2
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 +22 -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: 38486e705f04b56aad1b11d9c0fa746ccc4adb4889df6d7d1d8061a5b3afee58
|
4
|
+
data.tar.gz: eb2b937693ff7b8a42479904091d299f17fe4a01211258b27b9cf9f80bce7757
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b38e54462caafcaefa0c7f1cfef0f130abef9baa9d5c903085185ce6e798b7a0ddc017aaa4aca360c007bc45885d8ddd6700edc5987f8e277b6269c409033c45
|
7
|
+
data.tar.gz: deb1a4504f60bfd53c333b672bdbeccc58f35d3abad99454ffe60937494a06a441bc17df9b6324f048ee800be0cedb3d5e387a0ebccff3d06ca055db4f691c13
|
@@ -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;
|
@@ -52,12 +54,17 @@ VALUE webview_eval(VALUE self, VALUE code);
|
|
52
54
|
defer:NO];
|
53
55
|
if (self) {
|
54
56
|
[self setTitle:@"My Custom Window"];
|
57
|
+
[self setDevTool:flag];
|
55
58
|
[self setTitlebarAppearsTransparent: YES];
|
56
59
|
[self addWebViewToWindow:self];
|
57
60
|
}
|
58
61
|
return self;
|
59
62
|
}
|
60
63
|
|
64
|
+
- (void)setDevTool:(BOOL)flag {
|
65
|
+
showDevTool = flag;
|
66
|
+
}
|
67
|
+
|
61
68
|
- (void)setCocoaWebview:(VALUE)view {
|
62
69
|
rb_cocoawebview = view;
|
63
70
|
}
|
@@ -76,7 +83,9 @@ VALUE webview_eval(VALUE self, VALUE code);
|
|
76
83
|
|
77
84
|
[[config preferences] setValue:@YES forKey:@"fullScreenEnabled"];
|
78
85
|
|
79
|
-
|
86
|
+
if (showDevTool) {
|
87
|
+
[[config preferences] setValue:@YES forKey:@"developerExtrasEnabled"];
|
88
|
+
}
|
80
89
|
|
81
90
|
[[config preferences] setValue:@YES forKey:@"javaScriptCanAccessClipboard"];
|
82
91
|
|
@@ -134,7 +143,7 @@ Init_cocoawebview(void)
|
|
134
143
|
|
135
144
|
/* CocoaWebview */
|
136
145
|
rb_mCocoaWebviewClass = rb_define_class_under(rb_mCocoawebview, "CocoaWebview", rb_cObject);
|
137
|
-
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize,
|
146
|
+
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 1);
|
138
147
|
rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
|
139
148
|
rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
|
140
149
|
rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
|
@@ -153,9 +162,15 @@ VALUE nsapp_run(VALUE self) {
|
|
153
162
|
[application run];
|
154
163
|
}
|
155
164
|
|
156
|
-
VALUE webview_initialize(VALUE self) {
|
165
|
+
VALUE webview_initialize(VALUE self, VALUE debug) {
|
157
166
|
rb_iv_set(self, "@var", rb_hash_new());
|
158
|
-
|
167
|
+
BOOL flag = NO;
|
168
|
+
if (debug == Qtrue) {
|
169
|
+
flag = YES;
|
170
|
+
} else {
|
171
|
+
flag = NO;
|
172
|
+
}
|
173
|
+
CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag];
|
159
174
|
|
160
175
|
[webview setCocoaWebview:self];
|
161
176
|
|
data/lib/cocoawebview/version.rb
CHANGED