| 1 |
# vim:fileencoding=utf-8 |
| 2 |
# License: GPL v3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net> |
| 3 |
from __python__ import bound_methods, hash_literals |
| 4 |
|
| 5 |
from elementmaker import E |
| 6 |
from gettext import gettext as _ |
| 7 |
|
| 8 |
from dom import add_extra_css, build_rule, clear, ensure_id |
| 9 |
from utils import safe_set_inner_html |
| 10 |
from widgets import create_button |
| 11 |
|
| 12 |
CLASS_NAME = 'conversion-option-group' |
| 13 |
indent = '↳\xa0' |
| 14 |
|
| 15 |
add_extra_css(def (): |
| 16 |
style = '' |
| 17 |
sel = '.' + CLASS_NAME + ' ' |
| 18 |
style += build_rule(sel + 'input[type="checkbox"]', margin_left='0') |
| 19 |
style += build_rule(sel + '[data-option-name]', margin_bottom='1ex', display='block', padding_bottom='0.5ex') |
| 20 |
style += build_rule(sel + '.simple-group > label', display='table-row') |
| 21 |
style += build_rule(sel + '.simple-group > label > *', display='table-cell', padding_bottom='1ex', padding_right='1rem') |
| 22 |
style += build_rule(sel + 'label.vertical', display='block') |
| 23 |
style += build_rule(sel + 'label.vertical > *', display='block', padding_bottom='1ex', padding_right='1rem') |
| 24 |
style += build_rule(sel + '[data-profile]', margin_left='2em', text_indent='-2em', font_size='smaller', margin_bottom='1ex') |
| 25 |
style += build_rule(sel + '.subset-choice label', display='block', margin_bottom='1ex') |
| 26 |
return style |
| 27 |
) |
| 28 |
|
| 29 |
|
| 30 |
# globals {{{ |
| 31 |
container_id = None |
| 32 |
get_option_value = get_option_default_value = is_option_disabled = get_option_help = profiles = ui_data = None |
| 33 |
entry_points = {} |
| 34 |
registry = {} |
| 35 |
listeners = {} |
| 36 |
|
| 37 |
|
| 38 |
def ep(func): |
| 39 |
entry_points[func.name] = func |
| 40 |
return func |
| 41 |
|
| 42 |
|
| 43 |
def add_listener(name, callback): |
| 44 |
if not listeners[name]: |
| 45 |
listeners[name] = [] |
| 46 |
listeners[name].push(callback) |
| 47 |
|
| 48 |
|
| 49 |
def on_change(name): |
| 50 |
if listeners[name]: |
| 51 |
for callback in listeners[name]: |
| 52 |
callback(name) |
| 53 |
|
| 54 |
|
| 55 |
def sanitize_accelerator(text): |
| 56 |
return text.replace('&', '') |
| 57 |
# }}} |
| 58 |
|
| 59 |
|
| 60 |
def subset_choice(name, choices, tooltip=None): # {{{ |
| 61 |
if get_option_default_value(name) is undefined: |
| 62 |
raise KeyError(f'{name} is not a known option') |
| 63 |
ans = E.div(data_option_name=name, class_='subset-choice') |
| 64 |
if tooltip is not None: |
| 65 |
ans.setAttribute('title', tooltip or get_option_help(name)) |
| 66 |
names = Object.keys(choices) |
| 67 |
for cname in names: |
| 68 |
ans.appendChild(E.label(E.input(type='checkbox', name=cname), '\xa0' + choices[cname])) |
| 69 |
ops = { |
| 70 |
'get': def (container): |
| 71 |
ans = [] |
| 72 |
for w in container.querySelectorAll('input'): |
| 73 |
if w.checked: |
| 74 |
ans.push(w.name) |
| 75 |
return ','.join(ans) |
| 76 |
, |
| 77 |
'set': def (container, val): |
| 78 |
q = {x.strip(): True for x in (val or '').split(',')} |
| 79 |
for w in container.querySelectorAll('input'): |
| 80 |
w.checked = bool(q[w.name]) |
| 81 |
, |
| 82 |
'set_disabled': def (container, val): |
| 83 |
pass |
| 84 |
} |
| 85 |
registry[name] = ops |
| 86 |
ops.set(ans, get_option_value(name)) |
| 87 |
return ans |
| 88 |
# }}} |
| 89 |
|
| 90 |
|
| 91 |
def create_simple_widget(name, text, tooltip, input_widget_, getter, setter, suffix): # {{{ |
| 92 |
if get_option_default_value(name) is undefined: |
| 93 |
raise KeyError(f'{name} is not a known option') |
| 94 |
if not text.endswith(':'): |
| 95 |
text = text + ':' |
| 96 |
label = E.label(E.span(sanitize_accelerator(text)), E.span(input_widget_)) |
| 97 |
if suffix: |
| 98 |
label.lastChild.appendChild(document.createTextNode('\xa0' + suffix)) |
| 99 |
label.dataset.optionName = name |
| 100 |
label.setAttribute('title', tooltip or get_option_help(name)) |
| 101 |
|
| 102 |
def straight_input_widget(container): |
| 103 |
return container.lastChild.firstChild |
| 104 |
|
| 105 |
input_widget = straight_input_widget |
| 106 |
|
| 107 |
ops = { |
| 108 |
'get': def (container): |
| 109 |
return getter(input_widget(container)) |
| 110 |
, |
| 111 |
'set': def (container, val): |
| 112 |
setter(input_widget(container), val) |
| 113 |
, |
| 114 |
'set_disabled': def (container, val): |
| 115 |
if val: |
| 116 |
container.classList.add('disabled') |
| 117 |
input_widget(container).setAttribute('disabled', 'disabled') |
| 118 |
else: |
| 119 |
container.classList.remove('disabled') |
| 120 |
input_widget(container).removeAttribute('disabled') |
| 121 |
} |
| 122 |
registry[name] = ops |
| 123 |
ops.set(label, get_option_value(name)) |
| 124 |
if is_option_disabled(name): |
| 125 |
ops.set_disabled(label, True) |
| 126 |
input_widget(label).addEventListener('change', on_change.bind(None, name)) |
| 127 |
if listeners[name]: |
| 128 |
window.setTimeout(on_change.bind(None, name), 0) |
| 129 |
return label |
| 130 |
# }}} |
| 131 |
|
| 132 |
|
| 133 |
def checkbox(name, text, tooltip): # {{{ |
| 134 |
return create_simple_widget(name, text, tooltip, E.input(type='checkbox'), |
| 135 |
def getter(w): # noqa: unused-local |
| 136 |
return bool(w.checked) |
| 137 |
, |
| 138 |
def setter(w, val): # noqa: unused-local |
| 139 |
w.checked = bool(val) |
| 140 |
, |
| 141 |
) |
| 142 |
# }}} |
| 143 |
|
| 144 |
|
| 145 |
def lineedit(name, text, width=25, tooltip=None, suffix=None): # {{{ |
| 146 |
return create_simple_widget(name, text, tooltip, E.input(type='text', size=str(width)), |
| 147 |
def getter(w): # noqa: unused-local |
| 148 |
ans = w.value |
| 149 |
if ans and ans.strip(): |
| 150 |
return ans.strip() |
| 151 |
, |
| 152 |
def setter(w, val): # noqa: unused-local |
| 153 |
w.value = val or '' |
| 154 |
, suffix = suffix |
| 155 |
) |
| 156 |
# }}} |
| 157 |
|
| 158 |
|
| 159 |
def float_spin(name, text, tooltip=None, step=0.1, min=0, max=100, unit=None): # {{{ |
| 160 |
f = E.input(type='number', step=str(step), min=str(min), max=str(max), required=True) |
| 161 |
defval = get_option_default_value(name) |
| 162 |
return create_simple_widget(name, text, tooltip, f, |
| 163 |
def getter(w): # noqa: unused-local |
| 164 |
try: |
| 165 |
return float(w.value) |
| 166 |
except: |
| 167 |
return defval |
| 168 |
, |
| 169 |
def setter(w, val): # noqa: unused-local |
| 170 |
w.value = str(float(val)) |
| 171 |
, |
| 172 |
suffix = unit |
| 173 |
) |
| 174 |
# }}} |
| 175 |
|
| 176 |
|
| 177 |
def int_spin(name, text, tooltip=None, step=1, min=0, max=100, unit=None): # {{{ |
| 178 |
f = E.input(type='number', step=str(step), min=str(min), max=str(max), required=True) |
| 179 |
defval = get_option_default_value(name) |
| 180 |
return create_simple_widget(name, text, tooltip, f, |
| 181 |
def getter(w): # noqa: unused-local |
| 182 |
try: |
| 183 |
return int(w.value) |
| 184 |
except: |
| 185 |
return defval |
| 186 |
, |
| 187 |
def setter(w, val): # noqa: unused-local |
| 188 |
w.value = str(int(val)) |
| 189 |
, |
| 190 |
suffix = unit |
| 191 |
) |
| 192 |
# }}} |
| 193 |
|
| 194 |
|
| 195 |
def choices(name, text, choices, tooltip): # {{{ |
| 196 |
f = E.select() |
| 197 |
if Array.isArray(choices): |
| 198 |
for key in choices: |
| 199 |
f.appendChild(E.option(key, value=key)) |
| 200 |
else: |
| 201 |
for key in choices: |
| 202 |
f.appendChild(E.option(choices[key], value=key)) |
| 203 |
|
| 204 |
return create_simple_widget(name, text, tooltip, f, |
| 205 |
def getter(w): # noqa: unused-local |
| 206 |
return w.value |
| 207 |
, |
| 208 |
def setter(w, val): # noqa: unused-local |
| 209 |
w.value = val |
| 210 |
) |
| 211 |
# }}} |
| 212 |
|
| 213 |
|
| 214 |
def textarea(name, text, tooltip): # {{{ |
| 215 |
ans = create_simple_widget(name, text, tooltip, E.textarea(rows='30', cols='70'), |
| 216 |
def getter(w): # noqa: unused-local |
| 217 |
ans = w.value |
| 218 |
if ans and ans.strip(): |
| 219 |
return ans.strip() |
| 220 |
, |
| 221 |
def setter(w, val): # noqa: unused-local |
| 222 |
w.value = val or '' |
| 223 |
) |
| 224 |
ans.classList.add('vertical') |
| 225 |
return ans |
| 226 |
# }}} |
| 227 |
|
| 228 |
|
| 229 |
def container_for_option(name): |
| 230 |
return document.getElementById(container_id).querySelector(f'[data-option-name="{name}"]') |
| 231 |
|
| 232 |
|
| 233 |
def get(name): |
| 234 |
return registry[name].get(container_for_option(name)) |
| 235 |
|
| 236 |
|
| 237 |
def set(name, val): |
| 238 |
registry[name].set(container_for_option(name), val) |
| 239 |
|
| 240 |
|
| 241 |
def set_disabled(name, val): |
| 242 |
registry[name].set_disabled(container_for_option(name), val) |
| 243 |
|
| 244 |
|
| 245 |
# Look & feel {{{ |
| 246 |
@ep |
| 247 |
@no_prune |
| 248 |
def look_and_feel(container): |
| 249 |
def subhead(text): |
| 250 |
container.appendChild(E.div( |
| 251 |
style='border-bottom: solid 1px currentColor; margin-bottom: 1ex; max-width: 35em', E.b(sanitize_accelerator(text)))) |
| 252 |
|
| 253 |
subhead(_('&Fonts')) |
| 254 |
add_listener('disable_font_rescaling', def (name): |
| 255 |
disabled = get('disable_font_rescaling') |
| 256 |
for dname in 'font_size_mapping', 'base_font_size': |
| 257 |
set_disabled(dname, disabled) |
| 258 |
) |
| 259 |
g = E.div(class_='simple-group') |
| 260 |
container.appendChild(g) |
| 261 |
g.appendChild(checkbox('disable_font_rescaling', _('&Disable font size rescaling'))) |
| 262 |
g.appendChild(float_spin('base_font_size', _('Base font si&ze:'), max=50, unit='pt')) |
| 263 |
g.appendChild(lineedit('font_size_mapping', _('Font size &key:'))) |
| 264 |
g.appendChild(float_spin('minimum_line_height', _('Minim&um line height:'), max=900, unit='%')) |
| 265 |
g.appendChild(float_spin('line_height', _('Line hei&ght:'), unit='%')) |
| 266 |
g.appendChild(lineedit('embed_font_family', _('Embed font fami&ly:'))) |
| 267 |
g.appendChild(checkbox('embed_all_fonts', _('&Embed all fonts in document'))) |
| 268 |
g.appendChild(checkbox('subset_embedded_fonts', _('&Subset all embedded fonts'))) |
| 269 |
g.appendChild(checkbox('keep_ligatures', _('Keep &ligatures'))) |
| 270 |
|
| 271 |
subhead(_('Te&xt')) |
| 272 |
g = E.div(class_='simple-group') |
| 273 |
container.appendChild(g) |
| 274 |
g.appendChild(lineedit('input_encoding', _('I&nput character encoding:'))) |
| 275 |
g.appendChild(choices('change_justification', _('Text &justification:'), |
| 276 |
{'original': _('Original'), 'left': _('Left align'), 'justify': _('Justify text')} |
| 277 |
)) |
| 278 |
g.appendChild(checkbox('smarten_punctuation', _('Smarten &punctuation'))) |
| 279 |
g.appendChild(checkbox('unsmarten_punctuation', _('&Unsmarten punctuation'))) |
| 280 |
g.appendChild(checkbox('asciiize', _('&Transliterate Unicode characters to ASCII'))) |
| 281 |
|
| 282 |
subhead(_('Lay&out')) |
| 283 |
add_listener('remove_paragraph_spacing', def (name): |
| 284 |
disabled = get('remove_paragraph_spacing') |
| 285 |
set_disabled('remove_paragraph_spacing_indent_size', not disabled) |
| 286 |
) |
| 287 |
g = E.div(class_='simple-group') |
| 288 |
container.appendChild(g) |
| 289 |
g.appendChild(checkbox('remove_paragraph_spacing', _('Remove &spacing between paragraphs'))) |
| 290 |
g.appendChild(float_spin('remove_paragraph_spacing_indent_size', indent + _('I&ndent size:'), min=-0.1, unit='em')) |
| 291 |
g.appendChild(checkbox('insert_blank_line', _('Insert &blank line between paragraphs'))) |
| 292 |
g.appendChild(float_spin('insert_blank_line_size', indent + _('&Line size:'), unit='em')) |
| 293 |
g.appendChild(checkbox('linearize_tables', _('&Linearize tables'))) |
| 294 |
|
| 295 |
subhead(_('St&yling')) |
| 296 |
g = E.div(class_='simple-group') |
| 297 |
container.appendChild(g) |
| 298 |
g.appendChild(lineedit('filter_css', _('Filter style information'), 40)) |
| 299 |
container.appendChild(textarea('extra_css', 'E&xtra CSS')) |
| 300 |
# }}} |
| 301 |
|
| 302 |
|
| 303 |
# Heuristics {{{ |
| 304 |
@ep |
| 305 |
@no_prune |
| 306 |
def heuristics(container): |
| 307 |
settings = [] |
| 308 |
|
| 309 |
def add(func, name, text, **kw): |
| 310 |
g.appendChild(func(name, text, **kw)) |
| 311 |
settings.push(name) |
| 312 |
|
| 313 |
add_listener('enable_heuristics', def (name): |
| 314 |
disabled = not get('enable_heuristics') |
| 315 |
for dname in settings: |
| 316 |
set_disabled(dname, disabled) |
| 317 |
) |
| 318 |
blurb = _( |
| 319 |
'<b>Heuristic processing</b> means that calibre will scan your book for common patterns and fix them.' |
| 320 |
' As the name implies, this involves guesswork, which means that it could end up worsening the result' |
| 321 |
' of a conversion, if calibre guesses wrong. Therefore, it is disabled by default. Often, if a conversion' |
| 322 |
' does not turn out as you expect, turning on heuristics can improve matters. Read more about the various' |
| 323 |
' heuristic processing options in the <a href="%s">User Manual</a>.' '').replace( |
| 324 |
'%s', 'https://manual.calibre-ebook.com/conversion.html#heuristic-processing') |
| 325 |
container.appendChild(E.div(style='margin-bottom: 1ex')) |
| 326 |
safe_set_inner_html(container.lastChild, blurb) |
| 327 |
g = E.div(class_='simple-group') |
| 328 |
container.appendChild(g) |
| 329 |
g.appendChild(checkbox('enable_heuristics', _('Enable &heuristic processing'))) |
| 330 |
add(checkbox, 'unwrap_lines', _('Unwrap lines')) |
| 331 |
add(float_spin, 'html_unwrap_factor', indent + _('Line &un-wrap factor:'), max=1, step=0.05) |
| 332 |
|
| 333 |
add(checkbox, 'markup_chapter_headings', _('Detect and markup unformatted chapter headings and sub headings')) |
| 334 |
add(checkbox, 'renumber_headings', _('Renumber sequences of <h1> or <h2> tags to prevent splitting')) |
| 335 |
add(checkbox, 'delete_blank_paragraphs', _('Delete blank lines between paragraphs')) |
| 336 |
add(checkbox, 'format_scene_breaks', _('Ensure scene breaks are consistently formatted')) |
| 337 |
add(lineedit, 'replace_scene_breaks', _('Rep&lace soft scene breaks:')) |
| 338 |
add(checkbox, 'dehyphenate', _('Remove unnecessary hyphens')) |
| 339 |
add(checkbox, 'italicize_common_cases', _('Italicize common words and patterns')) |
| 340 |
add(checkbox, 'fix_indents', _('Replace entity indents with CSS indents')) |
| 341 |
# }}} |
| 342 |
|
| 343 |
|
| 344 |
# Page setup {{{ |
| 345 |
@ep |
| 346 |
@no_prune |
| 347 |
def page_setup(container): |
| 348 |
def show_profile_desc(name): |
| 349 |
profile = get(name) |
| 350 |
data = profiles.input if name is 'input_profile' else profiles.output |
| 351 |
profile = data[profile] |
| 352 |
container_for_option(name).parentNode.querySelector('[data-profile="{}"'.format( |
| 353 |
'input' if name is 'input_profile' else 'output')).textContent = indent + profile.description |
| 354 |
|
| 355 |
add_listener('input_profile', show_profile_desc) |
| 356 |
add_listener('output_profile', show_profile_desc) |
| 357 |
g = E.div(class_='simple-group') |
| 358 |
container.appendChild(g) |
| 359 |
g.appendChild(float_spin('margin_left', _('Left page margin'), unit='pt', step=0.1, min=-1, max=200)) |
| 360 |
g.appendChild(float_spin('margin_top', _('Top page margin'), unit='pt', step=0.1, min=-1, max=200)) |
| 361 |
g.appendChild(float_spin('margin_right', _('Right page margin'), unit='pt', step=0.1, min=-1, max=200)) |
| 362 |
g.appendChild(float_spin('margin_bottom', _('Bottom page margin'), unit='pt', step=0.1, min=-1, max=200)) |
| 363 |
g.appendChild(choices('input_profile', _('&Input profile:'), {name: profiles.input[name].name for name in profiles.input})) |
| 364 |
g.appendChild(E.div(data_profile='input')) |
| 365 |
g.appendChild(choices('output_profile', _('&Output profile:'), {name: profiles.output[name].name for name in profiles.output})) |
| 366 |
g.appendChild(E.div(data_profile='output')) |
| 367 |
# }}} |
| 368 |
|
| 369 |
|
| 370 |
# Structure detection {{{ |
| 371 |
@ep |
| 372 |
@no_prune |
| 373 |
def structure_detection(container): |
| 374 |
g = E.div(class_='simple-group') |
| 375 |
container.appendChild(g) |
| 376 |
g.appendChild(lineedit('chapter', _('Detect chapters at'), 50)) |
| 377 |
g.appendChild(choices('chapter_mark', _('Chap&ter mark:'), ['pagebreak', 'rule', 'both', 'none'])) |
| 378 |
g.appendChild(checkbox('remove_first_image', _('Remove first &image'))) |
| 379 |
g.appendChild(checkbox('remove_fake_margins', _('Remove &fake margins'))) |
| 380 |
g.appendChild(checkbox('add_alt_text_to_img', _('Add &alt text to images'))) |
| 381 |
g.appendChild(checkbox('insert_metadata', _('Insert metadata at start of book'))) |
| 382 |
g.appendChild(lineedit('page_breaks_before', _('Insert page breaks before'), 50)) |
| 383 |
g.appendChild(lineedit('start_reading_at', _('Start reading at'), 50)) |
| 384 |
# }}} |
| 385 |
|
| 386 |
|
| 387 |
# ToC {{{ |
| 388 |
@ep |
| 389 |
@no_prune |
| 390 |
def toc(container): |
| 391 |
g = E.div(class_='simple-group') |
| 392 |
container.appendChild(g) |
| 393 |
g.appendChild(checkbox('use_auto_toc', _('&Force use of auto-generated Table of Contents'))) |
| 394 |
g.appendChild(checkbox('no_chapters_in_toc', _('Do not add &detected chapters to the Table of Contents'))) |
| 395 |
g.appendChild(checkbox('duplicate_links_in_toc', _('Allow &duplicate links when creating the Table of Contents'))) |
| 396 |
g.appendChild(int_spin('max_toc_links', _('Number of &links to add to Table of Contents:'))) |
| 397 |
g.appendChild(int_spin('toc_threshold', _('Chapter &threshold:'))) |
| 398 |
g.appendChild(lineedit('toc_filter', _('TOC &filter:'))) |
| 399 |
g.appendChild(lineedit('level1_toc', _('Level &1 TOC (XPath expression):'))) |
| 400 |
g.appendChild(lineedit('level2_toc', _('Level &2 TOC (XPath expression):'))) |
| 401 |
g.appendChild(lineedit('level3_toc', _('Level &3 TOC (XPath expression):'))) |
| 402 |
# }}} |
| 403 |
|
| 404 |
|
| 405 |
# Search & replace {{{ |
| 406 |
@ep |
| 407 |
@no_prune |
| 408 |
def search_and_replace(container): |
| 409 |
def add(val): |
| 410 |
c = container_for_option('search_replace') |
| 411 |
c.appendChild(E.div( |
| 412 |
class_='simple-group sr-instance', |
| 413 |
style='border-bottom: solid 1px currentColor; margin-bottom: 1ex', |
| 414 |
E.label( |
| 415 |
E.span(_('Search:')), E.input(type='text', name='search') |
| 416 |
), |
| 417 |
E.label( |
| 418 |
E.span(_('Replace:')), E.input(type='text', name='replace') |
| 419 |
), |
| 420 |
)) |
| 421 |
if val and val[0]: |
| 422 |
c.lastChild.querySelector('input[name="search"]').value = val[0] |
| 423 |
c.lastChild.querySelector('input[name="replace"]').value = val[1] |
| 424 |
return c.lastChild |
| 425 |
|
| 426 |
container.appendChild(E.div(data_option_name='search_replace')) |
| 427 |
|
| 428 |
ops = { |
| 429 |
'get': def get(container): # noqa: unused-local |
| 430 |
ans = [] |
| 431 |
for div in container.querySelectorAll('.sr-instance'): |
| 432 |
search, replace = div.querySelectorAll('input') |
| 433 |
if search.value: |
| 434 |
r = replace.value or '' # noqa: unused-local |
| 435 |
ans.push([search.value, r]) |
| 436 |
return JSON.stringify(ans) |
| 437 |
, |
| 438 |
'set': def set(container, encval): # noqa: unused-local |
| 439 |
try: |
| 440 |
vals = JSON.parse(encval) |
| 441 |
except: |
| 442 |
vals = [] |
| 443 |
vals = vals or [] |
| 444 |
clear(container) |
| 445 |
for val in vals: |
| 446 |
add(val) |
| 447 |
add() |
| 448 |
, |
| 449 |
'set_disabled': def set_disabled(container, disabled): # noqa: unused-local |
| 450 |
pass |
| 451 |
} |
| 452 |
registry['search_replace'] = ops |
| 453 |
ops.set(container.lastChild, get_option_value('search_replace')) |
| 454 |
|
| 455 |
container.appendChild(E.div( |
| 456 |
create_button(_('Add'), 'plus', action=def (): add();) |
| 457 |
)) |
| 458 |
# }}} |
| 459 |
|
| 460 |
|
| 461 |
# Comic Input {{{ |
| 462 |
@ep |
| 463 |
@no_prune |
| 464 |
def comic_input(container): |
| 465 |
settings = [] |
| 466 |
|
| 467 |
def add(func, name, text, **kw): |
| 468 |
g.appendChild(func(name, text, **kw)) |
| 469 |
settings.push(name) |
| 470 |
|
| 471 |
add_listener('no_process', def (name): |
| 472 |
disabled = get('no_process') |
| 473 |
for dname in settings: |
| 474 |
set_disabled(dname, disabled) |
| 475 |
) |
| 476 |
|
| 477 |
g = E.div(class_='simple-group') |
| 478 |
container.appendChild(g) |
| 479 |
g.appendChild(checkbox('no_process', _('&Disable comic processing'))) |
| 480 |
add(checkbox, 'dont_grayscale', _('Disable conversion of images to &black and white')) |
| 481 |
add(checkbox, 'dont_add_comic_pages_to_toc', _('Don\'t add links to &pages to the Table of Contents for CBC files')) |
| 482 |
add(int_spin, 'colors', _('&Number of colors:'), max=256, step=8) |
| 483 |
add(lineedit, 'comic_image_size', _('Override image si&ze:')) |
| 484 |
add(checkbox, 'dont_normalize', _('Disable &normalize')) |
| 485 |
add(checkbox, 'keep_aspect_ratio', _('Keep &aspect ratio')) |
| 486 |
add(checkbox, 'dont_sharpen', _('Disable &sharpening')) |
| 487 |
add(checkbox, 'disable_trim', _('Disable &trimming')) |
| 488 |
add(checkbox, 'wide', _('&Wide')) |
| 489 |
add(checkbox, 'landscape', _('&Landscape')) |
| 490 |
add(checkbox, 'right2left', _('&Right to left')) |
| 491 |
add(checkbox, 'no_sort', _('Don\'t so&rt')) |
| 492 |
add(checkbox, 'despeckle', _('De&speckle')) |
| 493 |
g.appendChild(choices('output_format', _('O&utput format:'), ['png', 'jpg'])) |
| 494 |
settings.push('output_format') |
| 495 |
|
| 496 |
# }}} |
| 497 |
|
| 498 |
|
| 499 |
# FB2 Input {{{ |
| 500 |
@ep |
| 501 |
@no_prune |
| 502 |
def fb2_input(container): |
| 503 |
g = E.div(class_='simple-group') |
| 504 |
container.appendChild(g) |
| 505 |
g.appendChild(checkbox('no_inline_fb2_toc', _('Do not insert a Table of Contents at the beginning of the book'))) |
| 506 |
# }}} |
| 507 |
|
| 508 |
|
| 509 |
# PDF Input {{{ |
| 510 |
@ep |
| 511 |
@no_prune |
| 512 |
def pdf_input(container): |
| 513 |
g = E.div(class_='simple-group') |
| 514 |
container.appendChild(g) |
| 515 |
g.appendChild(float_spin('unwrap_factor', _('Line &un-wrapping factor:'), max=1, step=0.01)) |
| 516 |
g.appendChild(checkbox('no_images', _('No &images'))) |
| 517 |
g.appendChild(choices('pdf_engine', _('PDF &engine:'), {'calibre': 'calibre', 'pdftohtml': 'pdftohtml'})) |
| 518 |
g.appendChild(int_spin('pdf_header_skip', _('Remove headers at &top of page by:'), min=-1, max=999999, step=1)) |
| 519 |
g.appendChild(int_spin('pdf_footer_skip', _('Remove footers at &bottom of page by:'), min=-1, max=999999, step=1)) |
| 520 |
g.appendChild(lineedit('pdf_header_regex', _('Regular expression to remove &header at top of page:'))) |
| 521 |
g.appendChild(lineedit('pdf_footer_regex', _('Regular expression to remove &footer at bottom of page:'))) |
| 522 |
# }}} |
| 523 |
|
| 524 |
|
| 525 |
# RTF Input {{{ |
| 526 |
@ep |
| 527 |
@no_prune |
| 528 |
def rtf_input(container): |
| 529 |
g = E.div(class_='simple-group') |
| 530 |
container.appendChild(g) |
| 531 |
g.appendChild(checkbox('ignore_wmf', _('Ignore &WMF images in the RTF file'))) |
| 532 |
# }}} |
| 533 |
|
| 534 |
|
| 535 |
# DOCX Input {{{ |
| 536 |
@ep |
| 537 |
@no_prune |
| 538 |
def docx_input(container): |
| 539 |
g = E.div(class_='simple-group') |
| 540 |
container.appendChild(g) |
| 541 |
g.appendChild(checkbox('docx_no_cover', _('Do not try to autodetect a &cover from images in the document'))) |
| 542 |
g.appendChild(checkbox('docx_no_pagebreaks_between_notes', _('Do not add a page after every &endnote'))) |
| 543 |
g.appendChild(checkbox('docx_inline_subsup', _('Render &superscripts and subscripts so that they do not affect the line height'))) |
| 544 |
# }}} |
| 545 |
|
| 546 |
|
| 547 |
# TXT Input {{{ |
| 548 |
@ep |
| 549 |
@no_prune |
| 550 |
def txt_input(container): |
| 551 |
g = E.div(class_='simple-group') |
| 552 |
container.appendChild(g) |
| 553 |
g.appendChild(choices('paragraph_type', _('Para&graph style:'), ui_data.paragraph_types)) |
| 554 |
g.appendChild(choices('formatting_type', _('Forma&tting style:'), ui_data.formatting_types)) |
| 555 |
g.appendChild(checkbox('preserve_spaces', _('Preserve &spaces'))) |
| 556 |
g.appendChild(checkbox('txt_in_remove_indents', _('Remove &indents at the beginning of lines'))) |
| 557 |
|
| 558 |
container.appendChild(E.div( |
| 559 |
style='margin-top: 1ex', |
| 560 |
_('Allowed Markdown extensions:'), |
| 561 |
E.div( |
| 562 |
style='margin-left: 1em; margin-top: 1ex', |
| 563 |
subset_choice('markdown_extensions', ui_data.md_extensions) |
| 564 |
) |
| 565 |
)) |
| 566 |
# }}} |
| 567 |
|
| 568 |
|
| 569 |
# EPUB Output {{{ |
| 570 |
@ep |
| 571 |
@no_prune |
| 572 |
def epub_output(container): |
| 573 |
g = E.div(class_='simple-group') |
| 574 |
container.appendChild(g) |
| 575 |
g.appendChild(checkbox('dont_split_on_page_breaks', _('Do not &split on page breaks'))) |
| 576 |
g.appendChild(checkbox('no_default_epub_cover', _('No default &cover'))) |
| 577 |
g.appendChild(checkbox('epub_flatten', _('&Flatten EPUB file structure'))) |
| 578 |
g.appendChild(checkbox('no_svg_cover', _('No &SVG cover'))) |
| 579 |
g.appendChild(checkbox('preserve_cover_aspect_ratio', _('Preserve cover &aspect ratio'))) |
| 580 |
g.appendChild(checkbox('epub_inline_toc', _('Insert inline &Table of Contents'))) |
| 581 |
g.appendChild(checkbox('epub_toc_at_end', _('Put inserted Table of Contents at the &end of the book'))) |
| 582 |
g.appendChild(lineedit('toc_title', _('&Title for inserted ToC:'))) |
| 583 |
g.appendChild(int_spin('flow_size', _('Split files &larger than:'), unit='KB', max=1000000, step=20)) |
| 584 |
g.appendChild(lineedit('epub_max_image_size', _('Shrink &images larger than:'))) |
| 585 |
g.appendChild(choices('epub_version', _('EP&UB version:'), ui_data.versions)) |
| 586 |
# }}} |
| 587 |
|
| 588 |
|
| 589 |
# KEPUB Output {{{ |
| 590 |
@ep |
| 591 |
@no_prune |
| 592 |
def kepub_output(container): |
| 593 |
g = E.div(class_='simple-group') |
| 594 |
container.appendChild(g) |
| 595 |
g.appendChild(checkbox('dont_split_on_page_breaks', _('Do not &split on page breaks'))) |
| 596 |
g.appendChild(int_spin('flow_size', _('Split files &larger than:'), unit='KB', max=1000000, step=20)) |
| 597 |
g.appendChild(lineedit('kepub_max_image_size', _('Shrink &images larger than:'))) |
| 598 |
g.appendChild(lineedit('kepub_prefer_justification', _('Prefer improved text justification to proper highlighting'))) |
| 599 |
g.appendChild(checkbox('kepub_affect_hyphenation', _('Enable/disable &hyphenation for this book'))) |
| 600 |
g.appendChild(checkbox('kepub_disable_hyphenation', _('&Prevent all hyphenation'))) |
| 601 |
c = _('characters') |
| 602 |
g.appendChild(int_spin('kepub_hyphenation_min_chars', _('Hyphenation: &minimum word length:'), unit=c)) |
| 603 |
g.appendChild(int_spin('kepub_hyphenation_min_chars_before', _('Hyphenation: minimum characters &before:'), unit=c)) |
| 604 |
g.appendChild(int_spin('kepub_hyphenation_min_chars_after', _('Hyphenation: minimum characters &after:'), unit=c)) |
| 605 |
g.appendChild(int_spin('kepub_hyphenation_limit_lines', _('Hyphenation: &limit lines:'), unit=_('lines'))) |
| 606 |
# }}} |
| 607 |
|
| 608 |
|
| 609 |
# DOCX Output {{{ |
| 610 |
@ep |
| 611 |
@no_prune |
| 612 |
def docx_output(container): |
| 613 |
g = E.div(class_='simple-group') |
| 614 |
container.appendChild(g) |
| 615 |
g.appendChild(choices('docx_page_size', _('Paper si&ze:'), ui_data.page_sizes)) |
| 616 |
g.appendChild(lineedit('docx_custom_page_size', _('&Custom size:'))) |
| 617 |
g.appendChild(float_spin('docx_page_margin_left', _('Page &left margin'), unit='pt', min=-100, max=500)) |
| 618 |
g.appendChild(float_spin('docx_page_margin_top', _('Page &top margin'), unit='pt', min=-100, max=500)) |
| 619 |
g.appendChild(float_spin('docx_page_margin_right', _('Page &right margin'), unit='pt', min=-100, max=500)) |
| 620 |
g.appendChild(float_spin('docx_page_margin_bottom', _('Page &bottom margin'), unit='pt', min=-100, max=500)) |
| 621 |
g.appendChild(checkbox('docx_no_toc', _('Do not insert the &Table of Contents as a page at the start of the document'))) |
| 622 |
g.appendChild(checkbox('docx_no_cover', _('Do not insert &cover as image at start of document'))) |
| 623 |
g.appendChild(checkbox('preserve_cover_aspect_ratio', _('Preserve the aspect ratio of the image inserted as cover'))) |
| 624 |
# }}} |
| 625 |
|
| 626 |
|
| 627 |
# FB2 Output {{{ |
| 628 |
@ep |
| 629 |
@no_prune |
| 630 |
def fb2_output(container): |
| 631 |
g = E.div(class_='simple-group') |
| 632 |
container.appendChild(g) |
| 633 |
g.appendChild(choices('sectionize', _('Sec&tionize:'), ui_data.sectionize)) |
| 634 |
g.appendChild(choices('fb2_genre', _('&Genre:'), ui_data.genres)) |
| 635 |
# }}} |
| 636 |
|
| 637 |
|
| 638 |
# LRF Output {{{ |
| 639 |
@ep |
| 640 |
@no_prune |
| 641 |
def lrf_output(container): |
| 642 |
g = E.div(class_='simple-group') |
| 643 |
container.appendChild(g) |
| 644 |
g.appendChild(checkbox('autorotation', _('Enable &auto-rotation of wide images'))) |
| 645 |
g.appendChild(float_spin('wordspace', _('&Wordspace:'), min=1, max=20, unit='pt')) |
| 646 |
g.appendChild(float_spin('minimum_indent', _('Minim&um para. indent:'), unit='pt')) |
| 647 |
g.appendChild(checkbox('render_tables_as_images', _('Render &tables as images'))) |
| 648 |
g.appendChild(float_spin( |
| 649 |
'text_size_multiplier_for_rendered_tables', indent + _('Text size multiplier for text in rendered tables:'), step=0.01)) |
| 650 |
g.appendChild(checkbox('header', _('Add &header'))) |
| 651 |
g.appendChild(float_spin('header_separation', indent + _('Header &separation:'), unit='pt')) |
| 652 |
g.appendChild(lineedit('header_format', indent + _('Header &format:'))) |
| 653 |
g.appendChild(lineedit('serif_family', _('Serif fon&t family:'))) |
| 654 |
g.appendChild(lineedit('sans_family', _('Sans-serif font fami&ly:'))) |
| 655 |
g.appendChild(lineedit('mono_family', _('&Monospace font family:'))) |
| 656 |
# }}} |
| 657 |
|
| 658 |
|
| 659 |
# MOBI Output {{{ |
| 660 |
@ep |
| 661 |
@no_prune |
| 662 |
def mobi_output(container): |
| 663 |
g = E.div(class_='simple-group') |
| 664 |
container.appendChild(g) |
| 665 |
g.appendChild(checkbox('no_inline_toc', _('Do not add &Table of Contents to book'))) |
| 666 |
g.appendChild(lineedit('toc_title', indent + _('&Title for Table of Contents:'))) |
| 667 |
g.appendChild(checkbox('mobi_toc_at_start', _('Put generated Table of Contents at &start of book instead of end'))) |
| 668 |
g.appendChild(checkbox('mobi_ignore_margins', _('Ignore &margins'))) |
| 669 |
g.appendChild(checkbox('prefer_author_sort', _('Use author &sort for author'))) |
| 670 |
g.appendChild(checkbox('mobi_keep_original_images', _('Do not convert all images to &JPEG (may result in images not working in older viewers)'))) |
| 671 |
g.appendChild(checkbox('dont_compress', _('Disable &compression of the file contents'))) |
| 672 |
g.appendChild(choices('mobi_file_type', _('MOBI fi&le type:'), ui_data.file_types)) |
| 673 |
g.appendChild(lineedit('personal_doc', _('Personal Doc tag:'))) |
| 674 |
g.appendChild(checkbox('share_not_sync', _('Enable &sharing of book content via Facebook, etc. WARNING: Disables last read syncing'))) |
| 675 |
# }}} |
| 676 |
|
| 677 |
|
| 678 |
# AZW3 Output {{{ |
| 679 |
@ep |
| 680 |
@no_prune |
| 681 |
def azw3_output(container): |
| 682 |
g = E.div(class_='simple-group') |
| 683 |
container.appendChild(g) |
| 684 |
g.appendChild(checkbox('no_inline_toc', _('Do not add &Table of Contents to book'))) |
| 685 |
g.appendChild(lineedit('toc_title', indent + _('&Title for Table of Contents:'))) |
| 686 |
g.appendChild(checkbox('mobi_toc_at_start', _('Put generated Table of Contents at &start of book instead of end'))) |
| 687 |
g.appendChild(checkbox('prefer_author_sort', _('Use author &sort for author'))) |
| 688 |
g.appendChild(checkbox('dont_compress', _('Disable &compression of the file contents'))) |
| 689 |
g.appendChild(checkbox('share_not_sync', _('Enable &sharing of book content via Facebook, etc. WARNING: Disables last read syncing'))) |
| 690 |
# }}} |
| 691 |
|
| 692 |
|
| 693 |
# PDB Output {{{ |
| 694 |
@ep |
| 695 |
@no_prune |
| 696 |
def pdb_output(container): |
| 697 |
g = E.div(class_='simple-group') |
| 698 |
container.appendChild(g) |
| 699 |
g.appendChild(choices('format', _('Forma&t:'), ui_data.formats)) |
| 700 |
g.appendChild(lineedit('pdb_output_encoding', _('O&utput encoding:'))) |
| 701 |
g.appendChild(checkbox('inline_toc', _('&Inline TOC'))) |
| 702 |
# }}} |
| 703 |
|
| 704 |
|
| 705 |
# PDF Output {{{ |
| 706 |
@ep |
| 707 |
@no_prune |
| 708 |
def pdf_output(container): |
| 709 |
add_listener('use_profile_size', def (name): |
| 710 |
disabled = get('use_profile_size') |
| 711 |
for dname in 'paper_size', 'custom_size', 'unit': |
| 712 |
set_disabled(dname, disabled) |
| 713 |
) |
| 714 |
add_listener('pdf_use_document_margins', def (name): |
| 715 |
disabled = get('pdf_use_document_margins') |
| 716 |
for dname in 'left', 'top', 'right', 'bottom': |
| 717 |
set_disabled(f'pdf_page_margin_{dname}', disabled) |
| 718 |
) |
| 719 |
|
| 720 |
g = E.div(class_='simple-group') |
| 721 |
container.appendChild(g) |
| 722 |
g.appendChild(checkbox('use_profile_size', _('&Use the paper size set in output profile'))) |
| 723 |
g.appendChild(choices('paper_size', indent + _('&Paper size:'), ui_data.paper_sizes)) |
| 724 |
g.appendChild(lineedit('custom_size', indent + _('&Custom size:'))) |
| 725 |
g.appendChild(choices('unit', indent + _('Custom size unit:'), ui_data.units)) |
| 726 |
g.appendChild(checkbox('pdf_no_cover', _('Discard book &cover'))) |
| 727 |
g.appendChild(checkbox('preserve_cover_aspect_ratio', _('Preserve &aspect ratio of cover'))) |
| 728 |
g.appendChild(checkbox('pdf_page_numbers', _('Add page &numbers to the bottom of every page'))) |
| 729 |
g.appendChild(checkbox('pdf_hyphenate', _('&Break long words at the end of lines'))) |
| 730 |
g.appendChild(checkbox('pdf_add_toc', _('Add a printable &Table of Contents at the end'))) |
| 731 |
g.appendChild(lineedit('toc_title', indent + _('&Title for ToC:'))) |
| 732 |
g.appendChild(lineedit('pdf_serif_family', _('Serif famil&y:'))) |
| 733 |
g.appendChild(lineedit('pdf_sans_family', _('Sans fami&ly:'))) |
| 734 |
g.appendChild(lineedit('pdf_mono_family', _('&Monospace family:'))) |
| 735 |
g.appendChild(choices('pdf_standard_font', _('S&tandard font:'), ui_data.font_types)) |
| 736 |
g.appendChild(int_spin('pdf_default_font_size', _('Default font si&ze:'), unit='px')) |
| 737 |
g.appendChild(int_spin('pdf_mono_font_size', _('Default font si&ze:'), unit='px')) |
| 738 |
g.appendChild(lineedit('pdf_page_number_map', _('Page number &map:'))) |
| 739 |
g.appendChild(checkbox('pdf_use_document_margins', _('Use page margins from the &document being converted'))) |
| 740 |
g.appendChild(float_spin('pdf_page_margin_left', indent + _('Left page margin'), unit='pt', min=-100, max=500)) |
| 741 |
g.appendChild(float_spin('pdf_page_margin_top', indent + _('Top page margin'), unit='pt', min=-100, max=500)) |
| 742 |
g.appendChild(float_spin('pdf_page_margin_right', indent + _('Right page margin'), unit='pt', min=-100, max=500)) |
| 743 |
g.appendChild(float_spin('pdf_page_margin_bottom', indent + _('Bottom page margin'), unit='pt', min=-100, max=500)) |
| 744 |
g.appendChild(float_spin('pdf_odd_even_offset', indent + _('Odd/even offset'), unit='pt', min=-500, max=500)) |
| 745 |
g.appendChild(lineedit('pdf_header_template', _('&Header template:'))) |
| 746 |
g.appendChild(lineedit('pdf_footer_template', _('&Footer template:'))) |
| 747 |
# }}} |
| 748 |
|
| 749 |
|
| 750 |
# PMLZ Output {{{ |
| 751 |
@ep |
| 752 |
@no_prune |
| 753 |
def pml_output(container): |
| 754 |
g = E.div(class_='simple-group') |
| 755 |
container.appendChild(g) |
| 756 |
g.appendChild(lineedit('pml_output_encoding', _('O&utput encoding:'))) |
| 757 |
g.appendChild(checkbox('inline_toc', _('&Inline TOC'))) |
| 758 |
g.appendChild(checkbox('full_image_depth', _('Do not &reduce image size and depth'))) |
| 759 |
# }}} |
| 760 |
|
| 761 |
|
| 762 |
# RB Output {{{ |
| 763 |
@ep |
| 764 |
@no_prune |
| 765 |
def rb_output(container): |
| 766 |
g = E.div(class_='simple-group') |
| 767 |
container.appendChild(g) |
| 768 |
g.appendChild(checkbox('inline_toc', _('&Inline TOC'))) |
| 769 |
# }}} |
| 770 |
|
| 771 |
|
| 772 |
# TXT Output {{{ |
| 773 |
@ep |
| 774 |
@no_prune |
| 775 |
def txt_output(container): |
| 776 |
g = E.div(class_='simple-group') |
| 777 |
container.appendChild(g) |
| 778 |
g.appendChild(lineedit('txt_output_encoding', _('O&utput encoding:'))) |
| 779 |
g.appendChild(choices('newline', _('&Line ending style:'), ui_data.newline_types)) |
| 780 |
g.appendChild(choices('txt_output_formatting', _('Forma&tting:'), ui_data.formatting_types)) |
| 781 |
g = E.div(E.div(_('Options for plain text output:')), E.div(class_='simple-group', style='margin-left: 1rem; margin-top: 1ex')) |
| 782 |
container.appendChild(g) |
| 783 |
g = g.lastChild |
| 784 |
g.appendChild(checkbox('inline_toc', _('&Inline TOC'))) |
| 785 |
g.appendChild(int_spin('max_line_length', _('&Maximum line length:'), max=1000)) |
| 786 |
g.appendChild(checkbox('force_max_line_length', _('Force maximum line &length'))) |
| 787 |
g = E.div(E.div(_('Options for Markdown and TexTile output:')), E.div(class_='simple-group', style='margin-left: 1rem; margin-top: 1ex')) |
| 788 |
container.appendChild(g) |
| 789 |
g = g.lastChild |
| 790 |
g.appendChild(checkbox('keep_links', _('Do not remove links (<a> tags) before processing'))) |
| 791 |
g.appendChild(checkbox('keep_image_references', _('Do not remove image &references before processing'))) |
| 792 |
g.appendChild(checkbox('use_alt_text_for_images', _('Replace images with their alt attribute text'))) |
| 793 |
g.appendChild(checkbox('keep_color', _('Keep text &color, when possible'))) |
| 794 |
|
| 795 |
|
| 796 |
@ep |
| 797 |
@no_prune |
| 798 |
def txtz_output(container): |
| 799 |
return txt_output(container) |
| 800 |
# }}} |
| 801 |
|
| 802 |
|
| 803 |
# HTMLZ Output {{{ |
| 804 |
@ep |
| 805 |
@no_prune |
| 806 |
def htmlz_output(container): |
| 807 |
g = E.div(class_='simple-group') |
| 808 |
container.appendChild(g) |
| 809 |
g.appendChild(choices('htmlz_css_type', _('How to handle &CSS'), ui_data.css_choices)) |
| 810 |
g.appendChild(choices('htmlz_class_style', _('How to handle &CSS'), ui_data.sheet_choices)) |
| 811 |
g.appendChild(checkbox('htmlz_title_filename', _('Use book title as the filename for the HTML file'))) |
| 812 |
# }}} |
| 813 |
|
| 814 |
|
| 815 |
# SNB Output {{{ |
| 816 |
@ep |
| 817 |
@no_prune |
| 818 |
def snb_output(container): |
| 819 |
g = E.div(class_='simple-group') |
| 820 |
container.appendChild(g) |
| 821 |
g.appendChild(checkbox('snb_insert_empty_line', _('Insert &empty line between paragraphs'))) |
| 822 |
g.appendChild(checkbox('snb_dont_indent_first_line', _('Don\'t indent the &first line for each paragraph'))) |
| 823 |
g.appendChild(checkbox('snb_hide_chapter_name', _('Hide &chapter name'))) |
| 824 |
g.appendChild(checkbox('snb_full_screen', _('Optimize for full-&screen mode'))) |
| 825 |
# }}} |
| 826 |
|
| 827 |
|
| 828 |
def restore_defaults(): |
| 829 |
for setting in registry: |
| 830 |
set(setting, get_option_default_value(setting)) |
| 831 |
|
| 832 |
|
| 833 |
def create_option_group( |
| 834 |
group_name, ui_data_, profiles_, container, |
| 835 |
get_option_value_, get_option_default_value_, is_option_disabled_, get_option_help_, on_close |
| 836 |
): |
| 837 |
nonlocal get_option_value, get_option_default_value, is_option_disabled, container_id, registry, listeners, get_option_help, profiles, ui_data |
| 838 |
get_option_value, get_option_default_value, is_option_disabled, get_option_help = ( |
| 839 |
get_option_value_, get_option_default_value_, is_option_disabled_, get_option_help_ |
| 840 |
) |
| 841 |
profiles, ui_data = profiles_, ui_data_ |
| 842 |
registry = {} |
| 843 |
listeners = {} |
| 844 |
container_id = ensure_id(container) |
| 845 |
container.classList.add(CLASS_NAME) |
| 846 |
entry_points[group_name](container) |
| 847 |
container.appendChild(E.div( |
| 848 |
style='margin-top: 2ex; padding-top: 2ex; border-top: solid 1px currentColor', |
| 849 |
create_button(_('Done'), action=on_close), |
| 850 |
'\xa0\xa0', |
| 851 |
create_button(_('Restore defaults'), action=restore_defaults), |
| 852 |
)) |
| 853 |
|
| 854 |
|
| 855 |
def commit_changes(set_option_value): |
| 856 |
for name in registry: |
| 857 |
set_option_value(name, get(name)) |