[gnome-music/wip/jfelder/open-audio-files: 15/18] coremodel: Add a model to store opened files




commit c9a51f7c306dd88c8d21e17c27e6600dc2660901
Author: Jean Felder <jfelder src gnome org>
Date:   Thu Dec 2 18:04:37 2021 +0100

    coremodel: Add a model to store opened files
    
    This will be used in the next commit by the grilo filesystem wrapper
    to store the audio files received from command line.

 gnomemusic/coremodel.py | 16 ++++++++++++++++
 gnomemusic/player.py    |  1 +
 2 files changed, 17 insertions(+)
---
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 2ab5a59cf..6cd8cc8e6 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -168,6 +168,8 @@ class CoreModel(GObject.GObject):
         user_playlists_sorter.set_sort_func(self._playlists_sort)
         self._user_playlists_model_sort.set_sorter(user_playlists_sorter)
 
+        self._files_model: Gio.ListStore = Gio.ListStore(item_type=CoreSong)
+
         self._search: Search = application.props.search
 
         self._songs_model.connect(
@@ -321,6 +323,12 @@ class CoreModel(GObject.GObject):
             for song in self._songs_search_flatten:
                 songs_added.append(song)
 
+        elif playlist_type == PlayerPlaylist.Type.FILES:
+            self._current_playlist_model = model
+
+            for song in model:
+                songs_added.append(song)
+
         elif playlist_type == PlayerPlaylist.Type.PLAYLIST:
             self._current_playlist_model = model
 
@@ -372,6 +380,9 @@ class CoreModel(GObject.GObject):
         elif self._search.props.search_mode_active:
             playlist_type = PlayerPlaylist.Type.SEARCH_RESULT
             model = self._songs_search_flatten
+        elif self._active_core_object.props.is_filesystem:
+            playlist_type = PlayerPlaylist.Type.FILES
+            model = self._files_model
         else:
             playlist_type = PlayerPlaylist.Type.SONGS
             model = self._songs_model
@@ -520,3 +531,8 @@ class CoreModel(GObject.GObject):
         flags=GObject.ParamFlags.READABLE)
     def user_playlists_filter(self):
         return self._user_playlists_model_filter
+
+    @GObject.Property(
+        type=Gio.ListStore, default=None, flags=GObject.ParamFlags.READABLE)
+    def files(self):
+        return self._files_model
diff --git a/gnomemusic/player.py b/gnomemusic/player.py
index 5907548fd..c43779888 100644
--- a/gnomemusic/player.py
+++ b/gnomemusic/player.py
@@ -75,6 +75,7 @@ class PlayerPlaylist(GObject.GObject):
         ARTIST = 2
         PLAYLIST = 3
         SEARCH_RESULT = 4
+        FILES = 5
 
     repeat_mode = GObject.Property(type=object)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]