Ignore:
Timestamp:
06/08/17 18:36:07 (7 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The timetable can be queried, displayed and filtered (re #304)

Location:
src/mlx/gui
Files:
1 added
3 edited

Legend:

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

    r852 r858  
    106106
    107107    SELECTION_MULTIPLE = gtk.SELECTION_MULTIPLE
     108
     109    WINDOW_POPUP = gtk.WINDOW_POPUP
    108110
    109111    pixbuf_new_from_file = gdk.pixbuf_new_from_file
     
    549551#------------------------------------------------------------------------------
    550552
     553aircraftFamilyNames = {
     554    _const.AIRCRAFT_FAMILY_B737NG: xstr("aircraft_family_b737ng"),
     555
     556    _const.AIRCRAFT_FAMILY_B737CL: xstr("aircraft_family_b737cl"),
     557
     558    _const.AIRCRAFT_FAMILY_DH8D: xstr("aircraft_family_dh8d"),
     559
     560    _const.AIRCRAFT_FAMILY_B767: xstr("aircraft_family_b767"),
     561
     562    _const.AIRCRAFT_FAMILY_CRJ2: xstr("aircraft_family_crj2"),
     563
     564    _const.AIRCRAFT_FAMILY_F70: xstr("aircraft_family_f70"),
     565
     566    _const.AIRCRAFT_FAMILY_DC3: xstr("aircraft_family_dc3"),
     567
     568    _const.AIRCRAFT_FAMILY_T134: xstr("aircraft_family_t134"),
     569
     570    _const.AIRCRAFT_FAMILY_T154: xstr("aircraft_family_t154"),
     571
     572    _const.AIRCRAFT_FAMILY_YK40: xstr("aircraft_family_yk40"),
     573
     574    _const.AIRCRAFT_FAMILY_B462: xstr("aircraft_family_b462")
     575}
     576
     577#------------------------------------------------------------------------------
     578
    551579def formatFlightLogLine(timeStr, line):
    552580    """Format the given flight log line."""
  • src/mlx/gui/flightlist.py

    r857 r858  
    4242
    4343        @param index is the 0-based index of the column."""
    44         column = gtk.TreeViewColumn(self._heading, self._renderer,
    45                                     text = index)
     44        if isinstance(self._renderer, gtk.CellRendererText):
     45            column = gtk.TreeViewColumn(self._heading, self._renderer,
     46                                        text = index)
     47        elif isinstance(self._renderer, gtk.CellRendererToggle):
     48            column = gtk.TreeViewColumn(self._heading, self._renderer,
     49                                        active = index)
     50        else:
     51            column = gtk.TreeViewColumn(self._heading, self._renderer)
    4652        column.set_expand(True)
    4753        if self._sortable:
  • src/mlx/gui/gui.py

    r855 r858  
    1717from mlx.gui.bugreport import BugReportDialog
    1818from mlx.gui.acars import ACARS
     19from mlx.gui.timetable import TimetableWindow
    1920import cef
    2021
     
    120121
    121122        self._preferences = Preferences(self)
     123        self._timetableWindow = TimetableWindow(self)
     124        self._timetableWindow.connect("delete-event", self._hideTimetableWindow)
    122125        self._flightsWindow = AcceptedFlightsWindow(self)
    123126        self._flightsWindow.connect("delete-event", self._hideFlightsWindow)
     
    10631066        toolsMenuItem.set_submenu(toolsMenu)
    10641067        menuBar.append(toolsMenuItem)
     1068
     1069        self._timetableMenuItem = timetableMenuItem = \
     1070          gtk.ImageMenuItem(gtk.STOCK_INDENT)
     1071        timetableMenuItem.set_use_stock(True)
     1072        timetableMenuItem.set_label(xstr("menu_tools_timetable"))
     1073        timetableMenuItem.add_accelerator("activate", accelGroup,
     1074                                          ord(xstr("menu_tools_timetable_key")),
     1075                                          CONTROL_MASK, ACCEL_VISIBLE)
     1076        timetableMenuItem.connect("activate", self.showTimetable)
     1077        self._timetableMenuItem.set_sensitive(False)
     1078        toolsMenu.append(timetableMenuItem)
    10651079
    10661080        self._flightsMenuItem = flightsMenuItem = \
     
    12401254        """Called when the login is successful."""
    12411255        self._flightsMenuItem.set_sensitive(True)
     1256        self._timetableMenuItem.set_sensitive(True)
    12421257
    12431258    def isWizardActive(self):
    12441259        """Determine if the flight wizard is active."""
    12451260        return self._notebook.get_current_page()==0
     1261
     1262    def showTimetable(self, menuItem):
     1263        """Callback for showing the timetable."""
     1264        if self._timetableWindow.hasFlightPairs:
     1265            self._timetableWindow.show_all()
     1266        else:
     1267            date = datetime.date.today()
     1268            self._timetableWindow.setTypes(self.loginResult.types)
     1269            self._timetableWindow.setDate(date)
     1270            self.updateTimeTable(date)
     1271            self.beginBusy(xstr("timetable_query_busy"))
     1272
     1273    def updateTimeTable(self, date):
     1274        """Update the time table for the given date."""
     1275        self.beginBusy(xstr("timetable_query_busy"))
     1276        self._timetableWindow.set_sensitive(False)
     1277        window = self._timetableWindow.get_window()
     1278        if window is not None:
     1279            window.set_cursor(self._busyCursor)
     1280        self.webHandler.getTimetable(self._timetableCallback, date,
     1281                                     self.loginResult.types)
     1282
     1283    def _timetableCallback(self, returned, result):
     1284        """Called when the timetable has been received."""
     1285        gobject.idle_add(self._handleTimetable, returned, result)
     1286
     1287    def _handleTimetable(self, returned, result):
     1288        """Handle the result of the query for the timetable."""
     1289        self.endBusy()
     1290        window = self._timetableWindow.get_window()
     1291        if window is not None:
     1292            window.set_cursor(None)
     1293        self._timetableWindow.set_sensitive(True)
     1294        if returned:
     1295            self._timetableWindow.setFlightPairs(result.flightPairs)
     1296            self._timetableWindow.show_all()
     1297        else:
     1298            dialog = gtk.MessageDialog(parent = self.mainWindow,
     1299                                       type = MESSAGETYPE_ERROR,
     1300                                       message_format = xstr("timetable_failed"))
     1301            dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
     1302            dialog.set_title(WINDOW_TITLE_BASE)
     1303            dialog.run()
     1304            dialog.hide()
     1305            self._timetableWindow.clear()
    12461306
    12471307    def showFlights(self, menuItem):
     
    12731333            dialog.run()
    12741334            dialog.hide()
     1335
     1336    def _hideTimetableWindow(self, window, event):
     1337        """Hide the window of the timetable."""
     1338        self._timetableWindow.hide()
     1339        return True
    12751340
    12761341    def _hideFlightsWindow(self, window, event):
Note: See TracChangeset for help on using the changeset viewer.