From 2b011bab0fdaf325a419e657c8d808ef5a9fe657 Mon Sep 17 00:00:00 2001
From: "Samantha N. Bueno" <sbueno+anaconda@redhat.com>
Date: Wed, 7 Jan 2015 10:55:14 -0500
Subject: [PATCH 3/9] Get rid of the clear button in advanced storage spoke.

Just syncing behavior here with the rest of the GUI. This gets rid of
the 'clear' button.
---
 pyanaconda/ui/gui/spokes/filter.glade | 76 ++++++++---------------------------
 pyanaconda/ui/gui/spokes/filter.py    | 19 +++------
 2 files changed, 23 insertions(+), 72 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/filter.glade b/pyanaconda/ui/gui/spokes/filter.glade
index cacae43..6fe81bb 100644
--- a/pyanaconda/ui/gui/spokes/filter.glade
+++ b/pyanaconda/ui/gui/spokes/filter.glade
@@ -236,6 +236,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>
@@ -262,6 +264,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>
@@ -302,6 +306,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"/>
                                             <property name="width_chars">30</property>
                                           </object>
                                           <packing>
@@ -491,20 +497,6 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkButton" id="searchClearButton">
-                                    <property name="label" translatable="yes" context="GUI|Installation Destination|Filter|Search">_Clear</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_underline">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>
-                                  </packing>
-                                </child>
-                                <child>
                                   <object class="GtkButton" id="searchFindButton">
                                     <property name="label" translatable="yes" context="GUI|Installation Destination|Filter|Search">_Find</property>
                                     <property name="visible">True</property>
@@ -703,6 +695,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"/>
                                             <property name="width_chars">30</property>
                                           </object>
                                           <packing>
@@ -831,20 +825,6 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkButton" id="multipathClearButton">
-                                    <property name="label" translatable="yes" context="GUI|Installation Destination|Filter|Multipath">_Clear</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_underline">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>
-                                  </packing>
-                                </child>
-                                <child>
                                   <object class="GtkButton" id="multipathFindButton">
                                     <property name="label" translatable="yes" context="GUI|Installation Destination|Filter|Multipath">_Find</property>
                                     <property name="visible">True</property>
@@ -1024,22 +1004,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>
@@ -1051,7 +1015,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>
@@ -1173,6 +1137,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"/>
                                             <property name="width_chars">30</property>
                                           </object>
                                           <packing>
@@ -1263,20 +1229,6 @@
                                   </packing>
                                 </child>
                                 <child>
-                                  <object class="GtkButton" id="zClearButton">
-                                    <property name="label" translatable="yes" context="GUI|Installation Destination|Filter|zSeries">_Clear</property>
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="receives_default">True</property>
-                                    <property name="use_underline">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>
-                                  </packing>
-                                </child>
-                                <child>
                                   <object class="GtkTreeView" id="zTreeView">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
@@ -1446,6 +1398,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"/>
                                             <property name="width_chars">30</property>
                                             <property name="invisible_char_set">True</property>
                                           </object>
@@ -1493,6 +1447,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"/>
                                             <property name="width_chars">30</property>
                                             <property name="invisible_char_set">True</property>
                                           </object>
@@ -1534,6 +1490,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"/>
                                             <property name="width_chars">30</property>
                                             <property name="invisible_char_set">True</property>
                                           </object>
diff --git a/pyanaconda/ui/gui/spokes/filter.py b/pyanaconda/ui/gui/spokes/filter.py
index 0b6a9ca..3db7aab 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@redhat.com>
 #
 
+# pylint: disable-msg=E0611
+from gi.repository import Gtk
+
 from collections import namedtuple
 import itertools
 
@@ -579,11 +582,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()
@@ -658,10 +659,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)
 
     ##
@@ -672,10 +671,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)
 
     ##
@@ -686,10 +683,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)
 
     ##
@@ -700,8 +695,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

