ampv 1.1.3 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65f13c0d7f38f560c3937579e6d4339b09fafac8
4
- data.tar.gz: 2d6455627b9afe91aa9eb0a1a1672c4c60bb0e21
3
+ metadata.gz: 4cd792f9c7d994f5be1035bcbced7c95df683908
4
+ data.tar.gz: a16d8998f82dfd65d0611ee602447adbc6fb6c95
5
5
  SHA512:
6
- metadata.gz: ea8edc45f06b2c3ab8b9eb45adc6e04f9fb9b6ef71de5b62b87abf93c70181234cc8c62b838f0c1bd9f1ab824eb749fc8f0dc07f79b87e33002c402fc3e588d1
7
- data.tar.gz: 3d6a353dac2ab859dd2dbf1f81ff721a1f56fcf811b543494d357dfff9b13be22e88d743ef87d78cd4057fe088a2e0db82e2d7fe0fb3c2cb28b32fc1b0f04cec
6
+ metadata.gz: d5c646276dece49053e5ee73dceb67c2de4ce4485ba014c261701798ea9234ce66b68e23f970703e5d2c79ee5c9f7b14c2f3592be418611badfdb8239622747d
7
+ data.tar.gz: 8d0e88a8409d93bf33271abf62ca452af5e6296e47d5310007dad00e069e731a04c6284c1bf7772bf91acf7f19848c4bfa0f53599a13ea4d09dfaea8dd8b6170
@@ -19,9 +19,6 @@ module Ampv
19
19
  Gdk::EventScroll::RIGHT => 7
20
20
  }
21
21
 
22
- LEFT_PTR = Gdk::Cursor.new(Gdk::Cursor::LEFT_PTR)
23
- BLANK_CURSOR = Gdk::Cursor.new(Gdk::Cursor::BLANK_CURSOR)
24
-
25
22
  def initialize
26
23
  unless defined?(MpvWidget::PATH)
27
24
  dlg = Gtk::MessageDialog.new(nil,
@@ -60,6 +57,7 @@ module Ampv
60
57
  files = sd.uris.map { |f| URI.decode(f).sub(/^file:\/\/[^\/]*/, "") }
61
58
  @playlist.clear(true) unless @playlist.get_files & files == files
62
59
  load_files(files)
60
+ present
63
61
  Gtk::Drag.finish(dc, true, false, time)
64
62
  }
65
63
  signal_connect("motion_notify_event") { mouse_cursor_timeout }
@@ -68,22 +66,10 @@ module Ampv
68
66
  @mpv = MpvWidget.new(args)
69
67
  @progress_bar = ProgressBarWidget.new
70
68
  @playlist = Playlist.new
71
- @ignore_stop = false
72
69
 
73
70
  @mpv.signal_connect("file_changed") { |w, file|
74
71
  @playing = URI.decode(file).sub(/^file:\/\/[^\/]*/, "")
75
- # hacky work around when mpv catches drag and drop events.
76
- unless @playlist.include?(@playing)
77
- @playlist.clear(true)
78
- if (file = create_playlist(@playing)) != @playing and File.directory?(@playing)
79
- @playing = file
80
- GLib::Idle.add { @mpv.load_file(@playing); false }
81
- # mpv will fail to play the directory and then stop
82
- # ignore the next stop event so the playlist does not advance
83
- @ignore_stop = true
84
- end
85
- end
86
- @mpv.send("show_text ${media-title} 1500") if window.state.fullscreen? and !@ignore_stop
72
+ @mpv.send("show_text ${media-title} 1500") if window.state.fullscreen?
87
73
  @playlist.set_selected(@playing)
88
74
  set_title(File.basename(@playing))
89
75
  }
