~ubuntu-branches/ubuntu/natty/hamster-applet/natty

« back to all changes in this revision

Viewing changes to hamster/widgets/__init__.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2010-02-10 02:52:31 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20100210025231-x0q5h4q7nlvihl09
Tags: 2.29.90-0ubuntu1
* New upstream version
  - workspace tracking - switch activity, when switching desktops
  - chart improvements - theme friendly and less noisier
  - for those without GNOME panel there is now a standalone version, 
    accessible via Applications -> Accessories -> Time Tracker
  - overview window remembers position
  - maintaining cursor on the selected row after edits / refreshes
  - descriptions once again in the main input field, delimited by comma
  - activity suggestion box now sorts items by recency (Patryk Zawadzki)
  - searching
  - simplified save report dialog, thanks to the what you see is what you 
    report revamp
  - overview/stats replaced with activities / totals and stats accessible 
    from totals
  - interactive graphs to drill down in totals
  - miscellaneous performance improvements
  - pixel-perfect graphs
* Updated 01_startup-fix.patch to apply to new source layout
* debian/control:
  - Add build-depend on gnome-doc-utils

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# - coding: utf-8 -
2
 
 
3
 
# Copyright (C) 2007-2009 Toms Bauģis <toms.baugis at gmail.com>
4
 
 
5
 
# This file is part of Project Hamster.
6
 
 
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.
11
 
 
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.
16
 
 
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/>.
19
 
 
20
 
import datetime as dt
21
 
import gtk, pango
22
 
 
23
 
# import our children
24
 
from activityentry import ActivityEntry
25
 
from dateinput import DateInput
26
 
from timeinput import TimeInput
27
 
 
28
 
from timeline import TimeLine
29
 
from newtimeline import NewTimeLine
30
 
 
31
 
from dayline import DayLine
32
 
 
33
 
from tags import Tag
34
 
from tags import TagBox
35
 
from tags import TagsEntry
36
 
from tags import TagCellRenderer
37
 
 
38
 
from reportchooserdialog import ReportChooserDialog
39
 
 
40
 
from facttree import FactTree
41
 
 
42
 
# handy wrappers
43
 
def add_hint(entry, hint):
44
 
    entry.hint = hint        
45
 
    
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:
49
 
            return ""
50
 
        else:
51
 
            return self.real_get_text()
52
 
        
53
 
    def _set_hint(self, widget, event):
54
 
        if self.get_text(): # don't mess with user entered text
55
 
            return 
56
 
 
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)
61
 
        
62
 
        self.set_text(self.hint)
63
 
        
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)
68
 
 
69
 
        if self.real_get_text() == self.hint:
70
 
            self.set_text("")
71
 
            
72
 
    def _on_changed(self, widget):
73
 
        if self.real_get_text() == "" and self.is_focus() == False:
74
 
            self._set_hint(widget, None)
75
 
 
76
 
    import types
77
 
    instancemethod = types.MethodType
78
 
 
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)
84
 
    
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)
88
 
 
89
 
    entry._set_hint(entry, None)
90