diff --git a/terminatorlib/config.py b/terminatorlib/config.py index ce9e0010..4103b6c2 100755 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -210,7 +210,21 @@ class TerminatorConfValuestoreRC (TerminatorConfValuestore): try: ini.parse() except ParsedWithErrors, e: - sys.stderr.write(str(e)) + import gtk + from cgi import escape + msg = _("""Errors were encountered while parsing terminator_config(5) file: + + %s + +Some lines have been ignored.""") % escape(repr(self.rcfilename)) + errs = "\n\n".join(map(lambda error: + _(" * %(message)s, line %(lnum)d:\n %(line)s\n %(pad)s^") % { + 'message': error.message, 'file': escape(error.file), 'lnum': error.lnum, + 'line': escape(error.line.rstrip()), 'pad': '-' * error.pos}, e.errors)) + dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK) + dialog.set_markup(msg + "\n\n" + errs) + dialog.run() + dialog.destroy() for key in ini.settings: try: diff --git a/terminatorlib/configfile.py b/terminatorlib/configfile.py index f1a3dd25..ad347166 100644 --- a/terminatorlib/configfile.py +++ b/terminatorlib/configfile.py @@ -89,7 +89,8 @@ class ConfigFile: while True: mo = QuotedStrings[chr].match(self._line, self._pos) if mo is None: - raise ConfigSyntaxError("Unterminated quoted string", self) + self.parse_error(_("Unterminated quoted string")) + return False self._pos = mo.end() if self._line[self._pos - 2] == '\\': string += mo.group(1)[0:-1] + chr @@ -142,13 +143,13 @@ class ConfigFile: if not self._call_if_match(Colourvalue, self._value, 1): # bare value if not self._call_if_match(Barevalue, self._value, 1): - self.parse_error("Setting without a value") + self.parse_error(_("Setting without a value")) continue self._call_if_match(Ignore, lambda junk: dbg("Ignoring: %s" % junk)) if self._line[self._pos:] != '': - self.parse_error("Unexpected token") + self.parse_error(_("Unexpected token")) if self.errors: raise ParsedWithErrors(self.filename, self.errors)