cocoawebview 0.1.8 → 0.2.0
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 +29 -0
- 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: 0b9ceb3f514a6ed507c9db38001ff15bfc4725ee0bb1107e6a9a6872a4981afe
|
4
|
+
data.tar.gz: 673ae12e518d228d40b808edf789ed07a19b54f82fd1a7b52f036c477c995005
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d7972169c428d8cb5b7d80aa4038b34d8dbd1a7e11f961691d902ad09842fb77ca67668329c1a51cbed6afcd8283e2e2edc097a5d16defd6efa128ae360dd94
|
7
|
+
data.tar.gz: cf24d3bcfea910ea0c4bce2b8317cf1e100e704ac9a1462399efd88e11739fa1c69252b3ad8f8afa5801e2563376e6931803c9828dc51d7300ed8b7d39ec2657
|
@@ -18,6 +18,8 @@ VALUE webview_set_size(VALUE self, VALUE width, VALUE height);
|
|
18
18
|
VALUE webview_get_size(VALUE self);
|
19
19
|
VALUE webview_set_pos(VALUE self, VALUE x, VALUE y);
|
20
20
|
VALUE webview_get_pos(VALUE self);
|
21
|
+
VALUE webview_dragging(VALUE self);
|
22
|
+
VALUE webview_set_title(VALUE self, VALUE title);
|
21
23
|
|
22
24
|
@interface AppDelegate : NSObject <NSApplicationDelegate> {
|
23
25
|
VALUE app;
|
@@ -44,6 +46,7 @@ VALUE webview_get_pos(VALUE self);
|
|
44
46
|
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag;
|
45
47
|
- (void)eval:(NSString*)code;
|
46
48
|
- (void)setCocoaWebview:(VALUE)view;
|
49
|
+
- (void)dragging;
|
47
50
|
@end
|
48
51
|
|
49
52
|
@implementation CocoaWebview
|
@@ -60,6 +63,7 @@ VALUE webview_get_pos(VALUE self);
|
|
60
63
|
[self setTitle:@"My Custom Window"];
|
61
64
|
[self setDevTool:flag];
|
62
65
|
[self setTitlebarAppearsTransparent: YES];
|
66
|
+
[self setTitleVisibility:NSWindowTitleHidden];
|
63
67
|
[self addWebViewToWindow:self];
|
64
68
|
}
|
65
69
|
return self;
|
@@ -74,6 +78,11 @@ VALUE webview_get_pos(VALUE self);
|
|
74
78
|
[notification.object orderOut:nil];
|
75
79
|
}
|
76
80
|
|
81
|
+
- (void)dragging {
|
82
|
+
NSEvent *event = [NSApp currentEvent];
|
83
|
+
[self performWindowDragWithEvent:event];
|
84
|
+
}
|
85
|
+
|
77
86
|
- (void)userContentController:(WKUserContentController *)userContentController
|
78
87
|
didReceiveScriptMessage:(WKScriptMessage *)message {
|
79
88
|
if ([message.name isEqualToString:@"native"]) {
|
@@ -174,6 +183,8 @@ Init_cocoawebview(void)
|
|
174
183
|
rb_define_method(rb_mCocoaWebviewClass, "get_size", webview_get_size, 0);
|
175
184
|
rb_define_method(rb_mCocoaWebviewClass, "set_pos", webview_set_pos, 2);
|
176
185
|
rb_define_method(rb_mCocoaWebviewClass, "get_pos", webview_get_pos, 0);
|
186
|
+
rb_define_method(rb_mCocoaWebviewClass, "dragging", webview_dragging, 0);
|
187
|
+
rb_define_method(rb_mCocoaWebviewClass, "set_title", webview_set_title, 1);
|
177
188
|
}
|
178
189
|
|
179
190
|
VALUE nsapp_initialize(VALUE self) {
|
@@ -295,3 +306,21 @@ VALUE webview_get_pos(VALUE self) {
|
|
295
306
|
rb_ary_push(ary, rb_y);
|
296
307
|
return ary;
|
297
308
|
}
|
309
|
+
|
310
|
+
VALUE webview_dragging(VALUE self) {
|
311
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
312
|
+
CocoaWebview *webview;
|
313
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
314
|
+
|
315
|
+
[webview dragging];
|
316
|
+
}
|
317
|
+
|
318
|
+
VALUE webview_set_title(VALUE self, VALUE title) {
|
319
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
320
|
+
CocoaWebview *webview;
|
321
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
322
|
+
|
323
|
+
const char *c_title = StringValueCStr(title);
|
324
|
+
NSString *title_str = [[NSString alloc] initWithCString:c_title encoding:NSUTF8StringEncoding];
|
325
|
+
[webview setTitle:title_str];
|
326
|
+
}
|
data/lib/cocoawebview/version.rb
CHANGED