[gnome-music/wip/mschraal/gtk4: 5/84] Replace Gfm with GTK listmodels



commit 1badb56b116de5ad15c4bf8821ccc500a230df72
Author: Marinus Schraal <mschraal gnome org>
Date:   Wed Oct 30 22:47:45 2019 +0100

    Replace Gfm with GTK listmodels

 gnomemusic/corealbum.py                       |  6 +--
 gnomemusic/coreartist.py                      |  8 ++--
 gnomemusic/coredisc.py                        |  6 +--
 gnomemusic/coremodel.py                       | 58 +++++++++++++--------------
 gnomemusic/grilowrappers/grlsearchwrapper.py  |  6 +--
 gnomemusic/grilowrappers/grltrackerwrapper.py | 10 ++---
 gnomemusic/songliststore.py                   |  6 +--
 7 files changed, 49 insertions(+), 51 deletions(-)
---
diff --git a/gnomemusic/corealbum.py b/gnomemusic/corealbum.py
index 588001f7..f2303c32 100644
--- a/gnomemusic/corealbum.py
+++ b/gnomemusic/corealbum.py
@@ -23,8 +23,8 @@
 # delete this exception statement from your version.
 
 import gi
-gi.require_versions({"Gfm": "0.1", "Grl": "0.3"})
-from gi.repository import Gfm, Gio, Grl, GObject
+gi.require_versions({"Grl": "0.3"})
+from gi.repository import Gio, Grl, Gtk, GObject
 
 import gnomemusic.utils as utils
 
@@ -68,7 +68,7 @@ class CoreAlbum(GObject.GObject):
 
     def _get_album_model(self):
         disc_model = Gio.ListStore()
-        disc_model_sort = Gfm.SortListModel.new(disc_model)
+        disc_model_sort = Gtk.SortListModel.new(disc_model)
 
         def _disc_order_sort(disc_a, disc_b):
             return disc_a.props.disc_nr - disc_b.props.disc_nr
diff --git a/gnomemusic/coreartist.py b/gnomemusic/coreartist.py
index 9aeccd68..e89bae19 100644
--- a/gnomemusic/coreartist.py
+++ b/gnomemusic/coreartist.py
@@ -23,8 +23,8 @@
 # delete this exception statement from your version.
 
 import gi
-gi.require_versions({"Gfm": "0.1", "Grl": "0.3"})
-from gi.repository import Gfm, Gio, Grl, GObject
+gi.require_versions({"Grl": "0.3"})
+from gi.repository import Gio, Grl, Gtk, GObject
 
 from gnomemusic.artistart import ArtistArt
 import gnomemusic.utils as utils
@@ -60,11 +60,11 @@ class CoreArtist(GObject.GObject):
         self.props.artist = utils.get_artist_name(media)
 
     def _get_artist_album_model(self):
