glimmer-dsl-gtk 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +16 -0
- data/LICENSE.txt +20 -0
- data/README.md +340 -0
- data/VERSION +1 -0
- data/bin/girb +30 -0
- data/bin/girb_runner.rb +45 -0
- data/glimmer-dsl-gtk.gemspec +0 -0
- data/lib/glimmer/dsl/gtk/dsl.rb +45 -0
- data/lib/glimmer/dsl/gtk/on_expression.rb +35 -0
- data/lib/glimmer/dsl/gtk/property_expression.rb +41 -0
- data/lib/glimmer/dsl/gtk/widget_expression.rb +50 -0
- data/lib/glimmer/gtk/widget_proxy/application_proxy.rb +39 -0
- data/lib/glimmer/gtk/widget_proxy/box_proxy.rb +40 -0
- data/lib/glimmer/gtk/widget_proxy/message_dialog_proxy.rb +42 -0
- data/lib/glimmer/gtk/widget_proxy/window_proxy.rb +75 -0
- data/lib/glimmer/gtk/widget_proxy.rb +165 -0
- data/lib/glimmer/gtk.rb +39 -0
- data/lib/glimmer-dsl-gtk.rb +46 -0
- data/samples/hello/hello_application.rb +11 -0
- data/samples/hello/hello_button.rb +20 -0
- data/samples/hello/hello_entry.rb +30 -0
- data/samples/hello/hello_world.rb +9 -0
- metadata +201 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 37b724fe82d4b303b72b38e85fe8a12e14c5164af68c547aa40eaec4111a3a8c
|
4
|
+
data.tar.gz: aea4c43156733bc5930e4723da0690f1fd13e58495f1e3c4a253474047b3b046
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2b3a8cf4fe19a15e10a43509c5bbb34d5f3bceaeedae2fe390090704fb0e9b1b33de32e5b5e66efcd02ab4861b01c135e7fa7b54b2baaad794ede6f3afdf57c0
|
7
|
+
data.tar.gz: a8b55bba6bfdd4573cc2ee7bed84710861e75ac05ade6ae9e58a06279637a6800af2ac9272dd60c18eb7a82a70a677483b27098dd10036f39df989e4c15f3187
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## 0.0.1
|
4
|
+
|
5
|
+
- Initial version of Glimmer DSL for GTK
|
6
|
+
- General widget support with keyword arguments (e.g. `window(:toplevel).show`)
|
7
|
+
- General widget property support (e.g. `title 'Hello, Application!'`)
|
8
|
+
- General signal connect support via nested `on` keyword (e.g. `on(:activate) { ... }`)
|
9
|
+
- Have `window` automatically call `::Gtk::main_quit` upon hitting `window` close (destroy) button
|
10
|
+
- Automatically set `window` `default_size` to `190, 150` by default
|
11
|
+
- Automatically set `message_dialog` `default_width` to `190` by default
|
12
|
+
- Automatically set `application` first arg to `'org.glimmer-dsl-gtk.application'` and second arg to `:flags_none` when not supplied
|
13
|
+
- Automatically set `box` orientation to `:vertical` if not specified
|
14
|
+
- Hello, World! sample
|
15
|
+
- Hello, Application! sample
|
16
|
+
- Hello, Button! sample
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 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.
|
data/README.md
ADDED
@@ -0,0 +1,340 @@
|
|
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 GTK 0.0.1
|
2
|
+
## Ruby-GNOME Desktop Development GUI Library
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/glimmer-dsl-gtk.svg)](http://badge.fury.io/rb/glimmer-dsl-gtk)
|
4
|
+
[![Join the chat at https://gitter.im/AndyObtiva/glimmer](https://badges.gitter.im/AndyObtiva/glimmer.svg)](https://gitter.im/AndyObtiva/glimmer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
|
+
|
6
|
+
[Glimmer](https://github.com/AndyObtiva/glimmer) DSL for [GTK](https://www.gtk.org/) enables building desktop applications with [Ruby-GNOME](https://github.com/ruby-gnome/ruby-gnome).
|
7
|
+
|
8
|
+
[GTK](https://www.gtk.org/) (aka GIMP-Toolkit or [incorrectly] GNOME-Toolkit) is the premiere desktop GUI toolkit on [Linux](https://www.gtk.org/docs/installations/linux/), which also runs on [Mac](https://www.gtk.org/docs/installations/macos/) ([Quartz GTK+](https://wiki.gnome.org/Projects/GTK/OSX)) and [Windows](https://www.gtk.org/docs/installations/windows).
|
9
|
+
|
10
|
+
[Glimmer DSL for GTK](https://rubygems.org/gems/glimmer-dsl-gtk) aims to supercharge productivity and maintainability in developing [Ruby-GNOME](https://github.com/ruby-gnome/ruby-gnome) applications by providing a DSL similar to [Glimmer DSL for SWT](https://github.com/AndyObtiva/glimmer-dsl-swt) having:
|
11
|
+
- Declarative DSL syntax that visually maps to the GUI widget hierarchy
|
12
|
+
- Convention over configuration via smart defaults and automation of low-level details
|
13
|
+
- Requiring the least amount of syntax possible to build GUI
|
14
|
+
- Custom Keyword support
|
15
|
+
- Bidirectional Data-Binding to declaratively wire and automatically synchronize GUI with Business Models
|
16
|
+
- Scaffolding for new custom widgets, apps, and gems
|
17
|
+
- Native-Executable packaging on Mac, Windows, and Linux.
|
18
|
+
|
19
|
+
Hello, World!
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
window {
|
23
|
+
title 'Hello, World!'
|
24
|
+
|
25
|
+
label('Hello, World!')
|
26
|
+
}.show
|
27
|
+
```
|
28
|
+
|
29
|
+
Mac Screenshot:
|
30
|
+
|
31
|
+
![hello world screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-world.png)
|
32
|
+
|
33
|
+
NOTE: Glimmer DSL for GTK is currently in early alpha mode (incomplete proof-of-concept). 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.
|
34
|
+
|
35
|
+
Other [Glimmer](https://rubygems.org/gems/glimmer) DSL gems you might be interested in:
|
36
|
+
- [glimmer-dsl-swt](https://github.com/AndyObtiva/glimmer-dsl-swt): Glimmer DSL for SWT (JRuby Desktop Development GUI Framework)
|
37
|
+
- [glimmer-dsl-opal](https://github.com/AndyObtiva/glimmer-dsl-opal): Glimmer DSL for Opal (Pure Ruby Web GUI and Auto-Webifier of Desktop Apps)
|
38
|
+
- [glimmer-dsl-tk](https://github.com/AndyObtiva/glimmer-dsl-tk): Glimmer DSL for Tk (MRI Ruby Desktop Development GUI Library)
|
39
|
+
- [glimmer-dsl-libui](https://github.com/AndyObtiva/glimmer-dsl-libui): Glimmer DSL for Tk (Prerequisite-Free Ruby Desktop Development GUI Library)
|
40
|
+
- [glimmer-dsl-xml](https://github.com/AndyObtiva/glimmer-dsl-xml): Glimmer DSL for XML (& HTML)
|
41
|
+
- [glimmer-dsl-css](https://github.com/AndyObtiva/glimmer-dsl-css): Glimmer DSL for CSS
|
42
|
+
|
43
|
+
## Setup
|
44
|
+
|
45
|
+
### Option 1: Install
|
46
|
+
|
47
|
+
Run this command to install directly:
|
48
|
+
```
|
49
|
+
gem install glimmer-dsl-gtk
|
50
|
+
```
|
51
|
+
|
52
|
+
### Option 2: Bundler
|
53
|
+
|
54
|
+
Add the following to `Gemfile`:
|
55
|
+
```
|
56
|
+
gem 'glimmer-dsl-gtk', '~> 0.0.1'
|
57
|
+
```
|
58
|
+
|
59
|
+
And, then run:
|
60
|
+
```
|
61
|
+
bundle
|
62
|
+
```
|
63
|
+
|
64
|
+
## Usage
|
65
|
+
|
66
|
+
Require the library and mixin the `Glimmer` module to utilize the Glimmer GUI DSL for GTK:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
require 'glimmer-dsl-gtk'
|
70
|
+
|
71
|
+
include Glimmer
|
72
|
+
|
73
|
+
window {
|
74
|
+
title 'Demo'
|
75
|
+
|
76
|
+
on(:destroy) do
|
77
|
+
puts 'Bye Bye'
|
78
|
+
::Gtk.main_quit
|
79
|
+
end
|
80
|
+
}.show
|
81
|
+
```
|
82
|
+
|
83
|
+
For actual application development outside of simple demos, mixin the `Glimmer` module into an application class instead:
|
84
|
+
|
85
|
+
```
|
86
|
+
require 'glimmer-dsl-gtk'
|
87
|
+
|
88
|
+
class SomeGlimmerApplication
|
89
|
+
include Glimmer
|
90
|
+
|
91
|
+
def launch
|
92
|
+
application('org.glimmer.hello-application', :flags_none) {
|
93
|
+
on(:activate) do |app|
|
94
|
+
application_window(app) {
|
95
|
+
title 'Actual Application'
|
96
|
+
}.present
|
97
|
+
end
|
98
|
+
}.run
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
SomeGlimmerApplication.new.launch
|
103
|
+
```
|
104
|
+
|
105
|
+
### Glimmer GUI DSL
|
106
|
+
|
107
|
+
- Keywords: All GTK widgets are supported via lowercase underscored names accepting their constructor args (e.g. `application_window(app)` for `Gtk::ApplicationWindow.new(app)`). Keywords can be nested under other keywords to represent the true hierarchy of nested widgets on the screen (e.g. `window { label('Hello') }` is a `label` nested under a `window`). Note that widget objects returned are proxies of the GTK widget counterparts. This shields consumers of GTK from its lower-level details via composition (Proxy Design Pattern). To access lower-level GTK widget, simply call `#gtk` method on widget proxy object (e.g. `@w = window {...}; @w.gtk # Gtk::Window widget object`).
|
108
|
+
- Content: widget keywords can have a block of content that could contain nested widget keywords, properties, and signals. The block can optionally receive one argument representing the widget (e.g. `window {|w| ... }`):
|
109
|
+
- Properties: All GTK widget properties can be set via lowercase underscored names (without the 'set_' prefix) nested under widget keywords (e.g. `window {title 'Hello, World'}` sets `title` property of `window`)
|
110
|
+
- Signals: All GTK signals can be wired with `on(signal) { ... }` syntax (e.g. `on(:activate) { do_something }`)
|
111
|
+
|
112
|
+
## Girb (Glimmer IRB)
|
113
|
+
|
114
|
+
You can run the `girb` command (`bin/girb` if you cloned the project locally):
|
115
|
+
|
116
|
+
```
|
117
|
+
girb
|
118
|
+
```
|
119
|
+
|
120
|
+
![girb screenshot](/screenshots/glimmer-dsl-gtk-mac-girb.png)
|
121
|
+
|
122
|
+
This gives you `irb` with the `glimmer-dsl-gtk` gem loaded and the `Glimmer` module mixed into the main object for easy experimentation with GUI.
|
123
|
+
|
124
|
+
Gotcha: On the Mac, when you close a window opened in `girb`, it remains open until you enter exit or open another GUI window.
|
125
|
+
|
126
|
+
## Samples
|
127
|
+
|
128
|
+
### Hello Samples
|
129
|
+
|
130
|
+
#### Hello, World!
|
131
|
+
|
132
|
+
[samples/hello/hello_world.rb](/samples/hello/hello_world.rb)
|
133
|
+
|
134
|
+
Mac Screenshot:
|
135
|
+
|
136
|
+
![hello world screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-world.png)
|
137
|
+
|
138
|
+
Run (via installed gem):
|
139
|
+
|
140
|
+
```
|
141
|
+
ruby -r glimmer-dsl-gtk -e "require 'samples/hello/hello_world'"
|
142
|
+
```
|
143
|
+
|
144
|
+
Run (via locally cloned project):
|
145
|
+
|
146
|
+
```
|
147
|
+
ruby -r ./lib/glimmer-dsl-gtk.rb samples/hello/hello_world.rb
|
148
|
+
```
|
149
|
+
|
150
|
+
Code:
|
151
|
+
|
152
|
+
```ruby
|
153
|
+
window {
|
154
|
+
title 'Hello, World!'
|
155
|
+
|
156
|
+
label('Hello, World!')
|
157
|
+
}.show
|
158
|
+
```
|
159
|
+
|
160
|
+
#### Hello, Application!
|
161
|
+
|
162
|
+
[samples/hello/hello_application.rb](/samples/hello/hello_application.rb)
|
163
|
+
|
164
|
+
Mac Screenshot:
|
165
|
+
|
166
|
+
![hello application screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-application.png)
|
167
|
+
|
168
|
+
Run (via installed gem):
|
169
|
+
|
170
|
+
```
|
171
|
+
ruby -r glimmer-dsl-gtk -e "require 'samples/hello/hello_application'"
|
172
|
+
```
|
173
|
+
|
174
|
+
Run (via locally cloned project):
|
175
|
+
|
176
|
+
```
|
177
|
+
ruby -r ./lib/glimmer-dsl-gtk.rb samples/hello/hello_application.rb
|
178
|
+
```
|
179
|
+
|
180
|
+
Code:
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
require 'glimmer-dsl-gtk'
|
184
|
+
|
185
|
+
include Glimmer
|
186
|
+
|
187
|
+
application('org.glimmer.hello-application', :flags_none) {
|
188
|
+
on(:activate) do |app|
|
189
|
+
application_window(app) {
|
190
|
+
title 'Hello, Application!'
|
191
|
+
}.present
|
192
|
+
end
|
193
|
+
}.run
|
194
|
+
```
|
195
|
+
|
196
|
+
#### Hello, Button!
|
197
|
+
|
198
|
+
[samples/hello/hello_button.rb](/samples/hello/hello_button.rb)
|
199
|
+
|
200
|
+
Mac Screenshot:
|
201
|
+
|
202
|
+
![hello button screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-button.png)
|
203
|
+
|
204
|
+
![hello button clicked screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-button-clicked.png)
|
205
|
+
|
206
|
+
Run (via installed gem):
|
207
|
+
|
208
|
+
```
|
209
|
+
ruby -r glimmer-dsl-gtk -e "require 'samples/hello/hello_button'"
|
210
|
+
```
|
211
|
+
|
212
|
+
Run (via locally cloned project):
|
213
|
+
|
214
|
+
```
|
215
|
+
ruby -r ./lib/glimmer-dsl-gtk.rb samples/hello/hello_button.rb
|
216
|
+
```
|
217
|
+
|
218
|
+
Code:
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
require 'glimmer-dsl-gtk'
|
222
|
+
|
223
|
+
include Glimmer
|
224
|
+
|
225
|
+
window { |w|
|
226
|
+
title 'Hello, Button!'
|
227
|
+
|
228
|
+
button('Button') {
|
229
|
+
on(:clicked) do
|
230
|
+
message_dialog(w) { |md|
|
231
|
+
title 'Information'
|
232
|
+
text 'You clicked the button'
|
233
|
+
|
234
|
+
on(:response) do
|
235
|
+
md.destroy
|
236
|
+
end
|
237
|
+
}.show
|
238
|
+
end
|
239
|
+
}
|
240
|
+
}.show
|
241
|
+
```
|
242
|
+
|
243
|
+
#### Hello, Entry!
|
244
|
+
|
245
|
+
[samples/hello/hello_entry.rb](/samples/hello/hello_entry.rb)
|
246
|
+
|
247
|
+
Mac Screenshot:
|
248
|
+
|
249
|
+
![hello entry screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-entry.png)
|
250
|
+
|
251
|
+
![hello entry submitted screenshot](/screenshots/glimmer-dsl-gtk-mac-hello-entry-submitted.png)
|
252
|
+
|
253
|
+
Run (via installed gem):
|
254
|
+
|
255
|
+
```
|
256
|
+
ruby -r glimmer-dsl-gtk -e "require 'samples/hello/hello_entry'"
|
257
|
+
```
|
258
|
+
|
259
|
+
Run (via locally cloned project):
|
260
|
+
|
261
|
+
```
|
262
|
+
ruby -r ./lib/glimmer-dsl-gtk.rb samples/hello/hello_entry.rb
|
263
|
+
```
|
264
|
+
|
265
|
+
Code:
|
266
|
+
|
267
|
+
```ruby
|
268
|
+
require 'glimmer-dsl-gtk'
|
269
|
+
|
270
|
+
include Glimmer
|
271
|
+
|
272
|
+
window { |w|
|
273
|
+
title 'Hello, Entry!'
|
274
|
+
default_size 300, 50
|
275
|
+
|
276
|
+
box(:vertical) {
|
277
|
+
e = entry {
|
278
|
+
on(:changed) do
|
279
|
+
puts e.text
|
280
|
+
$stdout.flush # For Windows
|
281
|
+
end
|
282
|
+
}
|
283
|
+
|
284
|
+
button('Button') {
|
285
|
+
on(:clicked) do
|
286
|
+
message_dialog(w) { |md|
|
287
|
+
title 'You entered'
|
288
|
+
text e.text
|
289
|
+
|
290
|
+
on(:response) do
|
291
|
+
md.destroy
|
292
|
+
end
|
293
|
+
}.show
|
294
|
+
end
|
295
|
+
}
|
296
|
+
}
|
297
|
+
}.show
|
298
|
+
```
|
299
|
+
|
300
|
+
## Contributing
|
301
|
+
|
302
|
+
- Check out the latest master to make sure the feature hasn't been
|
303
|
+
implemented or the bug hasn't been fixed yet.
|
304
|
+
- Check out the issue tracker to make sure someone already hasn't
|
305
|
+
requested it and/or contributed it.
|
306
|
+
- Fork the project.
|
307
|
+
- Start a feature/bugfix branch.
|
308
|
+
- Commit and push until you are happy with your contribution.
|
309
|
+
- Make sure to add tests for it. This is important so I don't break it
|
310
|
+
in a future version unintentionally.
|
311
|
+
- Please try not to mess with the Rakefile, version, or history. If
|
312
|
+
you want to have your own version, or is otherwise necessary, that
|
313
|
+
is fine, but please isolate to its own commit so I can cherry-pick
|
314
|
+
around it.
|
315
|
+
|
316
|
+
## Planned Features and Feature Suggestions
|
317
|
+
|
318
|
+
These features have been planned or suggested. You might see them in a future version of [Glimmer DSL for GTK](https://rubygems.org/gems/glimmer-dsl-gtk). You are welcome to contribute more feature suggestions.
|
319
|
+
|
320
|
+
[TODO.md](TODO.md)
|
321
|
+
|
322
|
+
## Change Log
|
323
|
+
|
324
|
+
[CHANGELOG.md](CHANGELOG.md)
|
325
|
+
|
326
|
+
## Contributors
|
327
|
+
|
328
|
+
* [Andy Maleh](https://github.com/AndyObtiva) (Founder)
|
329
|
+
|
330
|
+
[Click here to view contributor commits.](https://github.com/AndyObtiva/glimmer-dsl-gtk/graphs/contributors)
|
331
|
+
|
332
|
+
## Copyright
|
333
|
+
|
334
|
+
[MIT](LICENSE.txt)
|
335
|
+
|
336
|
+
Copyright (c) 2021 Andy Maleh.
|
337
|
+
|
338
|
+
--
|
339
|
+
|
340
|
+
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built for [Glimmer](https://github.com/AndyObtiva/glimmer) (DSL Framework).
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/girb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright (c) 2020-2021 Andy Maleh
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
# This script was written for Windows and Linux only
|
25
|
+
|
26
|
+
require_relative 'girb_runner'
|
27
|
+
|
28
|
+
require 'irb'
|
29
|
+
|
30
|
+
IRB.start('.')
|
data/bin/girb_runner.rb
ADDED
@@ -0,0 +1,45 @@
|
|
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 'fileutils'
|
23
|
+
|
24
|
+
require_relative '../lib/glimmer-dsl-gtk'
|
25
|
+
|
26
|
+
include Glimmer
|
27
|
+
|
28
|
+
GIRB_RUNNER_EXIT_FILE = "#{Dir.home}/.glimmer_dsl_gtk_girb_runner_exit"
|
29
|
+
FileUtils.rm_rf GIRB_RUNNER_EXIT_FILE
|
30
|
+
|
31
|
+
@exit_method = method(:exit)
|
32
|
+
|
33
|
+
@exit_girb_block = lambda do
|
34
|
+
FileUtils.touch GIRB_RUNNER_EXIT_FILE
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.exit(*args)
|
38
|
+
@exit_girb_block.call
|
39
|
+
@exit_method.call(*args)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.quit(*args)
|
43
|
+
@exit_girb_block.call
|
44
|
+
@exit_method.call(*args)
|
45
|
+
end
|
Binary file
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Copyright (c) 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/engine'
|
23
|
+
Dir[File.expand_path('*_expression.rb', __dir__)].each {|f| require f}
|
24
|
+
|
25
|
+
# Glimmer DSL expression configuration module
|
26
|
+
#
|
27
|
+
# When DSL engine interprets an expression, it attempts to handle
|
28
|
+
# with expressions listed here in the order specified.
|
29
|
+
|
30
|
+
# Every expression has a corresponding Expression subclass
|
31
|
+
# in glimmer/dsl
|
32
|
+
|
33
|
+
module Glimmer
|
34
|
+
module DSL
|
35
|
+
module Gtk
|
36
|
+
Engine.add_dynamic_expressions(
|
37
|
+
Gtk,
|
38
|
+
%w[
|
39
|
+
property
|
40
|
+
widget
|
41
|
+
]
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Copyright (c) 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/gtk/widget_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module DSL
|
27
|
+
module Gtk
|
28
|
+
class OnExpression < StaticExpression
|
29
|
+
def interpret(parent, keyword, *args, &block)
|
30
|
+
parent.signal_connect(args.first, &block)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# Copyright (c) 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/gtk/widget_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module DSL
|
27
|
+
module Gtk
|
28
|
+
class PropertyExpression < Expression
|
29
|
+
def can_interpret?(parent, keyword, *args, &block)
|
30
|
+
parent.is_a?(Glimmer::Gtk::WidgetProxy) and
|
31
|
+
block.nil? and
|
32
|
+
parent.respond_to?(keyword, *args)
|
33
|
+
end
|
34
|
+
|
35
|
+
def interpret(parent, keyword, *args, &block)
|
36
|
+
parent.send(keyword, *args)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# Copyright (c) 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/dsl/parent_expression'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module DSL
|
27
|
+
module Gtk
|
28
|
+
class WidgetExpression < Expression
|
29
|
+
include ParentExpression
|
30
|
+
|
31
|
+
def can_interpret?(parent, keyword, *args, &block)
|
32
|
+
Glimmer::Gtk::WidgetProxy.exists?(keyword)
|
33
|
+
end
|
34
|
+
|
35
|
+
def interpret(parent, keyword, *args, &block)
|
36
|
+
@@inverted_keyword_aliases = Glimmer::Gtk::WidgetProxy::KEYWORD_ALIASES.invert unless defined?(@@inverted_keyword_aliases)
|
37
|
+
keyword = @@inverted_keyword_aliases[keyword] || keyword
|
38
|
+
Glimmer::Gtk::WidgetProxy.create(keyword, parent, args, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_content(parent, keyword, *args, &block)
|
42
|
+
super
|
43
|
+
parent.post_add_content
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
require 'glimmer/gtk/widget_proxy'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 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/gtk/widget_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module Gtk
|
26
|
+
class WidgetProxy
|
27
|
+
# Proxy for Gtk application objects
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class ApplicationProxy < WidgetProxy
|
31
|
+
def initialize(keyword, parent, args, &block)
|
32
|
+
args[0] = 'org.glimmer-dsl-gtk.application' if args[0].nil?
|
33
|
+
args[1] = :flags_none if args[1].nil?
|
34
|
+
super
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|