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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6d8353c646afd0ec95dcfc21b339ccbff41b11723bbfb35f1a97fcf10245542
4
- data.tar.gz: e368d715dd3aebd24b50eeb384aa9210e9f269546d7b0aaea9b198329310bf9d
3
+ metadata.gz: 38486e705f04b56aad1b11d9c0fa746ccc4adb4889df6d7d1d8061a5b3afee58
4
+ data.tar.gz: eb2b937693ff7b8a42479904091d299f17fe4a01211258b27b9cf9f80bce7757
5
5
  SHA512:
6
- metadata.gz: 63c472a2de65ae80617a268252fb55844439bc7590cd5ca17aac9018b583cd623eb7b7c2bc251c4e20f76105965a978d2d3b2e61536223582d3c318db2f53ac6
7
- data.tar.gz: 78c2d06a6aef4b6ed82a2eb194cf3c9812c1d98af30f028dbad248604c3c8b927de39b5500a67142a23fcd2a19b8f03cfa55502035caee4f835a3407f1d7c87d
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
- - (id)initWithFrame:(NSRect)frame;
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
- [[config preferences] setValue:@YES forKey:@"developerExtrasEnabled"];
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, 0);
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
- CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500)];
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cocoawebview
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoawebview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Jeff