Philipp Hörist pushed to branch master at gajim / gajim

Commits:
9dc389cc by Philipp Hörist at 2017-06-13T00:02:44+02:00
Show warning icon when encryption is disabled

'channel-insecure-symbolic' icon if no encryption is selected

'channel-secure-symbolic' if an encryption is selected

- - - - -


4 changed files:

- src/chat_control.py
- src/chat_control_base.py
- src/groupchat_control.py
- src/gtkgui_helpers.py


Changes:

=====================================
src/chat_control.py
=====================================
--- 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()


=====================================
src/chat_control_base.py
=====================================
--- 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'


=====================================
src/groupchat_control.py
=====================================
--- 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)


=====================================
src/gtkgui_helpers.py
=====================================
--- 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)))



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/9dc389cc32f8bc8f51c694f54b5a4785c04c5296
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to