cocoawebview 0.3.5 → 0.3.7

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: 4f9d8b6d440dc3f049b85926ccbe488134f7fe4c2f574fba2f7cd65d43084600
4
- data.tar.gz: 7c4e4cae2a70fd0dfedd0c4f0632a66367e2e0b667190d4655ba0706a5111952
3
+ metadata.gz: b23a062232a47f6e4b07c88a26ade032888a45d98d095793a66c0352dd86a8cc
4
+ data.tar.gz: 1e770d12e1a76131845986ea1d787b509918d01c51ca50fcd652e95a4cbd4e1a
5
5
  SHA512:
6
- metadata.gz: 7390369913cdf0173f685322679661007a72089384292d045afbf1d06da2c1620be31c103889a6425efa2b4c2e5252af83ec23c9986e972fb6b34b5d9ce20097
7
- data.tar.gz: c7f3bad9de5b031c0ab44e1867cb1f34913741511497c8f6c1f648e2c5072159e639f719d42474ddf1817393a26b8e3ce602bbebb96d71165cbe2c35c704329c
6
+ metadata.gz: 640892f28816916318df53680cbfe10bb8e41fa562a41c846266f7e07a66c2acc014dd53527c377cd35d555495a4773c31f664d4bb50c6f78e50a09c63defc1b
7
+ data.tar.gz: ab214136f80bd4a5e9ba210ebfa8d7482a4b51e7bbab6091b167f4b96fe216a59d8b36d819285e9186ae857bd14420060edabaca66311bf1410f8f540802e221
@@ -24,6 +24,7 @@ VALUE webview_set_title(VALUE self, VALUE title);
24
24
  VALUE webview_center(VALUE self);
25
25
  VALUE webview_is_visible(VALUE self);
26
26
  VALUE webview_set_topmost(VALUE self, VALUE topmost);
27
+ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a);
27
28
 
28
29
  @interface FileDropContainerView : NSView {
29
30
  VALUE rb_cocoawebview;
@@ -55,10 +56,15 @@ VALUE webview_set_topmost(VALUE self, VALUE topmost);
55
56
  NSArray<NSURL *> *fileURLs = [pasteboard readObjectsForClasses:@[[NSURL class]]
56
57
  options:@{NSPasteboardURLReadingFileURLsOnlyKey: @YES}];
57
58
 
58
- if (fileURLs.count > 0) {
59
- NSString *filePath = fileURLs[0].path;
59
+ VALUE files = rb_ary_new();
60
+ for (int i = 0; i < fileURLs.count; i++) {
61
+ NSString *filePath = fileURLs[i].path;
60
62
  VALUE ruby_file_path = rb_str_new_cstr([filePath UTF8String]);
61
- rb_funcall(rb_cocoawebview, rb_intern("file_did_drop"), 1, ruby_file_path);
63
+ rb_ary_push(files, ruby_file_path);
64
+ }
65
+
66
+ if (fileURLs.count > 0) {
67
+ rb_funcall(rb_cocoawebview, rb_intern("file_did_drop"), 1, files);
62
68
  return YES;
63
69
  }
64
70
  return NO;
@@ -244,7 +250,6 @@ VALUE webview_set_topmost(VALUE self, VALUE topmost);
244
250
  */
245
251
 
246
252
  // Add to window's contentView
247
- //[[window contentView] addSubview:fileDropView];
248
253
  [[window contentView] addSubview: webView];
249
254
  [[window contentView] addSubview:fileDropView positioned:NSWindowAbove relativeTo:webView];
250
255
 
@@ -294,6 +299,7 @@ Init_cocoawebview(void)
294
299
  rb_define_method(rb_mCocoaWebviewClass, "center", webview_center, 0);
295
300
  rb_define_method(rb_mCocoaWebviewClass, "visible?", webview_is_visible, 0);
296
301
  rb_define_method(rb_mCocoaWebviewClass, "set_topmost", webview_set_topmost, 1);
302
+ rb_define_method(rb_mCocoaWebviewClass, "set_bg", webview_set_bg, 4);
297
303
 
298
304
  }
299
305
 
@@ -481,3 +487,20 @@ VALUE webview_set_topmost(VALUE self, VALUE topmost) {
481
487
  [webview setLevel:NSNormalWindowLevel];
482
488
  }
483
489
  }
490
+
491
+ VALUE webview_set_bg(VALUE self, VALUE r, VALUE g, VALUE b, VALUE a) {
492
+ VALUE wrapper = rb_ivar_get(self, rb_intern("@webview"));
493
+ CocoaWebview *webview;
494
+ TypedData_Get_Struct(wrapper, CocoaWebview, &cocoawebview_obj_type, webview);
495
+
496
+ double c_r = NUM2DBL(r);
497
+ double c_g = NUM2DBL(g);
498
+ double c_b = NUM2DBL(b);
499
+ double c_a = NUM2DBL(a);
500
+
501
+ NSColor *rgbColor = [NSColor colorWithSRGBRed:c_r
502
+ green:c_g
503
+ blue:c_b
504
+ alpha:c_a];
505
+ [webview setBackgroundColor:rgbColor];
506
+ }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cocoawebview
4
- VERSION = "0.3.5"
4
+ VERSION = "0.3.7"
5
5
  end
data/lib/cocoawebview.rb CHANGED
@@ -46,8 +46,9 @@ module CocoaWebview
46
46
  puts "CocoaWebview did loaded"
47
47
  end
48
48
 
49
- def file_did_drop(file_path)
50
- puts "#{file_path} dropped"
49
+ def file_did_drop(files)
50
+ puts "Dropped below files:"
51
+ puts "#{files}"
51
52
  end
52
53
 
53
54
  def bind(name, &block)
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.5
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Jeff
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-07-03 00:00:00.000000000 Z
10
+ date: 2025-07-05 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Webview ruby binding for macOS
13
13
  email: