glimmer-dsl-tk 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0ce8665311ec56974f2f930183c6cd2ad4b2867436ddffbdf66984659f0e830f
4
- data.tar.gz: 13ddbe796e17917d0e392fc61e7c96443f430e4f403ff9730cd6b92e24b424aa
3
+ metadata.gz: d17b887519b4dcbc1d9730240835fa918d81902268ea4c8607a2528696b6c5fd
4
+ data.tar.gz: df8da719382108710096f6026e362c32fff92fb15b720ba43bceb5d12b688f04
5
5
  SHA512:
6
- metadata.gz: b005addc832a5f0af7aeb0285d41dc8e52b40d61088ea16272657c65ddcdbaa92c6af09cb11fd5fb34de6de1b10a11f2d6d0e31d9f2b1a279a0fbaa14fd17b21
7
- data.tar.gz: 2a154821ce05f1f53d0bbd8c3336daea2b4c2ee709753f9b3872015f839a1e5a41747666171481ef658d4e682f43e137659b692089a641520b20f5b95f0d1e8f
6
+ metadata.gz: c7384362360e983fd820843b0c9ceccad79a39e96a152aea42ae414327b2b4665c8b2af1470a7ee5da69695968daec98fb7b52c34d68b732934b3efeb59f0073
7
+ data.tar.gz: c809eecf36d5c60e81ade4beb39ed52260cd1b0e1fb9a8ee6ac97fd7d9bc68e315d17fd2e49fad6eb39e452fefe1551d627fa2381ac3b1594d3cdbe0efa8905c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.12
4
+
5
+ - Upgrade to glimmer 2.3.0
6
+ - Support Shine syntax for data-binding
7
+ - Update all data-binding samples to use Shine syntax for data-binding
8
+
3
9
  ## 0.0.11
4
10
 
5
11
  - Add preliminary support for `treeview` (no data-binding) with `columns`, `show`, and `heading_configure` attributes/methods
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.11
1
+ # [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=85 />](https://github.com/AndyObtiva/glimmer) Glimmer DSL for Tk 0.0.12
2
2
  ## MRI Ruby Desktop Development GUI Library
3
3
  [![Gem Version](https://badge.fury.io/rb/glimmer-dsl-tk.svg)](http://badge.fury.io/rb/glimmer-dsl-tk)
4
4
  [![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/glimmer-dsl-tk/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/glimmer-dsl-tk?branch=master)
@@ -46,7 +46,7 @@ Glimmer app:
46
46
 
47
47
  ![glimmer dsl tk screenshot sample hello world](images/glimmer-dsl-tk-screenshot-sample-hello-world.png)
48
48
 
49
- NOTE: Glimmer DSL for Tk is in alpha mode. Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
49
+ NOTE: Glimmer DSL for Tk is currently in early alpha mode (incomplete). Please help make better by contributing, adopting for small or low risk projects, and providing feedback. It is still an early alpha, so the more feedback and issues you report the better.
50
50
 
51
51
  Other [Glimmer](https://github.com/AndyObtiva/glimmer) DSL gems:
52
52
  - [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
@@ -81,7 +81,7 @@ gem install glimmer-dsl-tk
81
81
 
82
82
  Add the following to `Gemfile`:
83
83
  ```
84
- gem 'glimmer-dsl-tk', '~> 0.0.11'
84
+ gem 'glimmer-dsl-tk', '~> 0.0.12'
85
85
  ```
86
86
 
87
87
  And, then run:
@@ -211,7 +211,7 @@ Example:
211
211
  entry {
212
212
  grid column: 1, row: 2
213
213
  width 15
214
- text bind(@contact, :year_of_birth)
214
+ text <=> [@contact, :year_of_birth]
215
215
  }
216
216
  ```
217
217
 
@@ -219,7 +219,7 @@ More details can be found in the [Hello, Computed!](#hello-computed) sample belo
219
219
 
220
220
  ## Bidirectional Data-Binding
221
221
 
222
- Glimmer supports bidirectional data-binding via the `bind` keyword, which takes a model and an attribute.
222
+ Glimmer supports Shine syntax bidirectional data-binding via the `<=>` operator (read-write) and unidirectional data-binding via the `<=` operator (read-only), which takes a model and an attribute (the `bind` keyword may also be used as the old-style of data-binding).
223
223
 
224
224
  ### Combo Data-Binding
225
225
 
@@ -230,7 +230,7 @@ This assumes a `Person` model with a `country` attribute representing their curr
230
230
  ```ruby
231
231
  combobox {
232
232
  state 'readonly'
233
- text bind(person, :country)
233
+ text <=> [person, :country]
234
234
  }
235
235
  ```
236
236
 
@@ -252,7 +252,7 @@ This assumes a `Person` model with a `country` attribute representing their curr
252
252
  ```ruby
253
253
  list {
254
254
  selectmode 'browse'
255
- text bind(person, :country)
255
+ text <=> [person, :country]
256
256
  }
257
257
  ```
258
258
 
@@ -273,7 +273,7 @@ This assumes a `Person` model with a `provinces` attribute representing their cu
273
273
 
274
274
  ```ruby
275
275
  list {
276
- text bind(person, :provinces)
276
+ text <=> [person, :provinces]
277
277
  }
278
278
  ```
279
279
 
@@ -292,7 +292,7 @@ This assumes a `Person` model with a `country` attribute.
292
292
 
293
293
  ```ruby
294
294
  label {
295
- text bind(person, :country)
295
+ text <=> [person, :country]
296
296
  }
297
297
  ```
298
298
 
@@ -310,7 +310,7 @@ This assumes a `Person` model with a `country` attribute.
310
310
 
311
311
  ```ruby
312
312
  entry {
313
- text bind(person, :country)
313
+ text <=> [person, :country]
314
314
  }
315
315
  ```
316
316
 
@@ -425,7 +425,7 @@ root {
425
425
 
426
426
  combobox { |proxy|
427
427
  state 'readonly'
428
- text bind(person, :country)
428
+ text <=> [person, :country]
429
429
  }
430
430
 
431
431
  button { |proxy|
@@ -466,7 +466,7 @@ root {
466
466
 
467
467
  list {
468
468
  selectmode 'browse'
469
- selection bind(person, :country)
469
+ selection <=> [person, :country]
470
470
  }
471
471
 
472
472
  button {
@@ -504,7 +504,7 @@ root {
504
504
  title 'Hello, List Multi Selection!'
505
505
 
506
506
  list {
507
- selection bind(person, :provinces)
507
+ selection <=> [person, :provinces]
508
508
  }
509
509
 
510
510
  button {
@@ -551,7 +551,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
551
551
  entry {
552
552
  grid column: 1, row: 0
553
553
  width 15
554
- text bind(@contact, :first_name)
554
+ text <=> [@contact, :first_name]
555
555
  }
556
556
 
557
557
  label {
@@ -561,7 +561,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
561
561
  entry {
562
562
  grid column: 1, row: 1
563
563
  width 15
564
- text bind(@contact, :last_name)
564
+ text <=> [@contact, :last_name]
565
565
  }
566
566
 
567
567
  label {
@@ -571,7 +571,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
571
571
  entry {
572
572
  grid column: 1, row: 2
573
573
  width 15
574
- text bind(@contact, :year_of_birth)
574
+ text <=> [@contact, :year_of_birth]
575
575
  }
576
576
 
577
577
  label {
@@ -580,7 +580,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
580
580
  }
581
581
  label {
582
582
  grid column: 1, row: 3, sticky: 'w'
583
- text bind(@contact, :name, computed_by: [:first_name, :last_name])
583
+ text <=> [@contact, :name, computed_by: [:first_name, :last_name]]
584
584
  }
585
585
 
586
586
  label {
@@ -589,7 +589,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
589
589
  }
590
590
  label {
591
591
  grid column: 1, row: 4, sticky: 'w'
592
- text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
592
+ text <=> [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
593
593
  }
594
594
  }
595
595
  }.open
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.0.12
Binary file
@@ -40,6 +40,7 @@ module Glimmer
40
40
  data_binding
41
41
  block_attribute
42
42
  attribute
43
+ shine_data_binding
43
44
  widget
44
45
  ]
45
46
  )
@@ -0,0 +1,43 @@
1
+ # Copyright (c) 2007-2021 Andy Maleh
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ require 'glimmer/dsl/expression'
23
+ require 'glimmer/data_binding/model_binding'
24
+ require 'glimmer/data_binding/tk/widget_binding'
25
+ require 'glimmer/data_binding/shine'
26
+
27
+ module Glimmer
28
+ module DSL
29
+ module Tk
30
+ class ShineDataBindingExpression < Expression
31
+ def can_interpret?(parent, keyword, *args, &block)
32
+ args.size == 0 and
33
+ block.nil? and
34
+ (parent.respond_to?(:has_attribute?) and parent.has_attribute?(keyword))
35
+ end
36
+
37
+ def interpret(parent, keyword, *args, &block)
38
+ Glimmer::DataBinding::Shine.new(parent, keyword)
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -40,7 +40,7 @@ module Glimmer
40
40
  end
41
41
 
42
42
  def content(&block)
43
- Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::RootExpression.new, &block)
43
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::RootExpression.new, keyword, *args, &block)
44
44
  end
45
45
 
46
46
  def set_attribute(attribute, *args)
@@ -25,20 +25,6 @@ module Glimmer
25
25
  #
26
26
  # Follows the Proxy Design Pattern
27
27
  class WidgetProxy
28
- attr_reader :parent_proxy, :tk, :args
29
-
30
- DEFAULT_INITIALIZERS = {
31
- 'combobox' => lambda do |tk|
32
- tk.textvariable = ::TkVariable.new
33
- end,
34
- 'label' => lambda do |tk|
35
- tk.textvariable = ::TkVariable.new
36
- end,
37
- 'entry' => lambda do |tk|
38
- tk.textvariable = ::TkVariable.new
39
- end,
40
- }
41
-
42
28
  class << self
43
29
  def create(keyword, parent, args)
44
30
  widget_proxy_class(keyword).new(keyword, parent, args)
@@ -75,12 +61,27 @@ module Glimmer
75
61
  end
76
62
  end
77
63
 
64
+ attr_reader :parent_proxy, :tk, :args, :keyword
65
+
66
+ DEFAULT_INITIALIZERS = {
67
+ 'combobox' => lambda do |tk|
68
+ tk.textvariable = ::TkVariable.new
69
+ end,
70
+ 'label' => lambda do |tk|
71
+ tk.textvariable = ::TkVariable.new
72
+ end,
73
+ 'entry' => lambda do |tk|
74
+ tk.textvariable = ::TkVariable.new
75
+ end,
76
+ }
77
+
78
78
  # Initializes a new Tk Widget
79
79
  #
80
80
  # Styles is a comma separate list of symbols representing Tk styles in lower case
81
81
  def initialize(underscored_widget_name, parent_proxy, args)
82
82
  @parent_proxy = parent_proxy
83
83
  @args = args
84
+ @keyword = underscored_widget_name
84
85
  tk_widget_class = self.class.tk_widget_class_for(underscored_widget_name)
85
86
  @tk = tk_widget_class.new(@parent_proxy.tk, *args)
86
87
  # a common widget initializer
@@ -216,7 +217,7 @@ module Glimmer
216
217
  end
217
218
 
218
219
  def content(&block)
219
- Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::WidgetExpression.new, &block)
220
+ Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::WidgetExpression.new, keyword, *args, &block)
220
221
  end
221
222
 
222
223
  def method_missing(method, *args, &block)
@@ -45,7 +45,7 @@ class HelloCombo
45
45
 
46
46
  combobox {
47
47
  state 'readonly'
48
- text bind(person, :country)
48
+ text <=> [person, :country]
49
49
  }
50
50
 
51
51
  button {
@@ -48,7 +48,7 @@ class HelloComputed
48
48
  entry {
49
49
  grid column: 1, row: 0
50
50
  width 15
51
- text bind(@contact, :first_name)
51
+ text <=> [@contact, :first_name]
52
52
  }
53
53
 
54
54
  label {
@@ -58,7 +58,7 @@ class HelloComputed
58
58
  entry {
59
59
  grid column: 1, row: 1
60
60
  width 15
61
- text bind(@contact, :last_name)
61
+ text <=> [@contact, :last_name]
62
62
  }
63
63
 
64
64
  label {
@@ -68,7 +68,7 @@ class HelloComputed
68
68
  entry {
69
69
  grid column: 1, row: 2
70
70
  width 15
71
- text bind(@contact, :year_of_birth)
71
+ text <=> [@contact, :year_of_birth]
72
72
  }
73
73
 
74
74
  label {
@@ -77,7 +77,7 @@ class HelloComputed
77
77
  }
78
78
  label {
79
79
  grid column: 1, row: 3, sticky: 'w'
80
- text bind(@contact, :name, computed_by: [:first_name, :last_name])
80
+ text <=> [@contact, :name, computed_by: [:first_name, :last_name]]
81
81
  }
82
82
 
83
83
  label {
@@ -86,7 +86,7 @@ class HelloComputed
86
86
  }
87
87
  label {
88
88
  grid column: 1, row: 4, sticky: 'w'
89
- text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
89
+ text <=> [@contact, :age, on_write: :to_i, computed_by: :year_of_birth]
90
90
  }
91
91
  }
92
92
  }.open
@@ -54,7 +54,7 @@ class HelloListMultiSelection
54
54
  title 'Hello, List Multi Selection!'
55
55
 
56
56
  list {
57
- selection bind(person, :provinces)
57
+ selection <=> [person, :provinces]
58
58
  }
59
59
 
60
60
  button {
@@ -45,7 +45,7 @@ class HelloListSingleSelection
45
45
 
46
46
  list {
47
47
  selectmode 'browse'
48
- selection bind(person, :country)
48
+ selection <=> [person, :country]
49
49
  }
50
50
 
51
51
  button {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glimmer-dsl-tk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-29 00:00:00.000000000 Z
11
+ date: 2021-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -198,6 +198,7 @@ files:
198
198
  - lib/glimmer/dsl/tk/dsl.rb
199
199
  - lib/glimmer/dsl/tk/list_selection_data_binding_expression.rb
200
200
  - lib/glimmer/dsl/tk/root_expression.rb
201
+ - lib/glimmer/dsl/tk/shine_data_binding_expression.rb
201
202
  - lib/glimmer/dsl/tk/widget_expression.rb
202
203
  - lib/glimmer/tk/button_proxy.rb
203
204
  - lib/glimmer/tk/entry_proxy.rb
@@ -235,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
236
  - !ruby/object:Gem::Version
236
237
  version: '0'
237
238
  requirements: []
238
- rubygems_version: 3.2.22
239
+ rubygems_version: 3.2.28
239
240
  signing_key:
240
241
  specification_version: 4
241
242
  summary: Glimmer DSL for Tk