Changeset 132:92f78dc5b965 for src
- Timestamp:
- 04/30/12 10:55:37 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/config.py
r131 r132 3 3 4 4 #------------------------------------------------------------------------------- 5 6 import const 5 7 6 8 import os … … 24 26 """Our configuration.""" 25 27 DEFAULT_UPDATE_URL = "http://mlx.varadiistvan.hu/update" 28 29 _messageTypesSection = "messageTypes" 26 30 27 31 def __init__(self): … … 32 36 self._rememberPassword = False 33 37 38 self._language = "" 39 self._flareTimeFromFS = False 40 34 41 self._autoUpdate = True 35 42 self._updateURL = Config.DEFAULT_UPDATE_URL 36 37 self._language = "" 38 self._flareTimeFromFS = False 39 43 44 self._messageTypeLevels = {} 45 40 46 self._modified = False 41 47 … … 102 108 self._modified = True 103 109 110 def getMessageTypeLevel(self, messageType): 111 """Get the level for the given message type.""" 112 return self._messageTypeLevels[messageType] \ 113 if messageType in self._messageTypeLevels \ 114 else const.MESSAGELEVEL_NONE 115 116 def setMessageTypeLevel(self, messageType, level): 117 """Set the level of the given message type.""" 118 if messageType not in self._messageTypeLevels or \ 119 self._messageTypeLevels[messageType]!=level: 120 self._messageTypeLevels[messageType] = level 121 self._modified = True 122 104 123 @property 105 124 def autoUpdate(self): … … 136 155 "rememberPassword", False) 137 156 138 self._autoUpdate = self._getBoolean(config, "update", "auto", True)139 self._updateURL = self._get(config, "update", "url",140 Config.DEFAULT_UPDATE_URL)141 142 157 self._language = self._get(config, "general", "language", "") 143 158 self._flareTimeFromFS = self._getBoolean(config, "general", 144 159 "flareTimeFromFS", 145 160 False) 146 161 162 self._messageTypeLevels = {} 163 for messageType in const.messageTypes: 164 self._messageTypeLevels[messageType] = \ 165 self._getMessageTypeLevel(config, messageType) 166 167 self._autoUpdate = self._getBoolean(config, "update", "auto", True) 168 self._updateURL = self._get(config, "update", "url", 169 Config.DEFAULT_UPDATE_URL) 170 147 171 self._modified = False 148 172 … … 160 184 "yes" if self._rememberPassword else "no") 161 185 162 config.add_section("update")163 config.set("update", "auto",164 "yes" if self._autoUpdate else "no")165 config.set("update", "url", self._updateURL)166 167 186 config.add_section("general") 168 187 if self._language: … … 170 189 config.set("general", "flareTimeFromFS", 171 190 "yes" if self._flareTimeFromFS else "no") 172 191 192 config.add_section(Config._messageTypesSection) 193 for messageType in const.messageTypes: 194 if messageType in self._messageTypeLevels: 195 option = self._getMessageTypeLevelOptionName(messageType) 196 level = self._messageTypeLevels[messageType] 197 config.set(Config._messageTypesSection, option, 198 const.messageLevel2string(level)) 199 200 config.add_section("update") 201 config.set("update", "auto", 202 "yes" if self._autoUpdate else "no") 203 config.set("update", "url", self._updateURL) 204 173 205 try: 174 206 fd = os.open(configPath, os.O_CREAT|os.O_TRUNC|os.O_WRONLY, … … 194 226 else default 195 227 228 def _getMessageTypeLevel(self, config, messageType): 229 """Get the message type level for the given message type.""" 230 option = self._getMessageTypeLevelOptionName(messageType) 231 if config.has_option(Config._messageTypesSection, option): 232 value = config.get(Config._messageTypesSection, option) 233 return const.string2messageLevel(value) 234 else: 235 return const.MESSAGELEVEL_NONE 236 237 def _getMessageTypeLevelOptionName(self, messageType): 238 """Get the option name for the given message type level.""" 239 return const.messageType2string(messageType) 240 196 241 def getLanguage(self): 197 242 """Get the language to be used.""" -
src/mlx/const.py
r129 r132 115 115 # Flight stage: end 116 116 STAGE_END = 12 117 118 #-------------------------------------------------------------------------------119 120 # Plane status: unknown121 PLANE_UNKNOWN = 0122 123 # Plane status: at home, i.e. LHBP124 PLANE_HOME = 1125 126 # Plane status: away127 PLANE_AWAY = 2128 129 # Plane status: parking130 PLANE_PARKING = 3131 132 #-------------------------------------------------------------------------------133 134 # Flight type: scheduled135 FLIGHTTYPE_SCHEDULED = 0136 137 # Flight type: old-timer138 FLIGHTTYPE_OLDTIMER = 1139 140 # Flight type: VIP141 FLIGHTTYPE_VIP = 2142 143 # Flight type: charter144 FLIGHTTYPE_CHARTER = 3145 146 #-------------------------------------------------------------------------------147 148 # Delay code: loading problems149 DELAYCODE_LOADING = 0150 151 # Delay code: VATSIM problem152 DELAYCODE_VATSIM = 1153 154 # Delay code: network problems155 DELAYCODE_NETWORK = 2156 157 # Delay code: controller's fault158 DELAYCODE_CONTROLLER = 3159 160 # Delay code: system crash or freeze161 DELAYCODE_SYSTEM = 4162 163 # Delay code: navigation problem164 DELAYCODE_NAVIGATION = 5165 166 # Delay code: traffic problems167 DELAYCODE_TRAFFIC = 6168 169 # Delay code: apron navigation170 DELAYCODE_APRON = 7171 172 # Delay code: weather problems173 DELAYCODE_WEATHER = 8174 175 # Delay code: personal reasons176 DELAYCODE_PERSONAL = 9177 178 #-------------------------------------------------------------------------------179 180 # The available gates at LHBP181 lhbpGateNumbers = []182 183 for i in range(1, 7):184 lhbpGateNumbers.append(str(i))185 186 for i in range(10, 19):187 lhbpGateNumbers.append(str(i))188 189 for i in range(24, 28):190 lhbpGateNumbers.append(str(i))191 192 for i in range(31, 39):193 lhbpGateNumbers.append(str(i))194 195 for i in range(42, 47):196 lhbpGateNumbers.append(str(i))197 198 for i in range(60, 84):199 if i!=70 and i!=80:200 lhbpGateNumbers.append(str(i))201 117 202 118 #------------------------------------------------------------------------------- … … 221 137 #------------------------------------------------------------------------------- 222 138 139 # Plane status: unknown 140 PLANE_UNKNOWN = 0 141 142 # Plane status: at home, i.e. LHBP 143 PLANE_HOME = 1 144 145 # Plane status: away 146 PLANE_AWAY = 2 147 148 # Plane status: parking 149 PLANE_PARKING = 3 150 151 #------------------------------------------------------------------------------- 152 153 # Flight type: scheduled 154 FLIGHTTYPE_SCHEDULED = 0 155 156 # Flight type: old-timer 157 FLIGHTTYPE_OLDTIMER = 1 158 159 # Flight type: VIP 160 FLIGHTTYPE_VIP = 2 161 162 # Flight type: charter 163 FLIGHTTYPE_CHARTER = 3 164 165 #------------------------------------------------------------------------------- 166 167 # Delay code: loading problems 168 DELAYCODE_LOADING = 0 169 170 # Delay code: VATSIM problem 171 DELAYCODE_VATSIM = 1 172 173 # Delay code: network problems 174 DELAYCODE_NETWORK = 2 175 176 # Delay code: controller's fault 177 DELAYCODE_CONTROLLER = 3 178 179 # Delay code: system crash or freeze 180 DELAYCODE_SYSTEM = 4 181 182 # Delay code: navigation problem 183 DELAYCODE_NAVIGATION = 5 184 185 # Delay code: traffic problems 186 DELAYCODE_TRAFFIC = 6 187 188 # Delay code: apron navigation 189 DELAYCODE_APRON = 7 190 191 # Delay code: weather problems 192 DELAYCODE_WEATHER = 8 193 194 # Delay code: personal reasons 195 DELAYCODE_PERSONAL = 9 196 197 #------------------------------------------------------------------------------- 198 199 # Message type: logger error 200 MESSAGETYPE_LOGGER_ERROR = 1 201 202 # Message type: information 203 MESSAGETYPE_INFORMATION = 2 204 205 # Message type: fault messages 206 MESSAGETYPE_FAULT = 3 207 208 # Message type: NO-GO fault messages 209 MESSAGETYPE_NOGO = 4 210 211 # Message type: gate system messages 212 MESSAGETYPE_GATE_SYSTEM = 5 213 214 # Message type: environment messages 215 MESSAGETYPE_ENVIRONMENT = 6 216 217 # Message type: help messages 218 MESSAGETYPE_HELP = 7 219 220 # Message type: visibility messages 221 MESSAGETYPE_VISIBILITY = 8 222 223 #------------------------------------------------------------------------------- 224 225 messageTypes = [ MESSAGETYPE_LOGGER_ERROR, 226 MESSAGETYPE_INFORMATION, 227 MESSAGETYPE_FAULT, 228 MESSAGETYPE_NOGO, 229 MESSAGETYPE_GATE_SYSTEM, 230 MESSAGETYPE_ENVIRONMENT, 231 MESSAGETYPE_HELP, 232 MESSAGETYPE_VISIBILITY ] 233 234 #------------------------------------------------------------------------------- 235 236 _messageTypeStrings = { MESSAGETYPE_LOGGER_ERROR : "loggerError", 237 MESSAGETYPE_INFORMATION : "information", 238 MESSAGETYPE_FAULT : "fault", 239 MESSAGETYPE_NOGO : "nogo", 240 MESSAGETYPE_GATE_SYSTEM : "gateSystem", 241 MESSAGETYPE_ENVIRONMENT : "environment", 242 MESSAGETYPE_HELP : "help", 243 MESSAGETYPE_VISIBILITY : "visibility" } 244 245 def messageType2string(messageType): 246 """Get the string equivalent of the given message type.""" 247 return _messageTypeStrings[messageType] \ 248 if messageType in _messageTypeStrings else None 249 250 #------------------------------------------------------------------------------- 251 252 # Message display level: none 253 MESSAGELEVEL_NONE = 0 254 255 # Message display level: only message in the simulator 256 MESSAGELEVEL_FS = 1 257 258 # Message display level: only sound 259 MESSAGELEVEL_SOUND = 2 260 261 # Message display level: both 262 MESSAGELEVEL_BOTH = 3 263 264 #------------------------------------------------------------------------------- 265 266 messageLevels = [ MESSAGELEVEL_NONE, 267 MESSAGELEVEL_FS, 268 MESSAGELEVEL_SOUND, 269 MESSAGELEVEL_BOTH ] 270 271 #------------------------------------------------------------------------------- 272 273 _messageLevelStrings = { MESSAGELEVEL_NONE : "none", 274 MESSAGELEVEL_FS : "fs", 275 MESSAGELEVEL_SOUND : "sound", 276 MESSAGELEVEL_BOTH : "both" } 277 278 def messageLevel2string(messageLevel): 279 """Get the string equivalent of the given message level.""" 280 return _messageLevelStrings[messageLevel] \ 281 if messageLevel in _messageLevelStrings else None 282 283 def string2messageLevel(str): 284 """Get the message level for the given string.""" 285 for (value, s) in _messageLevelStrings.iteritems(): 286 if str==s: 287 return value 288 return MESSAGELEVEL_NONE 289 290 #------------------------------------------------------------------------------- 291 292 # The available gates at LHBP 293 lhbpGateNumbers = [] 294 295 for i in range(1, 7): 296 lhbpGateNumbers.append(str(i)) 297 298 for i in range(10, 19): 299 lhbpGateNumbers.append(str(i)) 300 301 for i in range(24, 28): 302 lhbpGateNumbers.append(str(i)) 303 304 for i in range(31, 39): 305 lhbpGateNumbers.append(str(i)) 306 307 for i in range(42, 47): 308 lhbpGateNumbers.append(str(i)) 309 310 for i in range(60, 84): 311 if i!=70 and i!=80: 312 lhbpGateNumbers.append(str(i)) 313 314 #------------------------------------------------------------------------------- 315 223 316 languages = ["$system", "en_GB", "hu_HU"] 317 -
src/mlx/gui/common.py
r127 r132 33 33 DIALOG_MODAL = gtk.DIALOG_MODAL 34 34 WRAP_WORD = gtk.WRAP_WORD 35 JUSTIFY_CENTER = gtk.JUSTIFY_CENTER 35 36 36 37 def text2unicode(text): … … 59 60 DIALOG_MODAL = gtk.DialogFlags.MODAL 60 61 WRAP_WORD = gtk.WrapMode.WORD 62 JUSTIFY_CENTER = gtk.Justification.CENTER 61 63 62 64 import codecs -
src/mlx/gui/prefs.py
r131 r132 37 37 notebook.append_page(general, label) 38 38 39 messages = self._buildMessages() 40 label = gtk.Label(xstr("prefs_tab_messages")) 41 label.set_use_underline(True) 42 label.set_tooltip_text(xstr("prefs_tab_message_tooltip")) 43 notebook.append_page(messages, label) 44 39 45 advanced = self._buildAdvanced() 40 46 label = gtk.Label(xstr("prefs_tab_advanced")) … … 62 68 self._setLanguage(config.language) 63 69 self._flareTimeFromFS.set_active(config.flareTimeFromFS) 70 71 for messageType in const.messageTypes: 72 level = config.getMessageTypeLevel(messageType) 73 button = self._msgFSCheckButtons[messageType] 74 button.set_active(level == const.MESSAGELEVEL_FS or 75 level == const.MESSAGELEVEL_BOTH) 76 button = self._msgSoundCheckButtons[messageType] 77 button.set_active(level == const.MESSAGELEVEL_SOUND or 78 level == const.MESSAGELEVEL_BOTH) 64 79 65 80 self._togglingAutoUpdate = True … … 75 90 config.language = self._getLanguage() 76 91 config.flareTimeFromFS = self._flareTimeFromFS.get_active() 92 93 for messageType in const.messageTypes: 94 fsButtonActive = self._msgFSCheckButtons[messageType].get_active() 95 soundButtonActive = self._msgSoundCheckButtons[messageType].get_active() 96 if fsButtonActive: 97 level = const.MESSAGELEVEL_BOTH if soundButtonActive \ 98 else const.MESSAGELEVEL_FS 99 elif soundButtonActive: 100 level = const.MESSAGELEVEL_SOUND 101 else: 102 level = const.MESSAGELEVEL_NONE 103 config.setMessageTypeLevel(messageType, level) 104 77 105 config.autoUpdate = self._autoUpdate.get_active() 78 106 config.updateURL = self._updateURL.get_text() … … 155 183 self._warnedRestartNeeded = True 156 184 185 def _buildMessages(self): 186 """Build the page for the message settings.""" 187 188 mainAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.0, 189 xscale = 0.0, yscale = 0.0) 190 mainAlignment.set_padding(padding_top = 16, padding_bottom = 8, 191 padding_left = 4, padding_right = 4) 192 mainBox = gtk.VBox() 193 mainAlignment.add(mainBox) 194 195 table = gtk.Table(len(const.messageTypes) + 1, 3) 196 table.set_row_spacings(8) 197 table.set_col_spacings(32) 198 table.set_homogeneous(False) 199 mainBox.pack_start(table, False, False, 4) 200 201 label = gtk.Label(xstr("prefs_msgs_fs")) 202 label.set_justify(JUSTIFY_CENTER) 203 label.set_alignment(0.5, 1.0) 204 table.attach(label, 1, 2, 0, 1) 205 206 label = gtk.Label(xstr("prefs_msgs_sound")) 207 label.set_justify(JUSTIFY_CENTER) 208 label.set_alignment(0.5, 1.0) 209 table.attach(label, 2, 3, 0, 1) 210 211 self._msgFSCheckButtons = {} 212 self._msgSoundCheckButtons = {} 213 row = 1 214 for messageType in const.messageTypes: 215 messageTypeStr = const.messageType2string(messageType) 216 label = gtk.Label(xstr("prefs_msgs_type_" + messageTypeStr)) 217 label.set_justify(JUSTIFY_CENTER) 218 label.set_use_underline(True) 219 label.set_alignment(0.5, 0.5) 220 table.attach(label, 0, 1, row, row+1) 221 222 fsCheckButton = gtk.CheckButton() 223 alignment = gtk.Alignment(xscale = 0.0, yscale = 0.0, 224 xalign = 0.5, yalign = 0.5) 225 alignment.add(fsCheckButton) 226 table.attach(alignment, 1, 2, row, row+1) 227 self._msgFSCheckButtons[messageType] = fsCheckButton 228 229 soundCheckButton = gtk.CheckButton() 230 alignment = gtk.Alignment(xscale = 0.0, yscale = 0.0, 231 xalign = 0.5, yalign = 0.5) 232 alignment.add(soundCheckButton) 233 table.attach(alignment, 2, 3, row, row+1) 234 self._msgSoundCheckButtons[messageType] = soundCheckButton 235 236 mnemonicWidget = gtk.Label("") 237 table.attach(mnemonicWidget, 3, 4, row, row+1) 238 label.set_mnemonic_widget(mnemonicWidget) 239 mnemonicWidget.connect("mnemonic-activate", 240 self._msgLabelActivated, 241 messageType) 242 243 row += 1 244 245 return mainAlignment 246 247 def _msgLabelActivated(self, button, cycle_group, messageType): 248 """Called when the mnemonic of a label is activated. 249 250 It cycles the corresponding options.""" 251 fsCheckButton = self._msgFSCheckButtons[messageType] 252 soundCheckButton = self._msgSoundCheckButtons[messageType] 253 254 num = 1 if fsCheckButton.get_active() else 0 255 num += 2 if soundCheckButton.get_active() else 0 256 num += 1 257 258 fsCheckButton.set_active((num&0x01)==0x01) 259 soundCheckButton.set_active((num&0x02)==0x02) 260 261 return True 262 157 263 def _buildAdvanced(self): 158 264 """Build the page for the advanced settings.""" -
src/mlx/i18n.py
r131 r132 543 543 self.add("prefs_tab_general", "_General") 544 544 self.add("prefs_tab_general_tooltip", "General preferences") 545 self.add("prefs_tab_messages", "_Messages") 546 self.add("prefs_tab_message_tooltip", 547 "Enable/disable message notifications in FS and/or by sound") 545 548 self.add("prefs_tab_advanced", "_Advanced") 546 549 self.add("prefs_tab_advanced_tooltip", … … 577 580 "The URL from which to download the updates. Change this " 578 581 "only if you know what you are doing!") 582 583 # A C G M O S 584 585 self.add("prefs_msgs_fs", "Displayed in FS") 586 self.add("prefs_msgs_sound", "Sound alert") 587 self.add("prefs_msgs_type_loggerError", "Logger _Error Messages") 588 self.add("prefs_msgs_type_information", 589 "_Information Messages\n(e.g. flight status)") 590 self.add("prefs_msgs_type_fault", 591 "_Fault Messages\n(e.g. strobe light fault)") 592 self.add("prefs_msgs_type_nogo", 593 "_NOGO Fault messages\n(e.g. MTOW NOGO)") 594 self.add("prefs_msgs_type_gateSystem", 595 "Ga_te System Messages\n(e.g. available gates)") 596 self.add("prefs_msgs_type_environment", 597 "Envi_ronment Messages\n(e.g. \"welcome to XY aiport\")") 598 self.add("prefs_msgs_type_help", 599 "_Help Messages\n(e.g. \"don't forget to set VREF\")") 600 self.add("prefs_msgs_type_visibility", 601 "_Visibility Messages") 579 602 580 603 #------------------------------------------------------------------------------ … … 1014 1037 self.add("prefs_tab_general", "_Általános") 1015 1038 self.add("prefs_tab_general_tooltip", "Általános beállítások") 1016 self.add("prefs_tab_advanced", "_Haladó") 1039 self.add("prefs_tab_messages", "_Üzenetek") 1040 self.add("prefs_tab_message_tooltip", 1041 "A szimulátorba és/vagy hangjelzés általi üzenetküldés be- " 1042 "és kikapcsolása") 1043 self.add("prefs_tab_advanced", "H_aladó") 1017 1044 self.add("prefs_tab_advanced_tooltip", 1018 1045 "Haladó beállítások: óvatosan módosítsd őket!") … … 1049 1076 "változtasd meg, ha biztos vagy a dolgodban!") 1050 1077 1078 # A Á H M O Ü 1079 1080 self.add("prefs_msgs_fs", "Szimulátorban\nmegjelenítés") 1081 self.add("prefs_msgs_sound", "Hangjelzés") 1082 self.add("prefs_msgs_type_loggerError", "_Logger hibaüzenetek") 1083 self.add("prefs_msgs_type_information", 1084 "_Információs üzenetek\n(pl. a repülés fázisa)") 1085 self.add("prefs_msgs_type_fault", 1086 "Hi_baüzenetek\n(pl. a villogó fény hiba)") 1087 self.add("prefs_msgs_type_nogo", 1088 "_NOGO hibaüzenetek\n(pl. MTOW NOGO)") 1089 self.add("prefs_msgs_type_gateSystem", 1090 "_Kapukezelő rendszer üzenetei\n(pl. a szabad kapuk listája)") 1091 self.add("prefs_msgs_type_environment", 1092 "Kö_rnyezeti üzenetek\n(pl. \"welcome to XY aiport\")") 1093 self.add("prefs_msgs_type_help", 1094 "_Segítő üzenetek\n(pl. \"don't forget to set VREF\")") 1095 self.add("prefs_msgs_type_visibility", 1096 "Lá_tótávolság üzenetek") 1097 1051 1098 #------------------------------------------------------------------------------ 1052 1099
Note:
See TracChangeset
for help on using the changeset viewer.