Kill risk of double color usage when color pool is not exhausted.
Make code a bit more pythonic.
This commit is contained in:
parent
0bfe53c158
commit
1b5b9138a4
2 changed files with 9 additions and 9 deletions
|
@ -213,10 +213,9 @@ class ConversationTextview:
|
|||
|
||||
colors = gajim.config.get('gc_nicknames_colors')
|
||||
colors = colors.split(':')
|
||||
for color in xrange(len(colors)):
|
||||
tagname = 'gc_nickname_color_' + str(color)
|
||||
for i,color in enumerate(colors):
|
||||
tagname = 'gc_nickname_color_' + str(i)
|
||||
tag = buffer.create_tag(tagname)
|
||||
color = colors[color]
|
||||
tag.set_property('foreground', color)
|
||||
|
||||
tag = buffer.create_tag('marked')
|
||||
|
|
|
@ -235,6 +235,12 @@ class GroupchatControl(ChatControlBase):
|
|||
|
||||
self.tooltip = tooltips.GCTooltip()
|
||||
|
||||
# nickname coloring
|
||||
self.gc_count_nicknames_colors = 0
|
||||
self.gc_custom_colors = {}
|
||||
self.number_of_colors = len(gajim.config.get('gc_nicknames_colors').\
|
||||
split(':'))
|
||||
|
||||
# connect the menuitems to their respective functions
|
||||
xm = gtkgui_helpers.get_glade('gc_control_popup_menu.glade')
|
||||
|
||||
|
@ -652,9 +658,6 @@ class GroupchatControl(ChatControlBase):
|
|||
fin = True
|
||||
return None
|
||||
|
||||
gc_count_nicknames_colors = 0
|
||||
gc_custom_colors = {}
|
||||
|
||||
def print_old_conversation(self, text, contact = '', tim = None,
|
||||
xhtml = None):
|
||||
if isinstance(text, str):
|
||||
|
@ -705,9 +708,7 @@ class GroupchatControl(ChatControlBase):
|
|||
str(self.gc_custom_colors[contact]))
|
||||
else:
|
||||
self.gc_count_nicknames_colors += 1
|
||||
number_of_colors = len(gajim.config.get('gc_nicknames_colors').\
|
||||
split(':'))
|
||||
if self.gc_count_nicknames_colors == number_of_colors:
|
||||
if self.gc_count_nicknames_colors == self.number_of_colors:
|
||||
self.gc_count_nicknames_colors = 0
|
||||
self.gc_custom_colors[contact] = \
|
||||
self.gc_count_nicknames_colors
|
||||
|
|
Loading…
Add table
Reference in a new issue