cocoawebview 0.3.15 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1ec109cf8255bd277ee378cfc3785086c5fb0706cfacb296dda79105e366731
4
- data.tar.gz: 2f8e836e3658226d6368b897f13c6f7b875ea5151c3a754b48f1b1bd80690e50
3
+ metadata.gz: b4a5dc8becbe3e08126dfc0c5920a10f73c7dc83c6dbd0498a61df08e716b198
4
+ data.tar.gz: df179bc016e9c58461733d6b9aa1028f636dd95234781612406d0358731669e2
5
5
  SHA512:
6
- metadata.gz: 19b3abe6843ac1ec662d6390ad8efb261fbf73f809a3505646bdd3d2321e57ce0546a7a5c4275a65fcfcb0b9ca11a568e03a774815398e4bd5311b156a90ef7a
7
- data.tar.gz: f10d376ef47bb04c5a1b7a8b6c4247d9d9a787ab7166da7c9da080e3f9ba2bb1e1c2aa51918b822a5e6e014abffb56894cdd136998e8e13a6a505c55c00c12e3
6
+ metadata.gz: 2545e3fc29b1e863015317a9e8375534bfb98050475cac4ed52ccad54a0c9ee9604b6f1b36bc43510ec5b2428681228ae417788a006f4af3020b7d22253d2ed3
7
+ data.tar.gz: 9173d6c094e3a87dfd6945b3c8f145f8f702d0264ff874d9279bd336d2ebdc76288a65ffb0259b2fdd61f8a5825f3cdadc852bf287d82a69f27795baeda3a670
@@ -12,6 +12,7 @@ VALUE nsapp_run(VALUE self);
12
12
  VALUE nsapp_exit(VALUE self);
13
13
 
14
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);
@@ -104,6 +105,10 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
104
105
  app = a;
105
106
  }
106
107
 
108
+ - (void)applicationWillTerminate:(NSNotification *)notification {
109
+ rb_funcall(app, rb_intern("app_will_exit"), 0);
110
+ }
111
+
107
112
  - (BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag {
108
113
  rb_funcall(app, rb_intern("dock_did_click"), 0);
109
114
  return YES;
@@ -127,6 +132,7 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
127
132
  - (void)setDeltaY:(int)dy;
128
133
  - (id)initWithFrame:(NSRect)frame debug:(BOOL)flag style:(int)style moveTitleButtons:(BOOL)moveTitleButtons deltaY:(int)dy;
129
134
  - (void)eval:(NSString*)code;
135
+ - (void)navigate:(NSString*)url;
130
136
  - (void)setCocoaWebview:(VALUE)view;
131
137
  - (void)dragging;
132
138
  @end
@@ -217,6 +223,12 @@ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
217
223
  [fileDropView setObj:view];
218
224
  }
219
225
 
226
+ - (void)navigate:(NSString*)url {
227
+ NSURL *url_ns = [NSURL URLWithString:url];
228
+ NSURLRequest *request = [NSURLRequest requestWithURL:url_ns];
229
+ [webView loadRequest:request];
230
+ }
231
+
220
232
  - (void)eval:(NSString*)code {
221
233
  [webView evaluateJavaScript:code completionHandler:^(id result, NSError *error) {
222
234
  if (error) {
@@ -302,6 +314,7 @@ Init_cocoawebview(void)
302
314
  rb_define_method(rb_mCocoaWebviewClass, "show", webview_show, 0);
303
315
  rb_define_method(rb_mCocoaWebviewClass, "hide", webview_hide, 0);
304
316
  rb_define_method(rb_mCocoaWebviewClass, "eval", webview_eval, 1);
317
+ rb_define_method(rb_mCocoaWebviewClass, "navigate", webview_navigate, 1);
305
318
  rb_define_method(rb_mCocoaWebviewClass, "set_size", webview_set_size, 2);
306
319
  rb_define_method(rb_mCocoaWebviewClass, "get_size", webview_get_size, 0);
307
320
  rb_define_method(rb_mCocoaWebviewClass, "set_pos", webview_set_pos, 2);
@@ -363,6 +376,18 @@ VALUE webview_initialize(VALUE self, VALUE debug, VALUE style, VALUE move_title_
363
376
  return self;
364
377
  }
365
378
 
379
+ VALUE webview_navigate(VALUE self, VALUE url) {
380
+ const char *url_c = StringValueCStr(url);
381
+ NSString *url_ns = [[NSString alloc] initWithCString:url_c encoding:NSUTF8StringEncoding];
382
+
383
+ VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
384
+ CocoaWebview *webview;
385
+ TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
386
+
387
+ [webview navigate:url_ns];
388
+ }
389
+
390
+
366
391
  VALUE webview_show(VALUE self) {
367
392
  VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
368
393
  CocoaWebview *webview;
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cocoawebview
4
- VERSION = "0.3.15"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/cocoawebview.rb CHANGED
@@ -23,6 +23,10 @@ module CocoaWebview
23
23
  def dock_did_click
24
24
  puts "Dock icon clicked"
25
25
  end
26
+
27
+ def app_will_exit
28
+ puts "NSApp will exit"
29
+ end
26
30
  end
27
31
 
28
32
  class CocoaWebview
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.3.15
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Jeff
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-07-09 00:00:00.000000000 Z
10
+ date: 2025-10-16 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Webview ruby binding for macOS
13
13
  email: