Ignore:
File:
1 edited

Legend:

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

    r349 r441  
    11
    22from common import *
     3
     4from mlx.gui.delaycodes import DelayCodeTable
    35
    46from mlx.i18n import xstr
     
    2123    """The flight info tab."""
    2224    @staticmethod
    23     def _delayCodes():
    24         """Get an array of delay codes."""
    25         return [ (const.DELAYCODE_LOADING, xstr("info_delay_loading")),
    26                  (const.DELAYCODE_VATSIM, xstr("info_delay_vatsim")),
    27                  (const.DELAYCODE_NETWORK, xstr("info_delay_net")),
    28                  (const.DELAYCODE_CONTROLLER, xstr("info_delay_atc")),
    29                  (const.DELAYCODE_SYSTEM, xstr("info_delay_system")),
    30                  (const.DELAYCODE_NAVIGATION, xstr("info_delay_nav")),
    31                  (const.DELAYCODE_TRAFFIC, xstr("info_delay_traffic")),
    32                  (const.DELAYCODE_APRON, xstr("info_delay_apron")),
    33                  (const.DELAYCODE_WEATHER, xstr("info_delay_weather")),
    34                  (const.DELAYCODE_PERSONAL, xstr("info_delay_personal")) ]
    35 
    36     @staticmethod
    3725    def _createCommentArea(label):
    3826        """Create a comment area.
     
    5240
    5341        scroller = gtk.ScrolledWindow()
    54         # FIXME: these should be constants
    55         scroller.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
    56                             else gtk.POLICY_AUTOMATIC,
    57                             gtk.PolicyType.AUTOMATIC if pygobject
    58                             else gtk.POLICY_AUTOMATIC)
    59         scroller.set_shadow_type(gtk.ShadowType.IN if pygobject
    60                                  else gtk.SHADOW_IN)
     42        scroller.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
     43        scroller.set_shadow_type(SHADOW_IN)
     44
    6145        comments = gtk.TextView()
    6246        comments.set_wrap_mode(WRAP_WORD)
     
    9478
    9579        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
    96                                   xscale = 0.0, yscale = 0.0)
     80                                  xscale = 1.0, yscale = 1.0)
    9781        alignment.set_padding(padding_top = 4, padding_bottom = 4,
    9882                              padding_left = 8, padding_right = 8)
    9983
    100         self._delayTable = table = gtk.Table(5, 2)
    101         table.set_col_spacings(16)
     84        self._delayCodeTable = table = DelayCodeTable()
     85        self._delayWindow = scrolledWindow = gtk.ScrolledWindow()
     86        scrolledWindow.add(table)
     87        scrolledWindow.set_size_request(-1, 185)
     88        scrolledWindow.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
     89        scrolledWindow.set_shadow_type(SHADOW_IN)
    10290
    103         row = 0
    104         column = 0
    105 
    106         self._delayCodeWidgets = []
    107         for (_code, label) in FlightInfo._delayCodes():
    108             button = gtk.CheckButton(label)
    109             button.set_use_underline(True)
    110             table.attach(button, column, column + 1, row, row + 1)
    111             self._delayCodeWidgets.append(button)
    112             if column==0:
    113                 column += 1
    114             else:
    115                 row += 1
    116                 column = 0
    117 
    118         alignment.add(table)
     91        alignment.add(scrolledWindow)
    11992        frame.add(alignment)
    12093
    12194        self._delayAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
    122                                              xscale = 0.0, yscale = 0.0)
     95                                             xscale = 1.0, yscale = 1.0)
    12396        self._delayAlignment.add(frame)
     97        self._delayAlignment.set_padding(padding_top = 0, padding_bottom = 0,
     98                                         padding_left = 8, padding_right = 8)
    12499
    125100        self.pack_start(self._delayAlignment, False, False, 8)
     
    147122    def delayCodes(self):
    148123        """Get the list of delay codes checked by the user."""
    149         codes =  []
    150         delayCodes = FlightInfo._delayCodes()
    151         for index in range(0, len(delayCodes)):
    152             if self._delayCodeWidgets[index].get_active():
    153                 codes.append(delayCodes[index][0])
    154         return codes
     124        return self._delayCodeTable.delayCodes
    155125
    156     def enable(self):
     126    def enable(self, aircraftType):
    157127        """Enable the flight info tab."""
    158128        self._comments.set_sensitive(True)
    159129        self._flightDefects.set_sensitive(True)
    160         self._delayTable.set_sensitive(True)
     130        self._delayCodeTable.setType(aircraftType)
     131        self._delayWindow.set_sensitive(True)
     132        self._delayCodeTable.setStyle()
    161133
    162134    def disable(self):
     
    164136        self._comments.set_sensitive(False)
    165137        self._flightDefects.set_sensitive(False)
    166         self._delayTable.set_sensitive(False)
     138        self._delayWindow.set_sensitive(False)
     139        self._delayCodeTable.setStyle()
    167140
    168141    def reset(self):
     
    170143        self._comments.get_buffer().set_text("")
    171144        self._flightDefects.get_buffer().set_text("")
    172 
    173         for widget in self._delayCodeWidgets:
    174             widget.set_active(False)
     145        self._delayCodeTable.reset()
    175146
    176147    def _commentsChanged(self, textbuffer):
Note: See TracChangeset for help on using the changeset viewer.