3
# Copyright (C) 2007-2009 Toms Bauģis <toms.baugis at gmail.com>
5
# This file is part of Project Hamster.
7
# Project Hamster is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# Project Hamster is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with Project Hamster. If not, see <http://www.gnu.org/licenses/>.
24
from activityentry import ActivityEntry
25
from dateinput import DateInput
26
from timeinput import TimeInput
28
from timeline import TimeLine
29
from newtimeline import NewTimeLine
31
from dayline import DayLine
34
from tags import TagBox
35
from tags import TagsEntry
36
from tags import TagCellRenderer
38
from reportchooserdialog import ReportChooserDialog
40
from facttree import FactTree
43
def add_hint(entry, hint):
46
def override_get_text(self):
47
#override get text so it does not return true when hint is in!
48
if self.real_get_text() == self.hint:
51
return self.real_get_text()
53
def _set_hint(self, widget, event):
54
if self.get_text(): # don't mess with user entered text
57
self.modify_text(gtk.STATE_NORMAL, gtk.gdk.Color("gray"))
58
hint_font = pango.FontDescription(gtk.Style().font_desc.to_string())
59
hint_font.set_style(pango.STYLE_ITALIC)
60
self.modify_font(hint_font)
62
self.set_text(self.hint)
64
def _set_normal(self, widget, event):
65
self.modify_text(gtk.STATE_NORMAL, gtk.Style().fg[gtk.STATE_NORMAL])
66
hint_font = pango.FontDescription(gtk.Style().font_desc.to_string())
67
self.modify_font(hint_font)
69
if self.real_get_text() == self.hint:
72
def _on_changed(self, widget):
73
if self.real_get_text() == "" and self.is_focus() == False:
74
self._set_hint(widget, None)
77
instancemethod = types.MethodType
79
entry._set_hint = instancemethod(_set_hint, entry, gtk.Entry)
80
entry._set_normal = instancemethod(_set_normal, entry, gtk.Entry)
81
entry._on_changed = instancemethod(_on_changed, entry, gtk.Entry)
82
entry.real_get_text = entry.get_text
83
entry.get_text = instancemethod(override_get_text, entry, gtk.Entry)
85
entry.connect('focus-in-event', entry._set_normal)
86
entry.connect('focus-out-event', entry._set_hint)
87
entry.connect('changed', entry._on_changed)
89
entry._set_hint(entry, None)