@@ -93,22 +79,21 @@ module Ampv
93
79
  @mpv.signal_connect("stopped") {
94
80
  @progress_bar.value = 0
95
81
  set_title(PACKAGE)
96
- unless @ignore_stop
97
- next_file = @playlist.get_next
98
- @really_stop ||= next_file.nil?
99
- if !@really_stop
100
- @mpv.load_file(next_file)
101
- else
102
- @playlist.playing_stopped
103
- toggle_fullscreen if window.state.fullscreen?
104
- end
82
+ next_file = @playlist.get_next
83
+ @really_stop ||= next_file.nil?
84
+ if !@really_stop
85
+ @mpv.load_file(next_file)
86
+ else
87
+ @playlist.playing_stopped
88
+ toggle_fullscreen if window.state.fullscreen?
105
89
  end
106
- @really_stop = @ignore_stop = false
90
+ @really_stop = false
107
91
  }
108
92
 
109
93
  @playlist.signal_connect("open_file_chooser") { open_file_chooser }
110
94
  @playlist.signal_connect("drag_data_received") { |w, dc, x, y, sd, type, time|
111
95
  sd.uris.each { |f| @playlist.add_file(URI.decode(f).sub(/^file:\/\/[^\/]*/, "")) }
96
+ present
112
97
  Gtk::Drag.finish(dc, true, false, time)
113
98
  }
114
99
  @playlist.signal_connect("play_entry") { |w, file| @mpv.load_file(file, true) }
@@ -178,10 +163,12 @@ module Ampv
178
163
  end
179
164
 
180
165
  def handle_mouse_event(e)
166
+ if e.event_type != Gdk::Event::MOTION_NOTIFY
167
+ button = e.event_type == Gdk::Event::SCROLL ? WHEEL_BUTTONS[e.direction] : e.button
168
+ return if Config["mouse_bindings"][e.event_type].nil?
169
+ process_cmd(Config["mouse_bindings"][e.event_type][button])
170
+ end
181
171
  mouse_cursor_timeout
182
- button = e.event_type == Gdk::Event::SCROLL ? WHEEL_BUTTONS[e.direction] : e.button
183
- return if Config["mouse_bindings"][e.event_type].nil?
184
- process_cmd(Config["mouse_bindings"][e.event_type][button])
185
172
  end
186
173
 
187
174
  def handle_keyboard_event(e)
@@ -196,11 +183,12 @@ module Ampv
196
183
  end
197
184
 
198
185
  def mouse_cursor_timeout
199
- window.set_cursor(LEFT_PTR)
186
+ window.set_cursor(nil)
200
187
  GLib::Source.remove(@cursor_timeout) if @cursor_timeout
201
188
  @cursor_timeout = GLib::Timeout.add(1000) {
202
- window.set_cursor(BLANK_CURSOR)
203
- } unless @mpv.is_paused
189
+ window.set_cursor(Gdk::Cursor.new(Gdk::Cursor::BLANK_CURSOR)) unless @mpv.is_paused
190
+ false
191
+ }
204
192
  end
205
193
 
206
194
  def process_cmd(cmd)
@@ -31,16 +31,12 @@ module Ampv
31
31
  @is_paused = true
32
32
 
33
33
  super()
34
- signal_connect("realize") { start }
35
34
 
36
- @socket = Gtk::Socket.new
37
- @socket.modify_bg(Gtk::STATE_NORMAL, Gdk::Color.parse("#000"))
38
- @socket.signal_connect("plug_removed") {
39
- signal_emit("stopped")
40
- @is_stopped = true
41
- }
35
+ @widget = Gtk::DrawingArea.new
36
+ @widget.modify_bg(Gtk::STATE_NORMAL, Gdk::Color.parse("#000"))
37
+ @widget.signal_connect("realize") { start }
42
38
 
43
- add(@socket)
39
+ add(@widget)
44
40
  end
45
41
 
46
42
  def send(cmd)
@@ -81,13 +77,13 @@ module Ampv
81
77
  --cursor-autohide=no \
82
78
  --no-mouse-movements \
83
79
  --msglevel=all=info \
