[gnome-music/wip/mschraal/gtk4: 9/70] Replace Gfm with GTK listmodels



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

    Replace Gfm with GTK listmodels

 gnomemusic/coredisc.py                        |  6 +--
 gnomemusic/coremodel.py                       | 63 +++++++++++++--------------
 gnomemusic/grilowrappers/grlsearchwrapper.py  |  4 +-
 gnomemusic/grilowrappers/grltrackerwrapper.py | 10 ++---
 gnomemusic/songliststore.py                   |  4 +-
 5 files changed, 43 insertions(+), 44 deletions(-)
---
diff --git a/gnomemusic/coredisc.py b/gnomemusic/coredisc.py
index a7def610..bcf70e5a 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
 from gi._gi import pygobject_new_full
 
 
@@ -50,10 +50,10 @@ class CoreDisc(GObject.GObject):
     @GObject.Property(type=Gio.ListModel, default=None)
     def model(self):
         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(
                 self._wrap_sort_func(self._disc_sort))
 
diff --git a/gnomemusic/coremodel.py b/gnomemusic/coremodel.py
index 13a8bc0e..479d2bc0 100644
--- a/gnomemusic/coremodel.py
+++ b/gnomemusic/coremodel.py
@@ -25,8 +25,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 gi._gi import pygobject_new_full
 
 from gnomemusic.coreartist import CoreArtist
@@ -91,47 +90,47 @@ class CoreModel(GObject.GObject):
 
         self._coreselection = application.props.coreselection
         self._album_model = Gio.ListStore()
-        self._album_model_sort = Gfm.SortListModel.new(self._album_model)
+        self._album_model_sort = Gtk.SortListModel.new(self._album_model)
         self._album_model_sort.set_sort_func(
             self._wrap_list_store_sort_func(self._albums_sort))
 
         self._artist_model = Gio.ListStore.new(CoreArtist)
-        self._artist_model_sort = Gfm.SortListModel.new(self._artist_model)
+        self._artist_model_sort = Gtk.SortListModel.new(self._artist_model)
         self._artist_model_sort.set_sort_func(
             self._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._song_search_proxy = Gio.ListStore.new(Gfm.FilterListModel)
-        self._song_search_flatten = Gfm.FlattenListModel.new(CoreSong)
+        self._song_search_proxy = Gio.ListStore.new(Gtk.FilterListModel)
+        self._song_search_flatten = Gtk.FlattenListModel.new(CoreSong)
         self._song_search_flatten.set_model(self._song_search_proxy)
 
-        self._album_search_model = Gfm.FilterListModel.new(
+        self._album_search_model = Gtk.FilterListModel.new(
             self._album_model)
         self._album_search_model.set_filter_func(lambda a: False)
 
-        self._album_search_filter = Gfm.FilterListModel.new(
+        self._album_search_filter = Gtk.FilterListModel.new(
             self._album_search_model)
 
-        self._artist_search_model = Gfm.FilterListModel.new(
+        self._artist_search_model = Gtk.FilterListModel.new(
             self._artist_model)
         self._artist_search_model.set_filter_func(lambda a: False)
 
-        self._artist_search_filter = Gfm.FilterListModel.new(
+        self._artist_search_filter = Gtk.FilterListModel.new(
             self._artist_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(
             self._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(
             self._wrap_list_store_sort_func(self._playlists_sort))
@@ -195,7 +194,7 @@ class CoreModel(GObject.GObject):
 
     def get_album_model(self, media):
         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
@@ -208,10 +207,10 @@ class CoreModel(GObject.GObject):
         return disc_model_sort
 
     def get_artist_album_model(self, media):
-        albums_model_filter = Gfm.FilterListModel.new(self._album_model)
+        albums_model_filter = Gtk.FilterListModel.new(self._album_model)
         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.props.grilo.get_artist_albums(media, albums_model_filter)
 
@@ -285,7 +284,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
 
@@ -310,7 +309,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
 
@@ -418,25 +417,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._album_model_sort
 
     @GObject.Property(
-        type=Gfm.SortListModel, default=None,
+        type=Gtk.SortListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def artists_sort(self):
         return self._artist_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._song_search_flatten
@@ -448,25 +447,25 @@ class CoreModel(GObject.GObject):
         return self._song_search_proxy
 
     @GObject.Property(
-        type=Gfm.FilterListModel, default=None,
+        type=Gtk.FilterListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def albums_search(self):
         return self._album_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._album_search_filter
 
     @GObject.Property(
-        type=Gfm.FilterListModel, default=None,
+        type=Gtk.FilterListModel, default=None,
         flags=GObject.ParamFlags.READABLE)
     def artists_search(self):
         return self._artist_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._artist_search_filter
@@ -482,25 +481,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 1b50dcba..3909f02f 100644
--- a/gnomemusic/grilowrappers/grlsearchwrapper.py
+++ b/gnomemusic/grilowrappers/grlsearchwrapper.py
@@ -24,7 +24,7 @@
 
 import gi
 gi.require_versions({"Grl": "0.3"})
-from gi.repository import Gfm, Gio, Grl, GObject
+from gi.repository import Gio, Grl, GObject
 
 from gnomemusic.coresong import CoreSong
 
@@ -64,7 +64,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 f8869659..5f94867d 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
@@ -95,7 +95,7 @@ class GrlTrackerWrapper(GObject.GObject):
         self._content_changed_timeout = None
         self._window = application.props.window
 
-        self._song_search_tracker = Gfm.FilterListModel.new(self._model)
+        self._song_search_tracker = Gtk.FilterListModel.new(self._model)
         self._song_search_tracker.set_filter_func(lambda a: False)
         self._song_search_proxy.append(self._song_search_tracker)
 
@@ -512,7 +512,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()
@@ -570,7 +570,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 bb73b3cd..b148785e 100644
--- a/gnomemusic/songliststore.py
+++ b/gnomemusic/songliststore.py
@@ -1,4 +1,4 @@
-from gi.repository import Gfm, Gio, GObject, Gtk
+from gi.repository import Gio, GObject, Gtk
 from gi._gi import pygobject_new_full
 
 import gnomemusic.utils as utils
@@ -13,7 +13,7 @@ class SongListStore(Gtk.ListStore):
         """
         super().__init__()
 
-        self._model = Gfm.SortListModel.new(model)
+        self._model = Gtk.SortListModel.new(model)
         self._model.set_sort_func(
             self._wrap_list_store_sort_func(self._songs_sort))
 


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