[gnome-music/wip/jfelder/gtk4-v3: 11/112] application: Fix style context provider




commit 1848d0f9adc72ae5690b88abb8a06d9e681fec7c
Author: Marinus Schraal <mschraal gnome org>
Date:   Thu Oct 31 13:18:41 2019 +0100

    application: Fix style context provider

 gnomemusic/application.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gnomemusic/application.py b/gnomemusic/application.py
index b5dff88dd..642c31a47 100644
--- a/gnomemusic/application.py
+++ b/gnomemusic/application.py
@@ -62,7 +62,6 @@ class Application(Gtk.Application):
         GLib.set_prgname(application_id)
         GLib.setenv("PULSE_PROP_media.role", "music", True)
 
-        self._init_style()
         self._window = None
 
         self._log = MusicLogger()
@@ -87,10 +86,10 @@ class Application(Gtk.Application):
     def _init_style(self):
         css_provider = Gtk.CssProvider()
         css_provider.load_from_resource('/org/gnome/Music/org.gnome.Music.css')
-        screen = Gdk.Screen.get_default()
-        style_context = Gtk.StyleContext()
-        style_context.add_provider_for_screen(
-            screen, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
+        display = Gdk.Display.get_default()
+        style_context = self._window.get_style_context()
+        style_context.add_provider_for_display(
+            display, css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
 
     @GObject.Property(
         type=CoreGrilo, default=None, flags=GObject.ParamFlags.READABLE)
@@ -244,6 +243,7 @@ class Application(Gtk.Application):
             self._window = Window(self)
             self.notify("window")
             self._window.set_default_icon_name(self.props.application_id)
+            self._init_style()
             if self.props.application_id == "org.gnome.Music.Devel":
                 self._window.get_style_context().add_class('devel')
             MPRIS(self)


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