ampv 1.1.1 → 1.1.2

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NDlmNGYzOTM1YzRmYTQ2ZmI4MDkzZjhjYWQ4ODgwMDlkNjU4YjU5MQ==
5
- data.tar.gz: !binary |-
6
- M2ZlYmE2N2QxZGIxNmJjNmYxMjc4ZTgzMTg5N2U5ZTQyNjkyM2ZiMQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NDMyMTlkZDc0NTk5YTIzOGRjOGJhZDRkYzlkNjFiM2NkYzI2ZGY2MGE5ZTBk
10
- Mzc5YzkzYWQ0MGNjMDMxZTQyNzdlOGZhZjVhYmZiMzg2MDlmMTFmYjdjN2Jk
11
- NTk0ZGU1ZWQ0MTg2MTZjZjc5OWQ2MmZkMjJhMWY5ODI1OTczNTU=
12
- data.tar.gz: !binary |-
13
- YmYwZDRiYWQyNjg0NTM5Y2JkNGY5NzZjY2Y4MjVmOGI3ODRjOWQyMzU0MmEx
14
- MWUwZjEwZDdlZWVlMTEwZTc2OTFmMWY0MzI4YTc5OTFmYmI2NjVhYzlhMTVi
15
- MDY0N2MxMzI2MTY5MTAxMGNkMWI5YTE3ZDBlOWM2NDFlZGQ2YmM=
2
+ SHA1:
3
+ metadata.gz: 67bcc7597fa24e08ca81a50a2bbb810a95fcf937
4
+ data.tar.gz: 67c22c9f18bacff3c12a077242db957868967a7a
5
+ SHA512:
6
+ metadata.gz: 8311e6dd3454d64619ca7a9f81822f30cd85250e60275d85079b3217fe2c26793e4e822d304c6e1a695892fb590189f9d50764196fd30d1b409011bb952337be
7
+ data.tar.gz: bdcdcf12923d80c54a19022e7463ea6e2dc80758b789f1f29f5975cf33ec5cdc20c3fb44dc7450121dd8dcb66135d9d58c69281c57dd1f4bfc959e74d92c5c05
@@ -57,7 +57,9 @@ module Ampv
57
57
  signal_connect("button_press_event") { |w, e| handle_mouse_event(e) }
58
58
  signal_connect("key_press_event") { |w, e| handle_keyboard_event(e) }
59
59
  signal_connect("drag_data_received") { |w, dc, x, y, sd, type, time|
60
- handle_drop_event(sd.uris, false, true)
60
+ files = sd.uris.map { |f| URI.decode(f).sub(/^file:\/\/[^\/]*/, "") }
61
+ @playlist.clear(true) unless @playlist.get_files & files == files
62
+ load_files(files)
61
63
  Gtk::Drag.finish(dc, true, false, time)
62
64
  }
63
65
  signal_connect("motion_notify_event") { mouse_cursor_timeout }
@@ -95,7 +97,7 @@ module Ampv
95
97
  next_file = @playlist.get_next
96
98
  @really_stop ||= next_file.nil?
97
99
  if !@really_stop
98
- load_file(next_file, false)
100
+ @mpv.load_file(next_file)
99
101
  elsif window.state.fullscreen?
100
102
  toggle_fullscreen
101
103
  end
@@ -105,10 +107,10 @@ module Ampv
105
107
 
106
108
  @playlist.signal_connect("open_file_chooser") { open_file_chooser }
107
109
  @playlist.signal_connect("drag_data_received") { |w, dc, x, y, sd, type, time|
108
- handle_drop_event(sd.uris, true, false)
110
+ sd.uris.each { |f| @playlist.add_file(URI.decode(f).sub(/^file:\/\/[^\/]*/, "")) }
109
111
  Gtk::Drag.finish(dc, true, false, time)
110
112
  }
