Cleanup: removal of mer, making things cleaner, etc
[quicknote] / src / search.py
index 37c90d2..fab6710 100644 (file)
@@ -7,16 +7,13 @@ import logging
 import gobject
 import gtk
 
 import gobject
 import gtk
 
-import gtk_toolbox
-import hildonize
-
 try:
        _
 except NameError:
        _ = lambda x: x
 
 
 try:
        _
 except NameError:
        _ = lambda x: x
 
 
-_moduleLogger = logging.getLogger("search")
+_moduleLogger = logging.getLogger(__name__)
 
 
 class Search(gtk.HBox):
 
 
 class Search(gtk.HBox):
@@ -28,15 +25,24 @@ class Search(gtk.HBox):
        def __init__(self):
                _moduleLogger.info("search, init")
                gtk.HBox.__init__(self, homogeneous = False, spacing = 3)
        def __init__(self):
                _moduleLogger.info("search, init")
                gtk.HBox.__init__(self, homogeneous = False, spacing = 3)
+               self.connect("hide", self._on_hide)
+               self.connect("show", self._on_show)
 
                label = gtk.Label(_("Search:  "))
 
                self._searchEntry = gtk.Entry()
                self._searchEntry.connect("changed", self._on_search_entry_changed, None)
 
 
                label = gtk.Label(_("Search:  "))
 
                self._searchEntry = gtk.Entry()
                self._searchEntry.connect("changed", self._on_search_entry_changed, None)
 
+               closeImage = gtk.Image()
+               closeImage.set_from_stock("gtk-close", gtk.ICON_SIZE_MENU)
+               closeSearch = gtk.Button()
+               closeSearch.set_image(closeImage)
+               closeSearch.connect("clicked", self._on_close)
+
                searchHBox = gtk.HBox()
                searchHBox.pack_start(label, expand = False, fill = False)
                searchHBox.pack_start(self._searchEntry, expand = True, fill = True)
                searchHBox = gtk.HBox()
                searchHBox.pack_start(label, expand = False, fill = False)
                searchHBox.pack_start(self._searchEntry, expand = True, fill = True)
+               searchHBox.pack_start(closeSearch, expand = False, fill = False)
                self.pack_start(searchHBox, expand = True, fill = True)
 
        def get_search_pattern(self):
                self.pack_start(searchHBox, expand = True, fill = True)
 
        def get_search_pattern(self):
@@ -44,3 +50,15 @@ class Search(gtk.HBox):
 
        def _on_search_entry_changed(self, widget = None, data = None):
                self.emit("search_changed")
 
        def _on_search_entry_changed(self, widget = None, data = None):
                self.emit("search_changed")
+
+       def _on_close(self, *args):
+               self.hide()
+
+       def _on_show(self, *args):
+               self._searchEntry.grab_focus()
+
+       def _on_hide(self, *args):
+               # HACK Disabled for now.  Clearing this resets the note list which
+               # causes the current note to lose focus.
+               # self._searchEntry.set_text("")
+               pass