Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPhilipp Hörist <forenjunkie@chello.at>2017-06-13 00:32:59 +0300
committerPhilipp Hörist <forenjunkie@chello.at>2017-06-13 01:02:44 +0300
commit9dc389cc32f8bc8f51c694f54b5a4785c04c5296 (patch)
tree381885bfbdaa7e7efdb850ed08af43f7b220c83f /src
parentf7754487ccee4f4a1e797225041f53966f6639c3 (diff)
Show warning icon when encryption is disabled
'channel-insecure-symbolic' icon if no encryption is selected 'channel-secure-symbolic' if an encryption is selected
Diffstat (limited to 'src')
-rw-r--r--src/chat_control.py1
-rw-r--r--src/chat_control_base.py15
-rw-r--r--src/groupchat_control.py1
-rw-r--r--src/gtkgui_helpers.py11
4 files changed, 26 insertions, 2 deletions
diff --git a/src/chat_control.py b/src/chat_control.py
index 58e31a67f..1009a8699 100644
--- a/src/chat_control.py
+++ b/src/chat_control.py
@@ -287,6 +287,7 @@ class ChatControl(ChatControlBase):
self.encryption_menu = self.xml.get_object('encryption_menu')
self.encryption_menu.set_menu_model(
gui_menu_builder.get_encryption_menu(self.contact, self.type_id))
+ self.set_encryption_menu_icon()
# restore previous conversation
self.restore_conversation()
self.msg_textview.grab_focus()
diff --git a/src/chat_control_base.py b/src/chat_control_base.py
index 9dd5acdf2..da7aff3a2 100644
--- a/src/chat_control_base.py
+++ b/src/chat_control_base.py
@@ -36,6 +36,7 @@ from gi.repository import GObject
from gi.repository import GLib
from gi.repository import Gio
import gtkgui_helpers
+from gtkgui_helpers import Color
import message_control
import dialogs
import history_window
@@ -442,6 +443,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
self.terminate_esessions()
action.set_state(param)
self.set_encryption_state(encryption)
+ self.set_encryption_menu_icon()
self.set_lock_image()
def set_encryption_state(self, encryption):
@@ -455,6 +457,19 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
state = gajim.config.get_per('encryption', config_key, 'encryption')
return state or None
+ def set_encryption_menu_icon(self):
+ for child in self.encryption_menu.get_children():
+ if isinstance(child, Gtk.Image):
+ image = child
+ break
+
+ if not self.encryption:
+ icon = gtkgui_helpers.get_icon_pixmap(
+ 'channel-insecure-symbolic', color=[Color.BLACK])
+ else:
+ icon = gtkgui_helpers.get_icon_pixmap('channel-secure-symbolic')
+ image.set_from_pixbuf(icon)
+
def set_speller(self):
# now set the one the user selected
per_type = 'contacts'
diff --git a/src/groupchat_control.py b/src/groupchat_control.py
index 834e709f0..ea0eff4f7 100644
--- a/src/groupchat_control.py
+++ b/src/groupchat_control.py
@@ -493,6 +493,7 @@ class GroupchatControl(ChatControlBase):
self.encryption_menu = self.xml.get_object('encryption_menu')
self.encryption_menu.set_menu_model(
gui_menu_builder.get_encryption_menu(self.contact, self.type_id))
+ self.set_encryption_menu_icon()
gajim.ged.register_event_handler('gc-presence-received', ged.GUI1,
self._nec_gc_presence_received)
diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py
index 687daa99e..18db3efb5 100644
--- a/src/gtkgui_helpers.py
+++ b/src/gtkgui_helpers.py
@@ -53,9 +53,16 @@ from common import configpaths
gtk_icon_theme = Gtk.IconTheme.get_default()
gtk_icon_theme.append_search_path(gajim.ICONS_DIR)
-def get_icon_pixmap(icon_name, size=16, quiet=False):
+class Color:
+ BLACK = Gdk.RGBA(red=0, green=0, blue=0, alpha=1)
+
+def get_icon_pixmap(icon_name, size=16, color=None, quiet=False):
try:
- return gtk_icon_theme.load_icon(icon_name, size, 0)
+ iconinfo = gtk_icon_theme.lookup_icon(icon_name, size, 0)
+ if color:
+ pixbuf, was_symbolic = iconinfo.load_symbolic(*color)
+ return pixbuf
+ return iconinfo.load_icon()
except GLib.GError as e:
if not quiet:
log.error('Unable to load icon %s: %s' % (icon_name, str(e)))