Changeset 226:473bbc9d355f for src
- Timestamp:
- 06/05/12 15:42:34 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/common.py
r225 r226 57 57 58 58 POLICY_AUTOMATIC = gtk.POLICY_AUTOMATIC 59 60 WEIGHT_BOLD = pango.WEIGHT_BOLD 59 61 60 62 def text2unicode(text): … … 105 107 POLICY_AUTOMATIC = gtk.PolicyType.AUTOMATIC 106 108 109 WEIGHT_BOLD = pango.Weight.BOLD 110 107 111 import codecs 108 112 _utf8Decoder = codecs.getdecoder("utf-8") … … 228 232 #------------------------------------------------------------------------------ 229 233 230 def formatFlightLogLine(timeStr, line , isFault = False):234 def formatFlightLogLine(timeStr, line): 231 235 """Format the given flight log line.""" 232 236 """Format the given line for flight logging.""" 233 237 if timeStr is not None: 234 238 line = timeStr + ": " + line 235 #if isFault:236 # line = "<b>" + line + "</b>"237 239 return line + "\n" 238 240 239 241 #------------------------------------------------------------------------------ 242 243 def addFaultTag(buffer): 244 """Add a tag named 'fault' to the given buffer.""" 245 faultTag = gtk.TextTag(name = "fault") 246 faultTag.set_property("foreground", "red") 247 faultTag.set_property("weight", WEIGHT_BOLD) 248 buffer.get_tag_table().add(faultTag) 249 250 #------------------------------------------------------------------------------ 251 252 def appendTextBuffer(buffer, text, isFault = False): 253 """Append the given line at the end of the given text buffer. 254 255 If isFault is set, use the tag named 'fault'.""" 256 if isFault: 257 buffer.insert_with_tags_by_name(buffer.get_end_iter(), text, 258 "fault") 259 else: 260 buffer.insert(buffer.get_end_iter(), text) 261 262 #------------------------------------------------------------------------------ -
src/mlx/gui/gui.py
r225 r226 112 112 113 113 (logWidget, self._logView) = self._buildLogWidget() 114 addFaultTag(self._logView.get_buffer()) 114 115 label = gtk.Label(xstr("tab_log")) 115 116 label.set_use_underline(True) … … 466 467 """Write the given message line to the log.""" 467 468 gobject.idle_add(self._writeLog, 468 formatFlightLogLine(timeStr, line , isFault = isFault),469 self._logView )470 471 def updateFlightLogLine(self, index, timeStr, line , isFault = False):469 formatFlightLogLine(timeStr, line), 470 self._logView, isFault) 471 472 def updateFlightLogLine(self, index, timeStr, line): 472 473 """Update the line with the given index.""" 473 474 gobject.idle_add(self._updateFlightLogLine, index, 474 formatFlightLogLine(timeStr, line, 475 isFault = isFault)) 475 formatFlightLogLine(timeStr, line)) 476 476 477 477 def _updateFlightLogLine(self, index, line): … … 914 914 return (alignment, logView) 915 915 916 def _writeLog(self, msg, logView ):916 def _writeLog(self, msg, logView, isFault = False): 917 917 """Write the given message to the log.""" 918 918 buffer = logView.get_buffer() 919 buffer.insert(buffer.get_end_iter(), msg)919 appendTextBuffer(buffer, msg, isFault = isFault) 920 920 logView.scroll_mark_onscreen(buffer.get_insert()) 921 921 -
src/mlx/gui/pirep.py
r225 r226 239 239 for (timeStr, line) in pirep.logLines: 240 240 isFault = lineIndex in pirep.faultLineIndexes 241 logBuffer.insert(logBuffer.get_end_iter(),242 formatFlightLogLine(timeStr, line ,243 isFault = isFault))241 appendTextBuffer(logBuffer, 242 formatFlightLogLine(timeStr, line), 243 isFault = isFault) 244 244 lineIndex += 1 245 245 … … 573 573 574 574 (logWindow, self._log) = PIREPViewer.getTextWindow(heightRequest = -1) 575 addFaultTag(self._log.get_buffer()) 575 576 mainBox.pack_start(logWindow, True, True, 0) 576 577
Note:
See TracChangeset
for help on using the changeset viewer.