source: src/mlx/gui/bugreport.py@ 491:3109e293df85

Last change on this file since 491:3109e293df85 was 490:9ee656e6c2d2, checked in by István Váradi <ivaradi@…>, 11 years ago

Added the appending of the log and the debug log to the bug report (re #190)

File size: 5.0 KB
Line 
1
2from common import *
3
4from mlx.i18n import xstr
5import mlx.const as const
6import mlx.config as config
7
8import os
9
10#------------------------------------------------------------------------------
11
12## @package mlx.gui.bugreport
13#
14# The bug report dialog
15#
16# This module implements the bug report dialog.
17
18#------------------------------------------------------------------------------
19
20class BugReportDialog(gtk.Dialog):
21 """The dialog to report a bug."""
22 def __init__(self, gui):
23 super(BugReportDialog, self).__init__(WINDOW_TITLE_BASE + " - " +
24 xstr("bugreport_title"),
25 gui.mainWindow,
26 DIALOG_MODAL)
27
28 self.add_button(xstr("button_cancel"), RESPONSETYPE_REJECT)
29 self._sendButton = self.add_button(xstr("button_send"), RESPONSETYPE_ACCEPT)
30 self._sendButton.set_can_default(True)
31 self._gui = gui
32
33 contentArea = self.get_content_area()
34
35 contentAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
36 xscale = 0.0, yscale = 0.0)
37 contentAlignment.set_padding(padding_top = 4, padding_bottom = 16,
38 padding_left = 8, padding_right = 8)
39
40 contentArea.pack_start(contentAlignment, False, False, 0)
41
42 contentVBox = gtk.VBox()
43 contentAlignment.add(contentVBox)
44
45 label = gtk.Label(xstr("bugreport_summary"))
46 label.set_use_underline(True)
47 label.set_alignment(0.0, 0.5)
48
49 contentVBox.pack_start(label, False, False, 4)
50
51 self._summary = summary = gtk.Entry()
52 summary.connect("changed", self._summaryChanged)
53 summary.set_tooltip_text(xstr("bugreport_summary_tooltip"))
54 summary.set_width_chars(80)
55 label.set_mnemonic_widget(summary)
56 contentVBox.pack_start(summary, True, True, 4)
57
58 label = gtk.Label(xstr("bugreport_description"))
59 label.set_use_underline(True)
60 label.set_alignment(0.0, 0.5)
61
62 contentVBox.pack_start(label, False, False, 4)
63
64 self._description = description = gtk.TextView()
65 description.set_tooltip_text(xstr("bugreport_description_tooltip"))
66 label.set_mnemonic_widget(description)
67
68 scrolledWindow = gtk.ScrolledWindow()
69 scrolledWindow.add(description)
70 scrolledWindow.set_size_request(-1, 200)
71 scrolledWindow.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
72 scrolledWindow.set_shadow_type(SHADOW_IN)
73
74 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 1.0, yscale = 1.0)
75 alignment.add(scrolledWindow)
76
77 contentVBox.pack_start(alignment, True, True, 4)
78
79 emailBox = gtk.HBox()
80 contentVBox.pack_start(emailBox, False, False, 4)
81
82 label = gtk.Label(xstr("bugreport_email"))
83 label.set_use_underline(True)
84 label.set_alignment(0.0, 0.5)
85
86 emailBox.pack_start(label, False, False, 0)
87
88 alignment = gtk.Alignment()
89 emailBox.pack_start(alignment, False, False, 8)
90
91 self._email = email = gtk.Entry()
92 email.set_tooltip_text(xstr("bugreport_email_tooltip"))
93 label.set_mnemonic_widget(email)
94 emailBox.pack_start(email, True, True, 0)
95
96
97 def run(self):
98 """Run the checklist editor dialog."""
99 self.set_sensitive(True)
100 self._description.set_sensitive(True)
101 self._updateButtons()
102 self._sendButton.grab_default()
103 self.show_all()
104 response = super(BugReportDialog, self).run()
105
106 print "response", response, RESPONSETYPE_ACCEPT
107 if response==RESPONSETYPE_ACCEPT:
108 self._send()
109 else:
110 self.hide()
111
112 def _summaryChanged(self, entry):
113 """Called when the summary has changed."""
114 self._updateButtons()
115
116 def _updateButtons(self):
117 """Update the sensitivity of the buttoms."""
118 self._sendButton.set_sensitive(self._summary.get_text()!="")
119
120 def _send(self):
121 """Send the bug report."""
122 descriptionBuffer = self._description.get_buffer()
123 description = \
124 descriptionBuffer.get_text(descriptionBuffer.get_start_iter(),
125 descriptionBuffer.get_end_iter(),
126 False)
127 description = text2unicode(description)
128 self.set_sensitive(False)
129 self._gui.sendBugReport(text2unicode(self._summary.get_text()),
130 description,
131 text2unicode(self._email.get_text()),
132 self._bugReportSent)
133
134 def _bugReportSent(self, returned, result):
135 """Called when the bug report was sent."""
136 self.set_sensitive(True)
137 self._description.set_sensitive(True)
138 if returned and result.success:
139 self.hide()
140 self._summary.set_text("")
141 self._description.get_buffer().set_text("")
142 self._email.set_text("")
143 else:
144 self.run()
Note: See TracBrowser for help on using the repository browser.