Changeset 484:e6fc7bff478b


Ignore:
Timestamp:
03/31/13 09:33:45 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Implemented the GUI logic of the bug report sending (re #190)

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • locale/en/mlx.po

    r483 r484  
    18331833msgid "bugreport_email_tooltip"
    18341834msgstr "If you enter your e-mail here, you will get status updates about your bug report to this address."
     1835
     1836msgid "sendBugReport_busy"
     1837msgstr "Sending bug report..."
     1838
     1839msgid "sendBugReport_success"
     1840msgstr "Bug report sent successfully."
     1841
     1842msgid "sendBugReport_success_sec"
     1843msgstr ""
     1844"The report will be analysed and you will be contacted "
     1845"as soon as possible."
     1846
     1847msgid "sendBugReport_error"
     1848msgstr "Failed to send the bug report."
     1849
     1850msgid "sendBugReport_siteerror_sec"
     1851msgstr ""
     1852"The website refused to process the bug report. "
     1853"Contact the logger's author."
     1854
     1855msgid "sendBugReport_error_sec"
     1856msgstr "There was some communication error, try again later."
  • locale/hu/mlx.po

    r483 r484  
    18481848msgid "bugreport_email_tooltip"
    18491849msgstr "Ha itt megadod az e-mail címed, a hibajelentés állapotáról értesítéseket fogsz kapni a megadott címre."
     1850
     1851msgid "sendBugReport_busy"
     1852msgstr "Hibajelentés küldése..."
     1853
     1854msgid "sendBugReport_success"
     1855msgstr "A hibajelentést elküldtem."
     1856
     1857msgid "sendBugReport_success_sec"
     1858msgstr ""
     1859"A jelentést elemezzük és felvesszük veled a kapcsolatot "
     1860"amilyen hamar csak lehet."
     1861
     1862msgid "sendBugReport_error"
     1863msgstr "Nem sikerült elküldeni a hibajelentést."
     1864
     1865msgid "sendBugReport_siteerror_sec"
     1866msgstr ""
     1867"A web szerver visszautasította a hibajelentést. "
     1868"Vedd fel a kapcsolatot a program szerzőjével."
     1869
     1870msgid "sendBugReport_error_sec"
     1871msgstr "Valamilyen kommunikációs probléma adódott, próbáld újra később."
  • src/mlx/gui/bugreport.py

    r483 r484  
    9797    def run(self):
    9898        """Run the checklist editor dialog."""
     99        self.set_sensitive(True)
     100        self._description.set_sensitive(True)
    99101        self._updateButtons()
    100102        self._sendButton.grab_default()
    101103        self.show_all()
    102104        response = super(BugReportDialog, self).run()
    103         self.hide()
     105
     106        print "response", response, RESPONSETYPE_ACCEPT
     107        if response==RESPONSETYPE_ACCEPT:
     108            self._send()
     109        else:
     110            self.hide()
    104111
    105112    def _summaryChanged(self, entry):
     
    110117        """Update the sensitivity of the buttoms."""
    111118        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        self.set_sensitive(False)
     128        self._gui.sendBugReport(self._summary.get_text(),
     129                                description,
     130                                self._email.get_text(),
     131                                self._bugReportSent)
     132
     133    def _bugReportSent(self, returned, result):
     134        """Called when the bug report was sent."""
     135        self.set_sensitive(True)
     136        self._description.set_sensitive(True)
     137        if returned and result.success:
     138            self.hide()
     139            self._summary.set_text("")
     140            self._description.get_buffer().set_text("")
     141            self._email.set_text("")
     142        else:
     143            self.run()
  • src/mlx/gui/gui.py

    r483 r484  
    8585
    8686        self._sendPIREPCallback = None
     87        self._sendBugReportCallback = None
    8788
    8889        self.webHandler = web.Handler()
     
    109110        self._checklistEditor = ChecklistEditor(self)
    110111        self._approachCalloutsEditor = ApproachCalloutsEditor(self)
    111         self._bugreportDialog = BugReportDialog(self)
     112        self._bugReportDialog = BugReportDialog(self)
    112113
    113114        menuBar = self._buildMenuBar(accelGroup)
     
    11411142    def _reportBug(self, menuItem):
    11421143        """Callback for reporting a bug."""
    1143         self._bugreportDialog.run()
     1144        self._bugReportDialog.run()
    11441145
    11451146    def _setupTimeSync(self):
     
    13821383            callback(returned, result)
    13831384
     1385    def sendBugReport(self, summary, description, email, callback = None):
     1386        """Send the bug report with the given data."""
     1387        self.beginBusy(xstr("sendBugReport_busy"))
     1388        self._sendBugReportCallback = callback
     1389        self.webHandler.sendBugReport(self._bugReportSentCallback,
     1390                                      summary, description, email)
     1391
     1392    def _bugReportSentCallback(self, returned, result):
     1393        """Callback function for the bug report sending result."""
     1394        gobject.idle_add(self._handleBugReportSent, returned, result)
     1395
     1396    def _handleBugReportSent(self, returned, result):
     1397        """Callback for the bug report sending result."""
     1398        self.endBusy()
     1399        secondaryMarkup = None
     1400        type = MESSAGETYPE_ERROR
     1401        if returned:
     1402            if result.success:
     1403                type = MESSAGETYPE_INFO
     1404                messageFormat = xstr("sendBugReport_success")
     1405                secondaryMarkup = xstr("sendBugReport_success_sec")
     1406            else:
     1407                messageFormat = xstr("sendBugReport_error")
     1408                secondaryMarkup = xstr("sendBugReport_siteerror_sec")
     1409        else:
     1410            messageFormat = xstr("sendBugReport_error")
     1411            secondaryMarkup = xstr("sendBugReport_error_sec")
     1412
     1413        dialog = gtk.MessageDialog(parent = self._wizard.gui._bugReportDialog,
     1414                                   type = type, message_format = messageFormat)
     1415        dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
     1416        dialog.set_title(WINDOW_TITLE_BASE)
     1417        if secondaryMarkup is not None:
     1418            dialog.format_secondary_markup(secondaryMarkup)
     1419
     1420        dialog.run()
     1421        dialog.hide()
     1422
     1423        callback = self._sendBugReportCallback
     1424        self._sendBugReportCallback = None
     1425        if callback is not None:
     1426            callback(returned, result)
     1427
    13841428    def _listenHotkeys(self):
    13851429        """Setup the hotkeys based on the configuration."""
  • src/mlx/web.py

    r443 r484  
    794794#------------------------------------------------------------------------------
    795795
     796class SendBugReport(Request):
     797    """A request to send a bug report to the project homepage."""
     798    _latin2Encoder = codecs.getencoder("iso-8859-2")
     799
     800    def __init__(self, callback, summary, description, email):
     801        """Construct the request for the given bug report."""
     802        super(SendBugReport, self).__init__(callback)
     803        self._summary = summary
     804        self._description = description
     805        self._email = email
     806
     807    def run(self):
     808        """Perform the sending of the bug report."""
     809        time.sleep(3)
     810
     811        result = Result()
     812        result.success = True
     813
     814        return result
     815
     816#------------------------------------------------------------------------------
     817
    796818class Handler(threading.Thread):
    797819    """The handler for the web services.
     
    835857        """Send the given ACARS"""
    836858        self._addRequest(SendACARS(callback, acars))
     859
     860    def sendBugReport(self, callback, summary, description, email):
     861        """Send a bug report with the given data."""
     862        self._addRequest(SendBugReport(callback, summary, description, email))
    837863
    838864    def run(self):
Note: See TracChangeset for help on using the changeset viewer.