gswax 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/bin/gswax +4 -0
  2. data/lib/gswax.rb +306 -0
  3. data/lib/gswax/Wax.rb +273 -0
  4. data/lib/gswax/browser.rb +224 -0
  5. data/lib/gswax/images/arm.png +0 -0
  6. data/lib/gswax/images/default.png +0 -0
  7. data/lib/gswax/images/defaultHOVER.png +0 -0
  8. data/lib/gswax/images/dugout.png +0 -0
  9. data/lib/gswax/images/dugoutHOVER.png +0 -0
  10. data/lib/gswax/images/info.png +0 -0
  11. data/lib/gswax/images/infoHOVER.png +0 -0
  12. data/lib/gswax/images/next.png +0 -0
  13. data/lib/gswax/images/nextHOVER.png +0 -0
  14. data/lib/gswax/images/no_cover.png +0 -0
  15. data/lib/gswax/images/pause.png +0 -0
  16. data/lib/gswax/images/pauseHOVER.png +0 -0
  17. data/lib/gswax/images/play.png +0 -0
  18. data/lib/gswax/images/playHOVER.png +0 -0
  19. data/lib/gswax/images/playlist.png +0 -0
  20. data/lib/gswax/images/playlistHOVER.png +0 -0
  21. data/lib/gswax/images/prev.png +0 -0
  22. data/lib/gswax/images/prevHOVER.png +0 -0
  23. data/lib/gswax/images/settings.png +0 -0
  24. data/lib/gswax/images/settingsHOVER.png +0 -0
  25. data/lib/gswax/images/shuffle.png +0 -0
  26. data/lib/gswax/images/shuffleHOVER.png +0 -0
  27. data/lib/gswax/images/stanton.png +0 -0
  28. data/lib/gswax/images/stanton1.png +0 -0
  29. data/lib/gswax/images/vol.png +0 -0
  30. data/lib/gswax/images/volslider.png +0 -0
  31. data/lib/gswax/playlist.rb +182 -0
  32. data/lib/gswax/playlists/default +0 -0
  33. data/lib/gswax/scrollbox.rb +100 -0
  34. data/lib/gswax/settings/settings.yml +16 -0
  35. data/lib/gswax/settings_manager.rb +284 -0
  36. data/lib/gswax/shared.rb +206 -0
  37. data/lib/gswax/turntable.rb +251 -0
  38. data/lib/gswax/version.rb +3 -0
  39. metadata +107 -0
