glimmer-dsl-tk 0.0.5 → 0.0.9

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.
@@ -1,5 +1,5 @@
1
- # Copyright (c) 2020 Andy Maleh
2
- #
1
+ # Copyright (c) 2020-2021 Andy Maleh
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -27,11 +27,14 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class RootProxy < WidgetProxy
30
-
31
30
  def initialize(*args)
32
31
  @tk = ::TkRoot.new
33
32
  end
34
33
 
34
+ def post_add_content
35
+ set_attribute('iconphoto', File.expand_path('../../../icons/glimmer.png', __dir__)) if @tk.iconphoto.nil?
36
+ end
37
+
35
38
  def open
36
39
  start_event_loop
37
40
  end
@@ -39,6 +42,17 @@ module Glimmer
39
42
  def content(&block)
40
43
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::RootExpression.new, &block)
41
44
  end
45
+
46
+ def set_attribute(attribute, *args)
47
+ if attribute.to_s == 'iconphoto'
48
+ if args.size == 1 && args.first.is_a?(String)
49
+ args[0] = ::TkPhotoImage.new(file: args.first)
50
+ end
51
+ super
52
+ else
53
+ super
54
+ end
55
+ end
42
56
 
43
57
  # Starts Tk mainloop
44
58
  def start_event_loop
@@ -1,5 +1,5 @@
1
- # Copyright (c) 2020 Andy Maleh
2
- #
1
+ # Copyright (c) 2020-2021 Andy Maleh
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -29,13 +29,13 @@ module Glimmer
29
29
 
30
30
  DEFAULT_INITIALIZERS = {
31
31
  'combobox' => lambda do |tk|
32
- tk.textvariable = ::TkVariable.new
32
+ tk.textvariable = ::TkVariable.new
33
33
  end,
34
34
  'label' => lambda do |tk|
35
- tk.textvariable = ::TkVariable.new
35
+ tk.textvariable = ::TkVariable.new
36
36
  end,
37
37
  'entry' => lambda do |tk|
38
- tk.textvariable = ::TkVariable.new
38
+ tk.textvariable = ::TkVariable.new
39
39
  end,
40
40
  }
41
41
 
@@ -50,17 +50,17 @@ module Glimmer
50
50
  Glimmer::Tk.const_get(class_name)
51
51
  rescue
52
52
  Glimmer::Tk::WidgetProxy
53
- end
53
+ end
54
54
  end
55
55
 
56
56
  # This supports widgets in and out of basic Tk
57
57
  def tk_widget_class_for(underscored_widget_name)
58
58
  tk_widget_class_basename = underscored_widget_name.camelcase(:upper)
59
59
  potential_tk_widget_class_names = [
60
- "::Tk::Tile::#{tk_widget_class_basename}",
61
- "::Tk::#{tk_widget_class_basename}",
62
- "::Tk#{tk_widget_class_basename}",
63
- "::Glimmer::Tk::#{tk_widget_class_basename}Proxy",
60
+ "::Tk::Tile::#{tk_widget_class_basename}",
61
+ "::Tk::#{tk_widget_class_basename}",
62
+ "::Tk#{tk_widget_class_basename}",
63
+ "::Glimmer::Tk::#{tk_widget_class_basename}Proxy",
64
64
  ]
65
65
  tk_widget_class = nil
66
66
  potential_tk_widget_class_names.each do |tk_widget_name|
@@ -69,11 +69,11 @@ module Glimmer
69
69
  break
70
70
  rescue RuntimeError, SyntaxError, NameError => e
71
71
  Glimmer::Config.logger.debug e.full_message
72
- end
72
+ end
73
73
  end
74
74
  tk_widget_class
75
75
  end
76
- end
76
+ end
77
77
 
78
78
  # Initializes a new Tk Widget
79
79
  #
@@ -81,11 +81,11 @@ module Glimmer
81
81
  def initialize(underscored_widget_name, parent_proxy, args)
82
82
  @parent_proxy = parent_proxy
83
83
  @args = args
84
- tk_widget_class = self.class.tk_widget_class_for(underscored_widget_name)
84
+ tk_widget_class = self.class.tk_widget_class_for(underscored_widget_name)
85
85
  @tk = tk_widget_class.new(@parent_proxy.tk, *args)
