cocoawebview 1.0.2 → 1.0.3

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: 25e667a669abd1fcbfec7bf7cf833129551cd737f0af6f5dd6cee8242760bdd8
4
- data.tar.gz: 315afe221445ddeb86de3e696e3e3b6351845bcde0f192345b2a4e06a57554d8
3
+ metadata.gz: 7240d63de747ac45b7873168e15de395138a1fd9ab1c375663458713e3fffe82
4
+ data.tar.gz: 62b822de8bb6a125f0422a43ae08df6b88b5e5defe78b5a6a71b31a1b6095c1f
5
5
  SHA512:
6
- metadata.gz: ac77f7ca9de87a6cb555e51d5cac3b4125dcbc4b65def7d259e5e2e2419c46c4b91b433d7a41a8ffe4dcba1b7f8d25882ba77ebbcce899f23a27548491b7c10d
7
- data.tar.gz: e3aefe0cad56e874e31353b893d4ffb51e0cafdda9955e91dd73a806539d42a379c7f0ae7c807b5ec8c09ca11b910a68cbd9cc9fd737fce7112efdabb7c956fc
6
+ metadata.gz: 9f7e5bb5e221c9c230bf34704c1ef5e4064dd69467ced99936527f2206484df752b1e1f12734a68b0ba57e8abefea2dc27a22f1806d4158ad75bac9a4bfed595
7
+ data.tar.gz: 6909f3f69fc318f5ac50ae0ea86a62ddb2c21f545afc1efafda63ff057b5591b59fd074b006a2db6b48bb9b314863ce74d94adedce485cc37596568270e5b92a
@@ -11,6 +11,7 @@ NSApplication *application = nil;
11
11
  VALUE nsapp_initialize(VALUE self);
12
12
  VALUE nsapp_run(VALUE self);
13
13
  VALUE nsapp_get_theme(VALUE self);
14
+ VALUE nsapp_get_app_icon(VALUE self, VALUE app_path);
14
15
  VALUE nsapp_exit(VALUE self);
15
16
 
16
17
  VALUE nsmenu_initialize(VALUE self);
@@ -363,6 +364,7 @@ Init_cocoawebview(void)
363
364
  rb_define_method(rb_mNSAppClass, "initialize", nsapp_initialize, 0);
364
365
  rb_define_method(rb_mNSAppClass, "run", nsapp_run, 0);
365
366
  rb_define_method(rb_mNSAppClass, "get_theme", nsapp_get_theme, 0);
367
+ rb_define_method(rb_mNSAppClass, "get_app_icon", nsapp_get_app_icon, 1);
366
368
  rb_define_method(rb_mNSAppClass, "exit", nsapp_exit, 0);
367
369
 
368
370
  /* Menu */
@@ -425,6 +427,33 @@ VALUE nsapp_get_theme(VALUE self) {
425
427
  return rb_utf8_str_new_cstr(utf8);
426
428
  }
427
429
 
430
+ VALUE nsapp_get_app_icon(VALUE self, VALUE app_path) {
431
+ const char *app_path_c = StringValueCStr(app_path);
432
+ NSString *app_path_ns = [[NSString alloc] initWithCString:app_path_c encoding:NSUTF8StringEncoding];
433
+
434
+ // 1. Get icon for the app bundle
435
+ NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:app_path_ns];
436
+ if (!icon) return Qnil;
437
+
438
+ // Optional: set desired size
439
+ [icon setSize:NSMakeSize(256, 256)];
440
+
441
+ // 2. Convert NSImage to PNG data
442
+ NSBitmapImageRep *rep = [[NSBitmapImageRep alloc]
443
+ initWithData:[icon TIFFRepresentation]];
444
+
445
+ NSData *pngData = [rep representationUsingType:NSBitmapImageFileTypePNG
446
+ properties:@{}];
447
+ if (!pngData) return Qnil;
448
+
449
+ // 3. Encode to Base64 string
450
+ NSString *base64 = [pngData base64EncodedStringWithOptions:0];
451
+ const char *utf8 = [base64 UTF8String];
452
+ if (!utf8) return Qnil;
453
+
454
+ return rb_utf8_str_new(utf8, strlen(utf8));
455
+ }
456
+
428
457
  VALUE nsapp_exit(VALUE self) {
429
458
  [[NSApplication sharedApplication] terminate:nil];
430
459
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cocoawebview
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoawebview
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Jeff