-        albums_model_filter = Gfm.FilterListModel.new(
+        albums_model_filter = Gtk.FilterListModel.new(
             self._coremodel.props.albums)
         albums_model_filter.set_filter_func(lambda a: False)
 
-        albums_model_sort = Gfm.SortListModel.new(albums_model_filter)
+        albums_model_sort = Gtk.SortListModel.new(albums_model_filter)
 
         self._coregrilo.get_artist_albums(
             self.props.media, albums_model_filter)
diff --git a/gnomemusic/coredisc.py b/gnomemusic/coredisc.py
index de421750..c1d588ac 100644
--- a/gnomemusic/coredisc.py
+++ b/gnomemusic/coredisc.py
@@ -22,7 +22,7 @@
 # code, but you are not obligated to do so.  If you do not wish to do so,
 # delete this exception statement from your version.
 
-from gi.repository import GObject, Gio, Gfm, Grl
+from gi.repository import GObject, Gio, Grl
 
 import gnomemusic.utils as utils
 
@@ -61,10 +61,10 @@ class CoreDisc(GObject.GObject):
             return song_a.props.track_number - song_b.props.track_number
 
         if self._model is None:
-            self._filter_model = Gfm.FilterListModel.new(
+            self._filter_model = Gtk.FilterListModel.new(
                 self._coremodel.props.songs)
             self._filter_model.set_filter_func(lambda a: False)
-            self._model = Gfm.SortListModel.new(self._filter_model)
+            self._model = Gtk.SortListModel.new(self._filter_model)
             self._model.set_sort_func(
                 utils.wrap_list_store_sort_func(_disc_sort))
 
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 75a1e21c..98c17314 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -24,9 +24,7 @@
 
 import math
 
-import gi
-gi.require_version("Gfm", "0.1")
-from gi.repository import GObject, Gio, Gfm, Gtk
+from gi.repository import GObject, Gio, Gtk
 
 from gnomemusic.coreartist import CoreArtist
 from gnomemusic.coresong import CoreSong
@@ -89,47 +87,47 @@ class CoreModel(GObject.GObject):
         self._application = application
 
         self._albums_model = Gio.ListStore()
-        self._albums_model_sort = Gfm.SortListModel.new(self._albums_model)
+        self._albums_model_sort = Gtk.SortListModel.new(self._albums_model)
         self._albums_model_sort.set_sort_func(
             utils.wrap_list_store_sort_func(self._albums_sort))
 
         self._artists_model = Gio.ListStore.new(CoreArtist)
-        self._artists_model_sort = Gfm.SortListModel.new(self._artists_model)
+        self._artists_model_sort = Gtk.SortListModel.new(self._artists_model)
         self._artists_model_sort.set_sort_func(
             utils.wrap_list_store_sort_func(self._artist_sort))
 
         self._playlist_model = Gio.ListStore.new(CoreSong)
-        self._playlist_model_sort = Gfm.SortListModel.new(self._playlist_model)
+        self._playlist_model_sort = Gtk.SortListModel.new(self._playlist_model)
 
-        self._songs_search_proxy = Gio.ListStore.new(Gfm.FilterListModel)
-        self._songs_search_flatten = Gfm.FlattenListModel.new(CoreSong)
+        self._songs_search_proxy = Gio.ListStore.new(Gtk.FilterListModel)
+        self._songs_search_flatten = Gtk.FlattenListModel.new(CoreSong)
         self._songs_search_flatten.set_model(self._songs_search_proxy)
 
-        self._albums_search_model = Gfm.FilterListModel.new(
+        self._albums_search_model = Gtk.FilterListModel.new(
             self._albums_model)
         self._albums_search_model.set_filter_func(lambda a: False)
 
-        self._albums_search_filter = Gfm.FilterListModel.new(
+        self._albums_search_filter = Gtk.FilterListModel.new(
             self._albums_search_model)
 
-        self._artists_search_model = Gfm.FilterListModel.new(
+        self._artists_search_model = Gtk.FilterListModel.new(
             self._artists_model)
         self._artists_search_model.set_filter_func(lambda a: False)
 
-        self._artists_search_filter = Gfm.FilterListModel.new(
+        self._artists_search_filter = Gtk.FilterListModel.new(
             self._artists_search_model)
 
         self._playlists_model = Gio.ListStore.new(Playlist)
-        self._playlists_model_filter = Gfm.FilterListModel.new(
+        self._playlists_model_filter = Gtk.FilterListModel.new(
             self._playlists_model)
-        self._playlists_model_sort = Gfm.SortListModel.new(
+        self._playlists_model_sort = Gtk.SortListModel.new(
             self._playlists_model_filter)
         self._playlists_model_sort.set_sort_func(
             utils.wrap_list_store_sort_func(self._playlists_sort))
 
-        self._user_playlists_model_filter = Gfm.FilterListModel.new(
+        self._user_playlists_model_filter = Gtk.FilterListModel.new(
             self._playlists_model)
-        self._user_playlists_model_sort = Gfm.SortListModel.new(
+        self._user_playlists_model_sort = Gtk.SortListModel.new(
             self._user_playlists_model_filter)
         self._user_playlists_model_sort.set_sort_func(
             utils.wrap_list_store_sort_func(self._playlists_sort))
@@ -234,7 +232,7 @@ class CoreModel(GObject.GObject):
             for disc in model:
                 proxy_model.append(disc.props.model)
 
-            self._flatten_model = Gfm.FlattenListModel.new(
+            self._flatten_model = Gtk.FlattenListModel.new(
                 CoreSong, proxy_model)
             self._current_playlist_model = self._flatten_model
 
@@ -250,7 +248,7 @@ class CoreModel(GObject.GObject):
                 for disc in artist_album.model:
                     proxy_model.append(disc.props.model)
 
-            self._flatten_model = Gfm.FlattenListModel.new(
+            self._flatten_model = Gtk.FlattenListModel.new(
                 CoreSong, proxy_model)
             self._current_playlist_model = self._flatten_model
 
@@ -313,25 +311,25 @@ class CoreModel(GObject.GObject):
         return self._playlist_model
 
     @GObject.Property(
-        type=Gfm.SortListModel, default=None,
+        type=Gtk.SortListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def albums_sort(self):
         return self._albums_model_sort
 
     @GObject.Property(
-        type=Gfm.SortListModel, default=None,
+        type=Gtk.SortListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def artists_sort(self):
         return self._artists_model_sort
 
     @GObject.Property(
-        type=Gfm.SortListModel, default=None,
+        type=Gtk.SortListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def playlist_sort(self):
         return self._playlist_model_sort
 
     @GObject.Property(
-        type=Gfm.FilterListModel, default=None,
+        type=Gtk.FilterListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def songs_search(self):
         return self._songs_search_flatten
@@ -343,25 +341,25 @@ class CoreModel(GObject.GObject):
         return self._songs_search_proxy
 
     @GObject.Property(
-        type=Gfm.FilterListModel, default=None,
+        type=Gtk.FilterListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def albums_search(self):
         return self._albums_search_model
 
     @GObject.Property(
-        type=Gfm.FilterListModel, default=None,
+        type=Gtk.FilterListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def albums_search_filter(self):
         return self._albums_search_filter
 
     @GObject.Property(
-        type=Gfm.FilterListModel, default=None,
+        type=Gtk.FilterListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def artists_search(self):
         return self._artists_search_model
 
     @GObject.Property(
-        type=Gfm.FilterListModel, default=None,
+        type=Gtk.FilterListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def artists_search_filter(self):
         return self._artists_search_filter
@@ -377,25 +375,25 @@ class CoreModel(GObject.GObject):
         return self._playlists_model
 
     @GObject.Property(
-        type=Gfm.SortListModel, default=None,
+        type=Gtk.SortListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def playlists_sort(self):
         return self._playlists_model_sort
 
     @GObject.Property(
-        type=Gfm.SortListModel, default=None,
+        type=Gtk.SortListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def playlists_filter(self):
         return self._playlists_model_filter
 
     @GObject.Property(
-        type=Gfm.SortListModel, default=None,
+        type=Gtk.SortListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def user_playlists_sort(self):
         return self._user_playlists_model_sort
 
     @GObject.Property(
-        type=Gfm.SortListModel, default=None,
+        type=Gtk.SortListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def user_playlists_filter(self):
         return self._user_playlists_model_filter
diff --git a/gnomemusic/grilowrappers/grlsearchwrapper.py b/gnomemusic/grilowrappers/grlsearchwrapper.py
index 3910f065..7f7df774 100644
--- a/gnomemusic/grilowrappers/grlsearchwrapper.py
+++ b/gnomemusic/grilowrappers/grlsearchwrapper.py
@@ -23,8 +23,8 @@
 # delete this exception statement from your version.
 
 import gi
-gi.require_versions({"Gfm": "0.1", "Grl": "0.3"})
-from gi.repository import Gfm, Gio, Grl, GObject
+gi.require_versions({"Grl": "0.3"})
+from gi.repository import Gio, Grl, Gtk, GObject
 
 from gnomemusic.coresong import CoreSong
 
@@ -75,7 +75,7 @@ class GrlSearchWrapper(GObject.GObject):
         self._song_search_store = Gio.ListStore.new(CoreSong)
         # FIXME: Workaround for adding the right list type to the proxy
         # list model.
-        self._song_search_model = Gfm.FilterListModel.new(
+        self._song_search_model = Gtk.FilterListModel.new(
             self._song_search_store)
         self._song_search_model.set_filter_func(lambda a: True)
         self._song_search_proxy.append(self._song_search_model)
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index 11f6ddf2..c5b37f27 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -23,8 +23,8 @@
 # delete this exception statement from your version.
 
 import gi
-gi.require_versions({"Gfm": "0.1", "Grl": "0.3", 'Tracker': "2.0"})
-from gi.repository import Gfm, Grl, GLib, GObject, Tracker
+gi.require_versions({"Grl": "0.3", "Tracker": "2.0"})
+from gi.repository import Grl, GLib, GObject, Tracker
 
 from gnomemusic.corealbum import CoreAlbum
 from gnomemusic.coreartist import CoreArtist
@@ -89,7 +89,7 @@ class GrlTrackerWrapper(GObject.GObject):
         self._tracker_wrapper = tracker_wrapper
         self._window = application.props.window
 
-        self._song_search_tracker = Gfm.FilterListModel.new(self._songs_model)
+        self._song_search_tracker = Gtk.FilterListModel.new(self._songs_model)
         self._song_search_tracker.set_filter_func(lambda a: False)
         self._song_search_proxy.append(self._song_search_tracker)
 
@@ -542,7 +542,7 @@ class GrlTrackerWrapper(GObject.GObject):
         """Get all albums by an artist
 
         :param Grl.Media media: The media with the artist id
-        :param Gfm.FilterListModel model: The model to fill
+        :param Gtk.FilterListModel model: The model to fill
         """
         self._window.notifications_popup.push_loading()
         artist_id = media.get_id()
@@ -600,7 +600,7 @@ class GrlTrackerWrapper(GObject.GObject):
         """Get all discs of an album
 
         :param Grl.Media media: The media with the album id
-        :param Gfm.SortListModel disc_model: The model to fill
+        :param Gtk.SortListModel disc_model: The model to fill
         """
         self._window.notifications_popup.push_loading()
         album_id = media.get_id()
diff --git a/gnomemusic/songliststore.py b/gnomemusic/songliststore.py
index ecd0c77c..abbb78df 100644
--- a/gnomemusic/songliststore.py
+++ b/gnomemusic/songliststore.py
@@ -22,7 +22,7 @@
 # code, but you are not obligated to do so.  If you do not wish to do so,
 # delete this exception statement from your version.
 
-from gi.repository import Gfm, Gio, GObject, Gtk
+from gi.repository import Gio, GObject, Gtk
 
 import gnomemusic.utils as utils
 
@@ -36,7 +36,7 @@ class SongListStore(Gtk.ListStore):
         """
         super().__init__()
 
-        self._model = Gfm.SortListModel.new(model)
+        self._model = Gtk.SortListModel.new(model)
         self._model.set_sort_func(
             utils.wrap_list_store_sort_func(self._songs_sort))
 
@@ -111,6 +111,6 @@ class SongListStore(Gtk.ListStore):
         """Gets the model of songs sorted.
 
         :returns: a list model of sorted songs
-        :rtype: Gfm.SortListModel
+        :rtype: Gtk.SortListModel
         """
         return self._model


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