86
86
  # a common widget initializer
87
87
  @tk.grid
88
- DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@tk)
88
+ DEFAULT_INITIALIZERS[underscored_widget_name]&.call(@tk)
89
89
  @parent_proxy.post_initialize_child(self)
90
90
  end
91
91
 
@@ -105,32 +105,24 @@ module Glimmer
105
105
 
106
106
  def tk_widget_has_attribute_setter?(attribute)
107
107
  result = nil
108
- begin
109
- # TK Widget currently doesn't support respond_to? properly, so I have to resort to this trick for now
108
+ begin
109
+ # TK Widget currently doesn't support respond_to? properly, so I have to resort to this trick for now
110
110
  @tk.send(attribute_setter(attribute), @tk.send(attribute))
111
111
  result = true
112
112
  rescue => e
113
113
  result = false
114
114
  end
115
- result
115
+ result
116
116
  end
117
117
 
118
118
  def tk_widget_has_attribute_getter_setter?(attribute)
119
- result = nil
120
- begin
121
- # TK Widget currently doesn't support respond_to? properly, so I have to resort to this trick for now
122
- @tk.send(attribute, @tk.send(attribute))
123
- result = true
124
- rescue => e
125
- result = false
126
- end
127
- result
119
+ @tk.respond_to?(attribute)
128
120
  end
129
121
 
130
122
  def has_attribute?(attribute, *args)
131
- (widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][attribute.to_s]) ||
132
- tk_widget_has_attribute_setter?(attribute) ||
133
- tk_widget_has_attribute_getter_setter?(attribute) ||
123
+ (widget_custom_attribute_mapping[tk.class] && widget_custom_attribute_mapping[tk.class][attribute.to_s]) ||
124
+ tk_widget_has_attribute_setter?(attribute) ||
125
+ tk_widget_has_attribute_getter_setter?(attribute) ||
134
126
  respond_to?(attribute_setter(attribute), args)
135
127
  end
136
128
 
@@ -221,7 +213,7 @@ module Glimmer
221
213
  attribute_listener_installers = @tk.class.ancestors.map {|ancestor| widget_attribute_listener_installers[ancestor]}.compact
222
214
  widget_listener_installers = attribute_listener_installers.map{|installer| installer[attribute.to_s]}.compact if !attribute_listener_installers.empty?
223
215
  widget_listener_installers.to_a.first&.call(observer)
224
- end
216
+ end
225
217
 
226
218
  def content(&block)
227
219
  Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Tk::WidgetExpression.new, &block)
@@ -242,7 +234,7 @@ module Glimmer
242
234
  end
243
235
 
244
236
  def respond_to?(method, *args, &block)
245
- super ||
237
+ super ||
246
238
  tk.respond_to?(method, *args, &block)
247
239
  end
248
240
  end
@@ -1,5 +1,5 @@
1
- # Copyright (c) 2020 Andy Maleh
2
- #
1
+ # Copyright (c) 2020-2021 Andy Maleh
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -1,5 +1,5 @@
1
- # Copyright (c) 2020 Andy Maleh
2
- #
1
+ # Copyright (c) 2020-2021 Andy Maleh
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -21,10 +21,10 @@
21
21
 
22
22
  require 'glimmer-dsl-tk'
23
23
 
24
- class Person
24
+ class Person
25
25
  attr_accessor :country, :country_options
26
26
 
27
- def initialize
27
+ def initialize
28
28
  self.country_options=["", "Canada", "US", "Mexico"]
29
29
  self.country = "Canada"
30
30
  end
