[gnome-music/wip/jfelder/gtk4-v3: 168/174] coverpaintable: Add back dark mode




commit 503032dd1d4c5aab0c53117a6b05e6e707465e82
Author: Marinus Schraal <mschraal gnome org>
Date:   Sat Feb 5 16:43:09 2022 +0100

    coverpaintable: Add back dark mode
    
    Might need some further tweaking.

 gnomemusic/coverpaintable.py | 10 +++++++---
 gnomemusic/defaulticon.py    |  3 ++-
 2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gnomemusic/coverpaintable.py b/gnomemusic/coverpaintable.py
index 2d0b21cfc..3ffdbdce1 100644
--- a/gnomemusic/coverpaintable.py
+++ b/gnomemusic/coverpaintable.py
@@ -11,10 +11,11 @@ class CoverPaintable(GObject.GObject, Gdk.Paintable):
 
     def __init__(
             self, art_size, widget, icon_type=DefaultIconType.ALBUM,
-            texture=None):
+            texture=None, dark=False):
         super().__init__()
 
         self._art_size = art_size
+        self._dark = dark
         self._icon_theme = Gtk.IconTheme.new().get_for_display(
             widget.get_display())
         self._icon_type = icon_type
@@ -44,8 +45,11 @@ class CoverPaintable(GObject.GObject, Gdk.Paintable):
                 self._icon_type.value, None, w * i_s,
                 self._widget.props.scale_factor, 0, 0)
 
-            snapshot.append_color(
-                Gdk.RGBA(1, 1, 1, 1), Graphene.Rect().init(0, 0, w, h))
+            bg_color = Gdk.RGBA(1, 1, 1, 1)
+            if self._dark:
+                bg_color = Gdk.RGBA(0.3, 0.3, 0.3, 1)
+
+            snapshot.append_color(bg_color, Graphene.Rect().init(0, 0, w, h))
             snapshot.translate(
                 Graphene.Point().init(
                     (w / 2) - (w * (i_s / 2)), (h / 2) - (h * (i_s / 2))))
diff --git a/gnomemusic/defaulticon.py b/gnomemusic/defaulticon.py
index f7c9338f9..29377a184 100644
--- a/gnomemusic/defaulticon.py
+++ b/gnomemusic/defaulticon.py
@@ -49,7 +49,8 @@ class DefaultIcon(GObject.GObject):
     def _make_default_icon(
             self, icon_type: DefaultIconType, art_size: ArtSize,
             dark: bool) -> CoverPaintable:
-        paintable = CoverPaintable(art_size, self._widget, icon_type=icon_type)
+        paintable = CoverPaintable(
+            art_size, self._widget, icon_type=icon_type, dark=dark)
 
         return paintable
 


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