diff options
author | Chris Lumens <clumens@redhat.com> | 2012-02-24 12:43:13 -0500 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2012-02-24 12:43:13 -0500 |
commit | e067d0d585eb5c198cf6f5a5c4b3cc0ece6081b8 (patch) | |
tree | 40e1e5e77765e74eb9aba159cc133665fcbd9920 /pyanaconda | |
parent | 9f17ca230c11f1c556bcde990fee1b2055cce08b (diff) | |
download | anaconda-e067d0d585eb5c198cf6f5a5c4b3cc0ece6081b8.tar.gz anaconda-e067d0d585eb5c198cf6f5a5c4b3cc0ece6081b8.tar.xz anaconda-e067d0d585eb5c198cf6f5a5c4b3cc0ece6081b8.zip |
Add a function to set a viewport's background, remove duplicate code.
Diffstat (limited to 'pyanaconda')
-rw-r--r-- | pyanaconda/ui/gui/hubs/__init__.py | 9 | ||||
-rw-r--r-- | pyanaconda/ui/gui/spokes/source.py | 11 | ||||
-rw-r--r-- | pyanaconda/ui/gui/spokes/storage.py | 10 | ||||
-rw-r--r-- | pyanaconda/ui/gui/utils.py | 32 |
4 files changed, 38 insertions, 24 deletions
diff --git a/pyanaconda/ui/gui/hubs/__init__.py b/pyanaconda/ui/gui/hubs/__init__.py index e0f4284d8..683ddde3c 100644 --- a/pyanaconda/ui/gui/hubs/__init__.py +++ b/pyanaconda/ui/gui/hubs/__init__.py @@ -96,6 +96,7 @@ class Hub(UIObject): def _createBox(self): from gi.repository import Gtk, AnacondaWidgets + from pyanaconda.ui.gui.utils import setViewportBackground # Collect all the categories this hub displays, then collect all the # spokes belonging to all those categories. @@ -157,13 +158,7 @@ class Hub(UIObject): viewport.add(box) spokeArea.add(viewport) - # We want the background of the spoke grid to have the same color as - # the background of the rest of the main window. - provider = Gtk.CssProvider() - provider.load_from_data("GtkViewport { background-color: @theme_bg_color }") - - context = viewport.get_style_context() - context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + setViewportBackground(viewport) def _handleCompleteness(self, spoke): from gi.repository import Gtk diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py index cd1df7e6d..1f7963f0e 100644 --- a/pyanaconda/ui/gui/spokes/source.py +++ b/pyanaconda/ui/gui/spokes/source.py @@ -213,8 +213,8 @@ class SourceSpoke(NormalSpoke): self._verifyIsoButton = self.builder.get_object("verifyIsoButton") def initialize(self): - from gi.repository import Gtk from pyanaconda.threads import threadMgr + from pyanaconda.ui.gui.utils import setViewportBackground from threading import Thread NormalSpoke.initialize(self) @@ -227,15 +227,8 @@ class SourceSpoke(NormalSpoke): self._isoButton.connect("toggled", self.on_source_toggled, self._isoBox) self._networkButton.connect("toggled", self.on_source_toggled, self._networkBox) - # We want the background of the viewport containing autodetected media - # to have the same color as the background of the main window. viewport = self.builder.get_object("autodetectViewport") - - provider = Gtk.CssProvider() - provider.load_from_data("GtkViewport { background-color: @theme_bg_color }") - - context = viewport.get_style_context() - context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + setViewportBackground(viewport) threadMgr.add(Thread(name="AnaSourceWatcher", target=self._initialize)) diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py index 6c342e924..4c2f0f9c0 100644 --- a/pyanaconda/ui/gui/spokes/storage.py +++ b/pyanaconda/ui/gui/spokes/storage.py @@ -389,6 +389,7 @@ class StorageSpoke(NormalSpoke): def initialize(self): from pyanaconda.threads import threadMgr + from pyanaconda.ui.gui.utils import setViewportBackground from threading import Thread NormalSpoke.initialize(self) @@ -399,15 +400,8 @@ class StorageSpoke(NormalSpoke): self.local_disks_box = self.builder.get_object("local_disks_box") #specialized_disks_box = self.builder.get_object("specialized_disks_box") - # We want the background of the viewports containing local and network - # disks to have the same color as the background of the main window. viewport = self.builder.get_object("localViewport") - - provider = Gtk.CssProvider() - provider.load_from_data("GtkViewport { background-color: @theme_bg_color }") - - context = viewport.get_style_context() - context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + setViewportBackground(viewport) threadMgr.add(Thread(name="AnaStorageWatcher", target=self._initialize)) diff --git a/pyanaconda/ui/gui/utils.py b/pyanaconda/ui/gui/utils.py new file mode 100644 index 000000000..a92902599 --- /dev/null +++ b/pyanaconda/ui/gui/utils.py @@ -0,0 +1,32 @@ +# Miscellaneous UI functions +# +# Copyright (C) 2012 Red Hat, Inc. +# +# This copyrighted material is made available to anyone wishing to use, +# modify, copy, or redistribute it subject to the terms and conditions of +# the GNU General Public License v.2, or (at your option) any later version. +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY expressed or implied, including the implied warranties of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. You should have received a copy of the +# GNU General Public License along with this program; if not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the +# source code or documentation are not subject to the GNU General Public +# License and may only be used or replicated with the express permission of +# Red Hat, Inc. +# +# Red Hat Author(s): Chris Lumens <clumens@redhat.com> +# +from gi.repository import Gtk + +def setViewportBackground(vp): + """Set the background color of the GtkViewport vp to be the same as the + overall UI background. This should not be called for every viewport, + as that will affect things like TreeViews as well. + """ + + provider = Gtk.CssProvider() + provider.load_from_data("GtkViewport { background-color: @theme_bg_color }") + context = vp.get_style_context() + context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) |