Commit 82c958cb authored by Jacek Sowiński's avatar Jacek Sowiński

Make TodoWidget._markup private again

Introduce proper TodoWidget.mark and TodoWidget.unmark public methods so
we don't have to expose _markup.
parent d7decafa
......@@ -16,7 +16,7 @@
import urwid
from topydo.ui.TodoWidget import TodoWidget, markup
from topydo.ui.TodoWidget import TodoWidget
from topydo.lib.Utils import translate_key_to_config
......@@ -207,9 +207,10 @@ class TodoListWidget(urwid.LineBox):
try:
todo = self.listbox.focus.todo
todo_id = str(self.view.todolist.number(todo))
result = urwid.emit_signal(self, 'toggle_mark', todo_id)
attr_spec = {None: markup(todo, result)}
self.listbox.focus.widget.set_attr_map(attr_spec)
if urwid.emit_signal(self, 'toggle_mark', todo_id):
self.listbox.focus.mark()
else:
self.listbox.focus.unmark()
except AttributeError:
# No todo item selected
pass
......
......@@ -36,7 +36,7 @@ def _to_urwid_color(p_color):
return 'h{}'.format(p_color.color)
def markup(p_todo, p_focus):
def _markup(p_todo, p_focus):
"""
Returns an attribute spec for the colors that correspond to the given todo
item.
......@@ -84,8 +84,8 @@ class TodoWidget(urwid.WidgetWrap):
self.widget = urwid.AttrMap(
self.columns,
markup(p_todo, False), # no focus
markup(p_todo, True) # focus
_markup(p_todo, False), # no focus
_markup(p_todo, True) # focus
)
super().__init__(self.widget)
......@@ -100,3 +100,9 @@ class TodoWidget(urwid.WidgetWrap):
def selectable(self):
# make sure that ListBox will highlight this widget
return True
def mark(self):
self.widget.set_attr_map({None: _markup(self.todo, True)})
def unmark(self):
self.widget.set_attr_map({None: _markup(self.todo, False)})
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment