[gnome-tweak-tool] allow localized searches



commit 44e370d050b992dfb303164fb3368e9269a0a69c
Author: Alex Muñoz <alexmudoz gmail com>
Date:   Mon Sep 16 00:44:59 2013 -0300

    allow localized searches
    
    The default encoding for python2 is ASCII, a localized
    character can't be represented using this encoding.
    
    UTF-8 allow represent every character in the Unicode character set.
    
    **UTF-8 is the default encoding for python3
    more info: http://docs.python.org/3.3/howto/unicode.html

 gtweak/tweakmodel.py              |    4 ++--
 gtweak/tweaks/tweak_group_test.py |   16 ++++++++++++++--
 gtweak/tweakview.py               |    2 +-
 3 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/gtweak/tweakmodel.py b/gtweak/tweakmodel.py
index 9a357b2..8179816 100644
--- a/gtweak/tweakmodel.py
+++ b/gtweak/tweakmodel.py
@@ -57,9 +57,9 @@ class Tweak(object):
 
     def search_matches(self, txt):
         if self._search_cache == None:
-            self._search_cache = self.name.lower() + " " + self.description.lower()
+            self._search_cache = self.name.decode("utf-8").lower() + " " + 
self.description.decode("utf-8").lower()
             try:
-                self._search_cache += " " + self.extra_info
+                self._search_cache += " " + self.extra_info.decode("utf-8").lower()
             except:
                 LOG.warning("Error adding search info", exc_info=True)
         return  txt in self._search_cache
diff --git a/gtweak/tweaks/tweak_group_test.py b/gtweak/tweaks/tweak_group_test.py
index 4bc802f..54d4afa 100644
--- a/gtweak/tweaks/tweak_group_test.py
+++ b/gtweak/tweaks/tweak_group_test.py
@@ -1,4 +1,5 @@
-# This file is part of gnome-tweak-tool.
+# This file is part of gnome-tweak-tool. 
+# -*- coding: utf-8 -*-
 #
 # Copyright (c) 2011 John Stowers
 #
@@ -89,6 +90,17 @@ TWEAK_GROUPS = [
         _TestInfoTweak("foo warning", "info widget", _tweak_warning="Warning"),
         Title("Test Notifications", "", uid="title-tweak-test"),
         _TestButtonTweak("Shows Information", "foo bar", _need_action=True),
-        _TestButtonTweak("Needs Logout", "foo bar log", _need_logout=True))
+        _TestButtonTweak("Needs Logout", "foo bar log", _need_logout=True)),
+
+    ListBoxTweakGroup(
+        "Unicode Test",
+        Title("Words", "", uid="title-tweak-test"),
+        *[_TestTweak( str(d), str(d)) for d in ["Muñoz",
+                                                "Español",
+                                                "größer",
+                                                "jünger",
+                                                "grün",
+                                                "счастье",
+                                                "سعادة"]]),
 ]
 
diff --git a/gtweak/tweakview.py b/gtweak/tweakview.py
index 71d0996..2396615 100644
--- a/gtweak/tweakview.py
+++ b/gtweak/tweakview.py
@@ -195,7 +195,7 @@ class Window(Gtk.ApplicationWindow):
             self.listbox.select_row(row)
 
     def _on_search(self, entry):
-        txt = entry.get_text().lower()
+        txt = entry.get_text().decode("utf-8").lower()
         tweaks, group = self._model.search_matches(txt)
         self.show_only_tweaks(tweaks)        
         self._on_list_changed(group)


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