cocoawebview 0.8.0 → 0.9.0
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 +12 -16
- data/lib/cocoawebview/version.rb +1 -1
- data/lib/cocoawebview.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 75f756929b44cbb524409c3e12fcfcb01cb6d7f6dea1b75581512f845f173708
|
|
4
|
+
data.tar.gz: 0af8a6e058870c1c52769c2d7880a2c93bd10574d7d32a88c578aaebdab33a80
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 709899b589ec4865a007c4820d5463c63bfb89144230baa3811e99c488a0bc762c5a455971468283c9440425c004ed10f5379d73362feb54383a29970b3ca181
|
|
7
|
+
data.tar.gz: c1bf0c84074f29c21cf6b2bec3060c0683dec4cb153aae9183a15065eeeed9a6467900a29232941fc616e876699a17dd35f1c7ce824ef83877bd0bf6d5e05c09
|
|
@@ -117,6 +117,7 @@ VALUE webview_increase_normal_level(VALUE self, VALUE delta);
|
|
|
117
117
|
|
|
118
118
|
@interface AppDelegate : NSObject <NSApplicationDelegate> {
|
|
119
119
|
VALUE app;
|
|
120
|
+
VALUE rb_menu;
|
|
120
121
|
}
|
|
121
122
|
@end
|
|
122
123
|
|
|
@@ -125,28 +126,18 @@ VALUE webview_increase_normal_level(VALUE self, VALUE delta);
|
|
|
125
126
|
- (void)handleMenuAction:(id)sender {
|
|
126
127
|
NSMenuItem *item = (NSMenuItem *)sender;
|
|
127
128
|
NSInteger tag = [item tag];
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
switch (tag) {
|
|
131
|
-
case 100: // New File
|
|
132
|
-
NSLog(@"Creating a new file...");
|
|
133
|
-
break;
|
|
134
|
-
case 101: // Save
|
|
135
|
-
NSLog(@"Saving data...");
|
|
136
|
-
break;
|
|
137
|
-
case 999: // Quit
|
|
138
|
-
[NSApp terminate:nil];
|
|
139
|
-
break;
|
|
140
|
-
default:
|
|
141
|
-
NSLog(@"Clicked: %@", [item title]);
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
129
|
+
VALUE rb_tag = INT2NUM(tag);
|
|
130
|
+
rb_funcall(rb_menu, rb_intern("handle_menu_action"), 1, rb_tag);
|
|
144
131
|
}
|
|
145
132
|
|
|
146
133
|
- (void)setApp:(VALUE)a {
|
|
147
134
|
app = a;
|
|
148
135
|
}
|
|
149
136
|
|
|
137
|
+
- (void)setMenu:(VALUE)m {
|
|
138
|
+
rb_menu = m;
|
|
139
|
+
}
|
|
140
|
+
|
|
150
141
|
- (void)applicationWillTerminate:(NSNotification *)notification {
|
|
151
142
|
rb_funcall(app, rb_intern("app_will_exit"), 0);
|
|
152
143
|
}
|
|
@@ -419,9 +410,14 @@ VALUE nsapp_exit(VALUE self) {
|
|
|
419
410
|
|
|
420
411
|
VALUE nsmenu_initialize(VALUE self) {
|
|
421
412
|
rb_iv_set(self, "@var", rb_hash_new());
|
|
413
|
+
rb_iv_set(self, "@bindings", rb_hash_new());
|
|
414
|
+
|
|
422
415
|
Menu *menu = [[Menu alloc] init];
|
|
423
416
|
menu.mainMenu = [NSMenu new];
|
|
424
417
|
|
|
418
|
+
AppDelegate *delegate = application.delegate;
|
|
419
|
+
[delegate setMenu:self];
|
|
420
|
+
|
|
425
421
|
// Wrap the Objective-C pointer into a Ruby object
|
|
426
422
|
VALUE wrapper = TypedData_Wrap_Struct(rb_cObject, &menu_obj_type, menu);
|
|
427
423
|
|
data/lib/cocoawebview/version.rb
CHANGED
data/lib/cocoawebview.rb
CHANGED
|
@@ -16,6 +16,11 @@ module CocoaWebview
|
|
|
16
16
|
# Your code goes here...
|
|
17
17
|
|
|
18
18
|
class NSMenu
|
|
19
|
+
def create_menu_item_with(title, tag, key, &block)
|
|
20
|
+
@bindings[tag] = block
|
|
21
|
+
create_menu_item(title, tag, key)
|
|
22
|
+
end
|
|
23
|
+
|
|
19
24
|
def main_menu
|
|
20
25
|
@menu
|
|
21
26
|
end
|
|
@@ -23,6 +28,11 @@ module CocoaWebview
|
|
|
23
28
|
def main_menu_bar
|
|
24
29
|
@menu_bar
|
|
25
30
|
end
|
|
31
|
+
|
|
32
|
+
def handle_menu_action(tag)
|
|
33
|
+
callback = @bindings[tag]
|
|
34
|
+
callback.call
|
|
35
|
+
end
|
|
26
36
|
end
|
|
27
37
|
|
|
28
38
|
class NSApp
|
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.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tommy Jeff
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-02-
|
|
10
|
+
date: 2026-02-07 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: Webview ruby binding for macOS
|
|
13
13
|
email:
|