From eb790cd78c3bd01b8182cb9add6de0bb15b66265 Mon Sep 17 00:00:00 2001 From: jgoerzen Date: Thu, 25 Jul 2002 05:46:27 +0100 Subject: [PATCH] /offlineimap/head: changeset 190 Lots of updates; see changelog --- offlineimap/head/debian/changelog | 12 +++++ offlineimap/head/offlineimap/imapserver.py | 3 ++ offlineimap/head/offlineimap/ui/Tk.py | 54 ++++++++++++++++++++-- offlineimap/head/offlineimap/ui/UIBase.py | 12 +++++ 4 files changed, 76 insertions(+), 5 deletions(-) diff --git a/offlineimap/head/debian/changelog b/offlineimap/head/debian/changelog index f9670ee..278cf29 100644 --- a/offlineimap/head/debian/changelog +++ b/offlineimap/head/debian/changelog @@ -1,3 +1,15 @@ +offlineimap (3.2.1) unstable; urgency=low + + * There is a new "connecting" event that will appear in all but the + Quiet UIs. It has a gray color in Blinkenlights. This event indicates + the the program is connecting to a remote server. + * Blinkenlights UI log window is now scrolled and has a new + config file option "bufferlines" to specify the size of the scroll + buffer. + * Make the Blinkenlights window non-resizable. + + -- John Goerzen Wed, 24 Jul 2002 17:04:04 -0500 + offlineimap (3.2.0) unstable; urgency=low * New BLINKENLIGHTS interface! Mesmerising, isn't it? diff --git a/offlineimap/head/offlineimap/imapserver.py b/offlineimap/head/offlineimap/imapserver.py index 007fbd4..730fb4d 100644 --- a/offlineimap/head/offlineimap/imapserver.py +++ b/offlineimap/head/offlineimap/imapserver.py @@ -19,6 +19,7 @@ from offlineimap import imaplib, imaputil, threadutil from threading import * import thread +import __main__ class UsefulIMAPMixIn: def getstate(self): @@ -120,6 +121,8 @@ class IMAPServer: self.connectionlock.release() # Release until need to modify data + __main__.ui.connecting(self.hostname, self.port) + # Generate a new connection. if self.tunnel: imapobj = UsefulIMAP4_Tunnel(self.tunnel) diff --git a/offlineimap/head/offlineimap/ui/Tk.py b/offlineimap/head/offlineimap/ui/Tk.py index ec37979..6861520 100644 --- a/offlineimap/head/offlineimap/ui/Tk.py +++ b/offlineimap/head/offlineimap/ui/Tk.py @@ -350,25 +350,38 @@ class LEDThreadFrame: class Blinkenlights(VerboseUI): def _createTopWindow(self): VerboseUI._createTopWindow(self, 0) + #self.top.resizable(width = 0, height = 0) self.top.configure(background = 'black', bd = 0) c = LEDCanvas(self.top, background = 'black', height = 20, bd = 0, highlightthickness = 0) c.setLEDCount(0) c.createLEDLock() self.canvas = c - c.pack(side = BOTTOM, expand = 1) + c.pack(side = BOTTOM, expand = 0, fill = X) widthmetric = tkFont.Font(family = 'Helvetica', size = 8).measure("0") self.loglines = 5 if self.config.has_option("ui.Tk.Blinkenlights", "loglines"): self.loglines = self.config.getint("ui.Tk.Blinkenlights", "loglines") - self.text = Text(self.top, bg = 'black', font = ("Helvetica", 8), + self.bufferlines = 500 + if self.config.has_option("ui.Tk.Blinkenlights", "bufferlines"): + self.bufferlines = self.config.getint("ui.tk.Blinkenlights", + "bufferlines") + self.text = ScrolledText(self.top, bg = 'black', #scrollbar = 'y', + font = ("Helvetica", 8), bd = 0, highlightthickness = 0, setgrid = 0, state = DISABLED, height = self.loglines, wrap = NONE, width = int(c.cget('width')) / widthmetric) + self.text.vbar.configure(background = '#000050', + activebackground = 'blue', + highlightbackground = 'black', + troughcolor = "black", bd = 0, + elementborderwidth = 2) + self.textenabled = 0 self.tags = [] self.textlock = Lock() + self.oldtextheight = 0 def gettf(s, newtype=LEDThreadFrame): return VerboseUI.gettf(s, newtype, s.canvas) @@ -386,6 +399,7 @@ class Blinkenlights(VerboseUI): s.menubar = menubar s.gettf().setcolor('red') s._msg(version.banner) + s.text.see(END) if s.config.has_option("ui.Tk.Blinkenlights", "showlog") and \ s.config.getboolean("ui.Tk.Blinkenlights", "showlog"): s._togglelog() @@ -401,14 +415,27 @@ class Blinkenlights(VerboseUI): def _togglelog(s): if s.textenabled: + s.oldtextheight = s.text.winfo_height() s.text.pack_forget() s.textenabled = 0 s.menubar.delete('Log') s.menubar.insert_command('Exit', label = 'Show Log', command = s._togglelog) + s.top.update() + print s.top.winfo_reqheight(), s.top.winfo_reqwidth() + #s.top.configure(height = s.top.winfo_reqheight(), + # width = s.top.winfo_reqwidth()) + s.top.geometry("%dx%d" % (s.top.winfo_reqwidth(), + s.top.winfo_reqheight())) + s.top.pack_propagate(1) + s.text.pack_propagate(1) + else: - s.text.pack(side = BOTTOM, expand = 1) + s.text.pack(side = BOTTOM, expand = 1, fill = BOTH) s.textenabled = 1 + s.top.update() + s.top.geometry("%dx%d" % (s.top.winfo_reqwidth(), + s.top.winfo_height() + s.oldtextheight)) s.menubar.delete('Show Log') logmenu = Menu(s.menubar, tearoff = 0, @@ -420,11 +447,16 @@ class Blinkenlights(VerboseUI): logmenu.add_command(label = "Larger Log", command = s._largerlog) logmenu.add_command(label = "Smaller Log", command = s._smallerlog) s.menubar.insert_cascade('Exit', label = "Log", menu = logmenu) + s._rescroll() def acct(s, accountname): s.gettf().setcolor('purple') VerboseUI.acct(s, accountname) + def connecting(s, hostname, port): + s.gettf().setcolor('gray') + VerboseUI.connecting(s, hostname, port) + def syncfolders(s, srcrepos, destrepos): s.gettf().setcolor('blue') VerboseUI.syncfolders(s, srcrepos, destrepos) @@ -481,6 +513,11 @@ class Blinkenlights(VerboseUI): s._msg("Next sync in %d:%02d" % (sleepsecs / 60, sleepsecs % 60)) UIBase.sleep(s, sleepsecs) + def _rescroll(s): + s.text.see(END) + lo, hi = s.text.vbar.get() + s.text.vbar.set(1.0 - (hi - lo), 1.0) + def _msg(s, msg): if "\n" in msg: for thisline in msg.split("\n"): @@ -488,6 +525,10 @@ class Blinkenlights(VerboseUI): return VerboseUI._msg(s, msg) color = s.gettf().getcolor() + rescroll = 1 + #print s.text.vbar.get()[1] + if s.text.vbar.get()[1] != 1.0: + rescroll = 0 s.textlock.acquire() try: @@ -495,12 +536,15 @@ class Blinkenlights(VerboseUI): if not color in s.tags: s.text.tag_config(color, foreground = color) s.tags.append(color) - s.text.insert(END, msg + "\n", color) + s.text.insert(END, "\n" + msg, color) # Trim down. Not quite sure why I have to say 7 instead of 5, # but so it is. - while float(s.text.index(END)) > s.loglines + 2.0: + while float(s.text.index(END)) > s.bufferlines + 2.0: s.text.delete(1.0, 2.0) + + if rescroll: + s._rescroll() finally: s.text.config(state = DISABLED) s.textlock.release() diff --git a/offlineimap/head/offlineimap/ui/UIBase.py b/offlineimap/head/offlineimap/ui/UIBase.py index 8019195..e7f91bb 100644 --- a/offlineimap/head/offlineimap/ui/UIBase.py +++ b/offlineimap/head/offlineimap/ui/UIBase.py @@ -63,6 +63,18 @@ class UIBase: if s.verbose >= 0: s._msg(offlineimap.version.banner) + def connecting(s, hostname, port): + if s.verbose < 0: + return + if hostname == None: + hostname = '' + if port != None: + port = ":%d" % port + displaystr = ' to %s%s.' % (hostname, port) + if hostname == '' and port == None: + displaystr = '.' + s._msg("Establishing connection" + displaystr) + def acct(s, accountname): if s.verbose >= 0: s._msg("***** Processing account %s" % accountname)