ruby_mvc 0.0.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.
Files changed (42) hide show
  1. data/LICENSE +19 -0
  2. data/README.md +69 -0
  3. data/lib/ruby_mvc.rb +33 -0
  4. data/lib/ruby_mvc/application.rb +53 -0
  5. data/lib/ruby_mvc/controllers/app_controller.rb +93 -0
  6. data/lib/ruby_mvc/controllers/rails_controller.rb +71 -0
  7. data/lib/ruby_mvc/models.rb +28 -0
  8. data/lib/ruby_mvc/models/array_table_model.rb +59 -0
  9. data/lib/ruby_mvc/models/keyed_array_table_model.rb +83 -0
  10. data/lib/ruby_mvc/models/table_model.rb +42 -0
  11. data/lib/ruby_mvc/module.rb +35 -0
  12. data/lib/ruby_mvc/renderers.rb +26 -0
  13. data/lib/ruby_mvc/renderers/html4_table_model_renderer.rb +100 -0
  14. data/lib/ruby_mvc/toolkit.rb +31 -0
  15. data/lib/ruby_mvc/toolkit/app.rb +32 -0
  16. data/lib/ruby_mvc/toolkit/dialog.rb +31 -0
  17. data/lib/ruby_mvc/toolkit/frame.rb +34 -0
  18. data/lib/ruby_mvc/toolkit/notification.rb +202 -0
  19. data/lib/ruby_mvc/toolkit/peers/wxruby.rb +31 -0
  20. data/lib/ruby_mvc/toolkit/peers/wxruby/app.rb +44 -0
  21. data/lib/ruby_mvc/toolkit/peers/wxruby/box_layout.rb +48 -0
  22. data/lib/ruby_mvc/toolkit/peers/wxruby/common.rb +72 -0
  23. data/lib/ruby_mvc/toolkit/peers/wxruby/frame.rb +49 -0
  24. data/lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb +87 -0
  25. data/lib/ruby_mvc/toolkit/web_view.rb +60 -0
  26. data/lib/ruby_mvc/toolkit/widget.rb +108 -0
  27. data/lib/ruby_mvc/views.rb +85 -0
  28. data/lib/ruby_mvc/views/ar_model_editor.rb +84 -0
  29. data/lib/ruby_mvc/views/ar_type_editor.rb +65 -0
  30. data/lib/ruby_mvc/views/ar_type_list.rb +45 -0
  31. data/lib/ruby_mvc/views/table_view.rb +96 -0
  32. data/lib/ruby_mvc/views/web_view.rb +65 -0
  33. data/lib/ruby_mvc/wx.rb +26 -0
  34. data/ruby_mvc.gemspec +37 -0
  35. data/sample/frame.rb +28 -0
  36. data/sample/mvc.rb +29 -0
  37. data/sample/test.html +118 -0
  38. data/sample/web_view.rb +34 -0
  39. data/test/unit/models/test_array_table_model.rb +56 -0
  40. data/test/unit/models/test_keyed_array_table_model.rb +54 -0
  41. data/test/unit/test_array_table_model.rb +38 -0
  42. metadata +107 -0
