Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
9dc389cc
by Philipp Hörist at 2017-06-13T00:02:44+02:00
4 changed files:
Changes:
| ... | ... | @@ -287,6 +287,7 @@ class ChatControl(ChatControlBase): |
| 287 | 287 |
self.encryption_menu = self.xml.get_object('encryption_menu')
|
| 288 | 288 |
self.encryption_menu.set_menu_model(
|
| 289 | 289 |
gui_menu_builder.get_encryption_menu(self.contact, self.type_id))
|
| 290 |
+ self.set_encryption_menu_icon()
|
|
| 290 | 291 |
# restore previous conversation
|
| 291 | 292 |
self.restore_conversation()
|
| 292 | 293 |
self.msg_textview.grab_focus()
|
| ... | ... | @@ -36,6 +36,7 @@ from gi.repository import GObject |
| 36 | 36 |
from gi.repository import GLib
|
| 37 | 37 |
from gi.repository import Gio
|
| 38 | 38 |
import gtkgui_helpers
|
| 39 |
+from gtkgui_helpers import Color
|
|
| 39 | 40 |
import message_control
|
| 40 | 41 |
import dialogs
|
| 41 | 42 |
import history_window
|
| ... | ... | @@ -442,6 +443,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 442 | 443 |
self.terminate_esessions()
|
| 443 | 444 |
action.set_state(param)
|
| 444 | 445 |
self.set_encryption_state(encryption)
|
| 446 |
+ self.set_encryption_menu_icon()
|
|
| 445 | 447 |
self.set_lock_image()
|
| 446 | 448 |
|
| 447 | 449 |
def set_encryption_state(self, encryption):
|
| ... | ... | @@ -455,6 +457,19 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): |
| 455 | 457 |
state = gajim.config.get_per('encryption', config_key, 'encryption')
|
| 456 | 458 |
return state or None
|
| 457 | 459 |
|
| 460 |
+ def set_encryption_menu_icon(self):
|
|
| 461 |
+ for child in self.encryption_menu.get_children():
|
|
| 462 |
+ if isinstance(child, Gtk.Image):
|
|
| 463 |
+ image = child
|
|
| 464 |
+ break
|
|
| 465 |
+ |
|
| 466 |
+ if not self.encryption:
|
|
| 467 |
+ icon = gtkgui_helpers.get_icon_pixmap(
|
|
| 468 |
+ 'channel-insecure-symbolic', color=[Color.BLACK])
|
|
| 469 |
+ else:
|
|
| 470 |
+ icon = gtkgui_helpers.get_icon_pixmap('channel-secure-symbolic')
|
|
| 471 |
+ image.set_from_pixbuf(icon)
|
|
| 472 |
+ |
|
| 458 | 473 |
def set_speller(self):
|
| 459 | 474 |
# now set the one the user selected
|
| 460 | 475 |
per_type = 'contacts'
|
| ... | ... | @@ -493,6 +493,7 @@ class GroupchatControl(ChatControlBase): |
| 493 | 493 |
self.encryption_menu = self.xml.get_object('encryption_menu')
|
| 494 | 494 |
self.encryption_menu.set_menu_model(
|
| 495 | 495 |
gui_menu_builder.get_encryption_menu(self.contact, self.type_id))
|
| 496 |
+ self.set_encryption_menu_icon()
|
|
| 496 | 497 |
|
| 497 | 498 |
gajim.ged.register_event_handler('gc-presence-received', ged.GUI1,
|
| 498 | 499 |
self._nec_gc_presence_received)
|
| ... | ... | @@ -53,9 +53,16 @@ from common import configpaths |
| 53 | 53 |
gtk_icon_theme = Gtk.IconTheme.get_default()
|
| 54 | 54 |
gtk_icon_theme.append_search_path(gajim.ICONS_DIR)
|
| 55 | 55 |
|
| 56 |
-def get_icon_pixmap(icon_name, size=16, quiet=False):
|
|
| 56 |
+class Color:
|
|
| 57 |
+ BLACK = Gdk.RGBA(red=0, green=0, blue=0, alpha=1)
|
|
| 58 |
+ |
|
| 59 |
+def get_icon_pixmap(icon_name, size=16, color=None, quiet=False):
|
|
| 57 | 60 |
try:
|
| 58 |
- return gtk_icon_theme.load_icon(icon_name, size, 0)
|
|
| 61 |
+ iconinfo = gtk_icon_theme.lookup_icon(icon_name, size, 0)
|
|
| 62 |
+ if color:
|
|
| 63 |
+ pixbuf, was_symbolic = iconinfo.load_symbolic(*color)
|
|
| 64 |
+ return pixbuf
|
|
| 65 |
+ return iconinfo.load_icon()
|
|
| 59 | 66 |
except GLib.GError as e:
|
| 60 | 67 |
if not quiet:
|
| 61 | 68 |
log.error('Unable to load icon %s: %s' % (icon_name, str(e)))
|