[meld/flatpak-ci] meldapp: Move custom CSS provider initialisation into MeldApp



commit 2c9680fe2f0619cf4cb2a0dc0cfdfada07a3ee82
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Fri Dec 20 07:47:54 2019 +1000

    meldapp: Move custom CSS provider initialisation into MeldApp

 bin/meld        | 8 --------
 meld/meldapp.py | 9 +++++++++
 2 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/bin/meld b/bin/meld
index 875aedf7..426df3b6 100755
--- a/bin/meld
+++ b/bin/meld
@@ -256,8 +256,6 @@ def check_requirements():
 
 def setup_resources():
     from gi.repository import Gio
-    from gi.repository import Gtk
-    from gi.repository import Gdk
     from gi.repository import GtkSource
 
     resource_filename = meld.conf.APPLICATION_ID + ".gresource"
@@ -282,12 +280,6 @@ def setup_resources():
         if not uninstalled:
             raise
 
-    provider = Gtk.CssProvider()
-    provider.load_from_resource('/org/gnome/meld/meld.css')
-    Gtk.StyleContext.add_provider_for_screen(
-        Gdk.Screen.get_default(), provider,
-        Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
-
     style_path = os.path.join(meld.conf.DATADIR, "styles")
     GtkSource.StyleSchemeManager.get_default().append_search_path(style_path)
 
diff --git a/meld/meldapp.py b/meld/meldapp.py
index 7a9d1d3b..965ca5e5 100644
--- a/meld/meldapp.py
+++ b/meld/meldapp.py
@@ -49,6 +49,15 @@ class MeldApp(Gtk.Application):
         Gtk.Window.set_default_icon_name(meld.conf.APPLICATION_ID)
         self.set_resource_base_path(meld.conf.RESOURCE_BASE)
 
+        provider = Gtk.CssProvider()
+        provider.load_from_resource(self.make_resource_path('meld.css'))
+        Gtk.StyleContext.add_provider_for_screen(
+            Gdk.Screen.get_default(), provider,
+            Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
+
+    def make_resource_path(self, resource_path: str) -> str:
+        return f'{self.props.resource_base_path}/{resource_path}'
+
     def do_startup(self):
         Gtk.Application.do_startup(self)
         meld.accelerators.register_accels(self)


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