[master/rhel7 2/2] Highlight languages in langsupport that contain selected locales (#1072355)

David Shea dshea at redhat.com
Wed Jul 30 17:46:13 UTC 2014


Resolves: rhbz#1072355
---
 pyanaconda/ui/gui/spokes/langsupport.glade |  8 ++++++
 pyanaconda/ui/gui/spokes/langsupport.py    | 39 +++++++++++++++++++++++++++---
 2 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/langsupport.glade b/pyanaconda/ui/gui/spokes/langsupport.glade
index 7c994e6..389f514 100644
--- a/pyanaconda/ui/gui/spokes/langsupport.glade
+++ b/pyanaconda/ui/gui/spokes/langsupport.glade
@@ -110,6 +110,14 @@
                               </object>
                             </child>
                             <child>
+                              <object class="GtkTreeViewColumn" id="highlighted">
+                                <property name="title">highlighted</property>
+                                <child>
+                                  <object class="GtkCellRendererPixbuf" id="highlightedRenderer"/>
+                                </child>
+                              </object>
+                            </child>
+                            <child>
                               <object class="GtkTreeViewColumn" id="nativeName">
                                 <property name="title" translatable="yes">nativeName</property>
                                 <property name="expand">True</property>
diff --git a/pyanaconda/ui/gui/spokes/langsupport.py b/pyanaconda/ui/gui/spokes/langsupport.py
index 4625168..4c6b766 100644
--- a/pyanaconda/ui/gui/spokes/langsupport.py
+++ b/pyanaconda/ui/gui/spokes/langsupport.py
@@ -21,7 +21,7 @@
 #
 
 # pylint: disable-msg=E0611
-from gi.repository import Gtk, Pango
+from gi.repository import Gtk, Pango, Gdk
 from pyanaconda.flags import flags
 from pyanaconda.i18n import _, N_
 from pyanaconda.iutil import strip_accents
@@ -38,6 +38,11 @@ log = logging.getLogger("anaconda")
 
 __all__ = ["LangsupportSpoke"]
 
+# #fdfbc0
+# Sure would be nice if gdk_rgba_parse returned a new object instead of
+# modifying an existing one.
+_HIGHLIGHT_COLOR = Gdk.RGBA(red=0.992157, green=0.984314, blue=0.752941, alpha=1.0)
+
 class LangsupportSpoke(LangLocaleHandler, NormalSpoke):
     builderObjects = ["languageStore", "languageStoreFilter", "localeStore", "langsupportWindow"]
     mainWidgetName = "langsupportWindow"
@@ -78,6 +83,19 @@ class LangsupportSpoke(LangLocaleHandler, NormalSpoke):
             renderer = self.builder.get_object(rend)
             override_cell_property(column, renderer, "weight", self._mark_selected_language_bold)
 
+        # If a language has selected locales, highlight every column so that
+        # the row appears highlighted
+        for col in self._langView.get_columns():
+            for rend in col.get_cells():
+                override_cell_property(col, rend, "cell-background-rgba",
+                        self._highlight_selected_language)
+
+        # and also set an icon so that we don't depend on a color to convey information
+        highlightedColumn = self.builder.get_object("highlighted")
+        highlightedRenderer = self.builder.get_object("highlightedRenderer")
+        override_cell_property(highlightedColumn, highlightedRenderer,
+                "icon-name", self._render_lang_highlighted)
+
     def apply(self):
         # store only additional langsupport locales
         self.data.lang.addsupport = sorted(self._selected_locales - set([self.data.lang.lang]))
@@ -127,13 +145,28 @@ class LangsupportSpoke(LangLocaleHandler, NormalSpoke):
         else:
             return Pango.Weight.NORMAL.real
 
+    def _is_lang_selected(self, lang):
+        lang_locales = set(localization.get_language_locales(lang))
+        return not lang_locales.isdisjoint(self._selected_locales)
+
     def _mark_selected_language_bold(self, column, renderer, model, itr, user_data=None):
-        lang_locales = set(localization.get_language_locales(model[itr][2]))
-        if not lang_locales.isdisjoint(self._selected_locales):
+        if self._is_lang_selected(model[itr][2]):
             return Pango.Weight.BOLD.real
         else:
             return Pango.Weight.NORMAL.real
 
+    def _highlight_selected_language(self, column, renderer, model, itr, user_data=None):
+        if self._is_lang_selected(model[itr][2]):
+            return _HIGHLIGHT_COLOR
+        else:
+            return None
+
+    def _render_lang_highlighted(self, column, renderer, model, itr, user_data=None):
+        if self._is_lang_selected(model[itr][2]):
+            return "emblem-ok-symbolic"
+        else:
+            return None
+
     # Signal handlers.
     def on_locale_toggled(self, renderer, path):
         itr = self._localeStore.get_iter(path)
-- 
2.0.0



More information about the anaconda-patches mailing list