Changeset 221:2126271cea84 for src


Ignore:
Timestamp:
06/04/12 11:39:30 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the PIREP viewer tabs for the comments and the log

Location:
src/mlx
Files:
4 edited

Legend:

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

    r220 r221  
    227227
    228228#------------------------------------------------------------------------------
     229
     230def formatFlightLogLine(timeStr, line):
     231    """Format the given flight log line."""
     232    """Format the given line for flight logging."""
     233    if timeStr is not None:
     234        line = timeStr + ": " + line
     235    return line + "\n"
     236
     237#------------------------------------------------------------------------------
  • src/mlx/gui/gui.py

    r220 r221  
    3333class GUI(fs.ConnectionListener):
    3434    """The main GUI class."""
    35     @staticmethod
    36     def _formatFlightLogLine(timeStr, line):
    37         """Format the given line for flight logging."""
    38         if timeStr is not None:
    39             line = timeStr + ": " + line
    40         return line + "\n"
    41        
    4235    def __init__(self, programDirectory, config):
    4336        """Construct the GUI."""
     
    473466        """Write the given message line to the log."""
    474467        gobject.idle_add(self._writeLog,
    475                          GUI._formatFlightLogLine(timeStr, line),
     468                         formatFlightLogLine(timeStr, line),
    476469                         self._logView)
    477470
     
    479472        """Update the line with the given index."""
    480473        gobject.idle_add(self._updateFlightLogLine, index,
    481                          GUI._formatFlightLogLine(timeStr, line))
     474                         formatFlightLogLine(timeStr, line))
    482475
    483476    def _updateFlightLogLine(self, index, line):
  • src/mlx/gui/pirep.py

    r220 r221  
    131131       
    132132        contentArea = self.get_content_area()
     133
     134        self._notebook = gtk.Notebook()
     135        contentArea.pack_start(self._notebook, False, False, 4)
     136       
    133137        dataTab = self._buildDataTab()
    134         contentArea.pack_start(dataTab, False, False, 0)
     138        label = gtk.Label(xstr("pirepView_tab_data"))
     139        label.set_use_underline(True)
     140        label.set_tooltip_text(xstr("pirepView_tab_data_tooltip"))
     141        self._notebook.append_page(dataTab, label)
     142       
     143        commentsTab = self._buildCommentsTab()
     144        label = gtk.Label(xstr("pirepView_tab_comments"))
     145        label.set_use_underline(True)
     146        label.set_tooltip_text(xstr("pirepView_tab_comments_tooltip"))
     147        self._notebook.append_page(commentsTab, label)
     148       
     149        logTab = self._buildLogTab()
     150        label = gtk.Label(xstr("pirepView_tab_log"))
     151        label.set_use_underline(True)
     152        label.set_tooltip_text(xstr("pirepView_tab_log_tooltip"))
     153        self._notebook.append_page(logTab, label)
    135154       
    136155    def setPIREP(self, pirep):
     
    205224            delayCodes += PIREP.delayCodes[code]
    206225       
    207         self._delayCodes.get_buffer().set_text(delayCodes)
     226        self._delayCodes.get_buffer().set_text(delayCodes)       
     227
     228        self._comments.get_buffer().set_text(pirep.comments)
     229        self._flightDefects.get_buffer().set_text(pirep.flightDefects)
     230
     231        logBuffer = self._log.get_buffer()
     232        logBuffer.set_text("")
     233        for (timeStr, line) in pirep.logLines:
     234            logBuffer.insert(logBuffer.get_end_iter(),
     235                             formatFlightLogLine(timeStr, line))
     236
     237        self._notebook.set_current_page(0)
    208238
    209239    def _buildDataTab(self):
     
    437467        table.set_row_spacings(4)
    438468        table.set_col_spacings(8)
     469        table.set_homogeneous(False)
    439470       
    440471        self._blockTimeStart = \
     
    501532        return frame       
    502533
     534    def _buildCommentsTab(self):
     535        """Build the tab with the comments and flight defects."""
     536        table = gtk.Table(2, 1)
     537        table.set_col_spacings(16)
     538
     539        (frame, commentsBox) = \
     540            PIREPViewer.createFrame(xstr("pirepView_comments"))
     541        table.attach(frame, 0, 1, 0, 1)
     542
     543        (commentsWindow, self._comments) = \
     544            PIREPViewer.getTextWindow(heightRequest = -1)
     545        commentsBox.pack_start(commentsWindow, True, True, 0)
     546
     547        (frame, flightDefectsBox) = \
     548            PIREPViewer.createFrame(xstr("pirepView_flightDefects"))
     549        table.attach(frame, 1, 2, 0, 1)
     550
     551        (flightDefectsWindow, self._flightDefects) = \
     552            PIREPViewer.getTextWindow(heightRequest = -1)
     553        flightDefectsBox.pack_start(flightDefectsWindow, True, True, 0)
     554       
     555        return table
     556
     557    def _buildLogTab(self):
     558        """Build the log tab."""
     559        mainBox = gtk.VBox()
     560
     561        (logWindow, self._log) = PIREPViewer.getTextWindow(heightRequest = -1)
     562        mainBox.pack_start(logWindow, True, True, 0)
     563       
     564        return mainBox
     565       
    503566#------------------------------------------------------------------------------
    504 #------------------------------------------------------------------------------
    505 #------------------------------------------------------------------------------
    506 #------------------------------------------------------------------------------
  • src/mlx/i18n.py

    r220 r221  
    878878        self.add("pirepView_title", "PIREP viewer")
    879879
     880        self.add("pirepView_tab_data", "_Data")
     881        self.add("pirepView_tab_data_tooltip",
     882                 "The main data of the flight.")
     883
    880884        self.add("pirepView_frame_flight", "Flight")
    881885        self.add("pirepView_callsign", "Callsign:")
     
    921925        self.add("pirepView_no", "no")
    922926        self.add("pirepView_delayCodes", "Delay codes:")
     927
     928        self.add("pirepView_tab_comments", "_Comments & defects")
     929        self.add("pirepView_tab_comments_tooltip",
     930                 "The comments and the flight defects.")
     931
     932        self.add("pirepView_comments", "Comments")
     933        self.add("pirepView_flightDefects", "Flight defects")
     934
     935        self.add("pirepView_tab_log", "_Log")
     936        self.add("pirepView_tab_log_tooltip", "The flight log.")
    923937
    924938#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.