everyday-menu 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/examples/basic_main_menu/app_delegate.rb +5 -1
- data/lib/everyday-menu/menu.rb +2 -2
- data/lib/everyday-menu/menu_item.rb +4 -4
- data/lib/everyday-menu/utils.rb +6 -4
- data/lib/everyday-menu/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66daeba8da989301477c3d0b2474c5d32ad19011
|
4
|
+
data.tar.gz: 9d47532f129aaea7c5057dba34872fd588b19401
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf969107f17c26e64f3e19e64ddb1e9b251f8c432c7f563cc6633fac82cf8a98375d9b7fb065b08a6883e65a3a19e0019e604dff2925c7b217d145d59cb78e05
|
7
|
+
data.tar.gz: 3b34fa1275f028cda1ae152809f0f559b89a5663d3c13574636852eda8b2d1a29079943633dd0f58e599c0c74874d4a072804231ab0081a7e08c24f47d969ac7
|
data/README.md
CHANGED
@@ -86,9 +86,13 @@ class AppDelegate
|
|
86
86
|
MainMenu[:app].subscribe(:hide_others) { |_, _| NSApp.hideOtherApplications(self) }
|
87
87
|
MainMenu[:app].subscribe(:quit) { |_, _| NSApp.terminate(self) }
|
88
88
|
|
89
|
-
MainMenu[:file].subscribe(:start_stop) { |command, _|
|
89
|
+
MainMenu[:file].subscribe(:start_stop, :start_stop_command_id) { |command, _|
|
90
90
|
@started = !@started
|
91
91
|
command.parent[:title] = @started ? 'Stop' : 'Start'
|
92
|
+
puts "subscribe 1 command id: #{command.command_id}"
|
93
|
+
}
|
94
|
+
MainMenu[:file].subscribe(:start_stop, :start_stop_command_id2) { |command, _|
|
95
|
+
puts "subscribe 2 command id: #{command.command_id}"
|
92
96
|
}
|
93
97
|
MainMenu[:file].subscribe(:new) { |_, _|
|
94
98
|
@has_open = true
|
@@ -16,9 +16,13 @@ class AppDelegate
|
|
16
16
|
@has_open = true
|
17
17
|
puts 'open'
|
18
18
|
}
|
19
|
-
MainMenu[:file].subscribe(:start_stop) { |command, _|
|
19
|
+
MainMenu[:file].subscribe(:start_stop, :start_stop_command_id) { |command, _|
|
20
20
|
@started = !@started
|
21
21
|
command.parent[:title] = @started ? 'Stop' : 'Start'
|
22
|
+
puts "subscribe 1 command id: #{command.command_id}"
|
23
|
+
}
|
24
|
+
MainMenu[:file].subscribe(:start_stop, :start_stop_command_id2) { |command, _|
|
25
|
+
puts "subscribe 2 command id: #{command.command_id}"
|
22
26
|
}
|
23
27
|
MainMenu[:statusbar].subscribe(:status_new) { |_, _|
|
24
28
|
@has_open = true
|
data/lib/everyday-menu/menu.rb
CHANGED
@@ -120,8 +120,8 @@ module EverydayMenu
|
|
120
120
|
@onBuild << block
|
121
121
|
end
|
122
122
|
|
123
|
-
def subscribe(&block)
|
124
|
-
@menuItem.subscribe(self, self.label, &block)
|
123
|
+
def subscribe(command_id = nil, &block)
|
124
|
+
@menuItem.subscribe(self, self.label, command_id, &block)
|
125
125
|
end
|
126
126
|
|
127
127
|
def execute
|
@@ -133,9 +133,9 @@ end
|
|
133
133
|
class NSMenuItem
|
134
134
|
attr_reader :commands
|
135
135
|
|
136
|
-
def subscribe(parent, label, &block)
|
136
|
+
def subscribe(parent, label, command_id = nil, &block)
|
137
137
|
@commands ||= EverydayMenu::CommandList.new(parent, label)
|
138
|
-
@commands.add &block
|
138
|
+
@commands.add command_id, &block
|
139
139
|
command = @commands.last
|
140
140
|
self.enabled = @commands.canExecute
|
141
141
|
unless @boundEnabled
|
data/lib/everyday-menu/utils.rb
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
module EverydayMenu
|
2
2
|
class EverydayCommand
|
3
|
-
attr_reader :label, :parent
|
3
|
+
attr_reader :label, :parent, :command_id
|
4
4
|
attr_writer :canExecute
|
5
5
|
|
6
|
-
def initialize(parent, label, canExecute = true, &block)
|
6
|
+
def initialize(parent, label, command_id = nil, canExecute = true, &block)
|
7
7
|
@parent = parent
|
8
8
|
@label = label
|
9
9
|
@block = block
|
10
|
+
@command_id = command_id
|
10
11
|
@canExecute = canExecute
|
11
12
|
@canExecuteBlock = nil
|
12
13
|
end
|
13
14
|
|
14
15
|
def canExecuteBlock(&block)
|
15
16
|
@canExecuteBlock = block
|
17
|
+
self
|
16
18
|
end
|
17
19
|
|
18
20
|
def canExecute
|
@@ -33,8 +35,8 @@ module EverydayMenu
|
|
33
35
|
@items = []
|
34
36
|
end
|
35
37
|
|
36
|
-
def add(&block)
|
37
|
-
@items << EverydayCommand.new(@parent, @label, &block)
|
38
|
+
def add(command_id = nil, &block)
|
39
|
+
@items << EverydayCommand.new(@parent, @label, command_id, &block)
|
38
40
|
end
|
39
41
|
|
40
42
|
def last
|