cocoawebview 0.2.9 → 0.3.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 +47 -6
- data/lib/cocoawebview/version.rb +1 -1
- data/lib/cocoawebview.rb +2 -2
- 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: a6429fedf1d1f28dd4375f23a4874920db7df15a3ad1b8385ae97332315f9031
|
4
|
+
data.tar.gz: 2697a99cd838afd93bf2af09c9a5d32e94ca596685149d53cab3735249b4d8f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cdd3cd1510626f4ae76f0ed65005e3d934d6ce6dfb35a490ec3e2293be6fe2b740427f7add14642c6566769d8d688e6f64f866ca1dbdb7442d6e025739e1bd2
|
7
|
+
data.tar.gz: 7ca9097dbfecace2f6bdbfb42674d2d8ec8ae52751dc2a1e4b79ec04415ffc7d1deb71c3e0e220c22399751c241789a8c063a428a34f3299460540be716707b4
|
@@ -11,7 +11,7 @@ VALUE nsapp_initialize(VALUE self);
|
|
11
11
|
VALUE nsapp_run(VALUE self);
|
12
12
|
VALUE nsapp_exit(VALUE self);
|
13
13
|
|
14
|
-
VALUE webview_initialize(VALUE self, VALUE debug, VALUE style);
|
14
|
+
VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_buttons);
|
15
15
|
VALUE webview_show(VALUE self);
|
16
16
|
VALUE webview_hide(VALUE self);
|
17
17
|
VALUE webview_eval(VALUE self, VALUE code);
|
@@ -45,16 +45,18 @@ VALUE webview_set_topmost(VALUE self, VALUE topmost);
|
|
45
45
|
WKWebView *webView;
|
46
46
|
VALUE rb_cocoawebview;
|
47
47
|
BOOL showDevTool;
|
48
|
+
BOOL shouldMoveTitleButtons;
|
48
49
|
}
|
50
|
+
- (void)setShouldMoveTitleButtons:(BOOL)flag;
|
49
51
|
- (void)setDevTool:(BOOL)flag;
|
50
|
-
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style;
|
52
|
+
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons;
|
51
53
|
- (void)eval:(NSString*)code;
|
52
54
|
- (void)setCocoaWebview:(VALUE)view;
|
53
55
|
- (void)dragging;
|
54
56
|
@end
|
55
57
|
|
56
58
|
@implementation CocoaWebview
|
57
|
-
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style{
|
59
|
+
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons{
|
58
60
|
self = [super initWithContentRect:frame
|
59
61
|
styleMask:style
|
60
62
|
backing:NSBackingStoreBuffered
|
@@ -66,10 +68,42 @@ VALUE webview_set_topmost(VALUE self, VALUE topmost);
|
|
66
68
|
[self setTitlebarAppearsTransparent: YES];
|
67
69
|
[self setTitleVisibility:NSWindowTitleHidden];
|
68
70
|
[self addWebViewToWindow:self];
|
71
|
+
[self setShouldMoveTitleButtons:moveTitleButtons];
|
72
|
+
if (moveTitleButtons) {
|
73
|
+
[self moveWindowButtonsForWindow:self];
|
74
|
+
}
|
75
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
76
|
+
selector:@selector(windowDidResize:)
|
77
|
+
name:NSWindowDidResizeNotification
|
78
|
+
object:self];
|
69
79
|
}
|
70
80
|
return self;
|
71
81
|
}
|
72
82
|
|
83
|
+
- (void)setShouldMoveTitleButtons:(BOOL)flag {
|
84
|
+
shouldMoveTitleButtons = flag;
|
85
|
+
}
|
86
|
+
|
87
|
+
- (void)windowDidResize:(NSNotification *)notification {
|
88
|
+
if (shouldMoveTitleButtons) {
|
89
|
+
[self moveWindowButtonsForWindow:self];
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
- (void)moveWindowButtonsForWindow:(NSWindow *)window {
|
94
|
+
//Close Button
|
95
|
+
NSButton *closeButton = [window standardWindowButton:NSWindowCloseButton];
|
96
|
+
[closeButton setFrameOrigin:NSMakePoint(closeButton.frame.origin.x + 10, closeButton.frame.origin.y - 10)];
|
97
|
+
|
98
|
+
//Minimize Button
|
99
|
+
NSButton *minimizeButton = [window standardWindowButton:NSWindowMiniaturizeButton];
|
100
|
+
[minimizeButton setFrameOrigin:NSMakePoint(minimizeButton.frame.origin.x + 10, minimizeButton.frame.origin.y - 10)];
|
101
|
+
|
102
|
+
//Zoom Button
|
103
|
+
NSButton *zoomButton = [window standardWindowButton:NSWindowZoomButton];
|
104
|
+
[zoomButton setFrameOrigin:NSMakePoint(zoomButton.frame.origin.x + 10, zoomButton.frame.origin.y - 10)];
|
105
|
+
}
|
106
|
+
|
73
107
|
- (void)close {
|
74
108
|
[self orderOut:nil]; // Hide instead of destroy
|
75
109
|
}
|
@@ -177,7 +211,7 @@ Init_cocoawebview(void)
|
|
177
211
|
|
178
212
|
/* CocoaWebview */
|
179
213
|
rb_mCocoaWebviewClass = rb_define_class_under(rb_mCocoawebview, "CocoaWebview", rb_cObject);
|
180
|
-
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize,
|
214
|
+
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 3);
|
181
215
|
rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
|
182
216
|
rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
|
183
217
|
rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
|
@@ -210,7 +244,7 @@ VALUE nsapp_exit(VALUE self) {
|
|
210
244
|
[[NSApplication sharedApplication] terminate:nil];
|
211
245
|
}
|
212
246
|
|
213
|
-
VALUE webview_initialize(VALUE self, VALUE debug, VALUE style) {
|
247
|
+
VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_buttons) {
|
214
248
|
rb_iv_set(self, "@var", rb_hash_new());
|
215
249
|
rb_iv_set(self, "@bindings", rb_hash_new());
|
216
250
|
BOOL flag = NO;
|
@@ -220,8 +254,14 @@ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style) {
|
|
220
254
|
flag = NO;
|
221
255
|
}
|
222
256
|
|
257
|
+
BOOL c_move_title_buttons = NO;
|
258
|
+
if (move_title_buttons == Qtrue) {
|
259
|
+
c_move_title_buttons = YES;
|
260
|
+
} else {
|
261
|
+
c_move_title_buttons = NO;
|
262
|
+
}
|
223
263
|
int c_style = NUM2INT(style);
|
224
|
-
CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag style:c_style];
|
264
|
+
CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag style:c_style moveTitleButtons:c_move_title_buttons];
|
225
265
|
|
226
266
|
[webview setReleasedWhenClosed:NO];
|
227
267
|
[webview setCocoaWebview:self];
|
@@ -238,6 +278,7 @@ VALUE webview_show(VALUE self) {
|
|
238
278
|
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
239
279
|
CocoaWebview *webview;
|
240
280
|
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
281
|
+
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
241
282
|
[webview makeKeyAndOrderFront:nil];
|
242
283
|
}
|
243
284
|
|
data/lib/cocoawebview/version.rb
CHANGED
data/lib/cocoawebview.rb
CHANGED
@@ -24,7 +24,7 @@ module CocoaWebview
|
|
24
24
|
class CocoaWebview
|
25
25
|
attr_accessor :callback
|
26
26
|
|
27
|
-
def self.create(debug: false, min: true, resize: true, close: true, &block)
|
27
|
+
def self.create(debug: false, min: true, resize: true, close: true, move_title_buttons: false, &block)
|
28
28
|
style = NSWindowStyleMaskTitled | NSWindowStyleMaskFullSizeContentView
|
29
29
|
|
30
30
|
style = style | NSWindowStyleMaskMiniaturizable if min
|
@@ -33,7 +33,7 @@ module CocoaWebview
|
|
33
33
|
|
34
34
|
style &= ~NSWindowStyleMaskFullScreen
|
35
35
|
|
36
|
-
webview = new(debug, style)
|
36
|
+
webview = new(debug, style, move_title_buttons)
|
37
37
|
webview.callback = block
|
38
38
|
webview
|
39
39
|
end
|