ruby_mvc 0.0.1 → 0.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.
Files changed (68) hide show
  1. data/README.md +14 -0
  2. data/lib/ruby_mvc.rb +3 -1
  3. data/lib/ruby_mvc/application.rb +52 -2
  4. data/lib/ruby_mvc/controllers.rb +28 -0
  5. data/lib/ruby_mvc/controllers/action.rb +93 -0
  6. data/lib/ruby_mvc/controllers/action_group.rb +70 -0
  7. data/lib/ruby_mvc/controllers/app_controller.rb +4 -2
  8. data/lib/ruby_mvc/controllers/rails_controller.rb +2 -0
  9. data/lib/ruby_mvc/models.rb +2 -0
  10. data/lib/ruby_mvc/models/ar_table_model.rb +133 -0
  11. data/lib/ruby_mvc/models/array_table_model.rb +81 -13
  12. data/lib/ruby_mvc/models/keyed_array_table_model.rb +1 -1
  13. data/lib/ruby_mvc/models/model.rb +129 -0
  14. data/lib/ruby_mvc/models/table_model.rb +107 -10
  15. data/lib/ruby_mvc/models/view_model_template.rb +140 -0
  16. data/lib/ruby_mvc/renderers.rb +1 -0
  17. data/lib/ruby_mvc/renderers/html4_table_model_renderer.rb +7 -6
  18. data/lib/ruby_mvc/renderers/hyperlink_cell_renderer.rb +47 -0
  19. data/lib/ruby_mvc/toolkit.rb +5 -1
  20. data/lib/ruby_mvc/toolkit/browser_history.rb +115 -0
  21. data/lib/ruby_mvc/toolkit/dialog.rb +12 -1
  22. data/lib/ruby_mvc/toolkit/frame.rb +3 -1
  23. data/lib/ruby_mvc/toolkit/grid_view.rb +46 -0
  24. data/lib/ruby_mvc/toolkit/messagebox.rb +32 -0
  25. data/lib/ruby_mvc/toolkit/peers/wxruby.rb +5 -0
  26. data/lib/ruby_mvc/toolkit/peers/wxruby/app.rb +23 -2
  27. data/lib/ruby_mvc/toolkit/peers/wxruby/common.rb +11 -1
  28. data/lib/ruby_mvc/toolkit/peers/wxruby/dialog.rb +82 -0
  29. data/lib/ruby_mvc/toolkit/peers/wxruby/form_builder.rb +108 -0
  30. data/lib/ruby_mvc/toolkit/peers/wxruby/frame.rb +85 -1
  31. data/lib/ruby_mvc/toolkit/peers/wxruby/grid_model.rb +79 -0
  32. data/lib/ruby_mvc/toolkit/peers/wxruby/grid_view.rb +117 -0
  33. data/lib/ruby_mvc/toolkit/peers/wxruby/messagebox.rb +58 -0
  34. data/lib/ruby_mvc/toolkit/peers/wxruby/web_view.rb +40 -10
  35. data/lib/ruby_mvc/toolkit/property_change_notifier.rb +46 -0
  36. data/lib/ruby_mvc/toolkit/signal_handler.rb +149 -0
  37. data/lib/ruby_mvc/toolkit/web_view.rb +1 -1
  38. data/lib/ruby_mvc/toolkit/widget.rb +13 -6
  39. data/lib/ruby_mvc/views.rb +8 -59
  40. data/lib/ruby_mvc/views/{ar_type_list.rb → ar_form_view.rb} +10 -13
  41. data/lib/ruby_mvc/views/ar_support.rb +29 -0
  42. data/lib/ruby_mvc/views/ar_type_editor.rb +17 -28
  43. data/lib/ruby_mvc/views/ar_web_model_view.rb +59 -0
  44. data/lib/ruby_mvc/views/ar_web_type_list.rb +44 -0
  45. data/lib/ruby_mvc/views/browser_view.rb +185 -0
  46. data/lib/ruby_mvc/views/form_view.rb +111 -0
  47. data/lib/ruby_mvc/views/grid_table_view.rb +96 -0
  48. data/lib/ruby_mvc/views/table_view.rb +0 -39
  49. data/lib/ruby_mvc/views/view.rb +121 -0
  50. data/lib/ruby_mvc/views/web_content_table_view.rb +40 -0
  51. data/lib/ruby_mvc/views/{web_view.rb → web_content_view.rb} +17 -28
  52. data/lib/ruby_mvc/views/web_model_view.rb +67 -0
  53. data/ruby_mvc.gemspec +1 -1
  54. data/sample/browser_view.rb +57 -0
  55. data/sample/form.rb +59 -0
  56. data/sample/form2.rb +63 -0
  57. data/sample/grid_table_view.rb +68 -0
  58. data/sample/grid_view.rb +44 -0
  59. data/sample/grid_view2.rb +57 -0
  60. data/sample/test.html +1 -0
  61. data/sample/test2.html +33 -0
  62. data/sample/web_view.rb +4 -0
  63. data/test/unit/models/test_array_table_model.rb +19 -3
  64. data/test/unit/models/test_keyed_array_table_model.rb +3 -2
  65. data/test/unit/models/test_model.rb +88 -0
  66. metadata +39 -20
  67. data/lib/ruby_mvc/toolkit/notification.rb +0 -202
  68. data/lib/ruby_mvc/views/ar_model_editor.rb +0 -84