@@ -0,0 +1,42 @@
1
+ #--
2
+ ######################################################################
3
+ #
4
+ # Copyright 2011 Andrew S. Townley
5
+ #
6
+ # Permission to use, copy, modify, and disribute this software for
7
+ # any purpose with or without fee is hereby granted, provided that
8
+ # the above copyright notices and this permission notice appear in
9
+ # all copies.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL
12
+ # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14
+ # AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT OR
15
+ # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
17
+ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18
+ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ #
20
+ # File: table_model.rb
21
+ # Created: Sat 19 Nov 2011 18:13:40 GMT
22
+ #
23
+ #####################################################################
24
+ #++
25
+
26
+ module ShoesMVC
27
+ module Models
28
+
29
+ # This class defines the behavior of a base TableModel API
30
+ # that is used by the TableView class. The model represents
31
+ # an ordered set of data rows which are "square" in that
32
+ # they are expected to all have the same number of columns.
33
+ #
34
+ # Logically, each of the elements in the table model is a
35
+ # row instance that provides keyed property access to the
36
+ # data in the model based on the [] method.
37
+
38
+ class TableModel
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,35 @@
1
+ #--
2
+ ######################################################################
3
+ #
4
+ # Copyright 2011 Andrew S. Townley
5
+ #
6
+ # Permission to use, copy, modify, and disribute this software for
7
+ # any purpose with or without fee is hereby granted, provided that
8
+ # the above copyright notices and this permission notice appear in
9
+ # all copies.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL
12
+ # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14
+ # AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT OR
15
+ # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
17
+ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18
+ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ #
20
+ # File: module.rb
21
+ # Created: Sat 19 Nov 2011 11:24:19 GMT
22
+ #
23
+ ######################################################################
24
+ #++
25
+
26
+ module RubyMVC
27
+ # This method is used to convert a name to a method name.
28
+ # It is borrowed and adapted from shoes.rb:538-540.
29
+
30
+ def self.method_name(str)
31
+ str.to_s.gsub("/", "").gsub("::", "_").
32
+ gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
33
+ gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ #--
2
+ ######################################################################
3
+ #
4
+ # Copyright 2011 Andrew S. Townley
5
+ #
6
+ # Permission to use, copy, modify, and disribute this software for
7
+ # any purpose with or without fee is hereby granted, provided that
8
+ # the above copyright notices and this permission notice appear in
9
+ # all copies.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL
12
+ # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14
+ # AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT OR
15
+ # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
17
+ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18
+ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ #
20
+ # File: renderers.rb
21
+ # Created: Wed 23 Nov 2011 17:06:49 GMT
22
+ #
23
+ #####################################################################
24
+ #++
25
+
26
+ require 'ruby_mvc/renderers/html4_table_model_renderer'
@@ -0,0 +1,100 @@
1
+ #--
2
+ ######################################################################
3
+ #
4
+ # Copyright 2011 Andrew S. Townley
5
+ #
6
+ # Permission to use, copy, modify, and disribute this software for
7
+ # any purpose with or without fee is hereby granted, provided that
8
+ # the above copyright notices and this permission notice appear in
9
+ # all copies.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL
12
+ # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14
+ # AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT OR
15
+ # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
17
+ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18
+ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ #
20
+ # File: html4_table_model_renderer.rb
21
+ # Created: Wed 23 Nov 2011 16:50:30 GMT
22
+ #
23
+ #####################################################################
24
+ #++
25
+
26
+ require 'tagz'
27
+
28
+ module RubyMVC
29
+ module Renderers
30
+
31
+ # This class provides a very basic HTML4 renderer for
32
+ # table models. The HTML generated by this renderer does
33
+ # not have any support for CSS, and will use a plethora of
34
+ # in-line deprecated HTML tags to support older rendering
35
+ # engines.
36
+
37
+ class Html4TableModelRenderer
38
+ include Tagz
39
+
40
+ OPTIONS = {
41
+ :border => 1,
42
+ :cellspacing => 0,
43
+ :cellpadding => 3
44
+ }.freeze
45
+
46
+ TD_OPTIONS = {
47
+ :valign => "top"
48
+ }.freeze
49
+
50
+ def self.render(model, cols, options = {})
51
+ self.new.render(model, cols, options)
52
+ end
53
+
54
+ def render(model, cols, options = {})
55
+ options = OPTIONS.merge(options)
56
+ tagz {
57
+ table_(options) {
58
+ build_header(model, cols, options)
59
+ model.each { |row| build_row(cols, row) }
60
+ }
61
+ }
62
+ end
63
+
64
+ protected
65
+ def build_header(model, cols, options = {})
66
+ return if options[:headers] == false
67
+
68
+ tr_ {
69
+ cols.each do |col|
70
+ th_(:align => "center", :valign => "bottom") {
71
+ strong_ col[:label]
72
+ }
73
+ end
74
+ }
75
+ end
76
+
77
+ def build_row(cols, row)
78
+ tr_ {
79
+ cols.each do |col|
80
+ if(r = col[:renderer])
81
+ tagz.concat r.render(self, row, col)
82
+ else
83
+ data = row[col[:key]]
84
+ style = TD_OPTIONS.merge(col[:style])
85
+ weight = style.delete(:weight)
86
+ td_(style) {
87
+ if weight == "bold"
88
+ strong_ data
89
+ else
90
+ data
91
+ end
92
+ }
93
+ end
94
+ end
95
+ }
96
+ end
97
+ end
98
+
99
+ end
100
+ end
@@ -0,0 +1,31 @@
1
+ #--
2
+ ######################################################################
3
+ #
4
+ # Copyright 2011 Andrew S. Townley
5
+ #
6
+ # Permission to use, copy, modify, and disribute this software for
7
+ # any purpose with or without fee is hereby granted, provided that
8
+ # the above copyright notices and this permission notice appear in
9
+ # all copies.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL
12
+ # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14
+ # AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT OR
15
+ # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
17
+ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18
+ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ #
20
+ # File: toolkit.rb
21
+ # Created: Wed 23 Nov 2011 10:41:51 GMT
22
+ #
23
+ #####################################################################
24
+ #++
25
+
26
+ require 'ruby_mvc/toolkit/notification'
27
+ require 'ruby_mvc/toolkit/widget'
28
+ require 'ruby_mvc/toolkit/app'
29
+ require 'ruby_mvc/toolkit/dialog'
30
+ require 'ruby_mvc/toolkit/frame'
31
+ require 'ruby_mvc/toolkit/web_view'
@@ -0,0 +1,32 @@
1
+ #--
2
+ ######################################################################
3
+ #
4
+ # Copyright 2011 Andrew S. Townley
5
+ #
6
+ # Permission to use, copy, modify, and disribute this software for
7
+ # any purpose with or without fee is hereby granted, provided that
8
+ # the above copyright notices and this permission notice appear in
9
+ # all copies.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL
12
+ # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14
+ # AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT OR
15
+ # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
17
+ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18
+ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ #
20
+ # File: frame.rb
21
+ # Created: Wed 23 Nov 2011 10:39:10 GMT
22
+ #
23
+ #####################################################################
24
+ #++
25
+
26
+ module RubyMVC
27
+ module Toolkit
28
+
29
+ class App < Widget; end
30
+
31
+ end
32
+ end
@@ -0,0 +1,31 @@
1
+ #--
2
+ ######################################################################
3
+ #
4
+ # Copyright 2011 Andrew S. Townley
5
+ #
6
+ # Permission to use, copy, modify, and disribute this software for
7
+ # any purpose with or without fee is hereby granted, provided that
8
+ # the above copyright notices and this permission notice appear in
9
+ # all copies.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL
12
+ # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14
+ # AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT OR
15
+ # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
17
+ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18
+ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ #
20
+ # File: dialog.rb
21
+ # Created: Wed 23 Nov 2011 10:41:15 GMT
22
+ #
23
+ #####################################################################
24
+ #++
25
+
26
+ module RubyMVC
27
+ module Toolkit
28
+
29
+ class Dialog < Widget; end
30
+ end
31
+ end
@@ -0,0 +1,34 @@
1
+ #--
2
+ ######################################################################
3
+ #
4
+ # Copyright 2011 Andrew S. Townley
5
+ #
6
+ # Permission to use, copy, modify, and disribute this software for
7
+ # any purpose with or without fee is hereby granted, provided that
8
+ # the above copyright notices and this permission notice appear in
9
+ # all copies.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL
12
+ # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14
+ # AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT OR
15
+ # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
17
+ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18
+ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ #
20
+ # File: frame.rb
21
+ # Created: Wed 23 Nov 2011 10:39:10 GMT
22
+ #
23
+ #####################################################################
24
+ #++
25
+
26
+ module RubyMVC
27
+ module Toolkit
28
+
29
+ class Frame < Widget
30
+ api_methods :add
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,202 @@
1
+ #--
2
+ ######################################################################
3
+ #
4
+ # Copyright 2008, Andrew S. Townley
5
+ #
6
+ # Permission to use, copy, modify, and disribute this software for
7
+ # any purpose with or without fee is hereby granted, provided that
8
+ # the above copyright notices and this permission notice appear in
9
+ # all copies.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL
12
+ # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14
+ # AUTHORS BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT OR
15
+ # CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
16
+ # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
17
+ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18
+ # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19
+ #
20
+ # File: notification.rb
21
+ # Author: Andrew S. Townley
22
+ # Created: Sat Nov 1 14:27:10 GMT 2008
23
+ # Borrowed: Wed 23 Nov 2011 22:29:22 GMT
24
+ #
25
+ ######################################################################
26
+ #++
27
+
28
+ module RubyMVC
29
+ module Toolkit
30
+
31
+ # This class allows obsevers to register a single block
32
+ # rather than implementing public observer methods (which
33
+ # can get messy and unnecessarily pollute the public API
34
+ # of the class)
35
+ #
36
+ # Each registered block will be called with the following
37
+ # arguments:
38
+ #
39
+ # 1) The notification name (or the method name to be called)
40
+ # 2) The sender of the notification
41
+ # 3) The notification parameters.
42
+
43
+ class ObserverReference
44
+ attr_reader :observer
45
+
46
+ def initialize(observer, &block)
47
+ @observer = observer
48
+ @block = block
49
+ end
50
+
51
+ def method_missing(method, *args, &block)
52
+ if @observer.respond_to? method
53
+ @observer.send(method, *args, &block)
54
+ elsif !@block.nil?
55
+ @block.call(method, *args)
56
+ else
57
+ super
58
+ end
59
+ end
60
+ end
61
+
62
+ class ObserverList
63
+ def initialize
64
+ @observers = {}
65
+ end
66
+
67
+ def <<(val)
68
+ if !val.is_a? ObserverReference
69
+ raise ArgumentError, "can only have observer references in the list!"
70
+ end
71
+
72
+ @observers[val.observer] = val if !@observers.include? val.observer
73
+ end
74
+
75
+ def delete(val)
76
+ @observers.delete(val)
77
+ end
78
+
79
+ def each(&block)
80
+ @observers.each_value(&block)
81
+ end
82
+ end
83
+
84
+ # This class is used to relay notifications from one sender
85
+ # to another sender's registered listeners.
86
+
87
+ class NotificationRelay
88
+ def initialize(sender, listeners)
89
+ @listeners = listeners
90
+ @sender = sender
91
+ end
92
+
93
+ def method_missing(method, *args, &block)
94
+ args[0] = @sender
95
+ @listeners.each { |l| l.send(method, *args, &block) }
96
+ end
97
+ end
98
+
99
+ module ViewChangeNotifier
100
+ def register_view_change_observer(observer, &block)
101
+ observers = (@view_change_observers ||= ObserverList.new)
102
+ observers << ObserverReference.new(observer, &block)
103
+ end
104
+
105
+ def unregister_view_change_observer(observer)
106
+ observers = (@view_change_observers ||= ObserverList.new)
107
+ observers.delete(observer)
108
+ end
109
+
110
+ protected
111
+ def fire_view_changed
112
+ observers = (@view_change_observers ||= [])
113
+ observers.each { |o| o.view_changed(self) }
114
+ end
115
+ end
116
+
117
+ module ChangeNotifier
118
+ def register_change_observer(observer, &block)
119
+ observers = (@change_observers ||= ObserverList.new)
120
+ observers << ObserverReference.new(observer, &block)
121
+ end
122
+
123
+ def unregister_change_observer(observer)
124
+ observers = (@change_observers ||= [])
125
+ observers.delete(observer)
126
+ end
127
+
128
+ def squelch=(val)
129
+ @notification_squelch = val
130
+ end
131
+
132
+ protected
133
+ def fire_changed
134
+ return if @notification_squelch
135
+ observers = (@change_observers ||= [])
136
+ observers.each { |o| o.changed(self) }
137
+ end
138
+ end
139
+
140
+ module PropertyChangeNotifier
141
+ def register_property_change_observer(observer, &block)
142
+ observers = (@property_change_observers ||= [])
143
+ observers << ObserverReference.new(observer, &block)
144
+ end
145
+
146
+ def unregister_property_change_observer(observer)
147
+ observers = (@property_change_observers ||= [])
148
+ observers.delete(observer)
149
+ end
150
+
151
+ def squelch=(val)
152
+ @notification_squelch = val
153
+ end
154
+
155
+ protected
156
+ def fire_property_changed(property, old_val, new_val)
157
+ return if @notification_squelch
158
+ observers = (@property_change_observers ||= [])
159
+ observers.each { |o| o.property_changed(self, property, old_val, new_val) }
160
+ end
161
+ end
162
+
163
+ module SignalHandler
164
+ module ClassMethods
165
+ def signals
166
+ @signals ||= {}
167
+ end
168
+
169
+ def signal(signal, options = { :vetoable => false })
170
+ signals[signal] = options
171
+ end
172
+
173
+ def valid_signal?(signal)
174
+ if !signals.has_key? signal
175
+ raise ArgumentError, "class #{self} does not support signal '#{signal}'"
176
+ end
177
+ end
178
+ end
179
+
180
+ def signal_connect(signal, &block)
181
+ self.class.valid_signal? signal if self.class.respond_to? :signals
182
+ signals = (@signals ||= {})
183
+ signals[signal] = block
184
+ end
185
+
186
+ def signal_disconnect(signal)
187
+ self.class.valid_signal? signal if self.class.respond_to? :signals
188
+ signals = (@signals ||= {})
189
+ signals.delete(signal)
190
+ end
191
+
192
+ def signal_emit(signal, *args)
193
+ self.class.valid_signal? signal if self.class.respond_to? :signals
194
+ signals = (@signals ||= {})
195
+ if signals.key? signal
196
+ proc = signals[signal]
197
+ proc.call(*args) if !proc.nil?
198
+ end
199
+ end
200
+ end
201
+ end
202
+ end