@@ -43,12 +43,12 @@ class HelloCombo
43
43
  root {
44
44
  title 'Hello, Combo!'
45
45
 
46
- combobox { |proxy|
47
- state 'readonly'
46
+ combobox {
47
+ state 'readonly'
48
48
  text bind(person, :country)
49
49
  }
50
50
 
51
- button { |proxy|
51
+ button {
52
52
  text "Reset Selection"
53
53
  command {
54
54
  person.reset_country
@@ -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 'glimmer-dsl-tk'
2
23
 
3
24
  require_relative 'hello_computed/contact'
@@ -17,7 +38,7 @@ class HelloComputed
17
38
  root {
18
39
  title 'Hello, Computed!'
19
40
 
20
- frame {
41
+ frame {
21
42
  grid column: 0, row: 0, padx: 5, pady: 5
22
43
 
23
44
  label {
@@ -1,5 +1,5 @@
1
- # Copyright (c) 2020 Andy Maleh
2
- #
1
+ # Copyright (c) 2020-2021 Andy Maleh
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -1,5 +1,5 @@
1
- # Copyright (c) 2020 Andy Maleh
2
- #
1
+ # Copyright (c) 2020-2021 Andy Maleh
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -21,7 +21,7 @@
21
21
 
22
22
  require 'glimmer-dsl-tk'
23
23
 
24
- class Person
24
+ class Person
25
25
  attr_accessor :country, :country_options
26
26
 
27
27
  def initialize
@@ -40,7 +40,7 @@ class HelloListSingleSelection
40
40
  def launch
41
41
  person = Person.new
42
42
 
43
- root {
43
+ root {
44
44
  title 'Hello, List Single Selection!'
45
45
 
46
46
  list {
@@ -1,5 +1,5 @@
1
- # Copyright (c) 2020 Andy Maleh
2
- #
1
+ # Copyright (c) 2020-2021 Andy Maleh
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -25,7 +25,7 @@ class HelloTab
25
25
  include Glimmer
26
26
 
27
27
  def launch
28
- root {
28
+ root {
29
29
  title 'Hello, Tab!'
30
30
 
31
31
  notebook {
@@ -1,5 +1,5 @@
1
- # Copyright (c) 2020 Andy Maleh
2
- #
1
+ # Copyright (c) 2020-2021 Andy Maleh
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining
4
4
  # a copy of this software and associated documentation files (the
5
5
  # "Software"), to deal in the Software without restriction, including
@@ -7,10 +7,10 @@
7
7
  # distribute, sublicense, and/or sell copies of the Software, and to
8
8
  # permit persons to whom the Software is furnished to do so, subject to
9
9
  # the following conditions:
10
- #
10
+ #
11
11
  # The above copyright notice and this permission notice shall be
12
12
  # included in all copies or substantial portions of the Software.
13
- #
13
+ #
14
14
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
15
  # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
16
  # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
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.5
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-15 00:00:00.000000000 Z
11
+ date: 2021-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glimmer
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.3
19
+ version: 2.1.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.3
26
+ version: 2.1.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: tk
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.2.0
33
+ version: 0.4.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.2.0
40
+ version: 0.4.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -120,14 +120,14 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: 0.10.0
123
+ version: 0.13.1
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: 0.10.0
130
+ version: 0.13.1
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: coveralls
133
133
  requirement: !ruby/object:Gem::Requirement
@@ -170,7 +170,7 @@ dependencies:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
172
  version: 0.7.0
173
- description: Glimmer DSL for Tk (Ruby Desktop GUI)
173
+ description: Glimmer DSL for Tk (Ruby Desktop Development GUI Library)
174
174
  email: andy.am@gmail.com
175
175
  executables:
176
176
  - girb
@@ -186,6 +186,7 @@ files:
186
186
  - VERSION
187
187
  - bin/girb
188
188
  - bin/girb_runner.rb
189
+ - icons/glimmer.png
189
190
  - lib/glimmer-dsl-tk.rb
190
191
  - lib/glimmer/data_binding/tk/list_selection_binding.rb
191
192
  - lib/glimmer/data_binding/tk/widget_binding.rb
@@ -220,6 +221,7 @@ post_install_message:
220
221
  rdoc_options: []
221
222
  require_paths:
222
223
  - lib
224
+ - "."
223
225
  required_ruby_version: !ruby/object:Gem::Requirement
224
226
  requirements:
225
227
  - - ">="
@@ -231,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
233
  - !ruby/object:Gem::Version
232
234
  version: '0'
233
235
  requirements: []
234
- rubygems_version: 3.1.2
236
+ rubygems_version: 3.2.22
235
237
  signing_key:
236
238
  specification_version: 4
237
239
  summary: Glimmer DSL for Tk