Permit zero-argument template functions.

This commit is contained in:
Charles Haley 2011-06-01 17:43:31 +01:00
parent 5c8745c6cf
commit efac88d69a

View File

@ -7,7 +7,9 @@ __docformat__ = 'restructuredtext en'
import json, traceback import json, traceback
from calibre.gui2 import error_dialog from PyQt4.Qt import QDialogButtonBox
from calibre.gui2 import error_dialog, warning_dialog
from calibre.gui2.preferences import ConfigWidgetBase, test_widget from calibre.gui2.preferences import ConfigWidgetBase, test_widget
from calibre.gui2.preferences.template_functions_ui import Ui_Form from calibre.gui2.preferences.template_functions_ui import Ui_Form
from calibre.gui2.widgets import PythonHighlighter from calibre.gui2.widgets import PythonHighlighter
@ -152,9 +154,14 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
_('Name already used'), show=True) _('Name already used'), show=True)
return return
if self.argument_count.value() == 0: if self.argument_count.value() == 0:
error_dialog(self.gui, _('Template functions'), box = warning_dialog(self.gui, _('Template functions'),
_('Argument count must be -1 or greater than zero'), _('Argument count should be -1 or greater than zero.'
show=True) 'Setting it to zero means that this function cannot '
'be used in single function mode.'), det_msg = '',
show=False)
box.bb.setStandardButtons(box.bb.standardButtons() | QDialogButtonBox.Cancel)
box.det_msg_toggle.setVisible(False)
if not box.exec_():
return return
try: try:
prog = unicode(self.program.toPlainText()) prog = unicode(self.program.toPlainText())