-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs: #124
- Loading branch information
Showing
3 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import locale | ||
|
||
from gi.repository import GObject | ||
|
||
|
||
def compare_artist_by_name_func( | ||
a: "ArtistModel", | ||
b: "ArtistModel", | ||
user_data: None, | ||
) -> int: | ||
names_comp = locale.strcoll(a.sortname, b.sortname) | ||
if names_comp != 0: | ||
return names_comp | ||
|
||
names_comp = locale.strcoll(a.name, b.name) | ||
if names_comp != 0: | ||
return names_comp | ||
|
||
if a.uri < b.uri: | ||
return -1 | ||
elif a.uri > b.uri: | ||
return 1 | ||
|
||
return 0 | ||
|
||
|
||
class ArtistInformationModel(GObject.Object): | ||
"""Model for artist information.""" | ||
|
||
abstract = GObject.Property(type=str) | ||
last_modified = GObject.Property(type=GObject.TYPE_DOUBLE, default=-1) | ||
|
||
|
||
class ArtistModel(GObject.Object): | ||
"""Model for an artist.""" | ||
|
||
uri = GObject.Property(type=str) | ||
name = GObject.Property(type=str) | ||
sortname = GObject.Property(type=str) | ||
image_path = GObject.Property(type=str) | ||
image_uri = GObject.Property(type=str) | ||
artist_mbid = GObject.Property(type=str) | ||
information = GObject.Property(type=ArtistInformationModel) |