gtk2mp3 3.0.210920 → 3.1.210926

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 180114c8a9dc0eb5d6338b18adcf5285f3e689ad2e4c07f20f808bd87bc90c1c
4
- data.tar.gz: 1bccb9897a607bdcf6220c6430c602a42b5670cc97d66cc2852ef8073e50f389
3
+ metadata.gz: f7c165134edc00cdf60e79473c1c85808eeb405719c81daa096b8ace59af8b83
4
+ data.tar.gz: d909d47246ceaf95959dbde7e30ea4e63de94e54d5f7c0852f5ffa449ffff5c9
5
5
  SHA512:
6
- metadata.gz: 64fe65004af2cbc43a1267c9ec0058a00affcba1bf8c4d47a3cfb64987463dc4d5809e54022194db41742bda3f410ab021e5ff256dbd2253e0b8ad91674818e8
7
- data.tar.gz: 8ad3748d951f1153ba05c4eab525da74cd59357eb69bb1c8f62d32aa2d1cabd8a1437c63909789550cd836bbc91e3b6109a91a8f03cd4f63b5af2f12359631fa
6
+ metadata.gz: f0c7bc19d1a82272bbd644e8a3fc3592b00053477e5fafefd4bffebca2e6904fd178267a3780e35aa2ed776dea909593f4e9ad2daaef60972117586c80cc54b9
7
+ data.tar.gz: ddb29e99f9c23a0cd710c656744afaf95180e08fa70f542a87c698a56777ec9f9323e3b1bf952a9ef70aebc55e66faaa5e5f4e370a5598b8c6549a6dd768a036
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Gtk2Mp3
2
2
 
