Changeset 362:f57c0009eddc


Ignore:
Timestamp:
12/14/12 19:20:26 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Fixed the handling of the tags in the log buffers

File:
1 edited

Legend:

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

    r345 r362  
    7474    POLICY_AUTOMATIC = gtk.POLICY_AUTOMATIC
    7575
     76    WEIGHT_NORMAL = pango.WEIGHT_NORMAL
    7677    WEIGHT_BOLD = pango.WEIGHT_BOLD
    7778
     
    138139    POLICY_AUTOMATIC = gtk.PolicyType.AUTOMATIC
    139140
     141    WEIGHT_NORMAL = pango.Weight.NORMAL
    140142    WEIGHT_BOLD = pango.Weight.BOLD
    141143
     
    294296def addFaultTag(buffer):
    295297    """Add a tag named 'fault' to the given buffer."""
    296     faultTag = gtk.TextTag(name = "fault")
    297     faultTag.set_property("foreground", "red")
    298     faultTag.set_property("weight", WEIGHT_BOLD)
    299     buffer.get_tag_table().add(faultTag)
     298    buffer.create_tag("fault", foreground="red", weight=WEIGHT_BOLD)
    300299
    301300#------------------------------------------------------------------------------
     
    312311    """Insert the given line into the given text buffer at the given iterator.
    313312
    314     If isFault is set, use the tag named 'fault'."""
     313    If isFault is set, use the tag named 'fault' else use the tag named
     314    'normal'."""
     315    line = iter.get_line()
     316
     317    buffer.insert(iter, text)
     318
     319    iter0 = buffer.get_iter_at_line(line)
     320    iter1 = buffer.get_iter_at_line(line+1)
    315321    if isFault:
    316         buffer.insert_with_tags_by_name(iter, text, "fault")
     322        buffer.apply_tag_by_name("fault", iter0, iter1)
    317323    else:
    318         buffer.insert(iter, text)
    319 
    320 #------------------------------------------------------------------------------
     324        buffer.remove_all_tags(iter0, iter1)
     325
     326#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.