@@ -0,0 +1,251 @@
1
+ =begin
2
+
3
+ this file is part of: gsWax v. 0.12.01
4
+
5
+ You should have received a copy of the GNU General Public License
6
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
7
+ =end
8
+
9
+
10
+ class Turntable
11
+ include Observable
12
+ attr_accessor :main
13
+
14
+ def initialize
15
+ @imagedir = File.join(Settings.brains_dir, "images")
16
+ @arm_pos = 0
17
+ @vol_pos = ((Settings.volume * -1) +1) * (170 * Settings.scale)
18
+ @main = Gtk::VBox.new(true, 2)
19
+ @arm_file = File.join(Settings.brains_dir, "images", "arm.png")
20
+ @cover_pix = Gdk::Pixbuf.new(File.join(@imagedir, "no_cover.png"), 485 * Settings.scale, 485 * Settings.scale)
21
+ @first = true
22
+ init_ui
23
+ end
24
+
25
+ def init_ui
26
+ @main.set_size_request(727 * Settings.scale, 598 * Settings.scale)
27
+ @arm_pix = Gdk::Pixbuf.new(@arm_file, 146 * Settings.scale, 512 * Settings.scale)
28
+
29
+ layout = Gtk::Layout.new
30
+
31
+ @cover_image = Gtk::Image.new(@cover_pix)
32
+
33
+ @play_overlay = Gdk::Pixbuf.new(File.join(@imagedir, "stanton1.png"), 727 * Settings.scale, 598 * Settings.scale)
34
+ @pause_overlay = Gdk::Pixbuf.new(File.join(@imagedir, "stanton.png"), 727 * Settings.scale, 598 * Settings.scale)
35
+ @table_overlay = Gtk::Image.new(@pause_overlay)
36
+
37
+ @arm_area = Gtk::EventBox.new
38
+ @arm_area.set_size_request(450.0 * Settings.scale, 540.0 * Settings.scale)
39
+ @arm_area.set_visible_window(false)
40
+ @arm_area.signal_connect("expose_event"){|w, e| draw_arm(w)}
41
+ @arm_area.signal_connect("button-press-event"){|w, e| send_seek_data(e)}####
42
+
43
+ transport_btns = Gtk::HBox.new(false, 0)
44
+
45
+ prev_btn = ImageButton.new{emit_signal("PREVIOUS_TRACK")}
46
+ prev_btn.set_images(
47
+ File.join(@imagedir, "prev.png"),
48
+ File.join(@imagedir, "prevHOVER.png"),
49
+ 68 * Settings.scale
50
+ )
51
+
52
+ @play_btn = ImageButton.new{emit_signal("PLAY_PAUSE_TRACK")}
53
+ @play_btn.set_images(
54
+ File.join(@imagedir, "play.png"),
55
+ File.join(@imagedir, "playHOVER.png"),
56
+ 68 * Settings.scale
57
+ )
58
+
59
+ next_btn = ImageButton.new{emit_signal("NEXT_TRACK")}
60
+ next_btn.set_images(
61
+ File.join(@imagedir, "next.png"),
62
+ File.join(@imagedir, "nextHOVER.png"),
63
+ 68 * Settings.scale
64
+ )
65
+
66
+ transport_btns.pack_start(prev_btn, false, false, 2)
67
+ transport_btns.pack_start(@play_btn, false, false, 2)
68
+ transport_btns.pack_start(next_btn, false, false, 2)
69
+
70
+ @shuf_btn = ImageButton.new{toggle_shuffle}
71
+ toggle_shuffle
72
+
73
+ playlist_browser_btns = Gtk::HBox.new(false, 0)
74
+
75
+ list_btn = ImageButton.new{emit_signal("PLAYLIST")}
76
+ list_btn.set_images(
77
+ File.join(@imagedir, "playlist.png"),
78
+ File.join(@imagedir, "playlistHOVER.png"),
79
+ 45 * Settings.scale
80
+ )
81
+
82
+ browser_btn = ImageButton.new{emit_signal("BROWSER")}
83
+ browser_btn.set_images(
84
+ File.join(@imagedir, "dugout.png"),
85
+ File.join(@imagedir, "dugoutHOVER.png"),
86
+ 45 * Settings.scale
87
+ )
88
+
89
+ playlist_browser_btns.pack_start(list_btn, false, false, 2)
90
+ playlist_browser_btns.pack_start(browser_btn, false, false, 2)
91
+
92
+ settings_btn = ImageButton.new{emit_signal("SETTINGS")}
93
+ settings_btn.set_images(
94
+ File.join(@imagedir, "settings.png"),
95
+ File.join(@imagedir, "settingsHOVER.png"),
96
+ 40 * Settings.scale
97
+ )
98
+
99
+ vbg_pix = Gdk::Pixbuf.new(
100
+ File.join(@imagedir, "vol.png"), 60 * Settings.scale, 198 * Settings.scale
101
+ )
102
+ vol_bg = Gtk::Image.new(vbg_pix)
103
+
104
+ @slider_area = Gtk::EventBox.new
105
+ @slider_area.set_size_request(60.0 * Settings.scale, 238.0 * Settings.scale)
106
+ @slider_area.set_visible_window(false)
107
+ @slider_area.signal_connect("expose_event"){|w, e| draw_slider(w, e)}
108
+ @slider_area.signal_connect('motion_notify_event'){ |w, e| move_vol_slider(w, e)}
109
+
110
+ @slider_pix = Gdk::Pixbuf.new(
111
+ File.join(@imagedir, "volslider.png"), 38 * Settings.scale, 35 * Settings.scale
112
+ )
113
+
114
+
115
+ layout.put(@cover_image, 49 * Settings.scale, 49 * Settings.scale)
116
+ layout.put(@table_overlay, 0, 0)
117
+ layout.put(@arm_area, 300.0 * Settings.scale, 0)
118
+ layout.put(transport_btns, 486.0 * Settings.scale, 500.0 * Settings.scale)
119
+ layout.put(@shuf_btn, 545.0 * Settings.scale, 460.0 * Settings.scale)
120
+ layout.put(playlist_browser_btns, 14.0 * Settings.scale, 518.0 * Settings.scale)
121
+ layout.put(settings_btn, 32.0 * Settings.scale, 26.0 * Settings.scale)
122
+ layout.put(vol_bg, 630.0 * Settings.scale, 280.0 * Settings.scale)
123
+ layout.put(@slider_area, 630.0 * Settings.scale, 260.0 * Settings.scale)
124
+
125
+ @main.pack_start(layout, true, true, 2)
126
+ end
127
+
128
+ def draw_arm(w)
129
+ @acc.destroy if @acc
130
+ @acc = w.window.create_cairo_context
131
+ @acc.translate(622.0 * Settings.scale, 149.0 * Settings.scale)
132
+ @acc.rotate((@arm_pos + 18.25) * Math::PI / 180)
133
+ @acc.set_source_pixbuf(@arm_pix, -109.0 * Settings.scale, -119.0 * Settings.scale)
134
+ @acc.paint
135
+ end
136
+
137
+ def set_arm_pos(percent)
138
+ @arm_pos=(((percent * 23) / 100))
139
+ @arm_area.queue_draw
140
+ end
141
+
142
+ def draw_slider(w, e)
143
+ @scc.destroy if @cc
144
+ @scc = w.window.create_cairo_context
145
+ @scc.translate(622.0 * Settings.scale, 149.0 * Settings.scale)
146
+ @scc.set_source_pixbuf(@slider_pix, 16.0 * Settings.scale, ((127.0 * Settings.scale) + @vol_pos))
147
+ @scc.paint
148
+ end
149
+
150
+ def move_vol_slider(w, e)
151
+ y = e.y - (35.0 * Settings.scale)
152
+ y = 0 if y < 0; y = 170 * Settings.scale if y > 170 * Settings.scale
153
+ @vol_pos = y
154
+ @slider_area.queue_draw
155
+ vol = (((@vol_pos / (170 * Settings.scale)) - 1) * -1).round(1)
156
+ vol = 0 if vol < 0; vol = 1.0 if vol > 1.0
157
+ emit_signal(["VOLUME", vol])
158
+ end
159
+
160
+ def set_state(state)
161
+ if state == "playing"
162
+ @table_overlay.pixbuf = @play_overlay
163
+ @play_btn.set_images(
164
+ File.join(@imagedir, "pause.png"),
165
+ File.join(@imagedir, "pauseHOVER.png"),
166
+ 68 * Settings.scale
167
+ )
168
+ else
169
+ @table_overlay.pixbuf = @pause_overlay
170
+ @play_btn.set_images(
171
+ File.join(@imagedir, "play.png"),
172
+ File.join(@imagedir, "playHOVER.png"),
173
+ 68 * Settings.scale
174
+ )
175
+ end
176
+ @table_overlay.show_all
177
+ @play_btn.show_all
178
+ end
179
+
180
+ def update(path)
181
+ get_cover(path)
182
+ @cover_image.pixbuf = @cover_pix
183
+ @cover_image.show
184
+ @armpos = 0
185
+ set_arm_pos(@armpos)
186
+ end
187
+
188
+ def get_cover(path)
189
+ cover_file = File.join(Settings.brains_dir, "images", "no_cover.png")
190
+ cover_size = 485.0 * Settings.scale
191
+
192
+ if path
193
+ dir = File.dirname(path)
194
+ Dir.chdir(dir)
195
+ files = Dir['*.{jpg,JPG,png,PNG,gif,GIF}']
196
+ if files[0]
197
+ cover_file = File.join(dir, files[0])
198
+ end
199
+ end
200
+ @cover_pix = Gdk::Pixbuf.new(cover_file, cover_size, cover_size)
201
+ end
202
+
203
+ def toggle_shuffle
204
+ emit_signal("SHUFFLE_TOGGLE") unless @first
205
+ @first = false
206
+
207
+ if Settings.shuffle
208
+ @shuf_btn.set_images(
209
+ File.join(@imagedir, "shuffle.png"),
210
+ File.join(@imagedir, "shuffleHOVER.png"),
211
+ 45 * Settings.scale
212
+ )
213
+ else
214
+ @shuf_btn.set_images(
215
+ File.join(@imagedir, "default.png"),
216
+ File.join(@imagedir, "defaultHOVER.png"),
217
+ 45 * Settings.scale
218
+ )
219
+ end
220
+
221
+ @shuf_btn.show_all
222
+ end
223
+
224
+ def resize
225
+ @main.children.each{|child| @main.remove(child)}
226
+ @first = true
227
+ @cover_pix = @cover_pix.scale(485 * Settings.scale, 485 * Settings.scale)
228
+ init_ui
229
+ @main.show_all
230
+ end
231
+
232
+ def send_seek_data(click_event)
233
+ x = click_event.x / Settings.scale
234
+ y = click_event.y / Settings.scale
235
+
236
+ x_flag = true if x > 25 and x < 165
237
+ y_flag = true if y > 360 and y < 490
238
+
239
+ if x_flag and y_flag
240
+ percent = ((y - 490.0) / -130.0).round(2)
241
+ percent = 0.01 if percent < 0.01; percent = 0.99 if percent > 0.99
242
+ emit_signal(["SEEK", percent])
243
+ end
244
+
245
+ end
246
+
247
+ def emit_signal(signal)
248
+ changed; notify_observers(signal)
249
+ end
250
+
251
+ end #Turntable
@@ -0,0 +1,3 @@
1
+ module Gswax
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gswax
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - j. kaiden
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: green_shoes
16
+ requirement: &82768080 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *82768080
25
+ - !ruby/object:Gem::Dependency
26
+ name: gstreamer
27
+ requirement: &82766800 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *82766800
36
+ description: an audio player for folks who miss thier vinyl
37
+ email:
38
+ - jakekaiden@gmail.com
39
+ executables:
40
+ - gswax
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - lib/gswax/Wax.rb
45
+ - lib/gswax/browser.rb
46
+ - lib/gswax/images/arm.png
47
+ - lib/gswax/images/default.png
48
+ - lib/gswax/images/defaultHOVER.png
49
+ - lib/gswax/images/dugout.png
50
+ - lib/gswax/images/dugoutHOVER.png
51
+ - lib/gswax/images/info.png
52
+ - lib/gswax/images/infoHOVER.png
53
+ - lib/gswax/images/next.png
54
+ - lib/gswax/images/nextHOVER.png
55
+ - lib/gswax/images/no_cover.png
56
+ - lib/gswax/images/pause.png
57
+ - lib/gswax/images/pauseHOVER.png
58
+ - lib/gswax/images/play.png
59
+ - lib/gswax/images/playHOVER.png
60
+ - lib/gswax/images/playlist.png
61
+ - lib/gswax/images/playlistHOVER.png
62
+ - lib/gswax/images/prev.png
63
+ - lib/gswax/images/prevHOVER.png
64
+ - lib/gswax/images/settings.png
65
+ - lib/gswax/images/settingsHOVER.png
66
+ - lib/gswax/images/shuffle.png
67
+ - lib/gswax/images/shuffleHOVER.png
68
+ - lib/gswax/images/stanton.png
69
+ - lib/gswax/images/stanton1.png
70
+ - lib/gswax/images/vol.png
71
+ - lib/gswax/images/volslider.png
72
+ - lib/gswax/playlist.rb
73
+ - lib/gswax/playlists/default
74
+ - lib/gswax/scrollbox.rb
75
+ - lib/gswax/settings/settings.yml
76
+ - lib/gswax/settings_manager.rb
77
+ - lib/gswax/shared.rb
78
+ - lib/gswax/turntable.rb
79
+ - lib/gswax/version.rb
80
+ - lib/gswax.rb
81
+ - bin/gswax
82
+ homepage: ''
83
+ licenses: []
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 1.8.10
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: an audio player for folks who miss their vinyl
106
+ test_files: []
107
+ has_rdoc: