Skip to content

Commit

Permalink
close #88. not a complete solution, it just makes the problem visible…
Browse files Browse the repository at this point in the history
… to users with eyes.
  • Loading branch information
mfrasca committed Dec 29, 2017
1 parent d4222cb commit 71eb927
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bauble/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,9 @@ def make_note_class(name, compute_serializable_fields, as_dict=None, retrieve=No
def is_defined(self):
return bool(self.user and self.category and self.note)

def is_empty(self):
return not self.user and not self.category and not self.note

def retrieve_or_create(cls, session, keys,
create=True, update=True):
"""return database object corresponding to keys
Expand Down
9 changes: 7 additions & 2 deletions bauble/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,9 @@ def set_content(self, text):
self.widgets.note_textview.set_buffer(buff)
utils.set_widget_value(self.widgets.note_textview,
text or '')
buff.connect('changed', self.on_note_buffer_changed)
if not text:
self.presenter.add_problem(self.presenter.PROBLEM_EMPTY, self.widgets.note_textview)
buff.connect('changed', self.on_note_buffer_changed, self.widgets.note_textview)

def __init__(self, presenter, model=None):
super(NoteBox, self).__init__()
Expand Down Expand Up @@ -1891,10 +1893,13 @@ def on_category_entry_changed(self, entry, *args):
value = None
self.set_model_attr('category', value)

def on_note_buffer_changed(self, buff, *args):
def on_note_buffer_changed(self, buff, widget, *args):
value = utils.utf8(buff.props.text)
if not value: # if value == ''
value = None
self.presenter.add_problem(self.presenter.PROBLEM_EMPTY, widget)
else:
self.presenter.remove_problem(self.presenter.PROBLEM_EMPTY, widget)
self.set_model_attr('note', value)

def update_label(self):
Expand Down

0 comments on commit 71eb927

Please sign in to comment.