data/ruby_mvc.gemspec CHANGED
@@ -27,7 +27,7 @@ require 'rake'
27
27
 
28
28
  Gem::Specification.new do |s|
29
29
  s.name = "ruby_mvc"
30
- s.version = "0.0.1"
30
+ s.version = "0.0.2"
31
31
  s.summary = "Ruby MVC"
32
32
  s.description = "A simple, cross-platform MVC framework for Ruby"
33
33
  s.authors = [ "Andrew S. Townley" ]
@@ -0,0 +1,57 @@
1
+ #--
2
+ ######################################################################
3
+ #
4
+ # Copyright 2011-2012 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: browser_view.rb
21
+ # Created: Mon 2 Jan 2012 23:03:17 CET
22
+ #
23
+ ######################################################################
24
+ #++
25
+
26
+ require 'mvc'
27
+ include RubyMVC
28
+
29
+ # NOTE: this is a simple, in-line test. You wouldn't really
30
+ # do it this way in a real application.
31
+
32
+ RubyMVC.app :title => "BrowserView Sample", :width => 800, :height => 600 do
33
+ data = [
34
+ { :id => 1, :fname => "Bob", :lname => "Jones" },
35
+ { :id => 2, :fname => "Leslie", :lname => "Smith" },
36
+ { :id => 3, :fname => "Jake", :lname => "Bennigan" }
37
+ ]
38
+
39
+ model = Models::HashArrayTableModel.new(data)
40
+ template = Models::ViewModelTemplate.new do
41
+ property :id, :alias => "ID", :editable => false
42
+ property :fname, :alias => "First name"
43
+ property :lname, :alias => "Last name"
44
+ end
45
+ web_table = Views::WebContentTableView.new(template.apply(model))
46
+
47
+ browser = Views::BrowserView.new
48
+ frame.add(browser)
49
+
50
+ browser.open "test.html"
51
+ browser.load_html("<h1>Hello</h1>", "internal:hello")
52
+ browser.load(web_table)
53
+ browser.signal_connect("navigation-requested") do |s, href, t|
54
+ puts "navigation requested: #{href}"
55
+ s.open href
56
+ end
57
+ end
data/sample/form.rb ADDED
@@ -0,0 +1,59 @@
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: form.rb
21
+ # Created: Fri 30 Dec 2011 16:08:40 CET
22
+ #
23
+ ######################################################################
24
+ #++
25
+
26
+ require 'mvc'
27
+ include RubyMVC
28
+
29
+ # NOTE: this is a simple, in-line test. You wouldn't really
30
+ # do it this way in a real application.
31
+
32
+ RubyMVC.app :title => "Simple Form", :width => 800, :height => 600 do
33
+ model = Models::Model.new
34
+ model[:id] = 1
35
+ model[:fname] = "Jane"
36
+ model[:lname] = "Doe"
37
+ model[:description] = "Jane Doe is the hardest working individual I personally know. She's amazing!"
38
+
39
+ # In this case, the FormView specifies the editors for the
40
+ # model properties, but the properties will always be
41
+ # displayed in the order in which they are defined in the
42
+ # model. If more control is desired, then a
43
+ # ViewModelTemplate instance should be used to provide the
44
+ # desired ordering.
45
+
46
+ form = Views::FormView.new(model) do
47
+ disabled :id
48
+ editor :lname, :textfield
49
+ editor :fname, :textfield
50
+ editor :description, :textarea
51
+ end
52
+ form.signal_connect("form-submit") do |form, m|
53
+ puts "Model: #{m.inspect}"
54
+ end
55
+
56
+ dialog :title=> "Test Form" do |dlg|
57
+ dlg.add(form)
58
+ end
59
+ end
data/sample/form2.rb ADDED
@@ -0,0 +1,63 @@
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: form2.rb
21
+ # Created: Sat 31 Dec 2011 13:30:53 CET
22
+ #
23
+ ######################################################################
24
+ #++
25
+
26
+ require 'mvc'
27
+ include RubyMVC
28
+
29
+ # NOTE: this is a simple, in-line test. You wouldn't really
30
+ # do it this way in a real application.
31
+
32
+ RubyMVC.app :title => "Simple Form", :width => 800, :height => 600 do
33
+ model = Models::Model.new
34
+ model[:id] = 1
35
+ model[:fname] = "Jane"
36
+ model[:lname] = "Doe"
37
+ model[:description] = "Jane Doe is the hardest working individual I personally know. She's amazing!"
38
+
39
+ # The ViewModelTemplate specifies the order in which the
40
+ # properties will be displayed, in addition to allowing the
41
+ # definition of the property aliases and whether the
42
+ # properties should be editable or not.
43
+
44
+ template = Models::ViewModelTemplate.new do
45
+ property :id, :alias => "ID", :editable => false
46
+ property :fname, :alias => "First name"
47
+ property :lname, :alias => "Last name"
48
+ end
49
+ template.apply model
50
+
51
+ # When using the ViewModelTemplate, the FormView should be
52
+ # completely initialized with the defaults (assuming that
53
+ # the editors are supposed to be text fields.
54
+
55
+ form = Views::FormView.new(template)
56
+ form.signal_connect("form-submit") do |form, m|
57
+ puts "Model: #{m.inspect}"
58
+ end
59
+
60
+ dialog :title=> "Test Form" do |dlg|
61
+ dlg.add(form)
62
+ end
63
+ end
@@ -0,0 +1,68 @@
1
+ #--
2
+ ######################################################################
3
+ #
4
+ # Copyright 2011-2012 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: grid_table_view.rb
21
+ # Created: Mon 2 Jan 2012 16:39:48 CET
22
+ #
23
+ ######################################################################
24
+ #++
25
+
26
+ require 'mvc'
27
+ include RubyMVC
28
+
29
+ # NOTE: this is a simple, in-line test. You wouldn't really
30
+ # do it this way in a real application.
31
+
32
+ RubyMVC.app :title => "GridTableView Sample", :width => 800, :height => 600 do
33
+ data = [
34
+ { :id => 1, :fname => "Bob", :lname => "Jones" },
35
+ { :id => 2, :fname => "Leslie", :lname => "Smith" },
36
+ { :id => 3, :fname => "Jake", :lname => "Bennigan" }
37
+ ]
38
+
39
+ model = Models::HashArrayTableModel.new(data, :row_template => {})
40
+ # model.signal_connect("rows-inserted") do |s, idx, rows|
41
+ # puts "insert #{rows.size} rows at #{idx}"
42
+ # puts "Model: #{model.inspect}"
43
+ # end
44
+ # model.signal_connect("rows-removed") do |s, idx, rows|
45
+ # puts "removed #{rows.size} rows"
46
+ # puts "Model: #{model.inspect}"
47
+ # end
48
+
49
+ template = Models::ViewModelTemplate.new do
50
+ property :id, :alias => "ID", :editable => false
51
+ property :fname, :alias => "First name"
52
+ property :lname, :alias => "Last name"
53
+ end
54
+
55
+ grid = Views::GridTableView.new(template.apply(model),
56
+ :show_row_labels => false, :editable => false)
57
+ grid.signal_connect("row-edit") do |s, m, i, r|
58
+ form = Views::FormView.new(template.apply(r))
59
+ form.signal_connect("form-submit") do |form, d|
60
+ m.update_row(i, r)
61
+ end
62
+ dialog :title => "Row Editor", :parent => frame do |dlg|
63
+ dlg.add(form)
64
+ end
65
+ end
66
+
67
+ frame.add(grid)
68
+ end
@@ -0,0 +1,44 @@
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: grid_view.rb
21
+ # Created: Sat 31 Dec 2011 19:04:31 CET
22
+ #
23
+ ######################################################################
24
+ #++
25
+
26
+ require 'mvc'
27
+ include RubyMVC
28
+
29
+ # NOTE: this is a simple, in-line test. You wouldn't really
30
+ # do it this way in a real application.
31
+
32
+ RubyMVC.app :title => "GridView", :width => 800, :height => 600 do
33
+ data = [
34
+ { :id => 1, :fname => "Bob", :lname => "Jones" },
35
+ { :id => 2, :fname => "Leslie", :lname => "Smith" },
36
+ { :id => 3, :fname => "Jake", :lname => "Bennigan" }
37
+ ]
38
+
39
+ model = Models::HashArrayTableModel.new(data)
40
+ grid = Toolkit::GridView.new(:show_row_labels => false)
41
+ grid.editable = false
42
+ grid.model = model
43
+ frame.add(grid)
44
+ end
@@ -0,0 +1,57 @@
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: grid_view.rb
21
+ # Created: Sat 31 Dec 2011 19:04:31 CET
22
+ #
23
+ ######################################################################
24
+ #++
25
+
26
+ require 'mvc'
27
+ include RubyMVC
28
+
29
+ # NOTE: this is a simple, in-line test. You wouldn't really
30
+ # do it this way in a real application.
31
+
32
+ RubyMVC.app :title => "GridView with Model Template", :width => 800, :height => 600 do
33
+ data = [
34
+ { :id => 1, :fname => "Bob", :lname => "Jones" },
35
+ { :id => 2, :fname => "Leslie", :lname => "Smith" },
36
+ { :id => 3, :fname => "Jake", :lname => "Bennigan" }
37
+ ]
38
+
39
+ model = Models::HashArrayTableModel.new(data)
40
+ template = Models::ViewModelTemplate.new do
41
+ property :id, :alias => "ID", :editable => false
42
+ property :fname, :alias => "First name"
43
+ property :lname, :alias => "Last name"
44
+ end
45
+ template.apply model
46
+
47
+ grid = Toolkit::GridView.new(:show_row_labels => false)
48
+ grid.editable = false
49
+ grid.model = template
50
+ grid.signal_connect('row-activated') do |s, m, r, key|
51
+ puts "activated on row[#{r}] and property #{key}"
52
+ end
53
+ grid.signal_connect('row-selection-changed') do |s, m, rows|
54
+ puts "selection: #{rows.inspect}"
55
+ end
56
+ frame.add(grid)
57
+ end
data/sample/test.html CHANGED
@@ -4,6 +4,7 @@
4
4
  </head>
