Show warning icon when encryption is disabled
'channel-insecure-symbolic' icon if no encryption is selected 'channel-secure-symbolic' if an encryption is selected
This commit is contained in:
		
							parent
							
								
									f7754487cc
								
							
						
					
					
						commit
						9dc389cc32
					
				
					 4 changed files with 26 additions and 2 deletions
				
			
		| 
						 | 
					@ -287,6 +287,7 @@ class ChatControl(ChatControlBase):
 | 
				
			||||||
        self.encryption_menu = self.xml.get_object('encryption_menu')
 | 
					        self.encryption_menu = self.xml.get_object('encryption_menu')
 | 
				
			||||||
        self.encryption_menu.set_menu_model(
 | 
					        self.encryption_menu.set_menu_model(
 | 
				
			||||||
            gui_menu_builder.get_encryption_menu(self.contact, self.type_id))
 | 
					            gui_menu_builder.get_encryption_menu(self.contact, self.type_id))
 | 
				
			||||||
 | 
					        self.set_encryption_menu_icon()
 | 
				
			||||||
        # restore previous conversation
 | 
					        # restore previous conversation
 | 
				
			||||||
        self.restore_conversation()
 | 
					        self.restore_conversation()
 | 
				
			||||||
        self.msg_textview.grab_focus()
 | 
					        self.msg_textview.grab_focus()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,6 +36,7 @@ from gi.repository import GObject
 | 
				
			||||||
from gi.repository import GLib
 | 
					from gi.repository import GLib
 | 
				
			||||||
from gi.repository import Gio
 | 
					from gi.repository import Gio
 | 
				
			||||||
import gtkgui_helpers
 | 
					import gtkgui_helpers
 | 
				
			||||||
 | 
					from gtkgui_helpers import Color
 | 
				
			||||||
import message_control
 | 
					import message_control
 | 
				
			||||||
import dialogs
 | 
					import dialogs
 | 
				
			||||||
import history_window
 | 
					import history_window
 | 
				
			||||||
| 
						 | 
					@ -442,6 +443,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
 | 
				
			||||||
                self.terminate_esessions()
 | 
					                self.terminate_esessions()
 | 
				
			||||||
        action.set_state(param)
 | 
					        action.set_state(param)
 | 
				
			||||||
        self.set_encryption_state(encryption)
 | 
					        self.set_encryption_state(encryption)
 | 
				
			||||||
 | 
					        self.set_encryption_menu_icon()
 | 
				
			||||||
        self.set_lock_image()
 | 
					        self.set_lock_image()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def set_encryption_state(self, encryption):
 | 
					    def set_encryption_state(self, encryption):
 | 
				
			||||||
| 
						 | 
					@ -455,6 +457,19 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
 | 
				
			||||||
        state = gajim.config.get_per('encryption', config_key, 'encryption')
 | 
					        state = gajim.config.get_per('encryption', config_key, 'encryption')
 | 
				
			||||||
        return state or None
 | 
					        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):
 | 
					    def set_speller(self):
 | 
				
			||||||
        # now set the one the user selected
 | 
					        # now set the one the user selected
 | 
				
			||||||
        per_type = 'contacts'
 | 
					        per_type = 'contacts'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -493,6 +493,7 @@ class GroupchatControl(ChatControlBase):
 | 
				
			||||||
        self.encryption_menu = self.xml.get_object('encryption_menu')
 | 
					        self.encryption_menu = self.xml.get_object('encryption_menu')
 | 
				
			||||||
        self.encryption_menu.set_menu_model(
 | 
					        self.encryption_menu.set_menu_model(
 | 
				
			||||||
            gui_menu_builder.get_encryption_menu(self.contact, self.type_id))
 | 
					            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,
 | 
					        gajim.ged.register_event_handler('gc-presence-received', ged.GUI1,
 | 
				
			||||||
            self._nec_gc_presence_received)
 | 
					            self._nec_gc_presence_received)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,9 +53,16 @@ from common import configpaths
 | 
				
			||||||
gtk_icon_theme = Gtk.IconTheme.get_default()
 | 
					gtk_icon_theme = Gtk.IconTheme.get_default()
 | 
				
			||||||
gtk_icon_theme.append_search_path(gajim.ICONS_DIR)
 | 
					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:
 | 
					    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:
 | 
					    except GLib.GError as e:
 | 
				
			||||||
        if not quiet:
 | 
					        if not quiet:
 | 
				
			||||||
            log.error('Unable to load icon %s: %s' % (icon_name, str(e)))
 | 
					            log.error('Unable to load icon %s: %s' % (icon_name, str(e)))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue