Port UI to GTK 4 (close #85)
This commit is contained in:
parent
6ba8bc550f
commit
75b99e5820
36 changed files with 1730 additions and 3285 deletions
48
src/utils.py
48
src/utils.py
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
gi.require_version('Gtk', '4.0')
|
||||
import hashlib
|
||||
import locale
|
||||
import os
|
||||
import urllib
|
||||
|
||||
from gi.repository import GdkPixbuf
|
||||
from gi.repository import Gdk, GdkPixbuf, GObject, Gtk
|
||||
|
||||
|
||||
|
||||
|
|
@ -87,3 +87,47 @@ class SortOrder:
|
|||
TITLE = 1
|
||||
YEAR = 2
|
||||
MODIFIED = 3
|
||||
|
||||
|
||||
|
||||
|
||||
class GridItem(GObject.GObject):
|
||||
__gtype_name__ = "GridItem"
|
||||
|
||||
tooltip = GObject.Property(type=str, default=None)
|
||||
cover = GObject.Property(type=Gdk.Paintable, default=None)
|
||||
|
||||
|
||||
def __init__(self, album, cover):
|
||||
super().__init__()
|
||||
self._album = album
|
||||
if cover:
|
||||
self.cover = Gdk.Texture.new_for_pixbuf(cover)
|
||||
self.tooltip = GObject.markup_escape_text("\n".join([
|
||||
album.get_title(),
|
||||
', '.join(album.get_dates()),
|
||||
Utils.create_artists_label(album),
|
||||
Utils.create_length_label(album)
|
||||
]))
|
||||
|
||||
|
||||
def get_album(self):
|
||||
return self._album
|
||||
|
||||
|
||||
def set_cover(self, cover):
|
||||
self.cover = Gdk.Texture.new_for_pixbuf(cover)
|
||||
|
||||
|
||||
|
||||
|
||||
class SearchFilter(Gtk.Filter):
|
||||
|
||||
|
||||
def __init__(self, search_string):
|
||||
super().__init__()
|
||||
self._search_string = search_string
|
||||
|
||||
|
||||
def do_match(self, grid_item):
|
||||
return grid_item.get_album().filter(self._search_string)
|
||||
|
|
|
|||
Loading…
Reference in a new issue