From 117a372189f38aefa9f86930ac084b6e945ef381 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Thu, 24 Dec 2020 15:08:01 +0100 Subject: [PATCH] Pass GioFiles from FileChooser instead of URIs Otherwise they are converted back to GioFile to check their existance and back again to URI which is unefficient. This change avoids doing that. --- clapper_src/dialogs.js | 5 ++--- clapper_src/player.js | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/clapper_src/dialogs.js b/clapper_src/dialogs.js index 8e36ab9e..ddfe6e2a 100644 --- a/clapper_src/dialogs.js +++ b/clapper_src/dialogs.js @@ -52,18 +52,17 @@ class ClapperFileChooser extends Gtk.FileChooserNative let playlist = []; while((file = files.get_item(index))) { - let uri = file.get_uri(); let filename = file.get_basename(); let [type, isUncertain] = Gio.content_type_guess(filename, null); if(this.subsMimes.includes(type)) { - subs = uri; + subs = file; files.remove(index); continue; } - playlist.push(uri); + playlist.push(file); index++; } diff --git a/clapper_src/player.js b/clapper_src/player.js index 76238aec..d0f40ef2 100644 --- a/clapper_src/player.js +++ b/clapper_src/player.js @@ -156,8 +156,12 @@ class ClapperPlayer extends PlayerBase return this._playlist; } - set_subtitles(uri) + set_subtitles(source) { + let uri = (source.get_uri) + ? source.get_uri() + : source; + this.set_subtitle_uri(uri); this.set_subtitle_track_enabled(true);