glimmer-dsl-tk 0.0.9 → 0.0.13

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: f60c7beb9a2127b33ef8089bb0d910a0db9bd66ab359e81a90f964d3f368d2d1
4
- data.tar.gz: 95369859cfa851e2687a5e9ed419b7dcff46e83960ac733614b6355c0021f94a
3
+ metadata.gz: 6dd8908007208ff366a6605b4193d5202c3b81994c9a39288f6f8b6f72c3ec95
4
+ data.tar.gz: 2a4651e42e10d7112d30823414f768d7c5607eaeb3a9e8de5b81af4adc932536
5
5
  SHA512:
6
- metadata.gz: e3e3aedafe8bbfbd79ed47b89ee884bf7f45d73f78f5e3d2cb72886b7452b9db48ac6f05aa9b005d1aa90c19ec30b3df36d5b6e3d3d5e878874761bd683cd216
7
- data.tar.gz: de842cf08e505ccc28d35098c96aa64e4572d46413ea7e4edc02785dd82c5648b08ba1294334153ce67693b6bf2fa5536686c57eada94f91dba0eba52b57eec2
6
+ metadata.gz: dd1c4ccaa1d1ea01b07f627333bac1d2b50f2e4a7eb1abb04f8e267b547fd2874daa62ae244eae86264d0f1c0fec6f3b040325b45343b360b09c1008b2468f1b
7
+ data.tar.gz: 1b77271bdd9288256625d3528537033adbd07397c3348a29d60434142b56fe3928fa8128a5981815aa94e5f63eee95404d61497c0f93da5cb6ae3fe88be81f99
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
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
+
9
+ ## 0.0.11
10
+
11
+ - Add preliminary support for `treeview` (no data-binding) with `columns`, `show`, and `heading_configure` attributes/methods
12
+
13
+ ## 0.0.10
14
+
15
+ - puts_debuggerer gem to help consumers with debugging in and out of girb
16
+
3
17
  ## 0.0.9
4
18
 
5
19
  - Upgrade to glimmer 2.1.2
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.9
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.13
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)
@@ -9,13 +9,13 @@
9
9
 
