Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
fa65653a
by Philipp Hörist at 2018-09-19T20:22:52Z
-
94b17b1f
by Philipp Hörist at 2018-09-19T20:22:52Z
-
0a66b6d9
by Philipp Hörist at 2018-09-19T20:22:52Z
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:
| ... | ... | @@ -338,6 +338,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 338 | 338 |
self._schedule_activity_timers()
|
| 339 | 339 |
|
| 340 | 340 |
self.encryption = self.get_encryption_state()
|
| 341 |
+ self.conv_textview.encryption_enabled = self.encryption is not None
|
|
| 341 | 342 |
|
| 342 | 343 |
# PluginSystem: adding GUI extension point for ChatControlBase
|
| 343 | 344 |
# instance object (also subclasses, eg. ChatControl or GroupchatControl)
|
| ... | ... | @@ -429,8 +430,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 429 | 430 |
def set_encryption_state(self, encryption):
|
| 430 | 431 |
config_key = '%s-%s' % (self.account, self.contact.jid)
|
| 431 | 432 |
self.encryption = encryption
|
| 433 |
+ self.conv_textview.encryption_enabled = encryption is not None
|
|
| 432 | 434 |
app.config.set_per('encryption', config_key,
|
| 433 |
- 'encryption', self.encryption or '')
|
|
| 435 |
+ 'encryption', self.encryption or '')
|
|
| 434 | 436 |
|
| 435 | 437 |
def get_encryption_state(self):
|
| 436 | 438 |
config_key = '%s-%s' % (self.account, self.contact.jid)
|
| ... | ... | @@ -186,6 +186,7 @@ class ConversationTextview(GObject.GObject): |
| 186 | 186 |
self.tv.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
|
| 187 | 187 |
self.tv.set_left_margin(2)
|
| 188 | 188 |
self.tv.set_right_margin(2)
|
| 189 |
+ self._buffer = self.tv.get_buffer()
|
|
| 189 | 190 |
self.handlers = {}
|
| 190 | 191 |
self.image_cache = {}
|
| 191 | 192 |
self.xep0184_marks = {}
|
| ... | ... | @@ -204,6 +205,7 @@ class ConversationTextview(GObject.GObject): |
| 204 | 205 |
self.account = account
|
| 205 | 206 |
self.cursor_changed = False
|
| 206 | 207 |
self.last_time_printout = 0
|
| 208 |
+ self.encryption_enabled = False
|
|
| 207 | 209 |
|
| 208 | 210 |
style = self.tv.get_style_context()
|
| 209 | 211 |
style.add_class('gajim-conversation-font')
|
| ... | ... | @@ -261,6 +263,9 @@ class ConversationTextview(GObject.GObject): |
| 261 | 263 |
self.tagMarked.set_property('foreground', color)
|
| 262 | 264 |
self.tagMarked.set_property('weight', Pango.Weight.BOLD)
|
| 263 | 265 |
|
| 266 |
+ textview_icon = buffer_.create_tag('textview-icon')
|
|
| 267 |
+ textview_icon.set_property('rise', Pango.units_from_double(-4.45))
|
|
| 268 |
+ |
|
| 264 | 269 |
tag = buffer_.create_tag('time_sometimes')
|
| 265 | 270 |
tag.set_property('foreground', 'darkgrey')
|
| 266 | 271 |
#Pango.SCALE_SMALL
|
| ... | ... | @@ -1147,14 +1152,13 @@ class ConversationTextview(GObject.GObject): |
| 1147 | 1152 |
if kind == 'status':
|
| 1148 | 1153 |
direction_mark = i18n.direction_mark
|
| 1149 | 1154 |
|
| 1155 |
+ # print the encryption icon
|
|
| 1156 |
+ self.print_encryption_status(iter_, additional_data)
|
|
| 1157 |
+ |
|
| 1150 | 1158 |
# print the time stamp
|
| 1151 | 1159 |
self.print_time(text, kind, tim, simple, direction_mark,
|
| 1152 | 1160 |
other_tags_for_time, iter_)
|
| 1153 | 1161 |
|
| 1154 |
- icon = load_icon('channel-secure-croped-symbolic', self.tv, pixbuf=True)
|
|
| 1155 |
- if encrypted:
|
|
| 1156 |
- buffer_.insert_pixbuf(iter_, icon)
|
|
| 1157 |
- |
|
| 1158 | 1162 |
# If there's a displaymarking, print it here.
|
| 1159 | 1163 |
if displaymarking:
|
| 1160 | 1164 |
self.print_displaymarking(displaymarking, iter_=iter_)
|
| ... | ... | @@ -1275,6 +1279,52 @@ class ConversationTextview(GObject.GObject): |
| 1275 | 1279 |
if text.startswith('/me ') or text.startswith('/me\n'):
|
| 1276 | 1280 |
return kind
|
| 1277 | 1281 |
|
| 1282 |
+ def print_encryption_status(self, iter_, additional_data):
|
|
| 1283 |
+ details = self._get_encryption_details(additional_data)
|
|
| 1284 |
+ if details is None:
|
|
| 1285 |
+ # Message was not encrypted
|
|
| 1286 |
+ if not self.encryption_enabled:
|
|
| 1287 |
+ return
|
|
| 1288 |
+ icon = 'channel-insecure-symbolic'
|
|
| 1289 |
+ color = 'unencrypted-color'
|
|
| 1290 |
+ tooltip = _('Not encrypted')
|
|
| 1291 |
+ else:
|
|
| 1292 |
+ icon = 'channel-secure-symbolic'
|
|
| 1293 |
+ color = 'encrypted-color'
|
|
| 1294 |
+ name, fingerprint = details
|
|
| 1295 |
+ if fingerprint is None:
|
|
| 1296 |
+ tooltip = name
|
|
| 1297 |
+ else:
|
|
| 1298 |
+ tooltip = '%s %s' % (name, fingerprint)
|
|
| 1299 |
+ |
|
| 1300 |
+ temp_mark = self._buffer.create_mark(None, iter_, True)
|
|
| 1301 |
+ self._buffer.insert(iter_, ' ')
|
|
| 1302 |
+ anchor = self._buffer.create_child_anchor(iter_)
|
|
| 1303 |
+ anchor.plaintext = ''
|
|
| 1304 |
+ self._buffer.insert(iter_, ' ')
|
|
| 1305 |
+ |
|
| 1306 |
+ # Apply mark to vertically center the icon
|
|
| 1307 |
+ start = self._buffer.get_iter_at_mark(temp_mark)
|
|
| 1308 |
+ self._buffer.apply_tag_by_name('textview-icon', start, iter_)
|
|
| 1309 |
+ |
|
| 1310 |
+ image = Gtk.Image.new_from_icon_name(icon, Gtk.IconSize.MENU)
|
|
| 1311 |
+ image.show()
|
|
| 1312 |
+ image.set_tooltip_text(tooltip)
|
|
| 1313 |
+ image.get_style_context().add_class(color)
|
|
| 1314 |
+ self.tv.add_child_at_anchor(image, anchor)
|
|
| 1315 |
+ |
|
| 1316 |
+ @staticmethod
|
|
| 1317 |
+ def _get_encryption_details(additional_data):
|
|
| 1318 |
+ encrypted = additional_data.get('encrypted')
|
|
| 1319 |
+ if encrypted is None:
|
|
| 1320 |
+ return
|
|
| 1321 |
+ |
|
| 1322 |
+ name = encrypted.get('name')
|
|
| 1323 |
+ if name is None:
|
|
| 1324 |
+ return
|
|
| 1325 |
+ fingerprint = encrypted.get('fingerprint')
|
|
| 1326 |
+ return name, fingerprint
|
|
| 1327 |
+ |
|
| 1278 | 1328 |
def print_time(self, text, kind, tim, simple, direction_mark, other_tags_for_time, iter_):
|
| 1279 | 1329 |
local_tim = time.localtime(tim)
|
| 1280 | 1330 |
buffer_ = self.tv.get_buffer()
|
No preview for this file type
| ... | ... | @@ -215,6 +215,10 @@ button.flat.link { padding: 0; border: 0; } |
| 215 | 215 |
.error-color { color: @error_color; }
|
| 216 | 216 |
.warning-color { color: @warning_color; }
|
| 217 | 217 |
|
| 218 |
+/*Encryption*/
|
|
| 219 |
+.encrypted-color { color: rgb(75, 181, 67) }
|
|
| 220 |
+.unencrypted-color { color: @error_color }
|
|
| 221 |
+ |
|
| 218 | 222 |
/*Dataforms*/
|
| 219 | 223 |
.field-fixed { font-size: 16px; font-weight: bold; padding-top:5px;}
|
| 220 | 224 |
.data-form-title { font-size: 16px; font-weight: bold; }
|
| ... | ... | @@ -534,6 +534,10 @@ class HistoryWindow: |
| 534 | 534 |
buf.insert_with_tags_by_name(
|
| 535 | 535 |
end_iter, tim + '\n', 'time_sometimes')
|
| 536 | 536 |
|
| 537 |
+ # print the encryption icon
|
|
| 538 |
+ self.history_textview.print_encryption_status(
|
|
| 539 |
+ end_iter, additional_data)
|
|
| 540 |
+ |
|
| 537 | 541 |
tag_name = ''
|
| 538 | 542 |
tag_msg = ''
|
| 539 | 543 |
|