1
# -*- coding: utf-8 -*-
3
# This file is part of emesene.
5
# Emesene is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# emesene is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with emesene; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
except: hasSexy = False
24
class FilterEntry(gtk.HBox):
26
def __init__(self, callback):
27
'''the callback is a function that receive
28
the string typed here as only parameter'''
30
gtk.HBox.__init__(self)
31
#self.set_border_width(2)
33
self.callback = callback
36
self.entry = sexy.IconEntry()
37
self.entry.set_icon(sexy.ICON_ENTRY_PRIMARY,gtk.image_new_from_stock(gtk.STOCK_FIND,gtk.ICON_SIZE_BUTTON))
38
self.entry.add_clear_button()
40
self.entry = gtk.Entry()
41
iconInfo = gtk.icon_theme_get_default().lookup_icon(gtk.STOCK_FIND, 22, 0)
46
self.icon = gtk.Image()
47
self.icon.set_from_pixbuf(iconInfo.load_icon())
48
self.pack_start(self.icon, False, False)
49
self.entry.connect('changed', self.entryChanged)
50
self.entry.connect('key_press_event', self.entryKeypressEvent)
52
self.pack_start(self.entry)
55
def entryChanged(self, *args):
56
self.callback(self.entry.get_text())
58
def entryKeypressEvent(self, widget, event):
59
keyval = gtk.gdk.keyval_name(event.keyval)
60
if keyval == 'Escape':
61
self.entry.props.text = ''