[PATCH 4/4] Get rid of the clear button in advanced storage spoke. (#1024949)

Samantha N. Bueno sbueno+anaconda at redhat.com
Tue Jan 14 17:35:12 UTC 2014


Just syncing behavior here with the rest of the GUI. This gets rid of
the 'clear' button and uses the Gtk secondary icon to clear text boxes.

Related: rhbz#1024949
---
 pyanaconda/ui/gui/spokes/filter.glade | 102 +++++++++-------------------------
 pyanaconda/ui/gui/spokes/filter.py    |  19 ++-----
 2 files changed, 33 insertions(+), 88 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/filter.glade b/pyanaconda/ui/gui/spokes/filter.glade
index 664433f..0382324 100644
--- a/pyanaconda/ui/gui/spokes/filter.glade
+++ b/pyanaconda/ui/gui/spokes/filter.glade
@@ -233,6 +233,8 @@
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="invisible_char">●</property>
+                                            <property name="secondary_icon_name">edit-clear-symbolic</property>
+                                            <signal name="icon-release" handler="on_clear_icon_clicked" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
@@ -259,6 +261,8 @@
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="invisible_char">●</property>
+                                            <property name="secondary_icon_name">edit-clear-symbolic</property>
+                                            <signal name="icon-release" handler="on_clear_icon_clicked" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
@@ -300,6 +304,8 @@
                                             <property name="can_focus">True</property>
                                             <property name="invisible_char">●</property>
                                             <property name="width_chars">30</property>
+                                            <property name="secondary_icon_name">edit-clear-symbolic</property>
+                                            <signal name="icon-release" handler="on_clear_icon_clicked" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
@@ -491,22 +497,6 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkButton" id="searchClearButton">
-                                    <property name="label">gtk-clear</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_stock">True</property>
-                                    <signal name="clicked" handler="on_clear_clicked" swapped="no"/>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">4</property>
-                                    <property name="top_attach">0</property>
-                                    <property name="width">1</property>
-                                    <property name="height">1</property>
-                                  </packing>
-                                </child>
-                                <child>
                                   <object class="GtkButton" id="searchFindButton">
                                     <property name="label">gtk-find</property>
                                     <property name="visible">True</property>
@@ -518,7 +508,7 @@
                                   <packing>
                                     <property name="left_attach">3</property>
                                     <property name="top_attach">0</property>
-                                    <property name="width">1</property>
+                                    <property name="width">2</property>
                                     <property name="height">1</property>
                                   </packing>
                                 </child>
@@ -716,6 +706,8 @@
                                             <property name="can_focus">True</property>
                                             <property name="invisible_char">●</property>
                                             <property name="width_chars">30</property>
+                                            <property name="secondary_icon_name">edit-clear-symbolic</property>
+                                            <signal name="icon-release" handler="on_clear_icon_clicked" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
@@ -749,7 +741,7 @@
                                     <property name="rules_hint">True</property>
                                     <property name="enable_search">False</property>
                                     <property name="enable_tree_lines">True</property>
-                                    <child>
+                                    <child internal-child="selection">
                                       <object class="GtkTreeSelection" id="treeview-selection2"/>
                                     </child>
                                     <child>
@@ -846,22 +838,6 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkButton" id="multipathClearButton">
-                                    <property name="label">gtk-clear</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_stock">True</property>
-                                    <signal name="clicked" handler="on_clear_clicked" swapped="no"/>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">4</property>
-                                    <property name="top_attach">0</property>
-                                    <property name="width">1</property>
-                                    <property name="height">1</property>
-                                  </packing>
-                                </child>
-                                <child>
                                   <object class="GtkButton" id="multipathFindButton">
                                     <property name="label">gtk-find</property>
                                     <property name="visible">True</property>
@@ -873,7 +849,7 @@
                                   <packing>
                                     <property name="left_attach">3</property>
                                     <property name="top_attach">0</property>
-                                    <property name="width">1</property>
+                                    <property name="width">2</property>
                                     <property name="height">1</property>
                                   </packing>
                                 </child>
@@ -1048,22 +1024,6 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkButton" id="otherClearButton">
-                                    <property name="label">gtk-clear</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_stock">True</property>
-                                    <signal name="clicked" handler="on_clear_clicked" swapped="no"/>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">4</property>
-                                    <property name="top_attach">0</property>
-                                    <property name="width">1</property>
-                                    <property name="height">1</property>
-                                  </packing>
-                                </child>
-                                <child>
                                   <object class="GtkButton" id="otherFindButton">
                                     <property name="label">gtk-find</property>
                                     <property name="visible">True</property>
@@ -1075,7 +1035,7 @@
                                   <packing>
                                     <property name="left_attach">3</property>
                                     <property name="top_attach">0</property>
-                                    <property name="width">1</property>
+                                    <property name="width">2</property>
                                     <property name="height">1</property>
                                   </packing>
                                 </child>
@@ -1202,6 +1162,8 @@
                                             <property name="invisible_char">●</property>
                                             <property name="width_chars">30</property>
                                             <property name="invisible_char_set">True</property>
+                                            <property name="secondary_icon_name">edit-clear-symbolic</property>
+                                            <signal name="icon-release" handler="on_clear_icon_clicked" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
@@ -1313,23 +1275,7 @@
                                   <packing>
                                     <property name="left_attach">3</property>
                                     <property name="top_attach">0</property>
-                                    <property name="width">1</property>
-                                    <property name="height">1</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkButton" id="zClearButton">
-                                    <property name="label">gtk-clear</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_stock">True</property>
-                                    <signal name="clicked" handler="on_clear_clicked" swapped="no"/>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">4</property>
-                                    <property name="top_attach">0</property>
-                                    <property name="width">1</property>
+                                    <property name="width">2</property>
                                     <property name="height">1</property>
                                   </packing>
                                 </child>
@@ -1506,9 +1452,11 @@
                                           <object class="GtkEntry" id="zCCWEntry">
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
-                                            <property name="invisible_char">???</property>
+                                            <property name="invisible_char">?</property>
                                             <property name="width_chars">30</property>
                                             <property name="invisible_char_set">True</property>
+                                            <property name="secondary_icon_name">edit-clear-symbolic</property>
+                                            <signal name="icon-release" handler="on_clear_icon_clicked" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
@@ -1553,9 +1501,11 @@
                                           <object class="GtkEntry" id="zWWPNEntry">
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
-                                            <property name="invisible_char">???</property>
+                                            <property name="invisible_char">?</property>
                                             <property name="width_chars">30</property>
                                             <property name="invisible_char_set">True</property>
+                                            <property name="secondary_icon_name">edit-clear-symbolic</property>
+                                            <signal name="icon-release" handler="on_clear_icon_clicked" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
@@ -1594,9 +1544,11 @@
                                           <object class="GtkEntry" id="zLUNEntry">
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
-                                            <property name="invisible_char">???</property>
+                                            <property name="invisible_char">?</property>
                                             <property name="width_chars">30</property>
                                             <property name="invisible_char_set">True</property>
+                                            <property name="secondary_icon_name">edit-clear-symbolic</property>
+                                            <signal name="icon-release" handler="on_clear_icon_clicked" swapped="no"/>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
@@ -1635,9 +1587,9 @@
                                     <property name="left_attach">1</property>
                                     <property name="top_attach">0</property>
                                     <property name="width">1</property>
-                                     <property name="height">1</property>
-                                   </packing>
-                                 </child>
+                                    <property name="height">1</property>
+                                  </packing>
+                                </child>
                               </object>
                             </child>
                           </object>
diff --git a/pyanaconda/ui/gui/spokes/filter.py b/pyanaconda/ui/gui/spokes/filter.py
index 268d7bd..24ad5e4 100644
--- a/pyanaconda/ui/gui/spokes/filter.py
+++ b/pyanaconda/ui/gui/spokes/filter.py
@@ -19,6 +19,9 @@
 # Red Hat Author(s): Chris Lumens <clumens at redhat.com>
 #
 
+# pylint: disable-msg=E0611
+from gi.repository import Gtk
+
 from collections import namedtuple
 import itertools
 
@@ -601,11 +604,9 @@ class FilterSpoke(NormalSpoke):
         self.pages[n].filterActive = True
         self.pages[n].model.refilter()
 
-    def on_clear_clicked(self, button):
-        n = self._notebook.get_current_page()
-        self.pages[n].filterActive = False
-        self.pages[n].model.refilter()
-        self.pages[n].clear()
+    def on_clear_icon_clicked(self, entry, icon_pos, event):
+        if icon_pos == Gtk.EntryIconPosition.SECONDARY:
+            entry.set_text("")
 
     def on_page_switched(self, notebook, newPage, newPageNum, *args):
         self.pages[newPageNum].model.refilter()
@@ -666,10 +667,8 @@ class FilterSpoke(NormalSpoke):
 
         notebook = self.builder.get_object("searchTypeNotebook")
         findButton = self.builder.get_object("searchFindButton")
-        clearButton = self.builder.get_object("searchClearButton")
 
         findButton.set_sensitive(ndx != 0)
-        clearButton.set_sensitive(ndx != 0)
         notebook.set_current_page(ndx)
 
     ##
@@ -680,10 +679,8 @@ class FilterSpoke(NormalSpoke):
 
         notebook = self.builder.get_object("multipathTypeNotebook")
         findButton = self.builder.get_object("multipathFindButton")
-        clearButton = self.builder.get_object("multipathClearButton")
 
         findButton.set_sensitive(ndx != 0)
-        clearButton.set_sensitive(ndx != 0)
         notebook.set_current_page(ndx)
 
     ##
@@ -694,10 +691,8 @@ class FilterSpoke(NormalSpoke):
 
         notebook = self.builder.get_object("otherTypeNotebook")
         findButton = self.builder.get_object("otherFindButton")
-        clearButton = self.builder.get_object("otherClearButton")
 
         findButton.set_sensitive(ndx != 0)
-        clearButton.set_sensitive(ndx != 0)
         notebook.set_current_page(ndx)
 
     ##
@@ -708,8 +703,6 @@ class FilterSpoke(NormalSpoke):
 
         notebook = self.builder.get_object("zTypeNotebook")
         findButton = self.builder.get_object("zFindButton")
-        clearButton = self.builder.get_object("zClearButton")
 
         findButton.set_sensitive(ndx != 0)
-        clearButton.set_sensitive(ndx != 0)
         notebook.set_current_page(ndx)
-- 
1.8.3.1



More information about the anaconda-patches mailing list