cocoawebview 1.0.0 → 1.0.2

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: '04608c0171a03a5d898a30d02d21d5603964482927148f21453124888adb8eac'
4
- data.tar.gz: 3d0fe0a44f12b933675f4006a00348f379b1fea7c22a02d2d726b77218bf6e43
3
+ metadata.gz: 25e667a669abd1fcbfec7bf7cf833129551cd737f0af6f5dd6cee8242760bdd8
4
+ data.tar.gz: 315afe221445ddeb86de3e696e3e3b6351845bcde0f192345b2a4e06a57554d8
5
5
  SHA512:
6
- metadata.gz: e2073540674b00372e220c75e4dfa45eac07eb657b9b49fcf43388633831f3190e325f37f46ab9e3fcb8f362cfbc9f2bfe5ae947e6cfe38d901ac8fedf7490c1
7
- data.tar.gz: 46539b807de6f6dfd67ac4b107ca31100f31a19c9fa31840b8168001bcae98cb820d9bca52135dab32a5e4c3bf3aa23a7cba69d7000781b16bc8b129182fbe60
6
+ metadata.gz: ac77f7ca9de87a6cb555e51d5cac3b4125dcbc4b65def7d259e5e2e2419c46c4b91b433d7a41a8ffe4dcba1b7f8d25882ba77ebbcce899f23a27548491b7c10d
7
+ data.tar.gz: e3aefe0cad56e874e31353b893d4ffb51e0cafdda9955e91dd73a806539d42a379c7f0ae7c807b5ec8c09ca11b910a68cbd9cc9fd737fce7112efdabb7c956fc
@@ -10,10 +10,13 @@ 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);
13
14
  VALUE nsapp_exit(VALUE self);
14
15
 
15
16
  VALUE nsmenu_initialize(VALUE self);
16
17
  VALUE nsmenu_new_menu_item(VALUE self);
18
+ VALUE nsmenu_menu_item_set_target(VALUE self, VALUE menu_item, VALUE target);
19
+ VALUE nsmenu_menu_item_set_action(VALUE self, VALUE menu_item, VALUE action);
17
20
  VALUE nsmenu_new_separator_item(VALUE self);
18
21
  VALUE nsmenu_create_menu_item(VALUE self, VALUE title, VALUE tag, VALUE key);
19
22
  VALUE nsmenu_new_menu(VALUE self);
@@ -359,12 +362,15 @@ Init_cocoawebview(void)
359
362
  rb_mNSAppClass = rb_define_class_under(rb_mCocoawebview, "NSApp", rb_cObject);
360
363
  rb_define_method(rb_mNSAppClass, "initialize", nsapp_initialize, 0);
361
364
  rb_define_method(rb_mNSAppClass, "run", nsapp_run, 0);
365
+ rb_define_method(rb_mNSAppClass, "get_theme", nsapp_get_theme, 0);
362
366
  rb_define_method(rb_mNSAppClass, "exit", nsapp_exit, 0);
363
367
 
364
368
  /* Menu */
365
369
  rb_mNSMenuClass = rb_define_class_under(rb_mCocoawebview, "NSMenu", rb_cObject);
366
370
  rb_define_method(rb_mNSMenuClass, "initialize", nsmenu_initialize, 0);
367
371
  rb_define_method(rb_mNSMenuClass, "new_menu", nsmenu_new_menu, 0);
372
+ rb_define_method(rb_mNSMenuClass, "set_menu_item_action", nsmenu_menu_item_set_action, 2);
373
+ rb_define_method(rb_mNSMenuClass, "set_menu_item_target", nsmenu_menu_item_set_target, 2);
368
374
  rb_define_method(rb_mNSMenuClass, "new_menu_item", nsmenu_new_menu_item, 0);
369
375
  rb_define_method(rb_mNSMenuClass, "new_separator", nsmenu_new_separator_item, 0);
370
376
  rb_define_method(rb_mNSMenuClass, "create_menu_item", nsmenu_create_menu_item, 3);
@@ -406,6 +412,19 @@ VALUE nsapp_run(VALUE self) {
406
412
  [application run];
407
413
  }
408
414
 
415
+ VALUE nsapp_get_theme(VALUE self) {
416
+ NSString *theme = [[NSUserDefaults standardUserDefaults]
417
+ stringForKey:@"AppleInterfaceStyle"];
418
+
419
+ if (!theme) {
420
+ // Light mode
421
+ return rb_utf8_str_new_cstr("Light");
422
+ }
423
+
424
+ const char *utf8 = [theme UTF8String];
425
+ return rb_utf8_str_new_cstr(utf8);
426
+ }
427
+
409
428
  VALUE nsapp_exit(VALUE self) {
410
429
  [[NSApplication sharedApplication] terminate:nil];
411
430
  }
@@ -432,6 +451,32 @@ VALUE nsmenu_initialize(VALUE self) {
432
451
  return self;
433
452
  }
434
453
 
454
+ VALUE nsmenu_menu_item_set_target(VALUE self, VALUE menu_item, VALUE target) {
455
+ NSMenuItem *item_ns;
456
+ TypedData_Get_Struct(menu_item, NSMenuItem, &menu_obj_type, item_ns);
457
+
458
+ if (NIL_P(target)) {
459
+ item_ns.target = nil;
460
+ } else {
461
+ id target_ns;
462
+ TypedData_Get_Struct(target, void, &menu_obj_type, target_ns);
463
+ item_ns.target = target_ns;
464
+ }
465
+ return Qnil;
466
+ }
467
+
468
+ VALUE nsmenu_menu_item_set_action(VALUE self, VALUE menu_item, VALUE action) {
469
+ NSMenuItem *item_ns;
470
+ const char *action_c = StringValueCStr(action);
471
+ NSString *action_ns = [[NSString alloc] initWithCString:action_c encoding:NSUTF8StringEncoding];
472
+
473
+ TypedData_Get_Struct(menu_item, NSMenuItem, &menu_obj_type, item_ns);
474
+
475
+ item_ns.action = NSSelectorFromString(action_ns);
476
+
477
+ return Qnil;
478
+ }
479
+
435
480
  VALUE nsmenu_new_separator_item(VALUE self) {
436
481
  NSMenuItem *menuItem = [NSMenuItem separatorItem];
437
482
  // Wrap the Objective-C pointer into a Ruby object
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cocoawebview
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.2"
5
5
  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: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Jeff
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-02-07 00:00:00.000000000 Z
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.5
49
+ rubygems_version: 3.6.9
50
50
  specification_version: 4
51
51
  summary: Webview ruby binding for macOS
52
52
  test_files: []