Ignore:
Timestamp:
10/22/15 18:43:58 (8 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
cef
Phase:
public
Message:

Progress reporting is more detailed and uses translatable strings (re #279)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r691 r692  
    15431543        self._cruiseLevel.set_text("")
    15441544        self._route.get_buffer().set_text(self._wizard._bookedFlight.route)
     1545        self._alternate.set_text("")
    15451546        self._updateForwardButton()
    15461547
     
    15941595    def _forwardClicked(self, button):
    15951596        """Called when the Forward button is clicked."""
    1596         if self._wizard.gui.config.useSimBrief:
     1597        if self._wizard.gui.config.useSimBrief and \
     1598           self._wizard.usingSimBrief is not False:
    15971599            self._wizard.nextPage()
    15981600        else:
     
    16181620        ]
    16191621
     1622    progress2Message = {
     1623        cef.SIMBRIEF_PROGRESS_SEARCHING_BROWSER: "simbrief_progress_searching_browser",
     1624        cef.SIMBRIEF_PROGRESS_LOADING_FORM: "simbrief_progress_loading_form",
     1625        cef.SIMBRIEF_PROGRESS_FILLING_FORM: "simbrief_progress_filling_form",
     1626        cef.SIMBRIEF_PROGRESS_WAITING_LOGIN: "simbrief_progress_waiting_login",
     1627        cef.SIMBRIEF_PROGRESS_LOGGING_IN: "simbrief_progress_logging_in",
     1628        cef.SIMBRIEF_PROGRESS_WAITING_RESULT: "simbrief_progress_waiting_result",
     1629        cef.SIMBRIEF_PROGRESS_RETRIEVING_BRIEFING: "simbrief_progress_retrieving_briefing"
     1630        }
     1631
     1632    result2Message = {
     1633        cef.SIMBRIEF_RESULT_ERROR_OTHER: "simbrief_result_error_other",
     1634        cef.SIMBRIEF_RESULT_ERROR_NO_FORM: "simbrief_result_error_no_form",
     1635        cef.SIMBRIEF_RESULT_ERROR_NO_POPUP: "simbrief_result_error_no_popup",
     1636        cef.SIMBRIEF_RESULT_ERROR_LOGIN_FAILED: "simbrief_result_error_login_failed"
     1637        }
     1638
    16201639    @staticmethod
    16211640    def getHTMLFilePath():
     
    17381757            startSound(const.SOUND_NOTAM)
    17391758
    1740     def _simBriefProgressCallback(self, message, done):
     1759    def _simBriefProgressCallback(self, progress, result, flightInfo):
    17411760        """Called by the SimBrief handling thread."""
    1742         gobject.idle_add(self._simBriefProgress, message, done)
    1743 
    1744     def _simBriefProgress(self, message, done):
     1761        gobject.idle_add(self._simBriefProgress, progress, result, flightInfo)
     1762
     1763    def _simBriefProgress(self, progress, result, flightInfo):
    17451764        """The real SimBrief progress handler."""
    1746         if done:
     1765        print "_simBriefProgress", progress, result, flightInfo
     1766        if result==cef.SIMBRIEF_RESULT_NONE:
     1767            message = SimBriefSetupPage.progress2Message.get(progress,
     1768                                                             "simbrief_progress_unknown")
     1769            self._wizard.gui.updateBusyState(xstr(message))
     1770        else:
    17471771            self._wizard.gui.endBusy()
    1748             self._wizard.nextPage()
    1749         else:
    1750             self._wizard.gui.updateBusyState(message)
     1772
     1773            if result==cef.SIMBRIEF_RESULT_OK:
     1774                self._wizard.nextPage()
     1775            else:
     1776                message = SimBriefSetupPage.result2Message.get(result,
     1777                                                               "simbrief_result_unknown")
     1778                dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
     1779                                           type = MESSAGETYPE_ERROR,
     1780                                           message_format =
     1781                                           xstr(message) + "\n"+
     1782                                           xstr("simbrief_cancelled"))
     1783
     1784                dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
     1785                dialog.set_title(WINDOW_TITLE_BASE)
     1786                secondary = xstr("flightsel_save_failed_sec")
     1787                dialog.format_secondary_markup(secondary)
     1788                dialog.run()
     1789                dialog.hide()
     1790
     1791                self._wizard.usingSimBrief = False
     1792                self._wizard.jumpPage(2, fromPageShift = 1)
    17511793
    17521794    def _getPlan(self):
     
    39513993        return self._loginResult
    39523994
    3953     def setCurrentPage(self, index, finalize = False):
    3954         """Set the current page to the one with the given index."""
     3995    def setCurrentPage(self, index, finalize = False, fromPageShift = None):
     3996        """Set the current page to the one with the given index.
     3997
     3998        @param fromPageShift if given, the relative index of one of the
     3999        previous pages that should be used as the from-page of the next
     4000        page. E.g. if fromPageShift is 1, the previous page will be the
     4001        from-page."""
    39554002        assert index < len(self._pages)
    39564003
     
    39614008                page.complete()
    39624009            self.remove(page)
     4010            if fromPageShift is not None:
     4011                fromPage -= fromPageShift
    39634012
    39644013        self._currentPage = index
     
    41574206        self.jumpPage(1, finalize)
    41584207
    4159     def jumpPage(self, count, finalize = True):
     4208    def jumpPage(self, count, finalize = True, fromPageShift = None):
    41604209        """Go to the page which is 'count' pages after the current one."""
    4161         self.setCurrentPage(self._currentPage + count, finalize = finalize)
     4210        self.setCurrentPage(self._currentPage + count,
     4211                            finalize = finalize, fromPageShift = fromPageShift)
    41624212
    41634213    def grabDefault(self):
     
    42084258        self._arrivalNOTAMs = None
    42094259        self._arrivalMETAR = None
    4210         self._usingSimBrief = False
     4260        self._usingSimBrief = None
    42114261
    42124262        firstPage = 0 if self._loginResult is None else 1
Note: See TracChangeset for help on using the changeset viewer.