84
- --wid=#{@socket.id} #{@mpv_options}"
80
+ --wid=#{@widget.window.xid} #{@mpv_options}"
85
81
 
86
82
  @thread = Thread.start {
87
83
  IO.popen(cmd) { |io|
88
84
  io.each { |line|
89
85
  line.chomp!
90
- if line.include?("Playing: ")
86
+ if line.start_with?("Playing: ")
91
87
  signal_emit("file_changed", (@playing = line.partition("Playing: ")[-1]))
92
88
  send("get_property length")
93
89
  send("get_property time-pos")
@@ -102,6 +98,9 @@ module Ampv
102
98
  play_pause if @force_play and @is_paused
103
99
  elsif line.start_with?("ANS_time-pos=")
104
100
  signal_emit("time_pos_changed", line.rpartition("=")[-1].to_f)
101
+ elsif line == "Creating non-video VO window."
102
+ signal_emit("stopped")
103
+ @is_stopped = true
105
104
  end
106
105
 
107
106
  puts(line) if @debug and !line.start_with?("ANS_")
@@ -114,7 +113,7 @@ module Ampv
114
113
  scrobbled = false
115
114
  watched = 0
116
115
  loop {
117
- send("get_property time-pos") unless @is_paused
116
+ send("get_property time-pos")
118
117
  unless scrobbled or watched < @length * 0.5
119
118
  system("#{Config["scrobbler"]} \"#{@playing}\"") if Config["scrobbler"]
120
119
  signal_emit("playing_watched")
@@ -42,11 +42,11 @@ module Ampv
42
42
  vbox.border_width = 10
43
43
  sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
44
44
 
45
- @treeview.enable_search = false
46
- @treeview.rubber_banding = true
47
- @treeview.reorderable = true
48
- @treeview.selection.mode = Gtk::SELECTION_MULTIPLE
49
- @treeview.tooltip_column = 0
45
+ @treeview.set_enable_search (false)
46
+ @treeview.set_rubber_banding(true)
47
+ @treeview.set_reorderable(true)
48
+ @treeview.set_tooltip_column(0)
49
+ @treeview.selection.set_mode(Gtk::SELECTION_MULTIPLE)
50
50
 
51
51
  @treeview.signal_connect("row_activated") { |w, p, c|
52
52
  signal_emit("play_entry", @model.get_iter(p)[0])
@@ -55,7 +55,11 @@ module Ampv
55
55
  remove_selected if e.keyval == Gdk::Keyval::GDK_Delete
56
56
  }
57
57
  @treeview.signal_connect("button_press_event") { |w, e|
58
- @menu.popup(nil, nil, e.button, e.time) if e.event_type == Gdk::Event::BUTTON_PRESS and e.button == 3
58
+ if e.event_type == Gdk::Event::BUTTON_PRESS and e.button == 3
59
+ path = @treeview.get_path(e.x, e.y)[0]
60
+ @treeview.set_cursor(path, nil, false) if path
61
+ @menu.popup(nil, nil, e.button, e.time)
62
+ end
59
63
  }
60
64
 
61
65
  ["Name", "Length"].each_with_index { |x, i|
@@ -1,5 +1,5 @@
1
1
  module Ampv
2
2
  PACKAGE = "ampv"
3
- VERSION = "1.1.3"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ampv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ahoka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-08 00:00:00.000000000 Z
11
+ date: 2014-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gtk2
@@ -62,9 +62,9 @@ files:
62
62
  - LICENSE
63
63
  - input.conf
64
64
  - lib/ampv/mpvwidget.rb
65
- - lib/ampv/playlist.rb
66
65
  - lib/ampv/progressbarwidget.rb
67
66
  - lib/ampv/config.rb
67
+ - lib/ampv/playlist.rb
68
68
  - lib/ampv/version.rb
69
69
  - lib/ampv.rb
70
70
  - bin/ampv