From cb8315b51eac58e9a892b72841dcc6cd56c0a801 Mon Sep 17 00:00:00 2001 From: Aitor Date: Sat, 1 Apr 2023 15:54:00 +0200 Subject: [PATCH 01/21] Add inode/directory MIME type to desktop file --- data/music.desktop.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/music.desktop.in b/data/music.desktop.in index 4513ca5f3..508035740 100644 --- a/data/music.desktop.in +++ b/data/music.desktop.in @@ -1,4 +1,4 @@ -[Desktop Entry] + [Desktop Entry] Type=Application Name=Music GenericName=Music Player @@ -7,7 +7,7 @@ Exec=io.elementary.music %U Icon=io.elementary.music Terminal=false Categories=Audio;Music;Player;AudioVideo;GTK; -MimeType=x-content/audio-player;x-content/audio-cdda;application/ogg;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-ogg;audio/3gpp;audio/aac;audio/ac3;audio/AMR;audio/AMR-WB;audio/basic;audio/flac;audio/midi;audio/mp2;audio/mp4;audio/mpeg;audio/ogg;audio/vnd.rn-realaudio;audio/x-aiff;audio/x-ape;audio/x-flac;audio/x-gsm;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;audio/x-musepack;audio/x-opus+ogg;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-realaudio;audio/x-real-audio;audio/x-sbc;audio/x-scpls;audio/x-speex;audio/x-tta;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-wav;audio/x-wavpack;audio/x-xm;audio/x-s3m; +MimeType=x-content/audio-player;x-content/audio-cdda;application/ogg;application/x-extension-m4a;application/x-extension-mp4;application/x-flac;application/x-ogg;audio/3gpp;audio/aac;audio/ac3;audio/AMR;audio/AMR-WB;audio/basic;audio/flac;audio/midi;audio/mp2;audio/mp4;audio/mpeg;audio/ogg;audio/vnd.rn-realaudio;audio/x-aiff;audio/x-ape;audio/x-flac;audio/x-gsm;audio/x-it;audio/x-m4a;audio/x-matroska;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-asf;audio/x-ms-asx;audio/x-ms-wax;audio/x-ms-wma;audio/x-musepack;audio/x-opus+ogg;audio/x-pn-aiff;audio/x-pn-au;audio/x-pn-realaudio;audio/x-pn-realaudio-plugin;audio/x-pn-wav;audio/x-pn-windows-acm;audio/x-realaudio;audio/x-real-audio;audio/x-sbc;audio/x-scpls;audio/x-speex;audio/x-tta;audio/x-vorbis;audio/x-vorbis+ogg;audio/x-wav;audio/x-wavpack;audio/x-xm;audio/x-s3m;inode/directory; StartupNotify=true Keywords=Noise;Audio;Player;MP3;Play;Playlist;Media;Songs; X-GNOME-UsesNotifications=true From 9b117a31fa0b4f9cc2c8f4d259626d1fc6e4a035 Mon Sep 17 00:00:00 2001 From: Aitor Date: Sat, 1 Apr 2023 16:20:20 +0200 Subject: [PATCH 02/21] Fix typo in desktop file --- data/music.desktop.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/music.desktop.in b/data/music.desktop.in index 508035740..5c59d6bd5 100644 --- a/data/music.desktop.in +++ b/data/music.desktop.in @@ -1,4 +1,4 @@ - [Desktop Entry] +[Desktop Entry] Type=Application Name=Music GenericName=Music Player From 1b39a131c2d49182a87ace9c56406e298e35eea7 Mon Sep 17 00:00:00 2001 From: Aitor Date: Sun, 2 Apr 2023 11:56:54 +0200 Subject: [PATCH 03/21] Experimental code that allows to open folders. Needs feedback --- src/Application.vala | 47 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index 84ec0f8cb..7a0979e76 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -103,12 +103,57 @@ public class Music.Application : Gtk.Application { settings.bind ("window-maximized", main_window, "maximized", SettingsBindFlags.SET); } + // FIXME(aitor-gomila): improve algorithm and make code cleaner + Array listDirectory(string directory) { + var dir = Dir.open(directory, 0); + string? name = null; + Array elements = new Array(); + + while((name = dir.read_name ()) != null) { + string filePath = Path.build_filename (directory, name); + File file = File.new_for_path(filePath); + elements.append_val(file); + } + return elements; + } + + private bool isDirectory(string file) { + return FileUtils.test(file, FileTest.IS_DIR); + } + + private void loopThroughFiles(Array files) { + for (var i = 0; i < files.length; i++) { + var file = files.index(i); + var filePath = file.get_path(); + var isDirectory = isDirectory(filePath); + + if (!isDirectory) { + File[] arr = new File[1]; + arr[0] = file; + playback_manager.queue_files(arr); + return; + } + // Is a directory + var directoryElements = listDirectory(filePath); + loopThroughFiles(directoryElements); + } + } + protected override void open (File[] files, string hint) { if (active_window == null) { activate (); } - playback_manager.queue_files (files); + // Turns File[] into Array + // Is there a cleaner way to do this? + Array filesArr = new Array(); + + for (var i = 0; i < files.length; i++) { + var file = files[i]; + filesArr.append_val(file); + } + + loopThroughFiles(filesArr); } private void action_play_pause () { From 7591b74fe1110e2f6bcd833a51d0cbc4c958b315 Mon Sep 17 00:00:00 2001 From: Aitor Date: Sun, 2 Apr 2023 12:37:18 +0200 Subject: [PATCH 04/21] Use continue instead of return not to stop loop --- src/Application.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index 7a0979e76..c01b1dd2a 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -131,7 +131,7 @@ public class Music.Application : Gtk.Application { File[] arr = new File[1]; arr[0] = file; playback_manager.queue_files(arr); - return; + continue; } // Is a directory var directoryElements = listDirectory(filePath); From 62e45e6a8fc9085b6ef973cb427a44354d3c41bb Mon Sep 17 00:00:00 2001 From: Aitor Date: Sun, 2 Apr 2023 12:42:21 +0200 Subject: [PATCH 05/21] Use File[] instead of Array --- src/Application.vala | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index c01b1dd2a..d354b497f 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -104,15 +104,15 @@ public class Music.Application : Gtk.Application { } // FIXME(aitor-gomila): improve algorithm and make code cleaner - Array listDirectory(string directory) { + File[] listDirectory(string directory) { var dir = Dir.open(directory, 0); string? name = null; - Array elements = new Array(); + File[] elements = new File[1]; while((name = dir.read_name ()) != null) { string filePath = Path.build_filename (directory, name); File file = File.new_for_path(filePath); - elements.append_val(file); + elements += file; } return elements; } @@ -121,9 +121,9 @@ public class Music.Application : Gtk.Application { return FileUtils.test(file, FileTest.IS_DIR); } - private void loopThroughFiles(Array files) { + private void loopThroughFiles(File[] files) { for (var i = 0; i < files.length; i++) { - var file = files.index(i); + var file = files[i]; var filePath = file.get_path(); var isDirectory = isDirectory(filePath); @@ -144,16 +144,7 @@ public class Music.Application : Gtk.Application { activate (); } - // Turns File[] into Array - // Is there a cleaner way to do this? - Array filesArr = new Array(); - - for (var i = 0; i < files.length; i++) { - var file = files[i]; - filesArr.append_val(file); - } - - loopThroughFiles(filesArr); + loopThroughFiles(files); } private void action_play_pause () { From 49e091a76457f9334ded5cc98b7022f9f3efe1fe Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 08:49:40 +0200 Subject: [PATCH 06/21] Implement changes in review, improve readibility --- src/Application.vala | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index d354b497f..68c70b247 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -103,17 +103,19 @@ public class Music.Application : Gtk.Application { settings.bind ("window-maximized", main_window, "maximized", SettingsBindFlags.SET); } - // FIXME(aitor-gomila): improve algorithm and make code cleaner File[] listDirectory(string directory) { var dir = Dir.open(directory, 0); + string? name = null; - File[] elements = new File[1]; + File[] elements = {}; while((name = dir.read_name ()) != null) { string filePath = Path.build_filename (directory, name); File file = File.new_for_path(filePath); + elements += file; } + return elements; } @@ -122,17 +124,19 @@ public class Music.Application : Gtk.Application { } private void loopThroughFiles(File[] files) { - for (var i = 0; i < files.length; i++) { - var file = files[i]; + foreach (var file in files) { var filePath = file.get_path(); var isDirectory = isDirectory(filePath); if (!isDirectory) { - File[] arr = new File[1]; + File[] arr = {}; arr[0] = file; + playback_manager.queue_files(arr); + continue; } + // Is a directory var directoryElements = listDirectory(filePath); loopThroughFiles(directoryElements); From 5b748d58eeec6eed227b0f5696cba2a9f19b0ee3 Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 09:14:38 +0200 Subject: [PATCH 07/21] Make loop code easier to understand and more performant --- src/Application.vala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 68c70b247..f6d82311b 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -124,15 +124,15 @@ public class Music.Application : Gtk.Application { } private void loopThroughFiles(File[] files) { + // All of these are added later in bulk + File[] elements = {}; + foreach (var file in files) { var filePath = file.get_path(); var isDirectory = isDirectory(filePath); if (!isDirectory) { - File[] arr = {}; - arr[0] = file; - - playback_manager.queue_files(arr); + elements += file; continue; } @@ -141,6 +141,8 @@ public class Music.Application : Gtk.Application { var directoryElements = listDirectory(filePath); loopThroughFiles(directoryElements); } + + playback_manager.queue_files (elements); } protected override void open (File[] files, string hint) { From a049712dd1446e63fb68a74cf89afaeea49bb8d9 Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 09:37:51 +0200 Subject: [PATCH 08/21] Implement changes in review --- src/Application.vala | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index f6d82311b..1b1679c37 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -103,7 +103,7 @@ public class Music.Application : Gtk.Application { settings.bind ("window-maximized", main_window, "maximized", SettingsBindFlags.SET); } - File[] listDirectory(string directory) { + File[] list_directory(string directory) { var dir = Dir.open(directory, 0); string? name = null; @@ -119,30 +119,28 @@ public class Music.Application : Gtk.Application { return elements; } - private bool isDirectory(string file) { + private bool is_directory(string file) { return FileUtils.test(file, FileTest.IS_DIR); } - private void loopThroughFiles(File[] files) { - // All of these are added later in bulk + private File[] loop_through_files(File[] files) { + // All of these will be returned later in bulk File[] elements = {}; foreach (var file in files) { var filePath = file.get_path(); - var isDirectory = isDirectory(filePath); - - if (!isDirectory) { - elements += file; + var isDirectory = is_directory(filePath); + if (isDirectory) { + var directoryElements = list_directory(filePath); + elements += loop_through_files(directoryElements); continue; } - // Is a directory - var directoryElements = listDirectory(filePath); - loopThroughFiles(directoryElements); + elements += file; } - playback_manager.queue_files (elements); + return elements; } protected override void open (File[] files, string hint) { @@ -150,7 +148,7 @@ public class Music.Application : Gtk.Application { activate (); } - loopThroughFiles(files); + playback_manager.queue_files(loop_through_files(files)); } private void action_play_pause () { From e14cdc84647032a206aa3700021c6eb89b979ad4 Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 09:57:22 +0200 Subject: [PATCH 09/21] Use try/catch to handle errors in list_directory --- src/Application.vala | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 1b1679c37..34924a79d 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -104,19 +104,24 @@ public class Music.Application : Gtk.Application { } File[] list_directory(string directory) { - var dir = Dir.open(directory, 0); + try { + var dir = Dir.open(directory, 0); - string? name = null; - File[] elements = {}; + string? name = null; + File[] elements = {}; - while((name = dir.read_name ()) != null) { - string filePath = Path.build_filename (directory, name); - File file = File.new_for_path(filePath); + while((name = dir.read_name ()) != null) { + string filePath = Path.build_filename (directory, name); + File file = File.new_for_path(filePath); - elements += file; - } + elements += file; + } - return elements; + return elements; + } catch (FileError e) { + warning(e.message); + return {}; + } } private bool is_directory(string file) { From cc64c6b793c9824afc271434a871cc05f6c8ee6e Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 10:00:40 +0200 Subject: [PATCH 10/21] Get files from subdirectories too --- src/Application.vala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index 34924a79d..d6cb21e14 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -138,7 +138,12 @@ public class Music.Application : Gtk.Application { if (isDirectory) { var directoryElements = list_directory(filePath); - elements += loop_through_files(directoryElements); + var directoryFiles = loop_through_files(directoryElements); + + foreach (var directoryFile in directoryFiles) { + elements += directoryFile; + } + continue; } From 8ac4f781c993abc982dcb913d9159460b558cd23 Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 10:15:11 +0200 Subject: [PATCH 11/21] Lint --- src/Application.vala | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index d6cb21e14..574cbc384 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -103,45 +103,45 @@ public class Music.Application : Gtk.Application { settings.bind ("window-maximized", main_window, "maximized", SettingsBindFlags.SET); } - File[] list_directory(string directory) { + File[] list_directory (string directory) { try { - var dir = Dir.open(directory, 0); + var dir = Dir.open (directory, 0); string? name = null; File[] elements = {}; - while((name = dir.read_name ()) != null) { - string filePath = Path.build_filename (directory, name); - File file = File.new_for_path(filePath); + while ((name = dir.read_name ()) != null) { + string file_path = Path.build_filename (directory, name); + File file = File.new_for_path (file_path); elements += file; } return elements; } catch (FileError e) { - warning(e.message); + warning (e.message); return {}; } } - private bool is_directory(string file) { - return FileUtils.test(file, FileTest.IS_DIR); + private bool is_directory (string file) { + return FileUtils.test (file, FileTest.IS_DIR); } - private File[] loop_through_files(File[] files) { + private File[] loop_through_files (File[] files) { // All of these will be returned later in bulk File[] elements = {}; foreach (var file in files) { - var filePath = file.get_path(); - var isDirectory = is_directory(filePath); + var file_path = file.get_path (); + var is_directory = is_directory (file_path); - if (isDirectory) { - var directoryElements = list_directory(filePath); - var directoryFiles = loop_through_files(directoryElements); + if (is_directory) { + var directory_elements = list_directory (file_path); + var directory_files = loop_through_files (directory_elements); - foreach (var directoryFile in directoryFiles) { - elements += directoryFile; + foreach (var directory_file in directory_files) { + elements += directory_file; } continue; @@ -158,7 +158,7 @@ public class Music.Application : Gtk.Application { activate (); } - playback_manager.queue_files(loop_through_files(files)); + playback_manager.queue_files (loop_through_files (files)); } private void action_play_pause () { From dbab76aa41c88ecdc548bdb52121e3f1b80ddc5d Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 14:43:53 +0200 Subject: [PATCH 12/21] Make field private --- src/Application.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index 574cbc384..34c1d58f0 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -103,7 +103,7 @@ public class Music.Application : Gtk.Application { settings.bind ("window-maximized", main_window, "maximized", SettingsBindFlags.SET); } - File[] list_directory (string directory) { + private File[] list_directory (string directory) { try { var dir = Dir.open (directory, 0); From 3c3bd2f5fb9ed7a592e674fa94864b860c857eb1 Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 14:57:35 +0200 Subject: [PATCH 13/21] Simplify code calling is_directory --- src/Application.vala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 34c1d58f0..72dc3151b 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -134,9 +134,8 @@ public class Music.Application : Gtk.Application { foreach (var file in files) { var file_path = file.get_path (); - var is_directory = is_directory (file_path); - if (is_directory) { + if (is_directory (file_path)) { var directory_elements = list_directory (file_path); var directory_files = loop_through_files (directory_elements); From cf8acb4839410b5065d91f81cae34e3d380b8c2e Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 15:01:20 +0200 Subject: [PATCH 14/21] Move is_directory declaration to inline --- src/Application.vala | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 72dc3151b..7459411e8 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -124,10 +124,6 @@ public class Music.Application : Gtk.Application { } } - private bool is_directory (string file) { - return FileUtils.test (file, FileTest.IS_DIR); - } - private File[] loop_through_files (File[] files) { // All of these will be returned later in bulk File[] elements = {}; @@ -135,7 +131,7 @@ public class Music.Application : Gtk.Application { foreach (var file in files) { var file_path = file.get_path (); - if (is_directory (file_path)) { + if (FileUtils.test (file_path, FileTest.IS_DIR)) { var directory_elements = list_directory (file_path); var directory_files = loop_through_files (directory_elements); From b96d440e77ee12ee49ba7954c7bac65dadbf78bd Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 15:06:43 +0200 Subject: [PATCH 15/21] Move rest of the try/catch outside --- src/Application.vala | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 7459411e8..59f05f977 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -106,22 +106,23 @@ public class Music.Application : Gtk.Application { private File[] list_directory (string directory) { try { var dir = Dir.open (directory, 0); + } catch (FileError e) { + warning (e.message); - string? name = null; - File[] elements = {}; + return {}; + } - while ((name = dir.read_name ()) != null) { - string file_path = Path.build_filename (directory, name); - File file = File.new_for_path (file_path); + string? name = null; + File[] elements = {}; - elements += file; - } + while ((name = dir.read_name ()) != null) { + string file_path = Path.build_filename (directory, name); + File file = File.new_for_path (file_path); - return elements; - } catch (FileError e) { - warning (e.message); - return {}; + elements += file; } + + return elements; } private File[] loop_through_files (File[] files) { From b9f816851bbc4e0dd04fdae3d882ffc608ec4678 Mon Sep 17 00:00:00 2001 From: Aitor <46191980+aitor-gomila@users.noreply.github.com> Date: Mon, 3 Apr 2023 13:16:29 +0000 Subject: [PATCH 16/21] Declare dir outside in try/catch Co-authored-by: Leo --- src/Application.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index 59f05f977..a4db13c35 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -104,8 +104,9 @@ public class Music.Application : Gtk.Application { } private File[] list_directory (string directory) { + Dir dir; try { - var dir = Dir.open (directory, 0); + dir = Dir.open (directory, 0); } catch (FileError e) { warning (e.message); From f0d3f82f2cd0deade96046aa446aab4ea6b0fd92 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Mon, 3 Apr 2023 19:38:02 +0100 Subject: [PATCH 17/21] Give flatpak access to users Music folder --- io.elementary.music.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/io.elementary.music.yml b/io.elementary.music.yml index bec3ea39d..b2b787393 100644 --- a/io.elementary.music.yml +++ b/io.elementary.music.yml @@ -9,6 +9,7 @@ finish-args: - '--socket=wayland' - '--socket=pulseaudio' - '--device=dri' + - '--filesystem=xdg-music:ro' modules: - name: music From 4c8a856475933de32e0b7063544a448696e8528d Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Mon, 3 Apr 2023 19:38:27 +0100 Subject: [PATCH 18/21] Ignore flatpack files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index dc83d7d7c..89c0dbc9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ .flatpak-builder +.flatpak build From 682d136739cfd7a9cfc4e06e6b753a9cee770ded Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Mon, 3 Apr 2023 19:38:47 +0100 Subject: [PATCH 19/21] Comment and debugging message --- src/Application.vala | 4 +++- src/PlaybackManager.vala | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index a4db13c35..92f14473b 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -155,7 +155,9 @@ public class Music.Application : Gtk.Application { activate (); } - playback_manager.queue_files (loop_through_files (files)); + var files_to_play = loop_through_files (files); + debug ("Application: Number of files to play %u", files_to_play.length); + playback_manager.queue_files (files_to_play); } private void action_play_pause () { diff --git a/src/PlaybackManager.vala b/src/PlaybackManager.vala index 77338412d..abdc6bdfc 100644 --- a/src/PlaybackManager.vala +++ b/src/PlaybackManager.vala @@ -83,6 +83,7 @@ public class Music.PlaybackManager : Object { playbin.seek_simple (Gst.Format.TIME, Gst.SeekFlags.FLUSH, (int64)(percent * current_audio.duration)); } + // Files[] must not contain any null entries public void queue_files (File[] files) { discoverer.start (); int invalids = 0; From d81fea2659c6a32e3ddae9820c5d7d229a292d11 Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 21:03:38 +0200 Subject: [PATCH 20/21] Remove unneeded linebreak --- src/Application.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index 92f14473b..2563f10dc 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -109,7 +109,6 @@ public class Music.Application : Gtk.Application { dir = Dir.open (directory, 0); } catch (FileError e) { warning (e.message); - return {}; } From 0c9de6df112993e7c4619552996423d871d45530 Mon Sep 17 00:00:00 2001 From: Aitor Date: Mon, 3 Apr 2023 21:06:28 +0200 Subject: [PATCH 21/21] Use type inference in File declaration at list_directory --- src/Application.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 2563f10dc..1b3c4df39 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -116,8 +116,8 @@ public class Music.Application : Gtk.Application { File[] elements = {}; while ((name = dir.read_name ()) != null) { - string file_path = Path.build_filename (directory, name); - File file = File.new_for_path (file_path); + var file_path = Path.build_filename (directory, name); + var file = File.new_for_path (file_path); elements += file; }