2006-04-07 03:32:46 +05:30
|
|
|
from gettext import gettext as _
|
2006-01-05 21:32:27 +05:30
|
|
|
|
|
|
|
import gtk
|
|
|
|
|
|
|
|
from _ErrorReportAssistant import ErrorReportAssistant
|
|
|
|
|
|
|
|
class ErrorView(object):
|
|
|
|
"""
|
|
|
|
A Dialog for displaying errors.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, error_detail, rotate_handler):
|
|
|
|
"""
|
|
|
|
Initialize the handler with the buffer size.
|
|
|
|
"""
|
|
|
|
|
|
|
|
self._error_detail = error_detail
|
|
|
|
self._rotate_handler = rotate_handler
|
|
|
|
|
|
|
|
self.draw_window()
|
|
|
|
self.run()
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
self.response = self.top.run()
|
|
|
|
if self.response == gtk.RESPONSE_HELP:
|
|
|
|
self.help_clicked()
|
|
|
|
elif self.response == gtk.RESPONSE_YES:
|
|
|
|
ErrorReportAssistant(error_detail = self._error_detail,
|
|
|
|
rotate_handler = self._rotate_handler)
|
|
|
|
self.top.destroy()
|
|
|
|
|
|
|
|
def draw_window(self):
|
|
|
|
title = "%s - GRAMPS" % _("Error Report")
|
|
|
|
self.top = gtk.Dialog(title)
|
|
|
|
#self.top.set_default_size(400,350)
|
|
|
|
self.top.set_has_separator(False)
|
|
|
|
self.top.vbox.set_spacing(5)
|
2006-01-08 00:24:13 +05:30
|
|
|
self.top.set_border_width(12)
|
|
|
|
hbox = gtk.HBox()
|
|
|
|
hbox.set_spacing(12)
|
|
|
|
image = gtk.Image()
|
|
|
|
image.set_from_stock(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_DIALOG)
|
2006-01-05 21:32:27 +05:30
|
|
|
label = gtk.Label('<span size="larger" weight="bold">%s</span>'
|
2006-01-08 00:24:13 +05:30
|
|
|
% _("GRAMPS has experienced an unexpected error"))
|
2006-01-05 21:32:27 +05:30
|
|
|
label.set_use_markup(True)
|
|
|
|
|
2006-01-08 00:24:13 +05:30
|
|
|
hbox.pack_start(image,False)
|
|
|
|
hbox.add(label)
|
2006-01-05 21:32:27 +05:30
|
|
|
|
2006-01-08 00:24:13 +05:30
|
|
|
self.top.vbox.pack_start(hbox,False,False,5)
|
|
|
|
|
|
|
|
instructions_label = gtk.Label(
|
2006-01-09 16:23:50 +05:30
|
|
|
_("Your data will be safe but it would be advisable to restart GRAMPS immediately. "\
|
2006-01-08 00:24:13 +05:30
|
|
|
"If you would like to report the problem to the GRAMPS team "\
|
|
|
|
"please click Report and the Error Reporting Wizard will help you "\
|
|
|
|
"to make a bug report."))
|
2006-01-05 21:32:27 +05:30
|
|
|
instructions_label.set_line_wrap(True)
|
|
|
|
instructions_label.set_use_markup(True)
|
|
|
|
|
|
|
|
self.top.vbox.pack_start(instructions_label,False,False,5)
|
|
|
|
|
|
|
|
tb_frame = gtk.Frame(_("Error Detail"))
|
2006-01-08 00:24:13 +05:30
|
|
|
tb_frame.set_border_width(6)
|
|
|
|
tb_label = gtk.TextView()
|
2006-01-09 02:01:39 +05:30
|
|
|
tb_label.get_buffer().set_text(self._error_detail.get_formatted_log())
|
2006-01-08 00:24:13 +05:30
|
|
|
tb_label.set_border_width(6)
|
|
|
|
tb_label.set_editable(False)
|
|
|
|
|
|
|
|
scroll = gtk.ScrolledWindow()
|
|
|
|
scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
|
2006-01-05 21:32:27 +05:30
|
|
|
|
2006-01-08 00:24:13 +05:30
|
|
|
tb_frame.add(scroll)
|
|
|
|
scroll.add_with_viewport(tb_label)
|
2006-01-05 21:32:27 +05:30
|
|
|
|
|
|
|
tb_expander = gtk.Expander('<span weight="bold">%s</span>' % _("Error Detail"))
|
|
|
|
tb_expander.set_use_markup(True)
|
|
|
|
tb_expander.add(tb_frame)
|
|
|
|
|
|
|
|
self.top.vbox.pack_start(tb_expander,True,True,5)
|
|
|
|
|
|
|
|
|
|
|
|
self.top.add_button(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL)
|
|
|
|
self.top.add_button(_("Report"),gtk.RESPONSE_YES)
|
|
|
|
self.top.add_button(gtk.STOCK_HELP,gtk.RESPONSE_HELP)
|
|
|
|
|
|
|
|
self.top.show_all()
|