[PATCH 3/4] Filter layouts in AddLayout dialog

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

 



---
 pyanaconda/ui/gui/spokes/language.py |   33 ++++++++++++++++++++++++++++++++-
 pyanaconda/ui/gui/spokes/language.ui |    7 ++++++-
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/language.py b/pyanaconda/ui/gui/spokes/language.py
index 7ee907e..e37fef8 100644
--- a/pyanaconda/ui/gui/spokes/language.py
+++ b/pyanaconda/ui/gui/spokes/language.py
@@ -32,14 +32,39 @@ from pyanaconda.ui.gui.categories.localization import LocalizationCategory
 __all__ = ["LanguageSpoke"]
 
 class AddLayoutDialog(UIObject):
-    builderObjects = ["addLayoutDialog", "newLayoutStore"]
+    builderObjects = ["addLayoutDialog", "newLayoutStore", "newLayoutStoreFilter"]
     mainWidgetName = "addLayoutDialog"
     uiFile = "spokes/language.ui"
 
+    def matches_entry(self, model, itr, user_data=None):
+        value = model.get_value(itr, 0)
+        entry_text = self._entry.get_text()
+        if entry_text is not None:
+            entry_text = entry_text.lower()
+            entry_text_words = entry_text.split()
+        else:
+            return False
+        try:
+            if value:
+                value = value.lower()
+                for word in entry_text_words:
+                    value.index(word)
+                return True
+            return False
+        except ValueError as valerr:
+            return False
+
+    def setup(self):
+        self._treeModelFilter = self.builder.get_object("newLayoutStoreFilter")
+        self._treeModelFilter.set_visible_func(self.matches_entry, None)
+        self._entry = self.builder.get_object("addLayoutEntry")
+        self._entry.grab_focus()
+
     def populate(self):
         self._store = self.builder.get_object("newLayoutStore")
         #XXX: will use values from the libxklavier
         self._addLayout(self._store, "English (US)")
+        self._addLayout(self._store, "English (US, with some other stuff)")
         self._addLayout(self._store, "Czech")
         self._addLayout(self._store, "Czech (qwerty)")
         self._addLayout(self._store, "values from libxklavier")
@@ -63,6 +88,12 @@ class AddLayoutDialog(UIObject):
     def on_cancel_clicked(self, *args):
         print "CANCELING"
 
+    def on_entry_changed(self, *args):
+        self._treeModelFilter.refilter()
+
+    def on_entry_icon_clicked(self, *args):
+        self._entry.set_text("")
+
     def _addLayout(self, store, name):
         store.append([name])
 
diff --git a/pyanaconda/ui/gui/spokes/language.ui b/pyanaconda/ui/gui/spokes/language.ui
index 6cfbc5b..0c994bc 100644
--- a/pyanaconda/ui/gui/spokes/language.ui
+++ b/pyanaconda/ui/gui/spokes/language.ui
@@ -104,7 +104,7 @@
                   <object class="GtkTreeView" id="newLayoutView">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="model">newLayoutStore</property>
+                    <property name="model">newLayoutStoreFilter</property>
                     <child internal-child="selection">
                       <object class="GtkTreeSelection" id="newLayoutSelection"/>
                     </child>
@@ -137,6 +137,8 @@
                 <property name="can_focus">True</property>
                 <property name="invisible_char">●</property>
                 <property name="secondary_icon_name">edit-clear-symbolic</property>
+                <signal name="changed" handler="on_entry_changed" swapped="no"/>
+                <signal name="icon-press" handler="on_entry_icon_clicked" swapped="no"/>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -461,6 +463,9 @@ any layout to the top of the list to select it as the default.</property>
       <column type="gchararray"/>
     </columns>
   </object>
+  <object class="GtkTreeModelFilter" id="newLayoutStoreFilter">
+    <property name="child_model">newLayoutStore</property>
+  </object>
   <object class="GtkImage" id="removeImage">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-- 
1.7.4.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list



[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux