gtk2mp3 0.4.0 → 0.5.0

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.
data/bin/gtk2mp3 CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'rubygems'
3
- gem 'gtk2applib', '~> 14.0'
3
+ gem 'gtk2applib', '~> 15.3'
4
4
  $help = <<EOT
5
5
 
6
6
  You can also give it the default mp3 directory via command line...
@@ -15,7 +15,7 @@ program = Gtk2AppLib::Program.new( {
15
15
  'website' => 'https://sites.google.com/site/gtk2applib/home/gtk2applib-applications/gtk2mp3',
16
16
  'website-label' => 'Ruby-Gnome MP3',
17
17
  'license' => 'GPL',
18
- 'copyright' => '2011-03-10 11:19:13',
18
+ 'copyright' => '2011-05-02 09:09:57',
19
19
  } )
20
20
 
21
21
  begin
@@ -25,12 +25,12 @@ module Configuration
25
25
  dialog.destroy
26
26
  DIRECTORY = directory
27
27
 
28
- options = {:modify_font => Gtk2AppLib::Configuration::FONT[:Large]}.freeze
28
+ options = {:modify_font => Gtk2AppLib::Configuration::FONT[:LARGE]}.freeze
29
29
  SPACER1 = [' ', options].freeze
30
30
  SPACER2 = [' ', options].freeze
31
31
  SPACER3 = [' ', options].freeze
32
32
  SPACER4 = [' ', options].freeze
33
- INFO = ['Gtk2 MP3 Next!!!!',{:modify_font => Gtk2AppLib::Configuration::FONT[:Small]}].freeze
33
+ INFO = ['Gtk2 MP3 Next!!!!',{:modify_font => Gtk2AppLib::Configuration::FONT[:SMALL]}].freeze
34
34
 
35
35
  RELOAD = '_Reload'
36
36
 
@@ -1,4 +1,5 @@
1
1
  # Gtk2AppLib defined
2
+ # File defined
2
3
  module Gtk2MP3 # Gtk2MP3 defined
3
4
  class Couple # Couple defined
4
5
  BASE = Hash.new(1.0)
@@ -19,28 +20,31 @@ class Couple # Couple defined
19
20
  end
20
21
 
21
22
  def self._load(dump,hash)
22
- File.open(dump,'r'){|fh| # File defined, built in
23
- fh.each{|line|
24
- if line=~/^(.*)\s([\d\.]+)\s*$/ then
25
- hash[$1.strip] = $2.to_f
26
- end
27
- }
28
- } if File.exist?(dump)
23
+ fh = File.open(dump,'r')
24
+ fh.each do |line|
25
+ if line=~/^(.*)\s([\d\.]+)\s*$/ then
26
+ hash[$1.strip] = $2.to_f
27
+ end
28
+ end
29
+ fh.close
29
30
  end
30
31
  def self.load
31
- Couple._load(BASE_DUMP,BASE)
32
- Couple._load(COUPLE_DUMP,COUPLE)
32
+ Couple._load(BASE_DUMP,BASE) if File.exist?(BASE_DUMP)
33
+ Couple._load(COUPLE_DUMP,COUPLE) if File.exist?(COUPLE_DUMP)
33
34
  end
34
35
 
35
36
  def self.delete(current)
36
37
  key = File.basename(current,Gtk2MP3::MP3)
37
38
  BASE.delete(key)
38
- COUPLE.delete_if{|k| k.split(SEPX).include?(key)}
39
+ COUPLE.delete_if{|pair| pair.split(SEPX).include?(key)}
39
40
  end
40
41
 
41
42
  def self._dump(dump,hash)
42
43
  # Note that the default value is 1.0, so no need to save 1.0 values.
43
- File.open(dump,'w'){|fh| hash.each{|k,v| fh.puts "#{k}\t#{v}" if v < 1.0 } }
44
+ # File.open(dump,'w'){|fh| hash.each{|k,v| fh.puts "#{k}\t#{v}" if v < 1.0 } }
45
+ fh = File.open(dump,'w')
46
+ hash.each{|key,value| fh.puts "#{key}\t#{value}" if value < 1.0 }
47
+ fh.close
44
48
  end
45
49
  def self.dump
46
50
  Couple._dump(BASE_DUMP,BASE)
data/lib/gtk2mp3.rb CHANGED
@@ -13,19 +13,18 @@ module Gtk2MP3 # Gtk2MP3 defined
13
13
  self.open
14
14
  end
15
15
  def _read
16
- @thread = Thread.new do # Thread defined
17
- @pipe.each do |line|
18
- line.strip!
19
- $stderr.puts line if $trace
20
- if line =~ /^\@I\s+(\S.*)$/ then
21
- # :-??
22
- elsif line == '@P 0' then
23
- if @gui.continue then
24
- @gui.couple.promote
25
- @gui.previous = @gui.current
26
- @gui.load_song
27
- end
28
- end
16
+ @gui.couple.promote
17
+ @gui.previous = @gui.current
18
+ @gui.load_song
19
+ end
20
+ def read
21
+ @pipe.each do |line|
22
+ line.strip!
23
+ $stderr.puts line if $trace
24
+ if line =~ /^\@I\s+(\S.*)$/ then
25
+ # :-??
26
+ elsif line == '@P 0' then
27
+ _read if @gui.continue
29
28
  end
30
29
  end
31
30
  end
