cocoawebview 1.0.0 → 1.0.1

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: 1f7e2c2321811e76b897163649af68cfe612b4fbb983573e2022af73f5a5aa68
4
+ data.tar.gz: 0a62a450993d8e3c30f3248d5762828cf7c31c1670f942ef062901cc7989857d
5
5
  SHA512:
6
- metadata.gz: e2073540674b00372e220c75e4dfa45eac07eb657b9b49fcf43388633831f3190e325f37f46ab9e3fcb8f362cfbc9f2bfe5ae947e6cfe38d901ac8fedf7490c1
7
- data.tar.gz: 46539b807de6f6dfd67ac4b107ca31100f31a19c9fa31840b8168001bcae98cb820d9bca52135dab32a5e4c3bf3aa23a7cba69d7000781b16bc8b129182fbe60
6
+ metadata.gz: c3466fe4d4d6de9fcb6c9e57522ee244f9253d3ab36059244046e60096a64e1486ca814cec295f63a50370478f8f0d1ab6be2d3313162c701572de84f98f8cab
7
+ data.tar.gz: 64e8c7763867cb6642d754103fc04d4628f3b4bd34085ee45ae675906cec8f5b5e9fc03c2ca79d807581a984c8e2a14c1117373c3cb08b2283e37bf01f180a84
@@ -14,6 +14,8 @@ VALUE nsapp_exit(VALUE self);
14
14
 
15
15
  VALUE nsmenu_initialize(VALUE self);
16
16
  VALUE nsmenu_new_menu_item(VALUE self);
17
+ VALUE nsmenu_menu_item_set_target(VALUE self, VALUE menu_item, VALUE target);
18
+ VALUE nsmenu_menu_item_set_action(VALUE self, VALUE menu_item, VALUE action);
17
19
  VALUE nsmenu_new_separator_item(VALUE self);
18
20
  VALUE nsmenu_create_menu_item(VALUE self, VALUE title, VALUE tag, VALUE key);
19
21
  VALUE nsmenu_new_menu(VALUE self);
@@ -365,6 +367,8 @@ Init_cocoawebview(void)
365
367
  rb_mNSMenuClass = rb_define_class_under(rb_mCocoawebview, "NSMenu", rb_cObject);
366
368
  rb_define_method(rb_mNSMenuClass, "initialize", nsmenu_initialize, 0);
367
369
  rb_define_method(rb_mNSMenuClass, "new_menu", nsmenu_new_menu, 0);
370
+ rb_define_method(rb_mNSMenuClass, "set_menu_item_action", nsmenu_menu_item_set_action, 2);
371
+ rb_define_method(rb_mNSMenuClass, "set_menu_item_target", nsmenu_menu_item_set_target, 2);
368
372
  rb_define_method(rb_mNSMenuClass, "new_menu_item", nsmenu_new_menu_item, 0);
369
373
  rb_define_method(rb_mNSMenuClass, "new_separator", nsmenu_new_separator_item, 0);
370
374
  rb_define_method(rb_mNSMenuClass, "create_menu_item", nsmenu_create_menu_item, 3);
@@ -432,6 +436,32 @@ VALUE nsmenu_initialize(VALUE self) {
432
436
  return self;
433
437
  }
434
438
 
439
+ VALUE nsmenu_menu_item_set_target(VALUE self, VALUE menu_item, VALUE target) {
440
+ NSMenuItem *item_ns;
441
+ TypedData_Get_Struct(menu_item, NSMenuItem, &menu_obj_type, item_ns);
442
+
443
+ if (NIL_P(target)) {
444
+ item_ns.target = nil;
445
+ } else {
446
+ id target_ns;
447
+ TypedData_Get_Struct(target, void, &menu_obj_type, target_ns);
448
+ item_ns.target = target_ns;
449
+ }
450
+ return Qnil;
451
+ }
452
+
453
+ VALUE nsmenu_menu_item_set_action(VALUE self, VALUE menu_item, VALUE action) {
454
+ NSMenuItem *item_ns;
455
+ const char *action_c = StringValueCStr(action);
456
+ NSString *action_ns = [[NSString alloc] initWithCString:action_c encoding:NSUTF8StringEncoding];
457
+
458
+ TypedData_Get_Struct(menu_item, NSMenuItem, &menu_obj_type, item_ns);
459
+
460
+ item_ns.action = NSSelectorFromString(action_ns);
461
+
462
+ return Qnil;
463
+ }
464
+
435
465
  VALUE nsmenu_new_separator_item(VALUE self) {
436
466
  NSMenuItem *menuItem = [NSMenuItem separatorItem];
437
467
  // 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.1"
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.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tommy Jeff