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