1 # -*- coding: UTF-8 -*-
2 # vim: expandtab sw=4 ts=4 sts=4:
7 __author__
= 'Michal Čihař'
8 __email__
= 'michal@cihar.com'
10 Copyright © 2003 - 2010 Michal Čihař
12 This program is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License version 2 as published by
14 the Free Software Foundation.
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 import Wammu
.Webbrowser
34 BUG_SEARCH_URL
= 'http://bugs.cihar.com/view_all_set.php?f=3&type=1&search=%s'
35 BUG_REPORT_URL
= 'http://bugs.cihar.com/set_project.php?ref=bug_report_page.php&project_id=1'
37 class ErrorMessage(wx
.Dialog
):
39 Error message box with support for saving debug log and reporting
40 bug to http://bugs.cihar.com/.
42 def __init__(self
, parent
, message
, title
, traceid
=None,
43 autolog
=None, exception
=None):
44 wx
.Dialog
.__init
__(self
, parent
, -1, title
)
46 sizer
= wx
.BoxSizer(wx
.VERTICAL
)
47 textsizer
= wx
.BoxSizer(wx
.HORIZONTAL
)
48 sizer
.Add(textsizer
, flag
=wx
.ALL
, border
=10)
50 bitmap
= wx
.Bitmap(Wammu
.Paths
.MiscPath('error'))
51 icon
= wx
.StaticBitmap(self
, -1, bitmap
,
52 size
= (bitmap
.GetWidth(), bitmap
.GetHeight()))
53 textsizer
.Add(icon
, flag
=wx
.RIGHT
, border
=10)
55 if exception
is not None:
58 if autolog
is not None:
61 _('Debug log has been automatically saved to %s, you are strongly encouraged to include it in bugreport.')
63 msg
= wx
.StaticText(self
, -1, message
)
67 buttonsizer
= wx
.StdDialogButtonSizer()
68 buttonsizer
.AddButton(wx
.Button(self
, wx
.ID_OK
))
71 savebutton
= wx
.Button(self
, -1, _('Save debug log...'))
72 buttonsizer
.SetCancelButton(savebutton
)
73 self
.Bind(wx
.EVT_BUTTON
, self
.OnSave
, savebutton
)
75 self
.traceid
= traceid
76 searchbutton
= wx
.Button(self
, -1, _('Search for similar reports'))
77 buttonsizer
.SetCancelButton(searchbutton
)
78 self
.Bind(wx
.EVT_BUTTON
, self
.OnSearch
, searchbutton
)
80 self
.reportbutton
= wx
.Button(self
, -1, _('Report bug'))
81 buttonsizer
.SetNegativeButton(self
.reportbutton
)
82 self
.Bind(wx
.EVT_BUTTON
, self
.OnReport
, self
.reportbutton
)
85 sizer
.Add(buttonsizer
, flag
= wx
.ALIGN_RIGHT | wx
.ALL
, border
= 10)
88 self
.SetAutoLayout(True)
91 def OnSave(self
, evt
):
93 Saves debug log to file.
95 dlg
= wx
.FileDialog(self
,
96 _('Save debug log as...'),
100 wx
.SAVE | wx
.OVERWRITE_PROMPT | wx
.CHANGE_DIR
)
101 if dlg
.ShowModal() == wx
.ID_OK
:
102 Wammu
.ErrorLog
.SaveLog(filename
= dlg
.GetPath())
104 def OnSearch(self
, evt
):
106 Opens search for simmilar problems in browser.
108 Wammu
.Webbrowser
.Open(BUG_SEARCH_URL
% self
.traceid
)
110 def OnReport(self
, evt
):
112 Opens web browser with bug reporting page.
114 Wammu
.Webbrowser
.Open(BUG_REPORT_URL
)