cocoawebview 0.2.0 → 0.2.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 +8 -9
- data/lib/cocoawebview/version.rb +1 -1
- data/lib/cocoawebview.rb +23 -0
- 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: 05bb426942087b9adcf0bbe7bb138673877c47d1f1fa255389290c96587f1c97
|
4
|
+
data.tar.gz: a43620f4c4b8bae04cbd616722ff4a82b407f3f0f6e1f1c7659a800536771584
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a8097932a8b163941332b71df5342e85a5386c945143990d43ee5c5f31911d6625d014ecfd91826754efe065803edd2d60f95ac38526ce1ddc47a815d147d16
|
7
|
+
data.tar.gz: 205960af615fea7db2ed211fd49c771e6fa48e969584878c00024ff731fe6ac4fdc98db42c91380bcc3cbebd251b6c948cb218200d56a200b30cb9d4e494591e
|
@@ -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, VALUE debug);
|
13
|
+
VALUE webview_initialize(VALUE self, VALUE debug, VALUE style);
|
14
14
|
VALUE webview_show(VALUE self);
|
15
15
|
VALUE webview_hide(VALUE self);
|
16
16
|
VALUE webview_eval(VALUE self, VALUE code);
|
@@ -43,17 +43,14 @@ VALUE webview_set_title(VALUE self, VALUE title);
|
|
43
43
|
BOOL showDevTool;
|
44
44
|
}
|
45
45
|
- (void)setDevTool:(BOOL)flag;
|
46
|
-
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag;
|
46
|
+
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style;
|
47
47
|
- (void)eval:(NSString*)code;
|
48
48
|
- (void)setCocoaWebview:(VALUE)view;
|
49
49
|
- (void)dragging;
|
50
50
|
@end
|
51
51
|
|
52
52
|
@implementation CocoaWebview
|
53
|
-
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag {
|
54
|
-
int style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
55
|
-
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskFullSizeContentView;
|
56
|
-
style &= ~NSWindowStyleMaskFullScreen;
|
53
|
+
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style{
|
57
54
|
self = [super initWithContentRect:frame
|
58
55
|
styleMask:style
|
59
56
|
backing:NSBackingStoreBuffered
|
@@ -175,7 +172,7 @@ Init_cocoawebview(void)
|
|
175
172
|
|
176
173
|
/* CocoaWebview */
|
177
174
|
rb_mCocoaWebviewClass = rb_define_class_under(rb_mCocoawebview, "CocoaWebview", rb_cObject);
|
178
|
-
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize,
|
175
|
+
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 2);
|
179
176
|
rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
|
180
177
|
rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
|
181
178
|
rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
|
@@ -200,7 +197,7 @@ VALUE nsapp_run(VALUE self) {
|
|
200
197
|
[application run];
|
201
198
|
}
|
202
199
|
|
203
|
-
VALUE webview_initialize(VALUE self, VALUE debug) {
|
200
|
+
VALUE webview_initialize(VALUE self, VALUE debug, VALUE style) {
|
204
201
|
rb_iv_set(self, "@var", rb_hash_new());
|
205
202
|
rb_iv_set(self, "@bindings", rb_hash_new());
|
206
203
|
BOOL flag = NO;
|
@@ -209,7 +206,9 @@ VALUE webview_initialize(VALUE self, VALUE debug) {
|
|
209
206
|
} else {
|
210
207
|
flag = NO;
|
211
208
|
}
|
212
|
-
|
209
|
+
|
210
|
+
int c_style = NUM2INT(style);
|
211
|
+
CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag style:c_style];
|
213
212
|
|
214
213
|
[webview setReleasedWhenClosed:NO];
|
215
214
|
[webview setCocoaWebview:self];
|
data/lib/cocoawebview/version.rb
CHANGED
data/lib/cocoawebview.rb
CHANGED
@@ -5,6 +5,13 @@ require_relative "cocoawebview/version"
|
|
5
5
|
require_relative "cocoawebview/cocoawebview"
|
6
6
|
|
7
7
|
module CocoaWebview
|
8
|
+
NSWindowStyleMaskResizable = 8
|
9
|
+
NSWindowStyleMaskMiniaturizable = 4
|
10
|
+
NSWindowStyleMaskTitled = 1
|
11
|
+
NSWindowStyleMaskClosable = 2
|
12
|
+
NSWindowStyleMaskFullSizeContentView = (1 << 15)
|
13
|
+
NSWindowStyleMaskFullScreen = (1 << 14)
|
14
|
+
|
8
15
|
class Error < StandardError; end
|
9
16
|
# Your code goes here...
|
10
17
|
|
@@ -15,6 +22,22 @@ module CocoaWebview
|
|
15
22
|
end
|
16
23
|
|
17
24
|
class CocoaWebview
|
25
|
+
attr_accessor :callback
|
26
|
+
|
27
|
+
def self.create(debug: false, min: true, max: true, close: true, &block)
|
28
|
+
style = NSWindowStyleMaskTitled | NSWindowStyleMaskFullSizeContentView
|
29
|
+
|
30
|
+
style = style | NSWindowStyleMaskMiniaturizable if min
|
31
|
+
style = style | NSWindowStyleMaskResizable if max
|
32
|
+
style = style | NSWindowStyleMaskClosable if close
|
33
|
+
|
34
|
+
style &= ~NSWindowStyleMaskFullScreen
|
35
|
+
|
36
|
+
webview = new(debug, style)
|
37
|
+
webview.callback = block
|
38
|
+
webview
|
39
|
+
end
|
40
|
+
|
18
41
|
def get_webview
|
19
42
|
@webview
|
20
43
|
end
|