diff options
-rw-r--r-- | alot/buffers.py | 9 | ||||
-rw-r--r-- | alot/db.py | 4 | ||||
-rw-r--r-- | alot/helper.py | 3 | ||||
-rwxr-xr-x | alot/init.py | 3 | ||||
-rw-r--r-- | alot/message.py | 11 | ||||
-rw-r--r-- | alot/ui.py | 19 | ||||
-rw-r--r-- | alot/widgets.py | 15 |
7 files changed, 36 insertions, 28 deletions
diff --git a/alot/buffers.py b/alot/buffers.py index b7d7cd8b..8e5d4c77 100644 --- a/alot/buffers.py +++ b/alot/buffers.py @@ -2,13 +2,14 @@ import urwid from notmuch.globals import NotmuchError import widgets -import settings +from settings import settings import commands from walker import PipeWalker from helper import shorten_author_string from db import NonexistantObjectError + class Buffer(object): """Abstract base class for buffers.""" @@ -105,8 +106,7 @@ class EnvelopeBuffer(Buffer): def rebuild(self): displayed_widgets = [] - hidden = settings.config.getstringlist('general', - 'envelope_headers_blacklist') + hidden = settings.get('envelope_headers_blacklist') #build lines lines = [] for (k, vlist) in self.envelope.headers.items(): @@ -145,8 +145,7 @@ class SearchBuffer(Buffer): self.dbman = ui.dbman self.ui = ui self.querystring = initialquery - default_order = settings.config.get('general', - 'search_threads_sort_order') + default_order = settings.get('search_threads_sort_order') self.sort_order = sort_order or default_order self.result_count = 0 self.isinitialized = False @@ -7,7 +7,7 @@ from datetime import datetime from collections import deque from message import Message -from settings import notmuchconfig as config +from settings import settings DB_ENC = 'utf-8' @@ -94,7 +94,7 @@ class DBManager(object): raise DatabaseLockedError() # read notmuch's config regarding imap flag synchronization - sync = config.getboolean('maildir', 'synchronize_flags') + sync = settings.get_notmuch_setting('maildir', 'synchronize_flags') # go through writequeue entries while self.writequeue: diff --git a/alot/helper.py b/alot/helper.py index cd258c7a..1ee2a722 100644 --- a/alot/helper.py +++ b/alot/helper.py @@ -18,6 +18,7 @@ import StringIO import logging from settings import config +from settings import settings def safely_get(clb, E, on_error=''): @@ -54,7 +55,7 @@ def string_sanitize(string, tab_width=None): 'foo bar' """ if tab_width == None: - tab_width = config.getint('general', 'tabwidth') + tab_width = settings.get('tabwidth') string = string.strip() string = string.replace('\r', '') diff --git a/alot/init.py b/alot/init.py index e602595b..1be3666d 100755 --- a/alot/init.py +++ b/alot/init.py @@ -174,8 +174,7 @@ def main(): cmdstring = 'compose %s' % args.subOptions.as_argparse_opts() cmd = commands.commandfactory(cmdstring, 'global') else: - default_commandline = settings.config.get('general', - 'initial_command') + default_commandline = settings.settings.get('initial_command') cmd = commands.commandfactory(default_commandline, 'global') except CommandParseError, e: sys.exit(e) diff --git a/alot/message.py b/alot/message.py index 4124e236..1557b7fa 100644 --- a/alot/message.py +++ b/alot/message.py @@ -17,6 +17,7 @@ import logging import helper from settings import get_mime_handler from settings import config +from settings import settings from helper import string_sanitize from helper import string_decode @@ -135,11 +136,11 @@ class Message(object): """ if self._datetime == None: return None - if config.has_option('general', 'timestamp_format'): - formatstring = config.get('general', 'timestamp_format') - res = self._datetime.strftime(formatstring) - else: + formatstring = settings.get('timestamp_format') + if formatstring == None: res = helper.pretty_datetime(self._datetime) + else: + res = self._datetime.strftime(formatstring) return res def get_author(self): @@ -597,7 +598,7 @@ class Envelope(object): if 'User-Agent' in headers: uastring_format = headers['User-Agent'][0] else: - uastring_format = config.get('general', 'user_agent').strip() + uastring_format = settings.get('user_agent').strip() uastring = uastring_format % {'version': __version__} if uastring: headers['User-Agent'] = [uastring] @@ -4,6 +4,7 @@ from twisted.internet import reactor, defer from twisted.python.failure import Failure from settings import config +from settings import settings from buffers import BufferlistBuffer import commands from commands import commandfactory @@ -46,7 +47,7 @@ class InputWrap(urwid.WidgetWrap): mode = self.ui.mode if self.select_cancel_only: mode = 'global' - cmdline = config.get_mapping(mode, key) + cmdline = settings.get_keybinding(mode, key) if cmdline: try: cmd = commandfactory(cmdline, mode) @@ -87,18 +88,19 @@ class UI(object): self.accountman = accountman if not colourmode: - colourmode = config.getint('general', 'colourmode') + # needs explicit int-constructor because we used "options" in specfile + colourmode = int(settings.get('colourmode')) logging.info('setup gui in %d colours' % colourmode) self.mainframe = urwid.Frame(urwid.SolidFill()) self.inputwrap = InputWrap(self, self.mainframe) self.mainloop = urwid.MainLoop(self.inputwrap, - config.get_palette(), + config.get_palette(), #todo: remove handle_mouse=False, event_loop=urwid.TwistedEventLoop(), unhandled_input=self.unhandeled_input) self.mainloop.screen.set_terminal_properties(colors=colourmode) - self.show_statusbar = config.getboolean('general', 'show_statusbar') + self.show_statusbar = settings.get('show_statusbar') self.notificationbar = None self.mode = 'global' self.commandprompthistory = [] @@ -208,7 +210,7 @@ class UI(object): logging.debug('UI: closing current buffer %s' % buf) index = buffers.index(buf) buffers.remove(buf) - offset = config.getint('general', 'bufferclose_focus_offset') + offset = settings.get('bufferclose_focus_offset') nextbuffer = buffers[(index + offset) % len(buffers)] self.buffer_focus(nextbuffer) buf.cleanup() @@ -374,7 +376,7 @@ class UI(object): else: if timeout >= 0: if timeout == 0: - timeout = config.getint('general', 'notify_timeout') + timeout = settings.get('notify_timeout') self.mainloop.set_alarm_in(timeout, clear) return msgs[0] @@ -438,7 +440,7 @@ class UI(object): logging.debug('calling pre-hook') try: cmd.prehook(ui=self, dbm=self.dbman, aman=self.accountman, - config=config) + config=settings) except: logging.exception('prehook failed') @@ -449,7 +451,8 @@ class UI(object): logging.debug('calling post-hook') try: cmd.posthook(ui=self, dbm=self.dbman, - aman=self.accountman, config=config) + aman=self.accountman, config=settings) + #TODO: ducument hooks wrt settingsmanager except: logging.exception('posthook failed') diff --git a/alot/widgets.py b/alot/widgets.py index a85e31e8..55065100 100644 --- a/alot/widgets.py +++ b/alot/widgets.py @@ -2,6 +2,7 @@ import urwid import logging from settings import config +from settings import settings from helper import shorten_author_string from helper import pretty_datetime from helper import tag_cmp @@ -75,8 +76,8 @@ class ThreadlineWidget(urwid.AttrMap): self.thread = dbman.get_thread(tid) #logging.debug('tid: %s' % self.thread) self.tag_widgets = [] - self.display_content = config.getboolean('general', - 'display_content_in_threadline') + self.display_content = settings.get('display_content_in_threadline') + #TODO replace self.highlight_components = config.getstringlist('highlighting', 'components') self.highlight_rules = config.get_highlight_rules() @@ -94,7 +95,7 @@ class ThreadlineWidget(urwid.AttrMap): datestring = u' ' * 10 else: if config.has_option('general', 'timestamp_format'): - formatstring = config.get('general', 'timestamp_format') + formatstring = settings.get('timestamp_format') datestring = newest.strftime(formatstring) else: datestring = pretty_datetime(newest).rjust(10) @@ -125,7 +126,7 @@ class ThreadlineWidget(urwid.AttrMap): authors = self.thread.get_authors() or '(None)' else: authors = '(None)' - maxlength = config.getint('general', 'authors_maxlength') + maxlength = settings.get('authors_maxlength') authorsstring = shorten_author_string(authors, maxlength) self.authors_w = urwid.AttrMap(urwid.Text(authorsstring), self._get_theme('authors')) @@ -247,8 +248,10 @@ class TagWidget(urwid.AttrMap): def __init__(self, tag, theme=''): self.tag = tag self.highlight = theme + # TODO: replace self.translated = config.get('tag-translate', tag, fallback=tag) self.txt = urwid.Text(self.translated.encode('utf-8'), wrap='clip') + # TODO: replace normal = config.get_tag_theme(tag, highlight=theme) focus = config.get_tag_theme(tag, focus=True, highlight=theme) urwid.AttrMap.__init__(self, self.txt, normal, focus) @@ -268,11 +271,13 @@ class TagWidget(urwid.AttrMap): return self.tag def set_focussed(self): + # TODO: replace self.set_attr_map({None: config.get_tag_theme( self.tag, focus=True, highlight=self.highlight)}) def set_unfocussed(self): + # TODO: replace self.set_attr_map({None: config.get_tag_theme( self.tag, highlight=self.highlight)}) @@ -412,7 +417,7 @@ class MessageWidget(urwid.WidgetWrap): # set available and to be displayed headers self._all_headers = self.mail.keys() - displayed = config.getstringlist('general', 'displayed_headers') + displayed = settings.get('displayed_headers') self._filtered_headers = [k for k in displayed if k in self.mail] self._displayed_headers = None |