gtk2mp3 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,7 @@ program = Program.new( {
18
18
  'website' => 'http://ruby-gnome-apps.blogspot.com/search/label/MP3',
19
19
  'website-label' => 'Ruby-Gnome MP3',
20
20
  'license' => 'GPL',
21
- 'copyright' => '2010-10-08 06:20:21',
21
+ 'copyright' => '2010-10-08 17:51:32',
22
22
  } )
23
23
 
24
24
  IO.popen(PLAYER,'w+') do |pipe|
@@ -20,16 +20,27 @@ module Gtk2MP3
20
20
  def load_song
21
21
  self.random_song
22
22
  @info.text = File.basename(@current,MP3)
23
- @pipe.puts "#{C_LOAD} #{@current}"
23
+ @pipe.puts "#{C_LOAD} #{@current}"; @pipe.flush
24
24
  end
25
25
 
26
26
  def skip_song
27
- @couple.demote
27
+ (@continue)? @couple.demote: (@continue = true)
28
28
  self.load_song
29
29
  end
30
30
 
31
+ def stop_song
32
+ if @continue then
33
+ @pipe.puts C_STOP; @pipe.flush
34
+ @previous = ''
35
+ @continue = false
36
+ else
37
+ @continue = true
38
+ self.load_song
39
+ end
40
+ end
41
+
31
42
  def pause_song
32
- @pipe.puts C_PAUSE
43
+ @pipe.puts C_PAUSE; @pipe.flush
33
44
  end
34
45
 
35
46
  def delete_song
@@ -40,13 +51,11 @@ module Gtk2MP3
40
51
  end
41
52
 
42
53
  def initialize(window,pipe,program)
43
- pipe.puts C_SILENCE
44
- window.signal_connect('destroy'){ pipe.puts C_QUIT }
45
-
46
54
  @pipe = pipe
47
55
  @playlist = Gtk2MP3::Playlist.new(DIRECTORY)
48
56
  @current = ''
49
57
  @previous = ''
58
+ @continue = true
50
59
 
51
60
  vbox = Widgets::VBox.new(window)
52
61
 
@@ -56,38 +65,49 @@ module Gtk2MP3
56
65
  hbox = Widgets::HBox.new(vbox)
57
66
  Widgets::Label.new(*SPACER1, hbox) # Spacer
58
67
  Widgets::Button.new(*NEXT, hbox){ self.skip_song }
59
- Widgets::Label.new(*SPACER2, hbox) # Spacer
60
- Widgets::Button.new(*PAUSE, hbox){ self.pause_song }
61
- Widgets::Label.new(*SPACER3, hbox) # Spacer
62
- Widgets.define_composite(:CheckButton,:Button)
63
- Widgets::CheckButtonButton.new(*DELETE, hbox){|is,*dummies|
64
- if is.checkbutton.active? then
65
- self.delete_song
66
- is.checkbutton.active = false
67
- end
68
- }
68
+ if PAUSE then
69
+ Widgets::Label.new(*SPACER2, hbox) # Spacer
70
+ Widgets::Button.new(*PAUSE, hbox){ self.pause_song }
71
+ end
72
+ if STOP then
73
+ Widgets::Label.new(*SPACER2, hbox) # Spacer
74
+ Widgets::Button.new(*STOP, hbox){ self.stop_song }
75
+ end
76
+ if DELETE then
77
+ Widgets::Label.new(*SPACER3, hbox) # Spacer
78
+ Widgets.define_composite(:CheckButton,:Button)
79
+ Widgets::CheckButtonButton.new(*DELETE, hbox){|is,*dummies|
80
+ if is.checkbutton.active? then
81
+ self.delete_song
82
+ is.checkbutton.active = false
83
+ end
84
+ }
85
+ end
69
86
  Widgets::Label.new(*SPACER4, hbox) # Spacer
70
87
 
88
+ @pipe.puts C_SILENCE; @pipe.flush
71
89
  self.load_song
72
90
  Thread.new do
73
- pipe.each do |line|
91
+ @pipe.each do |line|
74
92
  line.strip!
75
93
  $stderr.puts line if $trace
76
94
  if line =~ /^\@I\s+(\S.*)$/ then
77
95
  # :-??
78
96
  elsif line == '@P 0' then
79
- @couple.promote
80
- @previous = @current
81
- self.load_song
97
+ if @continue then
98
+ @couple.promote
99
+ @previous = @current
100
+ self.load_song
101
+ end
82
102
  end
83
103
  end
84
104
  false
85
105
  end
86
106
 
87
107
  program.append_app_menu(RELOAD){ @playlist.reload }
88
- program.append_dock_menu(PAUSE.first){ self.pause_song }
108
+ program.append_dock_menu(PAUSE.first){ self.pause_song } if PAUSE
109
+ program.append_dock_menu(STOP.first){ self.stop_song } if STOP
89
110
  program.append_dock_menu(NEXT.first){ self.skip_song }
90
-
91
111
  end
92
112
  end
93
113
  end
@@ -18,10 +18,10 @@ module Configuration
18
18
  WINDOW_DEFAULT_SIZE[0],WINDOW_DEFAULT_SIZE[1] = 0,0
19
19
  OPTIONS = {:modify_font => FONT[:Large]}.freeze
20
20
 
21
- SPACER1 =
22
- SPACER2 =
23
- SPACER3 =
24
- SPACER4 = [' ', OPTIONS].freeze
21
+ SPACER1 = [' ', OPTIONS].freeze
22
+ SPACER2 = [' ', OPTIONS].freeze
23
+ SPACER3 = [' ', OPTIONS].freeze
24
+ SPACER4 = [' ', OPTIONS].freeze
25
25
  INFO = {:modify_font => FONT[:Small]}.freeze
26
26
 
27
27
 
@@ -29,21 +29,22 @@ module Configuration
29
29
 
30
30
  CLICKED = 'clicked' # Signal (should be no need to edit)
31
31
  NEXT = ['Next!', OPTIONS, CLICKED].freeze
32
- PAUSE = ['Pause', OPTIONS, CLICKED].freeze
32
+ PAUSE = nil # ['Pause', OPTIONS, CLICKED].freeze # By default, want to keep it simple
33
+ STOP = ['Stop', OPTIONS, CLICKED].freeze
33
34
  DELETE = ['Delete', OPTIONS, CLICKED].freeze
34
35
 
35
36
  SELECT_A_FILE = [['Select a file', Gtk::FileChooser::ACTION_OPEN],HNIL].freeze
36
37
 
37
- PLAYER = 'mpg123 -q -a hw:0,0 -R'
38
+ PLAYER = 'mpg123 -q -R' # 'mpg123 -q -a hw:0,0 -R'
38
39
  # mpg123 commands
39
40
  C_PAUSE = 'P'
41
+ C_STOP = 'S'
40
42
  C_SILENCE = 'SILENCE'
41
43
  C_LOAD = 'L'
42
44
  C_QUIT = 'Q'
43
45
 
44
46
  ### Unused ####
45
47
  # C_LOADPAUSED = 'LP'
46
- # C_STOP = 'S'
47
48
  # C_VOLUME = 'V'
48
49
  # C_TAG = 'T'
49
50
 
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: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - carlosjhr64@gmail.com