@@ -33,7 +32,7 @@ module Gtk2MP3 # Gtk2MP3 defined
33
32
  if !@pipe then
34
33
  @pipe = IO.popen(Configuration::PLAYER,'w+') # IO defined
35
34
  self.puts Configuration::C_SILENCE
36
- self._read
35
+ @thread = Thread.new { self.read }
37
36
  end
38
37
  end
39
38
  def puts(string)
@@ -51,9 +50,11 @@ module Gtk2MP3 # Gtk2MP3 defined
51
50
  end
52
51
  end
53
52
 
53
+ # This is GUI
54
54
  class GUI
55
55
  attr_reader :continue, :couple, :current
56
56
  attr_writer :previous
57
+
57
58
  def initialize(window,program)
58
59
  @playlist = Gtk2MP3::Playlist.new(Configuration::DIRECTORY)
59
60
  @current = ''
@@ -70,41 +71,50 @@ module Gtk2MP3 # Gtk2MP3 defined
70
71
  hbox = Gtk2AppLib::Widgets::HBox.new(vbox)
71
72
  Gtk2AppLib::Widgets::Label.new(*Configuration::SPACER1+[hbox]) # Spacer
72
73
  Gtk2AppLib::Widgets::Button.new(*Configuration::NEXT+[hbox]){ self.skip_song }
74
+ spacer = Configuration::SPACER2+[hbox]
73
75
  if Configuration::PAUSE then
74
- Gtk2AppLib::Widgets::Label.new(*Configuration::SPACER2+[hbox]) # Spacer
76
+ Gtk2AppLib::Widgets::Label.new(*spacer) # Spacer
75
77
  Gtk2AppLib::Widgets::Button.new(*Configuration::PAUSE+[hbox]){ self.pause_song }
76
78
  end
77
79
  if Configuration::STOP then
78
- Gtk2AppLib::Widgets::Label.new(*Configuration::SPACER2+[hbox]) # Spacer
80
+ Gtk2AppLib::Widgets::Label.new(*spacer) # Spacer
79
81
  Gtk2AppLib::Widgets::Button.new(*Configuration::STOP+[hbox]){ self.stop_song }
80
82
  end
81
83
  if Configuration::DELETE then
82
84
  Gtk2AppLib::Widgets::Label.new(*Configuration::SPACER3+[hbox]) # Spacer
83
85
  Gtk2AppLib::Widgets.define_composite(:CheckButton,:Button)
84
86
  Gtk2AppLib::Widgets::CheckButtonButton.new(*Configuration::DELETE+[hbox]){|is,*dummies|
85
- if is.checkbutton.active? then
87
+ cb = is.checkbutton
88
+ if cb.active? then
86
89
  self.delete_song
87
- is.checkbutton.active = false
90
+ cb.active = false
88
91
  end
89
92
  }
90
93
  end
91
94
  Gtk2AppLib::Widgets::Label.new(*Configuration::SPACER4+[hbox]) # Spacer
92
95
 
93
96
  self.load_song
97
+ self.program_appends(program)
98
+ end
94
99
 
100
+ def program_appends(program)
95
101
  program.append_app_menu(Configuration::RELOAD){ @playlist.reload }
96
102
  program.append_dock_menu(Configuration::PAUSE.first){ self.pause_song } if Configuration::PAUSE
97
103
  program.append_dock_menu(Configuration::STOP.first){ self.stop_song } if Configuration::STOP
98
104
  program.append_dock_menu(Configuration::NEXT.first){ self.skip_song }
99
105
  end
100
106
 
107
+ def _random_song
108
+ @current = @playlist.random
109
+ $stderr.puts @current if $trace
110
+ @couple = Gtk2MP3::Couple.new(@current,@previous)
111
+ $stderr.puts "#{@couple.keys.last} #{@couple.treshold}" if $trace
112
+ end
113
+
101
114
  def random_song
102
115
  plays = false
103
116
  while !plays do
104
- @current = @playlist.random
105
- $stderr.puts @current if $trace
106
- @couple = Gtk2MP3::Couple.new(@current,@previous)
107
- $stderr.puts "#{@couple.keys.last} #{@couple.treshold}" if $trace
117
+ _random_song
108
118
  plays = @couple.play?
109
119
  end
110
120
  end
@@ -120,12 +130,16 @@ module Gtk2MP3 # Gtk2MP3 defined
120
130
  self.load_song
121
131
  end
122
132
 
133
+ def _stop_song
134
+ @pipe.puts Configuration::C_STOP
135
+ @previous = ''
136
+ @continue = false
137
+ @pipe.close
138
+ end
139
+
123
140
  def stop_song
124
141
  if @continue then
125
- @pipe.puts Configuration::C_STOP
126
- @previous = ''
127
- @continue = false
128
- @pipe.close
142
+ _stop_song
129
143
  else
130
144
  @continue = true
131
145
  self.load_song
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtk2mp3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
8
+ - 5
9
9
  - 0
10
- version: 0.4.0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - carlosjhr64@gmail.com
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-10 00:00:00 -08:00
18
+ date: 2011-05-02 00:00:00 -07:00
19
19
  default_executable: gtk2mp3
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,11 +26,11 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 51
29
+ hash: 49
30
30
  segments:
31
- - 14
32
- - 0
33
- version: "14.0"
31
+ - 15
32
+ - 3
33
+ version: "15.3"
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  description: a "Next!" button gui for mpg123