[f21/master] Load a stylesheet from product.img

David Shea dshea at redhat.com
Wed Nov 5 19:41:05 UTC 2014


Move an updated anaconda-gtk.css to /run/install/updates for
consistency. Change some of the stylesheet priorities so that they all
play nicely with one another. Missing icon overrides are loaded at a
higher priority than the default anaconda-gtk.css, and stylesheets from
updates.img and product.img are loaded at the same, even higher
priority.
---
 pyanaconda/ui/gui/__init__.py | 29 ++++++++++++++++++++++++++---
 scripts/makeupdates           |  2 +-
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
index 96a5238..ed747e1 100644
--- a/pyanaconda/ui/gui/__init__.py
+++ b/pyanaconda/ui/gui/__init__.py
@@ -44,6 +44,16 @@ SCREENSHOT_DELAY = 1  # in seconds
 
 ANACONDA_WINDOW_GROUP = Gtk.WindowGroup()
 
+# Stylesheet priorities to use for product-specific stylesheets and our
+# missing icon overrides. The missing icon rules should be higher than
+# the regular stylesheet, applied at GTK_STYLE_PROVIDER_PRIORITY_APPLICATION,
+# and stylesheets from updates.img and product.img should be higher than that,
+# so that they can override background images and not get re-overriden by us.
+# Both should be lower than GTK_STYLE_PROVIDER_PRIORITY_USER.
+STYLE_PROVIDER_PRIORITY_MISSING_ICON = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + 10
+STYLE_PROVIDER_PRIORITY_UPDATES = Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION + 20
+assert STYLE_PROVIDER_PRIORITY_UPDATES < Gtk.STYLE_PROVIDER_PRIORITY_USER
+
 class GUIObject(common.UIObject):
     """This is the base class from which all other GUI classes are derived.  It
        thus contains only attributes and methods that are common to everything
@@ -505,7 +515,7 @@ class GraphicalUserInterface(UserInterface):
                 provider = Gtk.CssProvider()
                 provider.load_from_data(".logo { background-image: url('%s'); }" % replacement_image_path)
                 Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
-                        Gtk.STYLE_PROVIDER_PRIORITY_USER)
+                        STYLE_PROVIDER_PRIORITY_MISSING_ICON)
             else:
                 log.warning("logo image is missing")
 
@@ -516,13 +526,13 @@ class GraphicalUserInterface(UserInterface):
             provider = Gtk.CssProvider()
             provider.load_from_data("AnacondaSpokeWindow #nav-box { background-image: none; }")
             Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
-                    Gtk.STYLE_PROVIDER_PRIORITY_USER)
+                    STYLE_PROVIDER_PRIORITY_MISSING_ICON)
 
         if not os.path.exists(sidebar_path):
             provider = Gtk.CssProvider()
             provider.load_from_data(".logo-sidebar { background-image: none; }")
             Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
-                    Gtk.STYLE_PROVIDER_PRIORITY_USER)
+                    STYLE_PROVIDER_PRIORITY_MISSING_ICON)
 
 
     def _widgetScale(self):
@@ -678,6 +688,19 @@ class GraphicalUserInterface(UserInterface):
         Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
                 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
 
+        # Look for updates to the stylesheet and apply them at a higher priority
+        if os.path.exists("/run/install/updates/anaconda-gtk.css"):
+            provider = Gtk.CssProvider()
+            provider.load_from_path("/run/install/updates/anaconda-gtk.css")
+            Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
+                    STYLE_PROVIDER_PRIORITY_UPDATES)
+
+        if os.path.exists("/run/install/product/anaconda-gtk.css"):
+            provider = Gtk.CssProvider()
+            provider.load_from_path("/run/install/product/anaconda-gtk.css")
+            Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,
+                    STYLE_PROVIDER_PRIORITY_UPDATES)
+
         # try to make sure a logo image is present
         self._assureLogoImage()
 
diff --git a/scripts/makeupdates b/scripts/makeupdates
index ece273a..de3c5dd 100755
--- a/scripts/makeupdates
+++ b/scripts/makeupdates
@@ -295,7 +295,7 @@ def copyUpdatedFiles(tag, updates, cwd):
         elif gitfile == "data/tmux.conf":
             install_to_dir(gitfile, "usr/share/anaconda")
         elif gitfile == "data/anaconda-gtk.css":
-            install_to_dir(gitfile, "usr/share/anaconda")
+            install_to_dir(gitfile, "run/install/updates")
         elif gitfile == "data/interactive-defaults.ks":
             install_to_dir(gitfile, "usr/share/anaconda")
         elif gitfile == "data/anaconda_options.txt":
-- 
2.1.0



More information about the anaconda-patches mailing list