cocoawebview 1.0.1 → 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 +4 -4
- data/ext/cocoawebview/cocoawebview.m +44 -0
- data/lib/cocoawebview/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7240d63de747ac45b7873168e15de395138a1fd9ab1c375663458713e3fffe82
|
|
4
|
+
data.tar.gz: 62b822de8bb6a125f0422a43ae08df6b88b5e5defe78b5a6a71b31a1b6095c1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f7e5bb5e221c9c230bf34704c1ef5e4064dd69467ced99936527f2206484df752b1e1f12734a68b0ba57e8abefea2dc27a22f1806d4158ad75bac9a4bfed595
|
|
7
|
+
data.tar.gz: 6909f3f69fc318f5ac50ae0ea86a62ddb2c21f545afc1efafda63ff057b5591b59fd074b006a2db6b48bb9b314863ce74d94adedce485cc37596568270e5b92a
|
|
@@ -10,6 +10,8 @@ NSApplication *application = nil;
|
|
|
10
10
|
|
|
11
11
|
VALUE nsapp_initialize(VALUE self);
|
|
12
12
|
VALUE nsapp_run(VALUE self);
|
|
13
|
+
VALUE nsapp_get_theme(VALUE self);
|
|
14
|
+
VALUE nsapp_get_app_icon(VALUE self, VALUE app_path);
|
|
13
15
|
VALUE nsapp_exit(VALUE self);
|
|
14
16
|
|
|
15
17
|
VALUE nsmenu_initialize(VALUE self);
|
|
@@ -361,6 +363,8 @@ Init_cocoawebview(void)
|
|
|
361
363
|
rb_mNSAppClass = rb_define_class_under(rb_mCocoawebview, "NSApp", rb_cObject);
|
|
362
364
|
rb_define_method(rb_mNSAppClass, "initialize", nsapp_initialize, 0);
|
|
363
365
|
rb_define_method(rb_mNSAppClass, "run", nsapp_run, 0);
|
|
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);
|
|
364
368
|
rb_define_method(rb_mNSAppClass, "exit", nsapp_exit, 0);
|
|
365
369
|
|
|
366
370
|
/* Menu */
|
|
@@ -410,6 +414,46 @@ VALUE nsapp_run(VALUE self) {
|
|
|
410
414
|
[application run];
|
|
411
415
|
}
|
|
412
416
|
|
|
417
|
+
VALUE nsapp_get_theme(VALUE self) {
|
|
418
|
+
NSString *theme = [[NSUserDefaults standardUserDefaults]
|
|
419
|
+
stringForKey:@"AppleInterfaceStyle"];
|
|
420
|
+
|
|
421
|
+
if (!theme) {
|
|
422
|
+
// Light mode
|
|
423
|
+
return rb_utf8_str_new_cstr("Light");
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const char *utf8 = [theme UTF8String];
|
|
427
|
+
return rb_utf8_str_new_cstr(utf8);
|
|
428
|
+
}
|
|
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
|
+
|
|
413
457
|
VALUE nsapp_exit(VALUE self) {
|
|
414
458
|
[[NSApplication sharedApplication] terminate:nil];
|
|
415
459
|
}
|
data/lib/cocoawebview/version.rb
CHANGED
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: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tommy Jeff
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: Webview ruby binding for macOS
|
|
13
13
|
email:
|
|
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: '0'
|
|
48
48
|
requirements: []
|
|
49
|
-
rubygems_version: 3.6.
|
|
49
|
+
rubygems_version: 3.6.9
|
|
50
50
|
specification_version: 4
|
|
51
51
|
summary: Webview ruby binding for macOS
|
|
52
52
|
test_files: []
|