]>
code.delx.au - offlineimap/blob - offlineimap/head/offlineimap/ui/Blinkenlights.py
f5814f52706628eca7e8ec51e0577ccc567cfd11
1 # Blinkenlights base classes
2 # Copyright (C) 2003 John Goerzen
3 # <jgoerzen@complete.org>
5 # This program 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 # This program 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 this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 from threading
import *
23 """This is a mix-in class that should be mixed in with either UIBase
24 or another appropriate base class. The Tk interface, for instance,
25 will probably mix it in with VerboseUI."""
27 def acct(s
, accountname
):
28 s
.gettf().setcolor('purple')
29 s
.__class
__.__bases
__[-1].acct(s
, accountname
)
31 def connecting(s
, hostname
, port
):
32 s
.gettf().setcolor('gray')
33 s
.__class
__.__bases
__[-1].connecting(s
, hostname
, port
)
35 def syncfolders(s
, srcrepos
, destrepos
):
36 s
.gettf().setcolor('blue')
37 s
.__class
__.__bases
__[-1].syncfolders(s
, srcrepos
, destrepos
)
39 def syncingfolder(s
, srcrepos
, srcfolder
, destrepos
, destfolder
):
40 s
.gettf().setcolor('cyan')
41 s
.__class
__.__bases
__[-1].syncingfolder(s
, srcrepos
, srcfolder
, destrepos
, destfolder
)
43 def loadmessagelist(s
, repos
, folder
):
44 s
.gettf().setcolor('green')
45 s
._msg
("Scanning folder [%s/%s]" % (s
.getnicename(repos
),
46 folder
.getvisiblename()))
48 def syncingmessages(s
, sr
, sf
, dr
, df
):
49 s
.gettf().setcolor('blue')
50 s
.__class
__.__bases
__[-1].syncingmessages(s
, sr
, sf
, dr
, df
)
52 def copyingmessage(s
, uid
, src
, destlist
):
53 s
.gettf().setcolor('orange')
54 s
.__class
__.__bases
__[-1].copyingmessage(s
, uid
, src
, destlist
)
56 def deletingmessages(s
, uidlist
, destlist
):
57 s
.gettf().setcolor('red')
58 s
.__class
__.__bases
__[-1].deletingmessages(s
, uidlist
, destlist
)
60 def deletingmessage(s
, uid
, destlist
):
61 s
.gettf().setcolor('red')
62 s
.__class
__.__bases
__[-1].deletingmessage(s
, uid
, destlist
)
64 def addingflags(s
, uid
, flags
, destlist
):
65 s
.gettf().setcolor('yellow')
66 s
.__class
__.__bases
__[-1].addingflags(s
, uid
, flags
, destlist
)
68 def deletingflags(s
, uid
, flags
, destlist
):
69 s
.gettf().setcolor('pink')
70 s
.__class
__.__bases
__[-1].deletingflags(s
, uid
, flags
, destlist
)
73 s
.availablethreadframes
= {}
77 def threadExited(s
, thread
):
78 threadid
= thread
.threadid
79 accountname
= s
.getthreadaccount(thread
)
82 if threadid
in s
.threadframes
[accountname
]:
83 tf
= s
.threadframes
[accountname
][threadid
]
84 del s
.threadframes
[accountname
][threadid
]
85 s
.availablethreadframes
[accountname
].append(tf
)
90 UIBase
.threadExited(s
, thread
)
93 threadid
= thread
.get_ident()
94 accountname
= s
.getthreadaccount()
99 if not accountname
in s
.threadframes
:
100 s
.threadframes
[accountname
] = {}
102 if threadid
in s
.threadframes
[accountname
]:
103 return s
.threadframes
[accountname
][threadid
]
105 if not accountname
in s
.availablethreadframes
:
106 s
.availablethreadframes
[accountname
] = []
108 if len(s
.availablethreadframes
[accountname
]):
109 tf
= s
.availablethreadframes
[accountname
].pop(0)
110 tf
.setthread(currentThread())
112 tf
= s
.getaccountframe().getnewthreadframe()
113 s
.threadframes
[accountname
][threadid
] = tf