111
- @playlist.signal_connect("play_entry") { |w, file| load_file(file, false, false, false, true) }
113
+ @playlist.signal_connect("play_entry") { |w, file| @mpv.load_file(file, true) }
112
114
  @playlist.signal_connect("playing_removed") { @mpv.stop; @really_stop = true }
113
115
 
114
116
  Gtk::Drag.dest_set(@playlist, Gtk::Drag::DEST_DEFAULT_ALL,
@@ -125,9 +127,9 @@ module Ampv
125
127
 
126
128
  if !files.empty?
127
129
  if files.length > 1
128
- files.each_with_index { |x, i| load_file(x, true, i != 0, false) }
130
+ load_files(files)
129
131
  else
130
- load_file(files[0])
132
+ load_file(files[0], false)
131
133
  end
132
134
  elsif Config["playlist"].length > 0
133
135
  Config["playlist"].each { |x| @playlist.add_file(x["file"], x["length"], x["watched"]) }
@@ -142,19 +144,32 @@ module Ampv
142
144
  end
143
145
 
144
146
  private
145
- def load_file(file, add_to_playlist = true, do_not_play = false, auto_add = true, force_play = false)
146
- file = File.expand_path(file) if file[0] == "~"
147
- return unless (File.directory?(file) or valid_video_file?(file))
147
+ def load_file(file, auto_add = true, play = true)
148
+ if file =~ /^#{URI::regexp}$/
149
+ uri = true
150
+ else
151
+ file = File.expand_path(file)
152
+ end
148
153
 
149
- if add_to_playlist
150
- if @playlist.count == 0 and auto_add and file !~ /^https?:\/\//
151
- file = create_playlist(file)
152
- else
153
- @playlist.add_file(file)
154
- end
154
+ return unless File.directory?(file) or valid_video_file?(file) or uri
155
+
156
+ if @playlist.count == 0 and auto_add
157
+ file = create_playlist(file)
158
+ elsif !@playlist.include?(file)
159
+ @playlist.add_file(file)
155
160
  end
156
161
 
157
- @mpv.load_file(file, force_play) unless do_not_play
162
+ @mpv.load_file(file) if play
163
+ end
164
+
165
+ def load_files(files)
166
+ if files.length == 1
167
+ load_file(files[0])
168
+ else
169
+ files.each_with_index { |x, i|
170
+ load_file(x, false, i == 0)
171
+ }
172
+ end
158
173
  end
159
174
 
160
175
  def create_playlist(file)
@@ -183,11 +198,6 @@ module Ampv
183
198
  end
184
199
  end
185
200
 
186
- def handle_drop_event(files, do_not_play, replace)
187
- @playlist.clear if replace
188
- files.each { |x| load_file(URI.decode(x).sub(/^file:\/\/[^\/]*/, ""), true, do_not_play) }
189
- end
190
-
191
201
  def mouse_cursor_timeout
192
202
  window.set_cursor(LEFT_PTR)
193
203
  GLib::Source.remove(@cursor_timeout) if @cursor_timeout
@@ -211,9 +221,11 @@ module Ampv
211
221
  when /add chapter/
212
222
  seek(cmd)
213
223
  when "playlist_next"
214
- load_file(@playlist.get_next, false)
224
+ file = @playlist.get_next
225
+ @mpv.load_file(file) if file
215
226
  when "playlist_prev"
216
- load_file(@playlist.get_prev, false)
227
+ file = @playlist.get_prev
228
+ @mpv.load_file(file) if file
217
229
  when "open_file_chooser"
218
230
  open_file_chooser
219
231
  when "cycle progress_bar"
@@ -256,10 +268,9 @@ module Ampv
256
268
  end
257
269
 
258
270
  def valid_video_file?(x)
259
- return (x and File.exists?(x) and !File.directory?(x) and VIDEO_EXTS.include?(File.extname(x).downcase))
271
+ return (x and File.exists?(x) and File.file?(x) and VIDEO_EXTS.include?(File.extname(x).downcase))
260
272
  end
261
273
 
262
-
263
274
  def open_file_chooser
264
275
  dialog = Gtk::FileChooserDialog.new("Open File - #{PACKAGE}",
265
276
  self, Gtk::FileChooser::ACTION_OPEN, nil,
@@ -277,10 +288,7 @@ module Ampv
277
288
  filterAll.add_pattern("*.*")
278
289
  dialog.add_filter(filterAll)
279
290
 
280
- dialog.filenames.each { |x|
281
- do_not_play = @playlist.count > 0
282
- load_file(x, true, do_not_play)
283
- } if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT
291
+ load_files(dialog.filenames) if dialog.run == Gtk::Dialog::RESPONSE_ACCEPT
284
292
  dialog.destroy
285
293
  end
286
294
 
@@ -7,6 +7,7 @@ module Ampv
7
7
  signal_new("open_file_chooser", GLib::Signal::RUN_FIRST, nil, nil)
8
8
 
9
9
  WATCHED_PIXBUF = Gtk::Invisible.new.render_icon(Gtk::Stock::OK, Gtk::IconSize::MENU)
10
+ PLAYING_PIXBUF = Gtk::Invisible.new.render_icon(Gtk::Stock::MEDIA_PLAY, Gtk::IconSize::MENU)
10
11
 
11
12
  def initialize
12
13
  buttons = {
@@ -114,6 +115,7 @@ module Ampv
114
115
 
115
116
  def on_playing_watched
116
117
  @playing_iter[2] = WATCHED_PIXBUF
118
+ @current_is_watched = true
117
119
  end
118
120
 
119
121
  def include?(file)
@@ -148,6 +150,12 @@ module Ampv
148
150
  entries
149
151
  end
150
152
 
153
+ def get_files
154
+ files = [ ]
155
+ @model.each { |m, p, iter| files << iter[0] }
156
+ files
157
+ end
158
+
151
159
  def clear(quiet = false)
152
160
  @model.clear
153
161
  signal_emit("playing_removed") unless quiet or @playing_iter.nil?
@@ -158,8 +166,14 @@ module Ampv
158
166
  i = 0
159
167
  @model.each { |m, p, iter|
160
168
  if iter[0] == @playing
169
+ # reset icon for previous playing entry
170
+ if @playing_iter
171
+ @playing_iter[2] = @current_is_watched ? WATCHED_PIXBUF : nil
172
+ end
161
173
  @treeview.set_cursor(Gtk::TreePath.new(i), nil, false)
162
174
  @playing_iter = iter
175
+ @current_is_watched = @playing_iter[2] == WATCHED_PIXBUF
176
+ @playing_iter[2] = PLAYING_PIXBUF
163
177
  break
164
178
  end
165
179
  i += 1
@@ -1,5 +1,5 @@
1
1
  module Ampv
2
2
  PACKAGE = "ampv"
3
- VERSION = "1.1.1"
3
+ VERSION = "1.1.2"
4
4
  end
5
5
 
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ampv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ahoka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-08 00:00:00.000000000 Z
11
+ date: 2014-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gtk2
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ruby-fifo
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: A minimal GTK2 mpv frontend.
@@ -61,11 +61,11 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - LICENSE
63
63
  - input.conf
64
- - lib/ampv/playlist.rb
65
- - lib/ampv/version.rb
66
64
  - lib/ampv/mpvwidget.rb
67
65
  - lib/ampv/progressbarwidget.rb
68
66
  - lib/ampv/config.rb
67
+ - lib/ampv/playlist.rb
68
+ - lib/ampv/version.rb
69
69
  - lib/ampv.rb
70
70
  - bin/ampv
71
71
  homepage: https://github.com/ahodesuka/ampv
@@ -78,12 +78,12 @@ require_paths:
78
78
  - lib
79
79
  required_ruby_version: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ! '>='
81
+ - - '>='
82
82
  - !ruby/object:Gem::Version
83
83
  version: 1.9.3
84
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - ! '>='
86
+ - - '>='
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: