Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
4b3a5b77
by Philipp Hörist at 2019-03-12T17:44:20Z
4 changed files:
- gajim/command_system/implementation/standard.py
- gajim/common/config.py
- gajim/conversation_textview.py
- gajim/groupchat_control.py
Changes:
| ... | ... | @@ -250,8 +250,6 @@ class StandardGroupChatCommands(CommandContainer): |
| 250 | 250 |
@doc(_("Clear the text window"))
|
| 251 | 251 |
def clear(self):
|
| 252 | 252 |
self.conv_textview.clear()
|
| 253 |
- self.gc_count_nicknames_colors = -1
|
|
| 254 |
- self.gc_custom_colors = {}
|
|
| 255 | 253 |
|
| 256 | 254 |
@command(raw=True)
|
| 257 | 255 |
@doc(_("Change your nickname in a group chat"))
|
| ... | ... | @@ -253,7 +253,6 @@ class Config: |
| 253 | 253 |
'hide_groupchat_occupants_list': [opt_bool, False, _('Hides the group chat occupants list in group chat window.')],
|
| 254 | 254 |
'chat_merge_consecutive_nickname': [opt_bool, False, _('In a chat, show the nickname at the beginning of a line only when it\'s not the same person talking than in previous message.')],
|
| 255 | 255 |
'chat_merge_consecutive_nickname_indent': [opt_str, ' ', _('Indentation when using merge consecutive nickname.')],
|
| 256 |
- 'gc_nicknames_colors': [opt_str, '#4e9a06:#f57900:#ce5c00:#3465a4:#204a87:#75507b:#5c3566:#c17d11:#8f5902:#ef2929:#cc0000:#a40000', _('List of colors, separated by ":", that will be used to color nicknames in group chats.'), True],
|
|
| 257 | 256 |
'ctrl_tab_go_to_next_composing': [opt_bool, True, _('Ctrl-Tab go to next composing tab when none is unread.')],
|
| 258 | 257 |
'confirm_metacontacts': [opt_str, '', _('Show the confirm metacontacts creation dialog or not? Empty string means never show the dialog.')],
|
| 259 | 258 |
'confirm_block': [opt_str, '', _('Show the confirm block contact dialog or not? Empty string means never show the dialog.')],
|
| ... | ... | @@ -34,6 +34,9 @@ from gi.repository import Gtk |
| 34 | 34 |
from gi.repository import Pango
|
| 35 | 35 |
from gi.repository import GObject
|
| 36 | 36 |
from gi.repository import GLib
|
| 37 |
+from gi.repository import Gdk
|
|
| 38 |
+ |
|
| 39 |
+from nbxmpp.util import text_to_colour
|
|
| 37 | 40 |
|
| 38 | 41 |
from gajim.common import app
|
| 39 | 42 |
from gajim.common import helpers
|
| ... | ... | @@ -43,14 +46,13 @@ from gajim.common.helpers import AdditionalDataDict |
| 43 | 46 |
from gajim.common.fuzzyclock import FuzzyClock
|
| 44 | 47 |
from gajim.common.const import StyleAttr
|
| 45 | 48 |
|
| 46 |
-from gajim.gtk.htmltextview import HtmlTextView
|
|
| 47 |
- |
|
| 48 | 49 |
from gajim.gtk import util
|
| 49 | 50 |
from gajim.gtk.util import load_icon
|
| 50 | 51 |
from gajim.gtk.util import get_cursor
|
| 51 | 52 |
from gajim.gtk.emoji_data import emoji_pixbufs
|
| 52 | 53 |
from gajim.gtk.emoji_data import is_emoji
|
| 53 | 54 |
from gajim.gtk.emoji_data import get_emoji_pixbuf
|
| 55 |
+from gajim.gtk.htmltextview import HtmlTextView
|
|
| 54 | 56 |
|
| 55 | 57 |
NOT_SHOWN = 0
|
| 56 | 58 |
ALREADY_RECEIVED = 1
|
| ... | ... | @@ -247,13 +249,6 @@ class ConversationTextview(GObject.GObject): |
| 247 | 249 |
desc = app.css_config.get_font('.gajim-outgoing-message-text')
|
| 248 | 250 |
self.tagOutText.set_property('font-desc', desc)
|
| 249 | 251 |
|
| 250 |
- colors = app.config.get('gc_nicknames_colors')
|
|
| 251 |
- colors = colors.split(':')
|
|
| 252 |
- for i, color in enumerate(colors):
|
|
| 253 |
- tagname = 'gc_nickname_color_' + str(i)
|
|
| 254 |
- tag = buffer_.create_tag(tagname)
|
|
| 255 |
- tag.set_property('foreground', color)
|
|
| 256 |
- |
|
| 257 | 252 |
self.tagMarked = buffer_.create_tag('marked')
|
| 258 | 253 |
color = app.css_config.get_value(
|
| 259 | 254 |
'.gajim-highlight-message', StyleAttr.COLOR)
|
| ... | ... | @@ -1223,6 +1218,11 @@ class ConversationTextview(GObject.GObject): |
| 1223 | 1218 |
if other_tags_for_name:
|
| 1224 | 1219 |
name_tags = other_tags_for_name[:] # create a new list
|
| 1225 | 1220 |
name_tags.append(kind)
|
| 1221 |
+ |
|
| 1222 |
+ for tag in name_tags:
|
|
| 1223 |
+ if tag.startswith('muc_nickname_color_'):
|
|
| 1224 |
+ self._add_new_colour_tags(tag, name)
|
|
| 1225 |
+ |
|
| 1226 | 1226 |
before_str = app.config.get('before_nickname')
|
| 1227 | 1227 |
before_str = helpers.from_one_line(before_str)
|
| 1228 | 1228 |
after_str = app.config.get('after_nickname')
|
| ... | ... | @@ -1230,6 +1230,12 @@ class ConversationTextview(GObject.GObject): |
| 1230 | 1230 |
format_ = before_str + name + direction_mark + after_str + ' '
|
| 1231 | 1231 |
buffer_.insert_with_tags_by_name(end_iter, format_, *name_tags)
|
| 1232 | 1232 |
|
| 1233 |
+ def _add_new_colour_tags(self, tag, name):
|
|
| 1234 |
+ if self._buffer.get_tag_table().lookup(tag) is not None:
|
|
| 1235 |
+ return
|
|
| 1236 |
+ gdk_color = Gdk.Color.from_floats(*text_to_colour(name))
|
|
| 1237 |
+ self._buffer.create_tag(tag, foreground_gdk=gdk_color)
|
|
| 1238 |
+ |
|
| 1233 | 1239 |
def print_subject(self, subject, iter_=None):
|
| 1234 | 1240 |
if subject: # if we have subject, show it too!
|
| 1235 | 1241 |
subject = _('Subject: %s\n') % subject
|
| ... | ... | @@ -193,12 +193,6 @@ class GroupchatControl(ChatControlBase): |
| 193 | 193 |
|
| 194 | 194 |
self.subject = ''
|
| 195 | 195 |
|
| 196 |
- # nickname coloring
|
|
| 197 |
- self.gc_count_nicknames_colors = -1
|
|
| 198 |
- self.gc_custom_colors = {}
|
|
| 199 |
- self.number_of_colors = len(app.config.get('gc_nicknames_colors').\
|
|
| 200 |
- split(':'))
|
|
| 201 |
- |
|
| 202 | 196 |
self.name_label = self.xml.get_object('banner_name_label')
|
| 203 | 197 |
self.event_box = self.xml.get_object('banner_eventbox')
|
| 204 | 198 |
|
| ... | ... | @@ -1347,17 +1341,7 @@ class GroupchatControl(ChatControlBase): |
| 1347 | 1341 |
if kind == 'incoming': # it's a message NOT from us
|
| 1348 | 1342 |
# highlighting and sounds
|
| 1349 | 1343 |
highlight, _sound = self.highlighting_for_message(text, tim)
|
| 1350 |
- if contact in self.gc_custom_colors:
|
|
| 1351 |
- other_tags_for_name.append('gc_nickname_color_' + \
|
|
| 1352 |
- str(self.gc_custom_colors[contact]))
|
|
| 1353 |
- else:
|
|
| 1354 |
- self.gc_count_nicknames_colors += 1
|
|
| 1355 |
- if self.gc_count_nicknames_colors == self.number_of_colors:
|
|
| 1356 |
- self.gc_count_nicknames_colors = 0
|
|
| 1357 |
- self.gc_custom_colors[contact] = \
|
|
| 1358 |
- self.gc_count_nicknames_colors
|
|
| 1359 |
- other_tags_for_name.append('gc_nickname_color_' + \
|
|
| 1360 |
- str(self.gc_count_nicknames_colors))
|
|
| 1344 |
+ other_tags_for_name.append('muc_nickname_color_%s' % contact)
|
|
| 1361 | 1345 |
if highlight:
|
| 1362 | 1346 |
# muc-specific chatstate
|
| 1363 | 1347 |
if self.parent_win:
|
| ... | ... | @@ -1369,10 +1353,6 @@ class GroupchatControl(ChatControlBase): |
| 1369 | 1353 |
|
| 1370 | 1354 |
self._nick_completion.record_message(contact, highlight)
|
| 1371 | 1355 |
|
| 1372 |
- if text.startswith('/me ') or text.startswith('/me\n'):
|
|
| 1373 |
- other_tags_for_text.append('gc_nickname_color_' + \
|
|
| 1374 |
- str(self.gc_custom_colors[contact]))
|
|
| 1375 |
- |
|
| 1376 | 1356 |
self.check_and_possibly_add_focus_out_line()
|
| 1377 | 1357 |
|
| 1378 | 1358 |
ChatControlBase.print_conversation_line(self, text, kind, contact, tim,
|
| ... | ... | @@ -1858,10 +1838,6 @@ class GroupchatControl(ChatControlBase): |
| 1858 | 1838 |
tv.last_received_message_id[nick]
|
| 1859 | 1839 |
del tv.last_received_message_id[nick]
|
| 1860 | 1840 |
|
| 1861 |
- # keep nickname color
|
|
| 1862 |
- if nick in self.gc_custom_colors:
|
|
| 1863 |
- self.gc_custom_colors[new_nick] = self.gc_custom_colors[nick]
|
|
| 1864 |
- |
|
| 1865 | 1841 |
self.remove_contact(nick)
|
| 1866 | 1842 |
self.add_contact_to_roster(new_nick)
|
| 1867 | 1843 |
|