Ignore:
Timestamp:
06/05/12 15:42:34 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Faults are logged highlighted

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/common.py

    r225 r226  
    5757
    5858    POLICY_AUTOMATIC = gtk.POLICY_AUTOMATIC
     59
     60    WEIGHT_BOLD = pango.WEIGHT_BOLD
    5961
    6062    def text2unicode(text):
     
    105107    POLICY_AUTOMATIC = gtk.PolicyType.AUTOMATIC
    106108
     109    WEIGHT_BOLD = pango.Weight.BOLD
     110
    107111    import codecs
    108112    _utf8Decoder = codecs.getdecoder("utf-8")
     
    228232#------------------------------------------------------------------------------
    229233
    230 def formatFlightLogLine(timeStr, line, isFault = False):
     234def formatFlightLogLine(timeStr, line):
    231235    """Format the given flight log line."""
    232236    """Format the given line for flight logging."""
    233237    if timeStr is not None:
    234238        line = timeStr + ": " + line
    235     #if isFault:
    236     #    line = "<b>" + line + "</b>"
    237239    return line + "\n"
    238240
    239241#------------------------------------------------------------------------------
     242
     243def 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
     252def 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#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.