cocoawebview 0.3.14 → 0.4.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 +38 -9
- data/lib/cocoawebview/version.rb +1 -1
- data/lib/cocoawebview.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cad99e128e05d31cff115cfd0d6fc28baff36d22d9247e5c7b5884b327138a8
|
4
|
+
data.tar.gz: 76bf581086b3728ee51dc4ee80c0313cfb53d25b0c3a960728c95db980817a77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b42b5d66a586af10424ecb0a1ef5db21491a08db9b94a81a113ad9d352cc4b0fbfc801493a14095cab83c3ca17015db681c615f00602a223d7591c21f6235498
|
7
|
+
data.tar.gz: 3c11815ce1c970017adc901344e16b3c06451debf750a1b3ec05ff2ae42995b799a97042d22f9876bd52c3f7a56ed30fc50d167d40acbed18bacd1e5faf7a755
|
@@ -11,7 +11,8 @@ 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, VALUE move_title_buttons);
|
14
|
+
VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_buttons, VALUE delta_y);
|
15
|
+
VALUE webview_navigate(VALUE self, VALUE url);
|
15
16
|
VALUE webview_show(VALUE self);
|
16
17
|
VALUE webview_hide(VALUE self);
|
17
18
|
VALUE webview_eval(VALUE self, VALUE code);
|
@@ -120,17 +121,20 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
|
|
120
121
|
BOOL showDevTool;
|
121
122
|
BOOL shouldMoveTitleButtons;
|
122
123
|
FileDropContainerView *fileDropView;
|
124
|
+
int deltaY;
|
123
125
|
}
|
124
126
|
- (void)setShouldMoveTitleButtons:(BOOL)flag;
|
125
127
|
- (void)setDevTool:(BOOL)flag;
|
126
|
-
- (
|
128
|
+
- (void)setDeltaY:(int)dy;
|
129
|
+
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons deltaY:(int)dy;
|
127
130
|
- (void)eval:(NSString*)code;
|
131
|
+
- (void)navigate:(NSString*)url;
|
128
132
|
- (void)setCocoaWebview:(VALUE)view;
|
129
133
|
- (void)dragging;
|
130
134
|
@end
|
131
135
|
|
132
136
|
@implementation CocoaWebview
|
133
|
-
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons{
|
137
|
+
- (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons deltaY:(int)dy {
|
134
138
|
self = [super initWithContentRect:frame
|
135
139
|
styleMask:style
|
136
140
|
backing:NSBackingStoreBuffered
|
@@ -139,6 +143,7 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
|
|
139
143
|
[self center];
|
140
144
|
[self setTitle:@"My Custom Window"];
|
141
145
|
[self setDevTool:flag];
|
146
|
+
[self setDeltaY:dy];
|
142
147
|
[self setTitlebarAppearsTransparent: YES];
|
143
148
|
[self setTitleVisibility:NSWindowTitleHidden];
|
144
149
|
[self addWebViewToWindow:self];
|
@@ -154,6 +159,10 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
|
|
154
159
|
return self;
|
155
160
|
}
|
156
161
|
|
162
|
+
- (void)setDeltaY:(int)dy {
|
163
|
+
deltaY = dy;
|
164
|
+
}
|
165
|
+
|
157
166
|
- (void)setShouldMoveTitleButtons:(BOOL)flag {
|
158
167
|
shouldMoveTitleButtons = flag;
|
159
168
|
}
|
@@ -167,15 +176,15 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
|
|
167
176
|
- (void)moveWindowButtonsForWindow:(NSWindow *)window {
|
168
177
|
//Close Button
|
169
178
|
NSButton *closeButton = [window standardWindowButton:NSWindowCloseButton];
|
170
|
-
[closeButton setFrameOrigin:NSMakePoint(closeButton.frame.origin.x + 10, closeButton.frame.origin.y -
|
179
|
+
[closeButton setFrameOrigin:NSMakePoint(closeButton.frame.origin.x + 10, closeButton.frame.origin.y - deltaY)];
|
171
180
|
|
172
181
|
//Minimize Button
|
173
182
|
NSButton *minimizeButton = [window standardWindowButton:NSWindowMiniaturizeButton];
|
174
|
-
[minimizeButton setFrameOrigin:NSMakePoint(minimizeButton.frame.origin.x + 10, minimizeButton.frame.origin.y -
|
183
|
+
[minimizeButton setFrameOrigin:NSMakePoint(minimizeButton.frame.origin.x + 10, minimizeButton.frame.origin.y - deltaY)];
|
175
184
|
|
176
185
|
//Zoom Button
|
177
186
|
NSButton *zoomButton = [window standardWindowButton:NSWindowZoomButton];
|
178
|
-
[zoomButton setFrameOrigin:NSMakePoint(zoomButton.frame.origin.x + 10, zoomButton.frame.origin.y -
|
187
|
+
[zoomButton setFrameOrigin:NSMakePoint(zoomButton.frame.origin.x + 10, zoomButton.frame.origin.y - deltaY)];
|
179
188
|
}
|
180
189
|
|
181
190
|
- (void)close {
|
@@ -210,6 +219,12 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
|
|
210
219
|
[fileDropView setObj:view];
|
211
220
|
}
|
212
221
|
|
222
|
+
- (void)navigate:(NSString*)url {
|
223
|
+
NSURL *url_ns = [NSURL URLWithString:url];
|
224
|
+
NSURLRequest *request = [NSURLRequest requestWithURL:url_ns];
|
225
|
+
[webView loadRequest:request];
|
226
|
+
}
|
227
|
+
|
213
228
|
- (void)eval:(NSString*)code {
|
214
229
|
[webView evaluateJavaScript:code completionHandler:^(id result, NSError *error) {
|
215
230
|
if (error) {
|
@@ -291,10 +306,11 @@ Init_cocoawebview(void)
|
|
291
306
|
|
292
307
|
/* CocoaWebview */
|
293
308
|
rb_mCocoaWebviewClass = rb_define_class_under(rb_mCocoawebview, "CocoaWebview", rb_cObject);
|
294
|
-
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize,
|
309
|
+
rb_define_method(rb_mCocoaWebviewClass, "initialize", webview_initialize, 4);
|
295
310
|
rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
|
296
311
|
rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
|
297
312
|
rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
|
313
|
+
rb_define_method(rb_mCocoaWebviewClass, "navigate", webview_navigate, 1);
|
298
314
|
rb_define_method(rb_mCocoaWebviewClass, "set_size", webview_set_size, 2);
|
299
315
|
rb_define_method(rb_mCocoaWebviewClass, "get_size", webview_get_size, 0);
|
300
316
|
rb_define_method(rb_mCocoaWebviewClass, "set_pos", webview_set_pos, 2);
|
@@ -325,7 +341,7 @@ VALUE nsapp_exit(VALUE self) {
|
|
325
341
|
[[NSApplication sharedApplication] terminate:nil];
|
326
342
|
}
|
327
343
|
|
328
|
-
VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_buttons) {
|
344
|
+
VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_buttons, VALUE delta_y) {
|
329
345
|
rb_iv_set(self, "@var", rb_hash_new());
|
330
346
|
rb_iv_set(self, "@bindings", rb_hash_new());
|
331
347
|
BOOL flag = NO;
|
@@ -342,7 +358,8 @@ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_
|
|
342
358
|
c_move_title_buttons = NO;
|
343
359
|
}
|
344
360
|
int c_style = NUM2INT(style);
|
345
|
-
|
361
|
+
int c_delta_y = NUM2INT(delta_y);
|
362
|
+
CocoaWebview *webview = [[CocoaWebview alloc] initWithFrame:NSMakeRect(100, 100, 400, 500) debug:flag style:c_style moveTitleButtons:c_move_title_buttons deltaY:c_delta_y];
|
346
363
|
|
347
364
|
[webview setReleasedWhenClosed:NO];
|
348
365
|
[webview setCocoaWebview:self];
|
@@ -355,6 +372,18 @@ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_
|
|
355
372
|
return self;
|
356
373
|
}
|
357
374
|
|
375
|
+
VALUE webview_navigate(VALUE self, VALUE url) {
|
376
|
+
const char *url_c = StringValueCStr(url);
|
377
|
+
NSString *url_ns = [[NSString alloc] initWithCString:url_c encoding:NSUTF8StringEncoding];
|
378
|
+
|
379
|
+
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
380
|
+
CocoaWebview *webview;
|
381
|
+
TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
|
382
|
+
|
383
|
+
[webview navigate:url_ns];
|
384
|
+
}
|
385
|
+
|
386
|
+
|
358
387
|
VALUE webview_show(VALUE self) {
|
359
388
|
VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
|
360
389
|
CocoaWebview *webview;
|
data/lib/cocoawebview/version.rb
CHANGED
data/lib/cocoawebview.rb
CHANGED
@@ -28,7 +28,7 @@ module CocoaWebview
|
|
28
28
|
class CocoaWebview
|
29
29
|
attr_accessor :callback
|
30
30
|
|
31
|
-
def self.create(debug: false, min: true, resize: true, close: true, move_title_buttons: false, &block)
|
31
|
+
def self.create(debug: false, min: true, resize: true, close: true, move_title_buttons: false, delta_y: 10, &block)
|
32
32
|
style = NSWindowStyleMaskTitled | NSWindowStyleMaskFullSizeContentView
|
33
33
|
|
34
34
|
style = style | NSWindowStyleMaskMiniaturizable if min
|
@@ -37,7 +37,7 @@ module CocoaWebview
|
|
37
37
|
|
38
38
|
style &= ~NSWindowStyleMaskFullScreen
|
39
39
|
|
40
|
-
webview = new(debug, style, move_title_buttons)
|
40
|
+
webview = new(debug, style, move_title_buttons, delta_y)
|
41
41
|
webview.callback = block
|
42
42
|
webview
|
43
43
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cocoawebview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommy Jeff
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-10-04 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: Webview ruby binding for macOS
|
13
13
|
email:
|