glimmer-cs-timer 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.md +80 -0
- data/VERSION +1 -0
- data/bin/glimmer-cs-timer +5 -0
- data/bin/timer +7 -0
- data/images/glimmer-timer-logo.png +0 -0
- data/lib/glimmer-cs-timer.rb +4 -0
- data/lib/views/glimmer/timer.rb +188 -0
- data/package/macosx/Timer.icns +0 -0
- data/package/windows/Timer.ico +0 -0
- data/sounds/alarm1.wav +0 -0
- data/vendor/org/yaml/snakeyaml/1.26/snakeyaml-1.26.jar +0 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 02f86919480f1cf766665393b6ac4c4228c6cef1690b1baf2f1b6934f64e3a34
|
4
|
+
data.tar.gz: 8d1d0accbb6b154e6a949eae330da76c9eb4ecfd6f6d98da43920c25e49fee16
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 539a27dd998411e9218613d8e09e49f4a2ce31822e9dac4a296615fbc9a9d04b5b4cef333e4730ad823b964a9ab1c426cac9bc5c2c41317b5abc7d9863562291
|
7
|
+
data.tar.gz: edbcf2f8797638190da40d38a1a5d4fb75ce0e313b7807e60abc7888a606eb884ed2377c742cc3661f76b9ca578078835760974044ec4340a1a9e10e082c226c
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2020 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,80 @@
|
|
1
|
+
# <img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/images/glimmer-timer-logo.png" height=80 /> Glimmer Timer
|
2
|
+
## [<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 /> Glimmer Custom Shell](https://github.com/AndyObtiva/glimmer#custom-shell-gem)
|
3
|
+
|
4
|
+
**Mac Version**
|
5
|
+
|
6
|
+
![glimmer-timer-screenshot](glimmer-timer-screenshot.png)
|
7
|
+
|
8
|
+
**Windows Version**
|
9
|
+
<br>
|
10
|
+
<br>
|
11
|
+
<br>
|
12
|
+
![glimmer-timer-screenshot-windows](glimmer-timer-screenshot-windows.png)
|
13
|
+
<br>
|
14
|
+
Glimmer Timer is a sample desktop GUI application built with Glimmer (Ruby Desktop Development Library).
|
15
|
+
|
16
|
+
Currently supports a countdown timer only.
|
17
|
+
|
18
|
+
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/images/glimmer-timer-logo.png" height=40 /> Download Mac Version](https://www.dropbox.com/s/cfd0rsjfuy3gexe/Timer-1.0.0.dmg?dl=1)
|
19
|
+
|
20
|
+
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer-cs-timer/master/images/glimmer-timer-logo.png" height=40 /> Download Windows Version](https://www.dropbox.com/s/z0auecd44crkn2l/Timer-1.0.0.msi?dl=1)
|
21
|
+
|
22
|
+
## Platforms
|
23
|
+
|
24
|
+
This has been tested and confirmed to be working on:
|
25
|
+
- Mac: [Download DMG File](https://www.dropbox.com/s/cfd0rsjfuy3gexe/Timer-1.0.0.dmg?dl=1)
|
26
|
+
- Windows: [Download MSI File](https://www.dropbox.com/s/z0auecd44crkn2l/Timer-1.0.0.msi?dl=1)
|
27
|
+
|
28
|
+
## Pre-requisites
|
29
|
+
|
30
|
+
- [Glimmer](https://github.com/AndyObtiva/glimmer) application, [Glimmer](https://github.com/AndyObtiva/glimmer) custom shell, or another [Glimmer](https://github.com/AndyObtiva/glimmer) custom widget
|
31
|
+
- JRuby version required by Glimmer
|
32
|
+
- Java version required by Glimmer
|
33
|
+
|
34
|
+
## Setup
|
35
|
+
|
36
|
+
### Glimmer Application
|
37
|
+
|
38
|
+
Add the following to a Glimmer application `Gemfile`:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
gem 'glimmer-cs-timer', '1.0.0'
|
42
|
+
```
|
43
|
+
|
44
|
+
Run:
|
45
|
+
|
46
|
+
```
|
47
|
+
jruby -S bundle
|
48
|
+
```
|
49
|
+
|
50
|
+
(or just `bundle` if using RVM)
|
51
|
+
|
52
|
+
### Glimmer Custom Shell or Glimmer Custom Widget
|
53
|
+
|
54
|
+
When reusing in a Glimmer custom shell or custom widget, you can follow the same steps for Glimmer application, and then add a require statement to your library file:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
require 'glimmer-cs-timer'
|
58
|
+
# ... more require statements follow
|
59
|
+
```
|
60
|
+
## Contributing to glimmer-cs-timer
|
61
|
+
|
62
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
63
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
64
|
+
* Fork the project.
|
65
|
+
* Start a feature/bugfix branch.
|
66
|
+
* Commit and push until you are happy with your contribution.
|
67
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
68
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
69
|
+
|
70
|
+
## Copyright
|
71
|
+
|
72
|
+
[MIT](https://opensource.org/licenses/MIT)
|
73
|
+
|
74
|
+
Copyright (c) 2020 Andy Maleh.
|
75
|
+
|
76
|
+
--
|
77
|
+
|
78
|
+
[<img src="https://raw.githubusercontent.com/AndyObtiva/glimmer/master/images/glimmer-logo-hi-res.png" height=40 />](https://github.com/AndyObtiva/glimmer) Built with [Glimmer](https://github.com/AndyObtiva/glimmer) (Ruby Desktop Development GUI Library)
|
79
|
+
|
80
|
+
Icon made by <a href="https://www.flaticon.com/authors/freepik" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon"> www.flaticon.com</a>
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/bin/timer
ADDED
Binary file
|
@@ -0,0 +1,188 @@
|
|
1
|
+
module Glimmer
|
2
|
+
class Timer
|
3
|
+
include Glimmer::UI::CustomShell
|
4
|
+
|
5
|
+
import 'javax.sound.sampled'
|
6
|
+
|
7
|
+
APP_ROOT = File.expand_path('../../../..', __FILE__)
|
8
|
+
VERSION = File.read(File.join(APP_ROOT, 'VERSION'))
|
9
|
+
LICENSE = File.read(File.join(APP_ROOT, 'LICENSE.txt'))
|
10
|
+
FILE_SOUND_ALARM = File.join(APP_ROOT, 'sounds', 'alarm1.wav')
|
11
|
+
|
12
|
+
## Add options like the following to configure CustomShell by outside consumers
|
13
|
+
#
|
14
|
+
# options :title, :background_color
|
15
|
+
# option :width, default: 320
|
16
|
+
# option :height, default: 240
|
17
|
+
option :greeting, default: 'Hello, World!'
|
18
|
+
|
19
|
+
attr_accessor :countdown, :min, :sec
|
20
|
+
|
21
|
+
## Use before_body block to pre-initialize variables to use in body
|
22
|
+
#
|
23
|
+
#
|
24
|
+
before_body {
|
25
|
+
Display.setAppName('Timer')
|
26
|
+
Display.setAppVersion(VERSION)
|
27
|
+
@display = display {
|
28
|
+
on_about {
|
29
|
+
display_about_dialog
|
30
|
+
}
|
31
|
+
on_preferences {
|
32
|
+
display_about_dialog
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
@min = 0
|
37
|
+
@sec = 0
|
38
|
+
}
|
39
|
+
|
40
|
+
## Use after_body block to setup observers for widgets in body
|
41
|
+
#
|
42
|
+
after_body {
|
43
|
+
Thread.new {
|
44
|
+
loop {
|
45
|
+
sleep(1)
|
46
|
+
if @countdown
|
47
|
+
sync_exec {
|
48
|
+
@countdown_time = Time.new(1, 1, 1, 0, min, sec)
|
49
|
+
@countdown_time -= 1
|
50
|
+
self.min = @countdown_time.min
|
51
|
+
self.sec = @countdown_time.sec
|
52
|
+
if @countdown_time.min <= 0 && @countdown_time.sec <= 0
|
53
|
+
stop_countdown
|
54
|
+
play_countdown_done_sound
|
55
|
+
end
|
56
|
+
}
|
57
|
+
end
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
## Add widget content inside custom shell body
|
63
|
+
## Top-most widget must be a shell or another custom shell
|
64
|
+
#
|
65
|
+
body {
|
66
|
+
shell {
|
67
|
+
# Replace example content below with custom shell content
|
68
|
+
minimum_size (OS.windows? ? 214 : 200), 114
|
69
|
+
image File.join(APP_ROOT, 'package', 'windows', "Timer.ico") if OS.windows?
|
70
|
+
text "Timer"
|
71
|
+
grid_layout
|
72
|
+
|
73
|
+
group {
|
74
|
+
text 'Countdown'
|
75
|
+
font height: 20
|
76
|
+
|
77
|
+
composite {
|
78
|
+
row_layout {
|
79
|
+
margin_width 0
|
80
|
+
margin_height 0
|
81
|
+
}
|
82
|
+
@min_spinner = spinner {
|
83
|
+
text_limit 2
|
84
|
+
digits 0
|
85
|
+
maximum 60
|
86
|
+
selection bind(self, :min)
|
87
|
+
enabled bind(self, :countdown, on_read: :!)
|
88
|
+
on_widget_default_selected {
|
89
|
+
start_countdown
|
90
|
+
}
|
91
|
+
}
|
92
|
+
label {
|
93
|
+
text ':'
|
94
|
+
font(height: 18) if OS.mac?
|
95
|
+
}
|
96
|
+
@sec_spinner = spinner {
|
97
|
+
text_limit 2
|
98
|
+
digits 0
|
99
|
+
maximum 60
|
100
|
+
selection bind(self, :sec)
|
101
|
+
enabled bind(self, :countdown, on_read: :!)
|
102
|
+
on_widget_default_selected {
|
103
|
+
start_countdown
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
composite {
|
109
|
+
row_layout {
|
110
|
+
margin_width 0
|
111
|
+
margin_height 0
|
112
|
+
}
|
113
|
+
@start_button = button {
|
114
|
+
text '&Start'
|
115
|
+
enabled bind(self, :countdown, on_read: :!)
|
116
|
+
on_widget_selected {
|
117
|
+
start_countdown
|
118
|
+
}
|
119
|
+
on_key_pressed { |event|
|
120
|
+
start_countdown if event.keyCode == swt(:cr)
|
121
|
+
}
|
122
|
+
}
|
123
|
+
@stop_button = button {
|
124
|
+
text 'St&op'
|
125
|
+
enabled bind(self, :countdown)
|
126
|
+
on_widget_selected {
|
127
|
+
stop_countdown
|
128
|
+
}
|
129
|
+
on_key_pressed { |event|
|
130
|
+
stop_countdown if event.keyCode == swt(:cr)
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
menu_bar {
|
136
|
+
menu {
|
137
|
+
text '&File'
|
138
|
+
menu_item {
|
139
|
+
text 'Preferences...'
|
140
|
+
on_widget_selected {
|
141
|
+
display_about_dialog
|
142
|
+
}
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
def display_about_dialog
|
150
|
+
message_box(body_root) {
|
151
|
+
text 'About'
|
152
|
+
message "Glimmer - Timer #{VERSION}\n\n#{LICENSE}"
|
153
|
+
}.open
|
154
|
+
end
|
155
|
+
|
156
|
+
def start_countdown
|
157
|
+
self.countdown = true
|
158
|
+
@stop_button.swt_widget.set_focus
|
159
|
+
end
|
160
|
+
|
161
|
+
def stop_countdown
|
162
|
+
self.countdown = false
|
163
|
+
@min_spinner.swt_widget.set_focus
|
164
|
+
end
|
165
|
+
|
166
|
+
def play_countdown_done_sound
|
167
|
+
begin
|
168
|
+
if FILE_SOUND_ALARM.start_with?('uri:classloader')
|
169
|
+
jar_file_path = FILE_SOUND_ALARM
|
170
|
+
file_path = jar_file_path.sub(/^uri\:classloader\:/, '').sub('//', '/') # the latter sub is needed for Mac
|
171
|
+
object = java.lang.Object.new
|
172
|
+
file_input_stream = object.java_class.resource_as_stream(file_path)
|
173
|
+
file_or_stream = java.io.BufferedInputStream.new(file_input_stream)
|
174
|
+
else
|
175
|
+
file_or_stream = java.io.File.new(FILE_SOUND_ALARM)
|
176
|
+
end
|
177
|
+
audio_stream = AudioSystem.get_audio_input_stream(file_or_stream)
|
178
|
+
clip = AudioSystem.clip
|
179
|
+
clip.open(audio_stream)
|
180
|
+
clip.start
|
181
|
+
rescue => e
|
182
|
+
pd e
|
183
|
+
puts e.full_message
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
end
|
Binary file
|
Binary file
|
data/sounds/alarm1.wav
ADDED
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: glimmer-cs-timer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andy Maleh
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 0.6.2
|
19
|
+
name: glimmer-dsl-swt
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.6.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 3.5.0
|
33
|
+
name: rspec
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.5.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.7.0
|
47
|
+
name: git-glimmer
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.7.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.3.9
|
61
|
+
name: jeweler
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.3.9
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
name: simplecov
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Timer - Glimmer Custom Shell - Currently supports a countdown timer only
|
84
|
+
email: andy.am@gmail.com
|
85
|
+
executables:
|
86
|
+
- glimmer-cs-timer
|
87
|
+
- timer
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files:
|
90
|
+
- LICENSE.txt
|
91
|
+
- README.md
|
92
|
+
files:
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- VERSION
|
96
|
+
- bin/glimmer-cs-timer
|
97
|
+
- bin/timer
|
98
|
+
- images/glimmer-timer-logo.png
|
99
|
+
- lib/glimmer-cs-timer.rb
|
100
|
+
- lib/views/glimmer/timer.rb
|
101
|
+
- package/macosx/Timer.icns
|
102
|
+
- package/windows/Timer.ico
|
103
|
+
- sounds/alarm1.wav
|
104
|
+
- vendor/org/yaml/snakeyaml/1.26/snakeyaml-1.26.jar
|
105
|
+
homepage: http://github.com/AndyObtiva/glimmer-cs-timer
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- vendor
|
113
|
+
- lib
|
114
|
+
- app
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubygems_version: 3.0.6
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Timer - Glimmer Custom Shell
|
130
|
+
test_files: []
|