summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpazz <patricktotzke@gmail.com>2011-05-29 20:17:27 +0100
committerpazz <patricktotzke@gmail.com>2011-05-29 20:17:27 +0100
commit55ed0b79f49020376d3e25b5c644c9e2ee6215d3 (patch)
treed26355f374d534840f73ce34e0fbc4df4f8b98e0
parent73b8e1a0dfc0b4f1590669a27f6edefc9238b3f2 (diff)
cleanup
-rw-r--r--alot/buffer.py27
-rw-r--r--alot/command.py3
-rw-r--r--alot/ui.py7
3 files changed, 15 insertions, 22 deletions
diff --git a/alot/buffer.py b/alot/buffer.py
index 3d332631..0b762f92 100644
--- a/alot/buffer.py
+++ b/alot/buffer.py
@@ -14,7 +14,7 @@ class Buffer:
self.body = widget
def __str__(self):
- return "[%s]" % (self.typename)
+ return ''
def render(self, size, focus=False):
return self.body.render(size, focus)
@@ -118,8 +118,7 @@ class SearchBuffer(Buffer):
}
def __str__(self):
- string = "[%s] for %s, (%d)"
- return string % (self.typename, self.querystring, self.result_count)
+ return '%s (%d threads)' % (self.querystring, self.result_count)
def rebuild(self):
if self.isinitialized:
@@ -153,19 +152,15 @@ class SearchBuffer(Buffer):
class SingleThreadBuffer(Buffer):
def __init__(self, ui, thread):
- self.read_thread(thread)
+ self.message_count = thread.get_total_messages()
+ self.subject = thread.get_subject()
+ self.messages = [(0, m) for m in thread.get_toplevel_messages()]
self.rebuild()
- Buffer.__init__(self, ui, self.body, 'search')
+ Buffer.__init__(self, ui, self.body, 'thread')
self.bindings = {}
def __str__(self):
- string = "[%s] %s, (%d)"
- return string % (self.typename, self.subject, self.message_count)
-
- def read_thread(self, thread):
- self.message_count = thread.get_total_messages()
- self.subject = thread.get_subject()
- self.messages = [(0, m) for m in thread.get_toplevel_messages()]
+ return '%s, (%d)' % (self.thread.subject, self.message_count)
def rebuild(self):
msgs = list()
@@ -178,16 +173,12 @@ class SingleThreadBuffer(Buffer):
else:
spacer = urwid.Text(' ' * depth)
msgs.append(urwid.Columns([('fixed', depth, spacer), mwidget]))
- self.messagelist = urwid.ListBox(msgs)
- self.body = self.messagelist
+ self.body = urwid.ListBox(msgs)
def get_selected_message(self):
- (messagewidget, size) = self.messagelist.get_focus()
+ (messagewidget, size) = self.body.get_focus()
return messagewidget.get_message()
- def get_selected_message_file(self):
- return self.get_selected_message().get_filename()
-
class TagListBuffer(Buffer):
def __init__(self, ui, alltags=[], filtfun=None):
diff --git a/alot/command.py b/alot/command.py
index cf445431..d46fb29c 100644
--- a/alot/command.py
+++ b/alot/command.py
@@ -44,7 +44,7 @@ class SearchCommand(Command):
def __init__(self, query, force_new=False, **kwargs):
"""
@param query initial querystring
- @param force_new True forces a new buffer, else focus old on same search
+ @param force_new True forces a new buffer
"""
self.query = query
self.force_new = force_new
@@ -276,6 +276,7 @@ class ThreadTagPromptCommand(Command):
threadwidget = sbuffer.get_selected_threadline()
threadwidget.rebuild() # rebuild and redraw the line
+
class RefineSearchPromptCommand(Command):
"""refine the current search"""
diff --git a/alot/ui.py b/alot/ui.py
index 17e9a05c..e75d95e9 100644
--- a/alot/ui.py
+++ b/alot/ui.py
@@ -14,7 +14,7 @@ class UI:
self.logger = log
self.dbman = db
- self.logger.debug('setup gui: %d'%colourmode)
+ self.logger.debug('setup gui: %d' % colourmode)
self.mainframe = urwid.Frame(urwid.SolidFill(' '))
self.mainloop = urwid.MainLoop(self.mainframe,
settings.palette,
@@ -114,7 +114,7 @@ class UI:
self.update()
def get_buffers_of_type(self, t):
- return filter(lambda x: isinstance(x,t), self.buffers)
+ return filter(lambda x: isinstance(x, t), self.buffers)
def update(self):
"""
@@ -133,7 +133,8 @@ class UI:
def update_footer(self):
idx = self.buffers.index(self.current_buffer)
- lefttxt = '%d: %s' % (idx, self.current_buffer)
+ lefttxt = '%d: [%s] %s' % (idx, self.current_buffer.typename,
+ self.current_buffer)
footerleft = urwid.Text(lefttxt, align='left')
righttxt = 'total messages: %d' % self.dbman.count_messages('*')
footerright = urwid.Text(righttxt, align='right')