- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/info.py
r349 r441 1 1 2 2 from common import * 3 4 from mlx.gui.delaycodes import DelayCodeTable 3 5 4 6 from mlx.i18n import xstr … … 21 23 """The flight info tab.""" 22 24 @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 @staticmethod37 25 def _createCommentArea(label): 38 26 """Create a comment area. … … 52 40 53 41 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 61 45 comments = gtk.TextView() 62 46 comments.set_wrap_mode(WRAP_WORD) … … 94 78 95 79 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 96 xscale = 0.0, yscale = 0.0)80 xscale = 1.0, yscale = 1.0) 97 81 alignment.set_padding(padding_top = 4, padding_bottom = 4, 98 82 padding_left = 8, padding_right = 8) 99 83 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) 102 90 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) 119 92 frame.add(alignment) 120 93 121 94 self._delayAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 122 xscale = 0.0, yscale = 0.0)95 xscale = 1.0, yscale = 1.0) 123 96 self._delayAlignment.add(frame) 97 self._delayAlignment.set_padding(padding_top = 0, padding_bottom = 0, 98 padding_left = 8, padding_right = 8) 124 99 125 100 self.pack_start(self._delayAlignment, False, False, 8) … … 147 122 def delayCodes(self): 148 123 """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 155 125 156 def enable(self ):126 def enable(self, aircraftType): 157 127 """Enable the flight info tab.""" 158 128 self._comments.set_sensitive(True) 159 129 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() 161 133 162 134 def disable(self): … … 164 136 self._comments.set_sensitive(False) 165 137 self._flightDefects.set_sensitive(False) 166 self._delayTable.set_sensitive(False) 138 self._delayWindow.set_sensitive(False) 139 self._delayCodeTable.setStyle() 167 140 168 141 def reset(self): … … 170 143 self._comments.get_buffer().set_text("") 171 144 self._flightDefects.get_buffer().set_text("") 172 173 for widget in self._delayCodeWidgets: 174 widget.set_active(False) 145 self._delayCodeTable.reset() 175 146 176 147 def _commentsChanged(self, textbuffer):
Note:
See TracChangeset
for help on using the changeset viewer.