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




commit 3e9697bdaadae31f70b1c0d5d507c318f8287f0b
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 97a930405..b2f355c21 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.new(CoreSong)
+
         self._search: Search = application.props.search
 
         self._songs_model.connect(
@@ -315,6 +317,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
 
@@ -366,6 +374,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
@@ -514,3 +525,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 4b0bdf162..283818bdc 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]