cocoawebview 0.1.9 → 0.2.1
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 +24 -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: b434fa5361c35d5a60d14a7c817e353896e2748b7a5663f0220b6ca7481f01f1
|
4
|
+
data.tar.gz: 87ff99830e7533c2579f8525e042e9c0e19212b03babaeff3942a452cd022499
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4a99f3ffebd8b527c0155f569dac8fdd4634241b042a69d74815fda262816267f85a8708df444e30a18ea49bc14206b44dfe98a24d31e9ded533d7f847df088
|
7
|
+
data.tar.gz: acc2363c86cf15816129176aaa863d89b6b810f1967a0aba5f3b2851168b432ed4649849cecd4dbfa06d9abc435c6c1d057778dfd33b66996c36fa018ea89cf7
|
@@ -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);
|
@@ -19,6 +19,7 @@ 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
21
|
VALUE webview_dragging(VALUE self);
|
22
|
+
VALUE webview_set_title(VALUE self, VALUE title);
|
22
23
|
|
23
24
|
@interface AppDelegate : NSObject <NSApplicationDelegate> {
|
24
25
|
VALUE app;
|
@@ -42,17 +43,14 @@ VALUE webview_dragging(VALUE self);
|
|
42
43
|
BOOL showDevTool;
|
43
44
|
}
|
44
45
|
- (void)setDevTool:(BOOL)flag;
|
45
|
-
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag;
|
46
|
+
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style;
|
46
47
|
- (void)eval:(NSString*)code;
|
47
48
|
- (void)setCocoaWebview:(VALUE)view;
|
48
49
|
- (void)dragging;
|
49
50
|
@end
|
50
51
|
|
51
52
|
@implementation CocoaWebview
|
52
|
-
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag {
|
53
|
-
int style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
|
54
|
-
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskFullSizeContentView;
|
55
|
-
style &= ~NSWindowStyleMaskFullScreen;
|
53
|
+
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style{
|
56
54
|
self = [super initWithContentRect:frame
|
57
55
|
styleMask:style
|
58
56
|
backing:NSBackingStoreBuffered
|
@@ -62,6 +60,7 @@ VALUE webview_dragging(VALUE self);
|
|
62
60
|
[self setTitle:@"My Custom Window"];
|
63
61
|
[self setDevTool:flag];
|
64
62
|
[self setTitlebarAppearsTransparent: YES];
|
63
|
+
[self setTitleVisibility:NSWindowTitleHidden];
|
65
64
|
[self addWebViewToWindow:self];
|
66
65
|
}
|
67
66
|
return self;
|
@@ -173,7 +172,7 @@ Init_cocoawebview(void)
|
|
173
172
|
|
174
173
|
/* CocoaWebview */
|
175
174
|
rb_mCocoaWebviewClass = rb_define_class_under(rb_mCocoawebview, "CocoaWebview", rb_cObject);
|
176
|
-
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize,
|
175
|
+
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 2);
|
177
176
|
rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
|
178
177
|
rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
|
179
178
|
rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
|
@@ -182,6 +181,7 @@ Init_cocoawebview(void)
|
|
182
181
|
rb_define_method(rb_mCocoaWebviewClass, "set_pos", webview_set_pos, 2);
|
183
182
|
rb_define_method(rb_mCocoaWebviewClass, "get_pos", webview_get_pos, 0);
|
184
183
|
rb_define_method(rb_mCocoaWebviewClass, "dragging", webview_dragging, 0);
|
184
|
+
rb_define_method(rb_mCocoaWebviewClass, "set_title", webview_set_title, 1);
|
185
185
|
}
|
186
186
|
|
187
187
|
VALUE nsapp_initialize(VALUE self) {
|
@@ -197,7 +197,7 @@ VALUE nsapp_run(VALUE self) {
|
|
197
197
|
[application run];
|
198
198
|
}
|
199
199
|
|
200
|
-
VALUE webview_initialize(VALUE self, VALUE debug) {
|
200
|
+
VALUE webview_initialize(VALUE self, VALUE debug, VALUE style) {
|
201
201
|
rb_iv_set(self, "@var", rb_hash_new());
|
202
202
|
rb_iv_set(self, "@bindings", rb_hash_new());
|
203
203
|
BOOL flag = NO;
|
@@ -206,7 +206,12 @@ VALUE webview_initialize(VALUE self, VALUE debug) {
|
|
206
206
|
} else {
|
207
207
|
flag = NO;
|
208
208
|
}
|
209
|
-
|
209
|
+
|
210
|
+
//int c_style = NUM2INT(style);
|
211
|
+
int c_style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable |
|
212
|
+
NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskFullSizeContentView;
|
213
|
+
style &= ~NSWindowStyleMaskFullScreen;
|
214
|
+
CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag style:c_style];
|
210
215
|
|
211
216
|
[webview setReleasedWhenClosed:NO];
|
212
217
|
[webview setCocoaWebview:self];
|
@@ -311,3 +316,13 @@ VALUE webview_dragging(VALUE self) {
|
|
311
316
|
|
312
317
|
[webview dragging];
|
313
318
|
}
|
319
|
+
|
320
|
+
VALUE webview_set_title(VALUE self, VALUE title) {
|
321
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
322
|
+
CocoaWebview *webview;
|
323
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
324
|
+
|
325
|
+
const char *c_title = StringValueCStr(title);
|
326
|
+
NSString *title_str = [[NSString alloc] initWithCString:c_title encoding:NSUTF8StringEncoding];
|
327
|
+
[webview setTitle:title_str];
|
328
|
+
}
|
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
|