3
- * [VERSION 3.0.210920](https://github.com/carlosjhr64/gtk2mp3/releases)
3
+ * [VERSION 3.1.210926](https://github.com/carlosjhr64/gtk2mp3/releases)
4
4
  * [github](https://www.github.com/carlosjhr64/gtk2mp3)
5
5
  * [rubygems](https://rubygems.org/gems/gtk2mp3)
6
6
 
@@ -32,6 +32,11 @@ Options:
32
32
  # Requires MPD/MPC.
33
33
  # See https://www.musicpd.org/clients/mpc/.
34
34
  ```
35
+ ## MORE:
36
+
37
+ You can add your own custom buttons.
38
+ See my [Picard](lib/gtk2mp3/picard_button.rb) button hook.
39
+
35
40
  ## LICENSE:
36
41
 
37
42
  (The MIT License)
@@ -3,9 +3,8 @@ class Gtk2Mp3
3
3
  extend Rafini::Empty # for s0,a0,h0
4
4
 
5
5
  CONFIG = {
6
- TOOLBOX: [:horizontal],
7
- toolbox: h0,
8
- toolbox!: [:TOOLBOX,:toolbox],
6
+ MonkeyPatch: s0,
7
+ BUTTONS: [:next_button!, :stop_button!],
9
8
 
10
9
  NEXT_BUTTON: [label: 'Next!'],
11
10
  next_button: h0,
@@ -19,6 +18,10 @@ class Gtk2Mp3
19
18
  id_label: {set_selectable: true},
20
19
  id_label!: [:ID_LABEL, :id_label],
21
20
 
21
+ TOOLBOX: [:horizontal],
22
+ toolbox: h0,
23
+ toolbox!: [:TOOLBOX,:toolbox],
24
+
22
25
  HelpFile: 'https://github.com/carlosjhr64/gtk2mp3',
23
26
  Logo: "#{UserSpace::XDG['data']}/gtk3app/gtk2mp3/logo.png",
24
27
  about_dialog: {
data/lib/gtk2mp3/gui.rb CHANGED
@@ -5,8 +5,9 @@ class Gtk2Mp3
5
5
 
6
6
  def initialize(stage, toolbar, options, &block)
7
7
  @toolbox = Such::Box.new toolbar, :toolbox!
8
- Such::Button.new(@toolbox, :next_button!){block.call :next}
9
- Such::Button.new(@toolbox, :stop_button!){block.call :stop}
8
+ CONFIG[:BUTTONS].each do |button|
9
+ Such::Button.new(@toolbox, button){block.call button}
10
+ end
10
11
  @label = Such::Label.new(stage, :id_label!)
11
12
  build_logo_menu(block)
12
13
  end
@@ -15,9 +16,9 @@ class Gtk2Mp3
15
16
  Gtk3App.logo_press_event do |button|
16
17
  case button
17
18
  when 1
18
- block.call :next
19
+ block.call :next_button!
19
20
  when 2
20
- block.call :stop
21
+ block.call :stop_button!
21
22
  when 3
22
23
  # Gtk3App's main menu
23
24
  end
data/lib/gtk2mp3/mpd.rb CHANGED
@@ -25,20 +25,24 @@ class Gtk2Mp3
25
25
 
26
26
  def Gtk2Mp3.mpc_command(command)
27
27
  case command
28
- when :next
29
- current = `mpc current`.strip
30
- if current.empty?
31
- system 'mpc play'
32
- else
33
- # On my system, if I don't pause first, the sound fails.
34
- system 'mpc pause'
28
+ when :next_button!
29
+ if system 'mpc pause-if-playing'
30
+ sleep 0.25
35
31
  system 'mpc next'
32
+ else
33
+ system 'mpc play'
36
34
  end
37
- when :stop
35
+ when :stop_button!
38
36
  system 'mpc stop'
37
+ else
38
+ Gtk2Mp3.hook(command)
39
39
  end
40
40
  end
41
41
 
42
+ def Gtk2Mp3.hook(command)
43
+ # You can monkey-patch this function
44
+ end
45
+
42
46
  def Gtk2Mp3.mpc_idleloop(gui)
43
47
  Thread.new do
44
48
  IO.popen('mpc idleloop', 'r') do |pipe|
@@ -0,0 +1,41 @@
1
+ # To activate this hook, edit your current configuration file:
2
+ # ~/.config/gtk3app/gtk2mp3/config-?.?.rbon
3
+ # Set:
4
+ # MonkeyPatch: "gtk2mp3/picard_button",
5
+ require 'shellwords'
6
+ class Gtk2Mp3
7
+ extend Rafini::Empty
8
+
9
+ CONFIG[:BUTTONS].push :picard_button!
10
+ CONFIG[:PICARD_BUTTON] = [label: 'Picard']
11
+ CONFIG[:picard_button] = h0,
12
+ CONFIG[:picard_button!] = [:PICARD_BUTTON,:picard_button,'clicked']
13
+ CONFIG[:Music] ||= File.expand_path '~/Music'
14
+
15
+ def Gtk2Mp3.hook(command)
16
+ case command
17
+ when :picard_button!
18
+ current = `mpc current`.strip
19
+ if current=~/^(.*) - (.*)/
20
+ artist,title = $1,$2
21
+ else
22
+ artist,title = nil,current
23
+ end
24
+ tfiles = `mpc search Title #{Shellwords.escape(title)} | egrep '\.mp3$'`
25
+ .strip.split
26
+ if artist and tfiles.length > 1
27
+ afiles =
28
+ `mpc search Artist #{Shellwords.escape(artist)} | egrep '\.mp3$'`
29
+ .strip.split
30
+ tfiles.delete_if{ not afiles.include? _1}
31
+ end
32
+ if tfiles.length > 0
33
+ files = tfiles.map{Shellwords.escape File.join(CONFIG[:Music], _1)}
34
+ .join(' ')
35
+ spawn "picard #{files}" if tfiles.length > 0
36
+ else
37
+ $stderr.puts "Not an mp3 file: #{current}"
38
+ end
39
+ end
40
+ end
41
+ end
data/lib/gtk2mp3.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Gtk2Mp3
2
- VERSION = '3.0.210920'
2
+ VERSION = '3.1.210926'
3
3
  HELP = <<~HELP
4
4
  Usage:
5
5
  gtk2mp3 [:options+]
@@ -28,6 +28,7 @@ class Gtk2Mp3
28
28
  require_relative 'gtk2mp3/config'
29
29
  require_relative 'gtk2mp3/gui'
30
30
  Gtk3App.run(klass:Gtk2Mp3) do |stage, toolbar, options|
31
+ require CONFIG[:MonkeyPatch] unless CONFIG[:MonkeyPatch].empty?
31
32
  gui = Gtk2Mp3.new(stage, toolbar, options){Gtk2Mp3.mpc_command _1}
32
33
  Gtk2Mp3.mpc_idleloop(gui)
33
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gtk2mp3
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.210920
4
+ version: 3.1.210926
5
5
  platform: ruby
6
6
  authors:
7
7
  - CarlosJHR64
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-20 00:00:00.000000000 Z
11
+ date: 2021-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gtk3app
@@ -47,6 +47,7 @@ files:
47
47
  - lib/gtk2mp3/config.rb
48
48
  - lib/gtk2mp3/gui.rb
49
49
  - lib/gtk2mp3/mpd.rb
50
+ - lib/gtk2mp3/picard_button.rb
50
51
  homepage: https://github.com/carlosjhr64/gtk2mp3
51
52
  licenses:
52
53
  - MIT