Changeset 264:6fbadb22b2c3
- Timestamp:
- 07/01/12 07:58:44 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/config.py
r249 r264 42 42 self.key == other.key 43 43 44 def __ne__(self, other): 45 """Check if the given hotkey is not equal to the other one.""" 46 return not self==other 47 44 48 def __str__(self): 45 49 """Construct the hotkey to a string.""" … … 92 96 return self._fileList == other._fileList 93 97 98 def __ne__(self, other): 99 """Determine if the checklist is not equal to the given other one.""" 100 return not self==other 101 94 102 def __len__(self): 95 103 """Get the length of the file list.""" … … 103 111 """Iterate over the files.""" 104 112 return iter(self._fileList) 113 114 #------------------------------------------------------------------------------- 115 116 class ApproachCallouts(object): 117 """The approach callouts for a certain aircraft type.""" 118 # The name of the section of the approach callouts 119 SECTION="callouts" 120 121 @staticmethod 122 def fromConfig(config, aircraftType): 123 """Create a checklist for the given aircraft type from the given 124 config.""" 125 baseName = "callouts." + const.icaoCodes[aircraftType] + "." 126 mapping = {} 127 while True: 128 option = baseName + str(len(mapping)) 129 if config.has_option(ApproachCallouts.SECTION, option): 130 value = config.get(ApproachCallouts.SECTION, option) 131 (altitude, path) = value.split(",") 132 altitude = int(altitude.strip()) 133 path = path.strip() 134 mapping[altitude] = path 135 else: 136 break 137 138 return ApproachCallouts(mapping) 139 140 def __init__(self, mapping = None): 141 """Construct the check list with the given mapping of altitudes to 142 files.""" 143 self._mapping = {} if mapping is None else mapping.copy() 144 145 def clone(self): 146 """Clone the callout information.""" 147 return ApproachCallouts(self._mapping) 148 149 def toConfig(self, config, aircraftType): 150 """Add this checklist to the given config.""" 151 baseName = "callouts." + const.icaoCodes[aircraftType] + "." 152 index = 0 153 for (altitude, path) in self._mapping.iteritems(): 154 option = baseName + str(index) 155 config.set(ApproachCallouts.SECTION, option, 156 "%d, %s" % (altitude, path)) 157 index += 1 158 159 def __eq__(self, other): 160 """Determine if the approach callout mapping is equal to the given 161 other one.""" 162 return self._mapping == other._mapping 163 164 def __ne__(self, other): 165 """Determine if the approach callout mapping is not equal to the given 166 other one.""" 167 return not self==other 168 169 def __len__(self): 170 """Get the number of elements in the mapping.""" 171 return len(self._mapping) 172 173 def __getitem__(self, altitude): 174 """Get the file that is associated with the highest altitude not higher 175 than the given one. 176 177 If no such file found, return None.""" 178 candidate = None 179 for (alt, path) in self._mapping.iteritems(): 180 if alt<=altitude: 181 if candidate is None or alt>candidate[0]: 182 candidate = (alt, path) 183 184 return candidate 185 186 def __iter__(self): 187 """Iterate over the pairs of altitudes and paths in decreasing order of 188 the altitude.""" 189 altitudes = self._mapping.keys() 190 altitudes.sort(reverse = True) 191 192 for altitude in altitudes: 193 yield (altitude, self._mapping[altitude]) 105 194 106 195 #------------------------------------------------------------------------------- … … 137 226 self._pilotHotkey = Hotkey(ctrl = True, shift = False, key = "0") 138 227 139 #self._approachCallOuts = False228 self._enableApproachCallouts = False 140 229 self._speedbrakeAtTD = True 141 230 … … 149 238 150 239 self._checklists = {} 240 self._approachCallouts = {} 151 241 for aircraftType in const.aircraftTypes: 152 242 self._checklists[aircraftType] = Checklist() 153 243 self._approachCallouts[aircraftType] = ApproachCallouts() 244 154 245 self._modified = False 155 246 … … 404 495 self._modified = True 405 496 406 #@property407 # def approachCallOuts(self):408 #"""Get whether the approach callouts should be played."""409 # return self._approachCallOuts410 411 # @approachCallOuts.setter412 # def approachCallOuts(self, approachCallOuts):413 #"""Set whether the approach callouts should be played."""414 # if approachCallOuts!=self._approachCallOuts:415 # self._approachCallOuts = approachCallOuts416 #self._modified = True497 @property 498 def enableApproachCallouts(self): 499 """Get whether the approach callouts should be played.""" 500 return self._enableApproachCallouts 501 502 @enableApproachCallouts.setter 503 def enableApproachCallouts(self, enableApproachCallouts): 504 """Set whether the approach callouts should be played.""" 505 if enableApproachCallouts!=self._enableApproachCallouts: 506 self._enableApproachCallouts = enableApproachCallouts 507 self._modified = True 417 508 418 509 @property … … 484 575 if checklist!=self._checklists[aircraftType]: 485 576 self._checklists[aircraftType] = checklist.clone() 577 self._modified = True 578 579 def getApproachCallouts(self, aircraftType): 580 """Get the approach callouts for the given aircraft type.""" 581 return self._approachCallouts[aircraftType] 582 583 def setApproachCallouts(self, aircraftType, approachCallouts): 584 """Set the approach callouts for the given aircraft type.""" 585 if not approachCallouts==self._approachCallouts[aircraftType]: 586 print "Updating approach callouts" 587 self._approachCallouts[aircraftType] = approachCallouts.clone() 486 588 self._modified = True 487 589 … … 538 640 self._pilotHotkey.set(self._get(config, "sounds", 539 641 "pilotHotkey", "C0")) 540 #self._approachCallOuts = self._getBoolean(config, "sounds",541 # "approachCallOuts", False)642 self._enableApproachCallOuts = \ 643 self._getBoolean(config, "sounds", "enableApproachCallOuts", False) 542 644 self._speedbrakeAtTD = self._getBoolean(config, "sounds", 543 645 "speedbrakeAtTD", True) … … 555 657 self._checklists[aircraftType] = \ 556 658 Checklist.fromConfig(config, aircraftType) 659 self._approachCallouts[aircraftType] = \ 660 ApproachCallouts.fromConfig(config, aircraftType) 557 661 558 662 self._modified = False … … 626 730 627 731 config.add_section(Checklist.SECTION) 732 config.add_section(ApproachCallouts.SECTION) 628 733 for aircraftType in const.aircraftTypes: 629 734 self._checklists[aircraftType].toConfig(config, aircraftType) 735 self._approachCallouts[aircraftType].toConfig(config, aircraftType) 630 736 631 737 try: -
src/mlx/gui/checklist.py
r260 r264 203 203 selection = self._fileList.get_selection() 204 204 (model, paths) = selection.get_selected_rows() 205 while paths: 206 model.remove(model.get_iter(paths[0])) 207 (model, paths) = selection.get_selected_rows() 205 206 iters = [model.get_iter(path) for path in paths] 207 208 for i in iters: 209 if i is not None: 210 model.remove(i) 208 211 209 212 def _moveUpButtonClicked(self, button): -
src/mlx/gui/common.py
r246 r264 62 62 WINDOW_STATE_ICONIFIED = gdk.WINDOW_STATE_ICONIFIED 63 63 WINDOW_STATE_WITHDRAWN = gdk.WINDOW_STATE_WITHDRAWN 64 65 SORT_ASCENDING = gtk.SORT_ASCENDING 66 SORT_DESCENDING = gtk.SORT_DESCENDING 64 67 65 68 pixbuf_new_from_file = gdk.pixbuf_new_from_file … … 118 121 WINDOW_STATE_WITHDRAWN = gdk.WindowState.WITHDRAWN 119 122 123 SORT_ASCENDING = gtk.SortType.ASCENDING 124 SORT_DESCENDING = gtk.SortType.DESCENDING 125 120 126 pixbuf_new_from_file = gdkPixbuf.Pixbuf.new_from_file 121 127 -
src/mlx/gui/gui.py
r261 r264 13 13 from mlx.gui.prefs import Preferences 14 14 from mlx.gui.checklist import ChecklistEditor 15 from mlx.gui.callouts import ApproachCalloutsEditor 15 16 from mlx.gui.pirep import PIREPViewer 16 17 … … 95 96 self._preferences = Preferences(self) 96 97 self._checklistEditor = ChecklistEditor(self) 98 self._approachCalloutsEditor = ApproachCalloutsEditor(self) 97 99 98 100 menuBar = self._buildMenuBar(accelGroup) … … 870 872 checklistMenuItem.connect("activate", self._editChecklist) 871 873 toolsMenu.append(checklistMenuItem) 874 875 approachCalloutsMenuItem = gtk.ImageMenuItem(gtk.STOCK_EDIT) 876 approachCalloutsMenuItem.set_use_stock(True) 877 approachCalloutsMenuItem.set_label(xstr("menu_tools_callouts")) 878 approachCalloutsMenuItem.add_accelerator("activate", accelGroup, 879 ord(xstr("menu_tools_callouts_key")), 880 CONTROL_MASK, ACCEL_VISIBLE) 881 approachCalloutsMenuItem.connect("activate", self._editApproachCallouts) 882 toolsMenu.append(approachCalloutsMenuItem) 872 883 873 884 prefsMenuItem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES) … … 1007 1018 """Callback for editing the checklists.""" 1008 1019 self._checklistEditor.run() 1020 1021 def _editApproachCallouts(self, menuItem): 1022 """Callback for editing the approach callouts.""" 1023 self._approachCalloutsEditor.run() 1009 1024 1010 1025 def _editPreferences(self, menuItem): -
src/mlx/i18n.py
r256 r264 181 181 self.add("menu_tools_chklst", "_Checklist Editor") 182 182 self.add("menu_tools_chklst_key", "c") 183 self.add("menu_tools_callouts", "_Approach Callouts Editor") 184 self.add("menu_tools_callouts_key", "e") 183 185 self.add("menu_tools_prefs", "_Preferences") 184 186 self.add("menu_tools_prefs_key", "p") … … 975 977 self.add("about_role_negotiation", "negotiation") 976 978 self.add("about_role_test", "testing") 979 980 self.add("callouts_title", "Approach Callouts Editor") 981 self.add("callouts_aircraftType", "Aircraft _type:") 982 self.add("callouts_aircraftType_tooltip", 983 "The type of the aircraft for which the approach " 984 "callouts are being edited.") 985 self.add("callouts_header_altitude", "Altitude") 986 self.add("callouts_header_path", "Callout file") 987 self.add("callouts_add", "_Add new callout") 988 self.add("callouts_add_tooltip", 989 "Add a new callout with some default altitude.") 990 self.add("callouts_remove", "_Remove") 991 self.add("callouts_remove_tooltip", 992 "Remove the selected items from the list of callouts.") 993 self.add("callouts_altitude_clash", 994 "There is already a callout for this altitude") 995 self.add("callouts_altitude_clash_sec", 996 "Shall I set the altitude nevertheless? If so, " 997 "both callouts will be played when reaching the altitude " 998 "simultaneously.") 999 # self.add("chklst_moveUp", "Move _up") 1000 # self.add("chklst_moveUp_tooltip", 1001 # "Move up the selected file(s) in the checklist.") 1002 # self.add("chklst_moveDown", "Move _down") 1003 # self.add("chklst_moveDown_tooltip", 1004 # "Move down the selected file(s) in the checklist.") 1005 # self.add("chklst_filter_audio", "Audio files") 977 1006 978 1007 #------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.