# vim:fileencoding=utf-8
# License: GPL v3 Copyright: 2019, Kovid Goyal <kovid at kovidgoyal.net>
from __python__ import bound_methods, hash_literals

from elementmaker import E
from gettext import gettext as _

from widgets import create_button


def create_button_box(restore_defaults_func, apply_func, cancel_func):
    cbutton = create_button(_('Cancel'), action=cancel_func)
    if restore_defaults_func:
        rbutton = create_button(_('Restore defaults'), action=restore_defaults_func)
    else:
        rbutton = E.div('\xa0')
    obutton = create_button(_('OK'), action=apply_func)
    for b in (rbutton, obutton, cbutton):
        b.style.marginTop = '1ex'
    return E.div(
        style='margin-top: 1rem; display: flex; justify-content: space-between; align-items: flex-start',
        rbutton,
        E.div(obutton, E.div('\xa0'), cbutton, style='margin-left: 1rem; display: flex; align-items: flex-start; flex-wrap: wrap'),
    )
