Philipp Hörist pushed to branch master at gajim / gajim
Commits: fa65653a by Philipp Hörist at 2018-09-19T20:22:52Z ConvTextview: Rework display of encryption
- - - - - 94b17b1f by Philipp Hörist at 2018-09-19T20:22:52Z Fix colors and icons
- - - - - 0a66b6d9 by Philipp Hörist at 2018-09-19T20:22:52Z remove icon
- - - - -
5 changed files:
- gajim/chat_control_base.py - gajim/conversation_textview.py - − gajim/data/icons/hicolor/16x16/status/channel-secure-croped-symbolic.symbolic.png - gajim/data/style/gajim.css - gajim/gtk/history.py
Changes:
===================================== gajim/chat_control_base.py ===================================== @@ -338,6 +338,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self._schedule_activity_timers()
self.encryption = self.get_encryption_state() + self.conv_textview.encryption_enabled = self.encryption is not None
# PluginSystem: adding GUI extension point for ChatControlBase # instance object (also subclasses, eg. ChatControl or GroupchatControl) @@ -429,8 +430,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): def set_encryption_state(self, encryption): config_key = '%s-%s' % (self.account, self.contact.jid) self.encryption = encryption + self.conv_textview.encryption_enabled = encryption is not None app.config.set_per('encryption', config_key, - 'encryption', self.encryption or '') + 'encryption', self.encryption or '')
def get_encryption_state(self): config_key = '%s-%s' % (self.account, self.contact.jid)
===================================== gajim/conversation_textview.py ===================================== @@ -186,6 +186,7 @@ class ConversationTextview(GObject.GObject): self.tv.set_wrap_mode(Gtk.WrapMode.WORD_CHAR) self.tv.set_left_margin(2) self.tv.set_right_margin(2) + self._buffer = self.tv.get_buffer() self.handlers = {} self.image_cache = {} self.xep0184_marks = {} @@ -204,6 +205,7 @@ class ConversationTextview(GObject.GObject): self.account = account self.cursor_changed = False self.last_time_printout = 0 + self.encryption_enabled = False
style = self.tv.get_style_context() style.add_class('gajim-conversation-font') @@ -261,6 +263,9 @@ class ConversationTextview(GObject.GObject): self.tagMarked.set_property('foreground', color) self.tagMarked.set_property('weight', Pango.Weight.BOLD)
+ textview_icon = buffer_.create_tag('textview-icon') + textview_icon.set_property('rise', Pango.units_from_double(-4.45)) + tag = buffer_.create_tag('time_sometimes') tag.set_property('foreground', 'darkgrey') #Pango.SCALE_SMALL @@ -1147,14 +1152,13 @@ class ConversationTextview(GObject.GObject): if kind == 'status': direction_mark = i18n.direction_mark
+ # print the encryption icon + self.print_encryption_status(iter_, additional_data) + # print the time stamp self.print_time(text, kind, tim, simple, direction_mark, other_tags_for_time, iter_)
- icon = load_icon('channel-secure-croped-symbolic', self.tv, pixbuf=True) - if encrypted: - buffer_.insert_pixbuf(iter_, icon) - # If there's a displaymarking, print it here. if displaymarking: self.print_displaymarking(displaymarking, iter_=iter_) @@ -1275,6 +1279,52 @@ class ConversationTextview(GObject.GObject): if text.startswith('/me ') or text.startswith('/me\n'): return kind
+ def print_encryption_status(self, iter_, additional_data): + details = self._get_encryption_details(additional_data) + if details is None: + # Message was not encrypted + if not self.encryption_enabled: + return + icon = 'channel-insecure-symbolic' + color = 'unencrypted-color' + tooltip = _('Not encrypted') + else: + icon = 'channel-secure-symbolic' + color = 'encrypted-color' + name, fingerprint = details + if fingerprint is None: + tooltip = name + else: + tooltip = '%s %s' % (name, fingerprint) + + temp_mark = self._buffer.create_mark(None, iter_, True) + self._buffer.insert(iter_, ' ') + anchor = self._buffer.create_child_anchor(iter_) + anchor.plaintext = '' + self._buffer.insert(iter_, ' ') + + # Apply mark to vertically center the icon + start = self._buffer.get_iter_at_mark(temp_mark) + self._buffer.apply_tag_by_name('textview-icon', start, iter_) + + image = Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.MENU) + image.show() + image.set_tooltip_text(tooltip) + image.get_style_context().add_class(color) + self.tv.add_child_at_anchor(image, anchor) + + @staticmethod + def _get_encryption_details(additional_data): + encrypted = additional_data.get('encrypted') + if encrypted is None: + return + + name = encrypted.get('name') + if name is None: + return + fingerprint = encrypted.get('fingerprint') + return name, fingerprint + def print_time(self, text, kind, tim, simple, direction_mark, other_tags_for_time, iter_): local_tim = time.localtime(tim) buffer_ = self.tv.get_buffer()
===================================== gajim/data/icons/hicolor/16x16/status/channel-secure-croped-symbolic.symbolic.png deleted ===================================== Binary files a/gajim/data/icons/hicolor/16x16/status/channel-secure-croped-symbolic.symbolic.png and /dev/null differ
===================================== gajim/data/style/gajim.css ===================================== @@ -215,6 +215,10 @@ button.flat.link { padding: 0; border: 0; } .error-color { color: @error_color; } .warning-color { color: @warning_color; }
+/*Encryption*/ +.encrypted-color { color: rgb(75, 181, 67) } +.unencrypted-color { color: @error_color } + /*Dataforms*/ .field-fixed { font-size: 16px; font-weight: bold; padding-top:5px;} .data-form-title { font-size: 16px; font-weight: bold; }
===================================== gajim/gtk/history.py ===================================== @@ -534,6 +534,10 @@ class HistoryWindow: buf.insert_with_tags_by_name( end_iter, tim + '\n', 'time_sometimes')
+ # print the encryption icon + self.history_textview.print_encryption_status( + end_iter, additional_data) + tag_name = '' tag_msg = ''
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/cb692ae4ebc7935e75e17255d7b5935bf3...