From: David Shea dshea@redhat.com
Define styles for GtkLevelBar widgets at the named levels "low", "medium" and "high". Define value offsets for these names in each of the GtkLevelBar widgets we use. --- data/Makefile.am | 8 ++-- data/anaconda-gtk.css | 62 ++++++++++++++++++++++++++++++ pyanaconda/ui/gui/__init__.py | 6 +++ pyanaconda/ui/gui/spokes/lib/passphrase.py | 3 ++ pyanaconda/ui/gui/spokes/password.py | 5 +++ pyanaconda/ui/gui/spokes/user.py | 5 +++ scripts/makeupdates | 2 + 7 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 data/anaconda-gtk.css
diff --git a/data/Makefile.am b/data/Makefile.am index b7eddfe..ebbdaaf 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -21,11 +21,9 @@ SUBDIRS = command-stubs icons liveinst pixmaps systemd post-scripts
CLEANFILES = *~
-ksdir = $(datadir)/$(PACKAGE_NAME) -dist_ks_DATA = interactive-defaults.ks - -tmuxdir = $(datadir)/$(PACKAGE_NAME) -dist_tmux_DATA = tmux.conf +dist_pkgdata_DATA = interactive-defaults.ks \ + tmux.conf \ + anaconda-gtk.css
helpdir = $(datadir)/$(PACKAGE_NAME) dist_help_DATA = anaconda_options.txt diff --git a/data/anaconda-gtk.css b/data/anaconda-gtk.css new file mode 100644 index 0000000..92669ba --- /dev/null +++ b/data/anaconda-gtk.css @@ -0,0 +1,62 @@ +/* Define styles to apply to the GtkLevelBar widgets for different values. + * + * This stylesheet defines properties for "low", "medium" and "high" level bar + * levels. The level bars themselves need to define what style applies at what + * value using gtk_level_bar_add_offset_value. Gtk defines "low" and "high" by + * default, but it defines them for level bars using a continuous value between + * 0 and 1, so our discrete level bars are effectively always at the "high" + * level. + * + * Fun surprises that might change in future versions: + * + * - Defining properties for a level will set properties on both the filled + * portion and the empty portion of the level bar. So if all of the display + * properties are set, which we do, the level bar effectively becomes 100% + * filled with whatever properties are set. Copying the .empty-fill-block + * properties from the theme so that they apply at the application level + * works around this. + * + * - There's a bug in the handling of the maximum offset in that it only + * applies when value == max-value, rather than when it's between + * max-value and the next lower offset. For example, consider a + * discrete-mode level bar with a max-value of 4 and offsets defined as + * "low": 2.0, "medium": 3.0 and "high": 4.0. Value 1 will be low, + * value 2 will be medium, value 3 will be in an undefined no-man's land, + * and value 4 will be high. To get around this we re-define the default + * fill-block values as the same as fill-block.level-high. + * + * - The GNOME Adwaita theme applies a gradient to the progress bar when the + * window is focused. It does this by redefining the colors in a + * background-image property, so unless we reset background-image our colors + * will only apply when the window is out of focus, which uses the :backdrop + * selector. + */ + +@define-color anaconda_level_bar_low red; +@define-color anaconda_level_bar_medium orange; +@define-color anaconda_level_bar_high green; + +.level-bar.fill-block.level-low { + border-color: darker(@anaconda_level_bar_low); + background-color: @anaconda_level_bar_low; + background-image: none; +} + +.level-bar.fill-block.level-medium { + border-color: darker(@anaconda_level_bar_medium); + background-color: @anaconda_level_bar_medium; + background-image: none; +} + +.level-bar.fill-block, +.level-bar.fill-block.level-high { + border-color: darker(@anaconda_level_bar_high); + background-color: @anaconda_level_bar_high; + background-image: none; +} + +.level-bar.fill-block.empty-fill-block { + background-color: transparent; + background-image: none; + border-color: alpha(#000000, 0.1); +} diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py index 966bc93..3d553e8 100644 --- a/pyanaconda/ui/gui/__init__.py +++ b/pyanaconda/ui/gui/__init__.py @@ -389,6 +389,12 @@ class GraphicalUserInterface(UserInterface): settings.set_property("gtk-font-name", "Cantarell") settings.set_property("gtk-icon-theme-name", "gnome")
+ # Apply the application stylesheet + provider = Gtk.CssProvider() + provider.load_from_path("/usr/share/anaconda/anaconda-gtk.css") + Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + self._currentAction.window.show_all()
# Do this at the last possible minute. diff --git a/pyanaconda/ui/gui/spokes/lib/passphrase.py b/pyanaconda/ui/gui/spokes/lib/passphrase.py index 938130b..c85e904 100644 --- a/pyanaconda/ui/gui/spokes/lib/passphrase.py +++ b/pyanaconda/ui/gui/spokes/lib/passphrase.py @@ -60,6 +60,9 @@ class PassphraseDialog(GUIObject): self._strength_bar.set_mode(Gtk.LevelBarMode.DISCRETE) self._strength_bar.set_min_value(0) self._strength_bar.set_max_value(4) + self._strength_bar.add_offset_value("low", 2) + self._strength_bar.add_offset_value("medium", 3) + self._strength_bar.add_offset_value("high", 4) box = self.builder.get_object("strength_box") box.pack_start(self._strength_bar, False, True, 0) box.show_all() diff --git a/pyanaconda/ui/gui/spokes/password.py b/pyanaconda/ui/gui/spokes/password.py index 25c9613..70bb6e5 100644 --- a/pyanaconda/ui/gui/spokes/password.py +++ b/pyanaconda/ui/gui/spokes/password.py @@ -67,6 +67,11 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke): self.pw_bar = self.builder.get_object("password_bar") self.pw_label = self.builder.get_object("password_label")
+ # Configure levels for the password bar + self.pw_bar.add_offset_value("low", 2) + self.pw_bar.add_offset_value("medium", 3) + self.pw_bar.add_offset_value("high", 4) + def refresh(self): self.pw.grab_focus() self._checkPassword() diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py index d9b205e..e834ebf 100644 --- a/pyanaconda/ui/gui/spokes/user.py +++ b/pyanaconda/ui/gui/spokes/user.py @@ -199,6 +199,11 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke): self.pw_bar = self.builder.get_object("password_bar") self.pw_label = self.builder.get_object("password_label")
+ # Configure levels for the password bar + self.pw_bar.add_offset_value("low", 2) + self.pw_bar.add_offset_value("medium", 3) + self.pw_bar.add_offset_value("high", 4) + # indicate when the password was set by kickstart self._user.password_kickstarted = self.data.user.seen if self._user.password_kickstarted: diff --git a/scripts/makeupdates b/scripts/makeupdates index f1d6ecc..6079fac 100755 --- a/scripts/makeupdates +++ b/scripts/makeupdates @@ -159,6 +159,8 @@ def copyUpdatedFiles(tag, updates, cwd): install_to_dir(file, "lib/systemd/system-generators") elif file == "data/tmux.conf": install_to_dir(file, "usr/share/anaconda") + elif file == "data/anaconda-gtk.css": + install_to_dir(file, "usr/share/anaconda") elif file == "data/interactive-defaults.ks": install_to_dir(file, "usr/share/anaconda") elif file == "data/liveinst/liveinst":