Specialize accept button text based on whether we are editing a current annotation or not

This commit is contained in:
Kovid Goyal 2020-08-03 23:16:21 +05:30
parent 5d63ddfc03
commit b8e04661b7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 3 deletions

View File

@ -117,9 +117,10 @@ def custom_styles_equal(a, b):
class EditNotesAndColors: # {{{
def __init__(self, container, is_dark_theme, current_notes, current_style, close_editor):
def __init__(self, container, is_dark_theme, current_notes, current_style, annot_id, close_editor):
self.initial_style = current_style
self.is_dark_theme = is_dark_theme
self.annot_id = annot_id
def finish():
close_editor(True)
@ -159,7 +160,10 @@ class EditNotesAndColors: # {{{
E.span('\xa0'),
remove_button
),
create_button(_('Finish'), 'check', finish, _('Finish editing highlight') + ' [Ctrl+Enter]', True),
create_button(
_('Apply') if self.annot_id else _('Create'),
'check', finish,
(_('Finish editing highlight') if self.annot_id else _('Create highlight')) + ' [Ctrl+Enter]', True),
)
)

View File

@ -607,8 +607,9 @@ class SelectionBar:
clear(container)
container.style.display = 'block'
self.state = EDITING
cs = self.view.currently_showing.selection
self.current_editor = EditNotesAndColors(
container, self.view.current_color_scheme.is_dark_theme, notes, highlight_style, self.hide_editor)
container, self.view.current_color_scheme.is_dark_theme, notes, highlight_style, cs.annot_id, self.hide_editor)
self.place_editor()
def place_editor(self):