5
5
  <body>
6
6
  <h1>Hello WebView!</h1>
7
+ <p><a href="test2.html">Load another page</a></p>
7
8
  <p>
8
9
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit
9
10
  amet leo enim. Curabitur ultricies, dolor a fermentum molestie, ante
data/sample/test2.html ADDED
@@ -0,0 +1,33 @@
1
+ <html>
2
+ <head>
3
+ <title>Test 2 HTML</title>
4
+ </head>
5
+ <body>
6
+ <h1>Another Page</h1>
7
+ <p>
8
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit
9
+ amet leo enim. Curabitur ultricies, dolor a fermentum molestie, ante
10
+ dui imperdiet magna, sed tincidunt enim nisl sit amet quam. Ut
11
+ adipiscing luctus adipiscing. Nullam elementum, arcu a molestie
12
+ laoreet, lorem arcu pretium dolor, ut auctor nisi quam eget odio.
13
+ Proin sagittis accumsan erat, a vestibulum diam pharetra ut. Nullam
14
+ vitae leo tellus, id venenatis erat. Vivamus a nisi tellus, et
15
+ volutpat augue. Nam ac massa nunc, eget consequat neque. Proin
16
+ tincidunt, eros sed pretium gravida, ipsum lectus blandit ipsum, ut
17
+ laoreet leo velit non risus. Nullam at dolor purus, vitae iaculis
18
+ lorem.
19
+ </p><p>
20
+ Pellentesque habitant morbi tristique senectus et netus et malesuada
21
+ fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci
22
+ luctus et ultrices posuere cubilia Curae; Pellentesque eu enim odio.
23
+ Sed rhoncus ornare magna, lacinia porttitor nunc tincidunt ut.
24
+ Vestibulum sed placerat nunc. Nulla ut eros eget urna ornare volutpat.
25
+ Suspendisse egestas lacus vitae velit congue ut tincidunt mauris
26
+ faucibus. Donec non felis est, a fermentum quam. Morbi auctor justo
27
+ non nibh rhoncus sed consequat nibh sollicitudin. Vivamus consectetur,
28
+ eros eu lobortis dignissim, justo sapien mollis metus, ac vehicula
29
+ velit leo in nisi. Suspendisse potenti. Suspendisse ut eleifend enim.
30
+ Donec dignissim tincidunt purus vitae tempor.
31
+ </p>
32
+ </body>
33
+ </html>
data/sample/web_view.rb CHANGED
@@ -31,4 +31,8 @@ RubyMVC.app :title => "WebView", :width => 800, :height => 600 do
31
31
  html = Toolkit::WebView.new