10
10
  [Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [Tk](https://www.tcl.tk/) enables desktop development with [Glimmer](https://github.com/AndyObtiva/glimmer) in [Ruby](https://github.com/ruby/ruby).
11
11
 
12
- [Tcl/Tk](https://www.tcl.tk/) has evolved into a practical desktop GUI toolkit due to gaining truly native looking themed widgets on Mac, Windows, and Linux in [Tk version 8.5](https://www.tcl.tk/software/tcltk/8.5.html#:~:text=Highlights%20of%20Tk%208.5&text=Font%20rendering%3A%20Now%20uses%20anti,and%20window%20layout%2C%20and%20more.).
12
+ [Tcl/Tk](https://www.tcl.tk/) has evolved into a practical desktop GUI toolkit due to gaining native looking themed widgets on Mac, Windows, and Linux in [Tk version 8.5](https://www.tcl.tk/software/tcltk/8.5.html#:~:text=Highlights%20of%20Tk%208.5&text=Font%20rendering%3A%20Now%20uses%20anti,and%20window%20layout%2C%20and%20more.).
13
13
 
14
14
  Additionally, [Ruby](https://www.ruby-lang.org/en/) 3.0 Ractor (formerly known as [Guilds](https://olivierlacan.com/posts/concurrency-in-ruby-3-with-guilds/)) supports truly parallel multi-threading, making both [MRI](https://github.com/ruby/ruby) and [Tk](https://www.tcl.tk/) finally viable for support in [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development GUI Library) as an alternative to [JRuby on SWT](https://github.com/AndyObtiva/glimmer-dsl-swt).
15
15
 
16
16
  The trade-off is that while [SWT](https://www.eclipse.org/swt/) provides a plethora of high quality reusable widgets for the Enterprise (such as [Nebula](https://www.eclipse.org/nebula/)), [Tk](https://www.tcl.tk/) enables very fast app startup time and a small memory footprint via [MRI Ruby](https://www.ruby-lang.org/en/).
17
17
 
18
- [Glimmer](https://github.com/AndyObtiva/glimmer) aims to provide a DSL similar to the [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) to enable more productive desktop development in Ruby with:
18
+ [Glimmer DSL for Tk](https://github.com/AndyObtiva/glimmer-dsl-tk) aims to provide a DSL similar to the [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) to enable more productive desktop development in Ruby with:
19
19
  - Declarative DSL syntax that visually maps to the GUI widget hierarchy
20
20
  - Convention over configuration via smart defaults and automation of low-level details
21
21
  - Requiring the least amount of syntax possible to build GUI
@@ -46,10 +46,11 @@ 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)
53
+ - [glimmer-dsl-libui](https://github.com/AndyObtiva/glimmer-dsl-libui): Glimmer DSL for LibUI (Prerequisite-Free Ruby Desktop Development GUI Library)
53
54
  - [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
54
55
  - [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
55
56
  - [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS (Cascading Style Sheets)
@@ -80,7 +81,7 @@ gem install glimmer-dsl-tk
80
81
 
81
82
  Add the following to `Gemfile`:
82
83
  ```
83
- gem 'glimmer-dsl-tk', '~> 0.0.9'
84
+ gem 'glimmer-dsl-tk', '~> 0.0.13'
84
85
  ```
85
86
 
86
87
  And, then run:
@@ -166,6 +167,23 @@ root {
166
167
  }.open
167
168
  ```
168
169
 
170
+ ### Supported Widgets
171
+
172
+ keyword(args) | attributes | listeners/events
173
+ ------------- | ---------- | ---------
174
+ `button` | `text` | `command`
175
+ `entry` | `width`, `text` | None
176
+ `frame(text: )` | None | None
177
+ `label` | `text` | None
178
+ `list` | `selectmode`, `selection` | None
179
+ `message_box(type: , message: , detail: , title: , icon: , default: , parent: )` | None | None
180
+ `notebook` | None | None
181
+ `root` | `title`, `iconphoto` | None
182
+
183
+ #### Common Attributes
184
+
185
+ - `grid`
186
+
169
187
  ### Smart Defaults and Convensions
170
188
 
171
189
  #### Grid Layout
@@ -210,7 +228,7 @@ Example:
210
228
  entry {
211
229
  grid column: 1, row: 2
212
230
  width 15
213
- text bind(@contact, :year_of_birth)
231
+ text <=> [@contact, :year_of_birth]
214
232
  }
215
233
  ```
216
234
 
@@ -218,9 +236,9 @@ More details can be found in the [Hello, Computed!](#hello-computed) sample belo
218
236
 
219
237
  ## Bidirectional Data-Binding
220
238
 
221
- Glimmer supports bidirectional data-binding via the `bind` keyword, which takes a model and an attribute.
239
+ 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).
222
240
 
223
- ### Combo Data-Binding
241
+ ### Combobox Data-Binding
224
242
 
225
243
  Example:
226
244
 
@@ -229,7 +247,7 @@ This assumes a `Person` model with a `country` attribute representing their curr
229
247
  ```ruby
230
248
  combobox {
231
249
  state 'readonly'
232
- text bind(person, :country)
250
+ text <=> [person, :country]
233
251
  }
234
252
  ```
235
253
 
@@ -238,7 +256,7 @@ It also binds the `text` selection of the `combobox` to the `country` property o
238
256
 
239
257
  It automatically handles all the Tk plumbing behind the scenes, such as using `TkVariable` and setting `combobox` `values` from `person.country_options` by convention (attribute_name + "_options").
240
258
 
241
- More details can be found in the [Hello, Combo!](#hello-combo) sample below.
259
+ More details can be found in the [Hello, Combobox!](#hello-combobox) sample below.
242
260
 
243
261
  ### List Single Selection Data-Binding
244
262
 
@@ -251,7 +269,7 @@ This assumes a `Person` model with a `country` attribute representing their curr
251
269
  ```ruby
252
270
  list {
253
271
  selectmode 'browse'
254
- text bind(person, :country)
272
+ text <=> [person, :country]
255
273
  }
256
274
  ```
257
275
 
@@ -272,7 +290,7 @@ This assumes a `Person` model with a `provinces` attribute representing their cu
272
290
 
273
291
  ```ruby
274
292
  list {
275
- text bind(person, :provinces)
293
+ text <=> [person, :provinces]
276
294
  }
277
295
  ```
278
296
 
@@ -291,7 +309,7 @@ This assumes a `Person` model with a `country` attribute.
291
309
 
292
310
  ```ruby
293
311
  label {
294
- text bind(person, :country)
312
+ text <=> [person, :country]
295
313
  }
296
314
  ```
297
315
 
@@ -309,7 +327,7 @@ This assumes a `Person` model with a `country` attribute.
309
327
 
310
328
  ```ruby
311
329
  entry {
312
- text bind(person, :country)
330
+ text <=> [person, :country]
313
331
  }
314
332
  ```
315
333
 
@@ -336,7 +354,7 @@ Example:
336
354
 
337
355
  This resets the person country.
338
356
 
339
- More details can be found in the [Hello, Combo!](#hello-combo) sample below.
357
+ More details can be found in the [Hello, Combobox!](#hello-combobox) sample below.
340
358
 
341
359
  ## Samples
342
360
 
@@ -413,18 +431,111 @@ Glimmer app:
413
431
  ![glimmer dsl tk screenshot sample hello tab English](images/glimmer-dsl-tk-screenshot-sample-hello-tab-english.png)
414
432
  ![glimmer dsl tk screenshot sample hello tab French](images/glimmer-dsl-tk-screenshot-sample-hello-tab-french.png)
415
433
 
416
- ### Hello, Combo!
434
+ ### Hello, Message Box!
435
+
436
+ Glimmer code (from [samples/hello/hello_message_box.rb](samples/hello/hello_message_box.rb)):
437
+
438
+ ```ruby
439
+ root { |r|
440
+ title 'Hello, Message Box!'
441
+
442
+ frame {
443
+ grid sticky: 'nsew', padx: 15, pady: 15
444
+
445
+ button {
446
+ text 'Please Click To Win a Surprise'
447
+
448
+ command {
449
+ # specifying parent ensures dialog shows up centered on top of window (instead of centered in display monitor)
450
+ @result_label.text = message_box(parent: r, title: 'Surprise', message: "Congratulations!\n\nYou won $1,000,000!") # type: 'ok' by default
451
+ }
452
+ }
453
+
454
+ button {
455
+ text 'Download Software Update'
456
+
457
+ command {
458
+ @result_label.text = message_box(type: 'okcancel', title: 'Software Update', message: "We will begin to download software update.")
459
+ }
460
+ }
461
+
462
+ button {
463
+ text 'Format Hard Drive'
464
+
465
+ command {
466
+ @result_label.text = message_box(type: 'yesno', icon: 'question', title: 'Format', message: "Would you like to format your hard drive?")
467
+ }
468
+ }
469
+
470
+ button {
471
+ text 'Submit Application'
472
+
473
+ command {
474
+ @result_label.text = message_box(type: 'yesnocancel', icon: 'question', title: 'Application', message: "Would you like to review application before submitting?")
475
+ }
476
+ }
477
+
478
+ button {
479
+ text 'Play Video'
480
+
481
+ command {
482
+ @result_label.text = message_box(type: 'retrycancel', icon: 'error', title: 'Video Replay', message: "Video has failed to play. Would you like to retry?")
483
+ }
484
+ }
485
+
486
+ button {
487
+ text 'Installation Completed'
488
+
489
+ command {
490
+ @result_label.text = message_box(type: 'abortretryignore', icon: 'warning', default: 'ignore', title: 'Failed To Install Extra Utilities', message: "Installation is complete, but extra utilities have failed to install. Would you like to retry installing extra utilities?", detail: 'Encountered network error in downloading extra utilities, resulting in failure to install them')
491
+ }
492
+ }
493
+ }
494
+
495
+ frame {
496
+ grid sticky: 'nsew', padx: 15, pady: 15
497
+
498
+ label {
499
+ grid row: 0, column: 0
500
+ text 'Result:'
501
+ }
502
+
503
+ @result_label = label {
504
+ grid row: 0, column: 1
505
+ }
506
+ }
507
+ }.open
508
+ ```
509
+
510
+ Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
511
+
512
+ ```
513
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_tab'"
514
+ ```
515
+
516
+ Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
517
+
518
+ ```
519
+ ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_tab'"
520
+ ```
521
+
522
+ Glimmer app:
523
+
524
+ ![glimmer dsl tk screenshot sample hello message box](images/glimmer-dsl-tk-screenshot-sample-hello-message-box.png)
525
+ ![glimmer dsl tk screenshot sample hello message box open](images/glimmer-dsl-tk-screenshot-sample-hello-message-box-open.png)
526
+
527
+ ### Hello, Combobox!
417
528
 
418
- Glimmer code (from [samples/hello/hello_combo.rb](samples/hello/hello_combo.rb)):
529
+ Glimmer code (from [samples/hello/hello_combobox.rb](samples/hello/hello_combobox.rb)):
419
530
 
420
531
  ```ruby
421
532
  # ... more code precedes
422
533
  root {
423
- title 'Hello, Combo!'
534
+ title 'Hello, Combobox!'
424
535
 
425
536
  combobox { |proxy|
426
537
  state 'readonly'
427
- text bind(person, :country)
538
+ text <=> [person, :country]
428
539
  }
429
540
 
430
541
  button { |proxy|
@@ -440,19 +551,19 @@ root {
440
551
  Run with [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
441
552
 
442
553
  ```
443
- ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_combo'"
554
+ ruby -r glimmer-dsl-tk -e "require 'samples/hello/hello_combobox'"
444
555
  ```
445
556
 
446
557
  Alternatively, run from cloned project without [glimmer-dsl-tk](https://rubygems.org/gems/glimmer-dsl-tk) gem installed:
447
558
 
448
559
  ```
449
- ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_combo'"
560
+ ruby -e "require './lib/glimmer-dsl-tk'; require './samples/hello/hello_combobox'"
450
561
  ```
451
562
 
452
563
  Glimmer app:
453
564
 
454
- ![glimmer dsl tk screenshot sample hello combo](images/glimmer-dsl-tk-screenshot-sample-hello-combo.png)
455
- ![glimmer dsl tk screenshot sample hello combo dropdown](images/glimmer-dsl-tk-screenshot-sample-hello-combo-dropdown.png)
565
+ ![glimmer dsl tk screenshot sample hello combobox](images/glimmer-dsl-tk-screenshot-sample-hello-combobox.png)
566
+ ![glimmer dsl tk screenshot sample hello combobox dropdown](images/glimmer-dsl-tk-screenshot-sample-hello-combobox-dropdown.png)
456
567
 
457
568
  ### Hello, List Single Selection!
458
569
 
@@ -465,7 +576,7 @@ root {
465
576
 
466
577
  list {
467
578
  selectmode 'browse'
468
- selection bind(person, :country)
579
+ selection <=> [person, :country]
469
580
  }
470
581
 
471
582
  button {
@@ -503,7 +614,7 @@ root {
503
614
  title 'Hello, List Multi Selection!'
504
615
 
505
616
  list {
506
- selection bind(person, :provinces)
617
+ selection <=> [person, :provinces]
507
618
  }
508
619
 
509
620
  button {
@@ -550,7 +661,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
550
661
  entry {
551
662
  grid column: 1, row: 0
552
663
  width 15
553
- text bind(@contact, :first_name)
664
+ text <=> [@contact, :first_name]
554
665
  }
555
666
 
556
667
  label {
@@ -560,7 +671,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
560
671
  entry {
561
672
  grid column: 1, row: 1
562
673
  width 15
563
- text bind(@contact, :last_name)
674
+ text <=> [@contact, :last_name]
564
675
  }
565
676
 
566
677
  label {
@@ -570,7 +681,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
570
681
  entry {
571
682
  grid column: 1, row: 2
572
683
  width 15
573
- text bind(@contact, :year_of_birth)
684
+ text <=> [@contact, :year_of_birth]
574
685
  }
575
686
 
576
687
  label {
@@ -579,7 +690,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
579
690
  }
580
691
  label {
581
692
  grid column: 1, row: 3, sticky: 'w'
582
- text bind(@contact, :name, computed_by: [:first_name, :last_name])
693
+ text <=> [@contact, :name, computed_by: [:first_name, :last_name]]
583
694
  }
584
695
 
585
696
  label {
@@ -588,7 +699,7 @@ Glimmer code (from [samples/hello/hello_computed.rb](samples/hello/hello_compute
588
699
  }
589
700
  label {
590
701
  grid column: 1, row: 4, sticky: 'w'
591
- text bind(@contact, :age, on_write: :to_i, computed_by: [:year_of_birth])
702
+ text <=> [@contact, :age, on_write: :to_i, computed_by: [:year_of_birth]]
592
703
  }
593
704
  }
594
705
  }.open
@@ -629,7 +740,7 @@ If you need live help, try to [![Join the chat at https://gitter.im/AndyObtiva/g
629
740
 
630
741
  ## Planned Features and Feature Suggestions
631
742
 
632
- These features have been planned or suggested. You might see them in a future version of Glimmer DSL for Tk. You are welcome to contribute more feature suggestions.
743
+ These features have been planned or suggested. You might see them in a future version of [Glimmer DSL for Tk](https://rubygems.org/gems/glimmer-dsl-tk). You are welcome to contribute more feature suggestions.
633
744
 
634
745
  [TODO.md](TODO.md)
635
746
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.9
1
+ 0.0.13
data/bin/girb CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Copyright (c) 2007-2021 Andy Maleh
3
+ # Copyright (c) 2020-2021 Andy Maleh
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining
6
6
  # a copy of this software and associated documentation files (the
data/bin/girb_runner.rb CHANGED
@@ -1,3 +1,24 @@
1
+ # Copyright (c) 2020-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
+
1
22
  require 'puts_debuggerer'
2
23
  require 'fileutils'
3
24
  require 'etc'
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,36 @@
1
+ # Copyright (c) 2020-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/static_expression'
23
+ require 'glimmer/tk/root_proxy'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module Tk
28
+ class MessageBoxExpression < StaticExpression
29
+ def interpret(parent, keyword, *args, &block)
30
+ args.first[:parent] = args.first[:parent].tk if args.first.is_a?(Hash) && args.first[:parent].is_a?(Glimmer::Tk::RootProxy)
31
+ ::Tk::messageBox(*args)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -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
@@ -58,3 +58,4 @@ require 'glimmer/tk/button_proxy'
58
58
  require 'glimmer/tk/label_proxy'
59
59
  require 'glimmer/tk/list_proxy'
60
60
  require 'glimmer/tk/entry_proxy'
61
+ require 'glimmer/tk/treeview_proxy'
@@ -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)
@@ -0,0 +1,50 @@
1
+ # Copyright (c) 2020-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/tk/widget_proxy'
23
+
24
+ module Glimmer
25
+ module Tk
26
+ # Custom treeview widget implementation
27
+ class TreeviewProxy < WidgetProxy
28
+ def has_attribute?(attribute, *args)
29
+ attribute == 'columns' || super
30
+ end
31
+
32
+ def set_attribute(attribute, *args)
33
+ if attribute == 'columns'
34
+ self[attribute] = args.first
35
+ else
36
+ super
37
+ end
38
+ end
39
+
40
+ def get_attribute(attribute)
41
+ if attribute == 'columns'
42
+ self[attribute]
43
+ else
44
+ super
45
+ end
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -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
@@ -133,7 +134,7 @@ module Glimmer
133
134
  elsif tk_widget_has_attribute_setter?(attribute)
134
135
  @tk.send(attribute_setter(attribute), *args) unless @tk.send(attribute) == args.first
135
136
  elsif tk_widget_has_attribute_getter_setter?(attribute)
136
- @tk.send(attribute, *args) unless @tk.send(attribute) == args.first
137
+ @tk.send(attribute, *args)
137
138
  else
138
139
  send(attribute_setter(attribute), args)
139
140
  end
@@ -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)
@@ -34,18 +34,18 @@ class Person
34
34
  end
35
35
  end
36
36
 
37
- class HelloCombo
37
+ class HelloCombobox
38
38
  include Glimmer
39
39
 
40
40
  def launch
41
41
  person = Person.new
42
42
 
43
43
  root {
44
- title 'Hello, Combo!'
44
+ title 'Hello, Combobox!'
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 {
@@ -58,4 +58,4 @@ class HelloCombo
58
58
  end
59
59
  end
60
60
 
61
- HelloCombo.new.launch
61
+ HelloCombobox.new.launch
@@ -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 {
@@ -0,0 +1,94 @@
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-tk'
23
+
24
+ include Glimmer
25
+
26
+ root { |r|
27
+ title 'Hello, Message Box!'
28
+
29
+ frame {
30
+ grid sticky: 'nsew', padx: 15, pady: 15
31
+
32
+ button {
33
+ text 'Please Click To Win a Surprise'
34
+
35
+ command {
36
+ # specifying parent ensures dialog shows up centered on top of window (instead of centered in display monitor)
37
+ @result_label.text = message_box(parent: r, title: 'Surprise', message: "Congratulations!\n\nYou won $1,000,000!") # type: 'ok' by default
38
+ }
39
+ }
40
+
41
+ button {
42
+ text 'Download Software Update'
43
+
44
+ command {
45
+ @result_label.text = message_box(type: 'okcancel', title: 'Software Update', message: "We will begin to download software update.")
46
+ }
47
+ }
48
+
49
+ button {
50
+ text 'Format Hard Drive'
51
+
52
+ command {
53
+ @result_label.text = message_box(type: 'yesno', icon: 'question', title: 'Format', message: "Would you like to format your hard drive?")
54
+ }
55
+ }
56
+
57
+ button {
58
+ text 'Submit Application'
59
+
60
+ command {
61
+ @result_label.text = message_box(type: 'yesnocancel', icon: 'question', title: 'Application', message: "Would you like to review application before submitting?")
62
+ }
63
+ }
64
+
65
+ button {
66
+ text 'Play Video'
67
+
68
+ command {
69
+ @result_label.text = message_box(type: 'retrycancel', icon: 'error', title: 'Video Replay', message: "Video has failed to play. Would you like to retry?")
70
+ }
71
+ }
72
+
73
+ button {
74
+ text 'Installation Completed'
75
+
76
+ command {
77
+ @result_label.text = message_box(type: 'abortretryignore', icon: 'warning', default: 'ignore', title: 'Failed To Install Extra Utilities', message: "Installation is complete, but extra utilities have failed to install. Would you like to retry installing extra utilities?", detail: 'Encountered network error in downloading extra utilities, resulting in failure to install them')
78
+ }
79
+ }
80
+ }
81
+
82
+ frame {
83
+ grid sticky: 'nsew', padx: 15, pady: 15
84
+
85
+ label {
86
+ grid row: 0, column: 0
87
+ text 'Result:'
88
+ }
89
+
90
+ @result_label = label {
91
+ grid row: 0, column: 1
92
+ }
93
+ }
94
+ }.open
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.9
4
+ version: 0.0.13
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-14 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
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: puts_debuggerer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.13.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.13.1
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: tk
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -114,20 +128,6 @@ dependencies:
114
128
  - - ">="
115
129
  - !ruby/object:Gem::Version
116
130
  version: 0.2.1
117
- - !ruby/object:Gem::Dependency
118
- name: puts_debuggerer
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: 0.13.1
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - "~>"
129
- - !ruby/object:Gem::Version
130
- version: 0.13.1
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: coveralls
133
133
  requirement: !ruby/object:Gem::Requirement
@@ -186,6 +186,7 @@ files:
186
186
  - VERSION
187
187
  - bin/girb
188
188
  - bin/girb_runner.rb
189
+ - glimmer-dsl-tk.gemspec
189
190
  - icons/glimmer.png
190
191
  - lib/glimmer-dsl-tk.rb
191
192
  - lib/glimmer/data_binding/tk/list_selection_binding.rb
@@ -196,7 +197,9 @@ files:
196
197
  - lib/glimmer/dsl/tk/data_binding_expression.rb
197
198
  - lib/glimmer/dsl/tk/dsl.rb
198
199
  - lib/glimmer/dsl/tk/list_selection_data_binding_expression.rb
200
+ - lib/glimmer/dsl/tk/message_box_expression.rb
199
201
  - lib/glimmer/dsl/tk/root_expression.rb
202
+ - lib/glimmer/dsl/tk/shine_data_binding_expression.rb
200
203
  - lib/glimmer/dsl/tk/widget_expression.rb
201
204
  - lib/glimmer/tk/button_proxy.rb
202
205
  - lib/glimmer/tk/entry_proxy.rb
@@ -205,12 +208,14 @@ files:
205
208
  - lib/glimmer/tk/list_proxy.rb
206
209
  - lib/glimmer/tk/notebook_proxy.rb
207
210
  - lib/glimmer/tk/root_proxy.rb
211
+ - lib/glimmer/tk/treeview_proxy.rb
208
212
  - lib/glimmer/tk/widget_proxy.rb
209
- - samples/hello/hello_combo.rb
213
+ - samples/hello/hello_combobox.rb
210
214
  - samples/hello/hello_computed.rb
211
215
  - samples/hello/hello_computed/contact.rb
212
216
  - samples/hello/hello_list_multi_selection.rb
213
217
  - samples/hello/hello_list_single_selection.rb
218
+ - samples/hello/hello_message_box.rb
214
219
  - samples/hello/hello_tab.rb
215
220
  - samples/hello/hello_world.rb
216
221
  homepage: http://github.com/AndyObtiva/glimmer-dsl-tk
@@ -233,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
238
  - !ruby/object:Gem::Version
234
239
  version: '0'
235
240
  requirements: []
236
- rubygems_version: 3.2.22
241
+ rubygems_version: 3.2.28
237
242
  signing_key:
238
243
  specification_version: 4
239
244
  summary: Glimmer DSL for Tk