[hamster-applet] override gettext so it never returns our hint
- From: Toms Baugis <tbaugis src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [hamster-applet] override gettext so it never returns our hint
- Date: Tue, 24 Nov 2009 10:44:35 +0000 (UTC)
commit 42f7d3ceb077faf38cdefe8d159ca55cd35615cd
Author: Toms Bauģis <toms baugis gmail com>
Date: Tue Nov 24 01:07:01 2009 +0000
override gettext so it never returns our hint
hamster/widgets/__init__.py | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/hamster/widgets/__init__.py b/hamster/widgets/__init__.py
index 1bc2e5e..656e1b8 100644
--- a/hamster/widgets/__init__.py
+++ b/hamster/widgets/__init__.py
@@ -37,6 +37,13 @@ from reportchooserdialog import ReportChooserDialog
def add_hint(entry, hint):
entry.hint = hint
+ def override_get_text(self):
+ #override get text so it does not return true when hint is in!
+ if self.real_get_text() == self.hint:
+ return ""
+ else:
+ return self.real_get_text()
+
def _set_hint(self, widget, event):
if self.get_text(): # don't mess with user entered text
return
@@ -53,7 +60,7 @@ def add_hint(entry, hint):
hint_font = pango.FontDescription(gtk.Style().font_desc.to_string())
self.modify_font(hint_font)
- if self.get_text() == self.hint:
+ if self.real_get_text() == self.hint:
self.set_text("")
import types
@@ -61,6 +68,8 @@ def add_hint(entry, hint):
entry._set_hint = instancemethod(_set_hint, entry, gtk.Entry)
entry._set_normal = instancemethod(_set_normal, entry, gtk.Entry)
+ entry.real_get_text = entry.get_text
+ entry.get_text = instancemethod(override_get_text, entry, gtk.Entry)
entry.connect('focus-in-event', entry._set_normal)
entry.connect('focus-out-event', entry._set_hint)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]