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 = gajim.config.get('gc_nicknames_colors')
|
||||||
colors = colors.split(':')
|
colors = colors.split(':')
|
||||||
for color in xrange(len(colors)):
|
for i,color in enumerate(colors):
|
||||||
tagname = 'gc_nickname_color_' + str(color)
|
tagname = 'gc_nickname_color_' + str(i)
|
||||||
tag = buffer.create_tag(tagname)
|
tag = buffer.create_tag(tagname)
|
||||||
color = colors[color]
|
|
||||||
tag.set_property('foreground', color)
|
tag.set_property('foreground', color)
|
||||||
|
|
||||||
tag = buffer.create_tag('marked')
|
tag = buffer.create_tag('marked')
|
||||||
|
|
|
@ -235,6 +235,12 @@ class GroupchatControl(ChatControlBase):
|
||||||
|
|
||||||
self.tooltip = tooltips.GCTooltip()
|
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
|
# connect the menuitems to their respective functions
|
||||||
xm = gtkgui_helpers.get_glade('gc_control_popup_menu.glade')
|
xm = gtkgui_helpers.get_glade('gc_control_popup_menu.glade')
|
||||||
|
|
||||||
|
@ -652,9 +658,6 @@ class GroupchatControl(ChatControlBase):
|
||||||
fin = True
|
fin = True
|
||||||
return None
|
return None
|
||||||
|
|
||||||
gc_count_nicknames_colors = 0
|
|
||||||
gc_custom_colors = {}
|
|
||||||
|
|
||||||
def print_old_conversation(self, text, contact = '', tim = None,
|
def print_old_conversation(self, text, contact = '', tim = None,
|
||||||
xhtml = None):
|
xhtml = None):
|
||||||
if isinstance(text, str):
|
if isinstance(text, str):
|
||||||
|
@ -705,9 +708,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
str(self.gc_custom_colors[contact]))
|
str(self.gc_custom_colors[contact]))
|
||||||
else:
|
else:
|
||||||
self.gc_count_nicknames_colors += 1
|
self.gc_count_nicknames_colors += 1
|
||||||
number_of_colors = len(gajim.config.get('gc_nicknames_colors').\
|
if self.gc_count_nicknames_colors == self.number_of_colors:
|
||||||
split(':'))
|
|
||||||
if self.gc_count_nicknames_colors == number_of_colors:
|
|
||||||
self.gc_count_nicknames_colors = 0
|
self.gc_count_nicknames_colors = 0
|
||||||
self.gc_custom_colors[contact] = \
|
self.gc_custom_colors[contact] = \
|
||||||
self.gc_count_nicknames_colors
|
self.gc_count_nicknames_colors
|
||||||
|
|
Loading…
Add table
Reference in a new issue