32
32
  frame.add(html)
33
33
  html.open "test.html"
34
+ html.signal_connect("navigation-requested") do |w, href, targ|
35
+ puts "navigation request: #{href}"
36
+ html.open href
37
+ end
34
38
  end
@@ -23,19 +23,21 @@
23
23
  ######################################################################
24
24
  #++
25
25
 
26
+ $:.unshift File.join(File.dirname(__FILE__), "../../../lib")
27
+
26
28
  require 'testy'
27
- require 'ruby_mvc/models'
29
+ require 'ruby_mvc'
28
30
 
29
31
  include RubyMVC::Models
30
32
 
31
- Testy.testing "Core ArrayTableModel tests" do
33
+ Testy.testing "Core HashArrayTableModel tests" do
32
34
  test "Basic functionality" do |result|
33
35
  keys = [ :foo, :bar ]
34
36
  data = [
35
37
  { :foo => "Foo1", :bar => "Bar1" },
36
38
  { :foo => "Foo2", :bar => "Bar2" } ]
37
39
 
38
- model = ArrayTableModel.new(data)
40
+ model = HashArrayTableModel.new(data)
39
41
  model.each_with_index do |row, i|
40
42
  keys.each do |key|
41
43
  result.check "row[#{i}][:#{key}] value is correct",
@@ -53,4 +55,18 @@ Testy.testing "Core ArrayTableModel tests" do
53
55
  end
54
56
  end
55
57
  end
58
+
59
+ test "Signal handling" do |result|
60
+ data = [
61
+ { :foo => "Foo1", :bar => "Bar1" },
62
+ { :foo => "Foo2", :bar => "Bar2" } ]
63
+
64
+ model = HashArrayTableModel.new([])
65
+ model.signal_connect("rows-inserted") do |s, i, r|
66
+ result.check "rows-inserted",
67
+ :expect => [ 0, true ],
68
+ :actual => [ i, r.size == 2 ]
69
+ end
70
+ model.insert_rows(0, data)
71
+ end
56
72
  end