diff --git a/gajim/chat_control.py b/gajim/chat_control.py index 3e60fbf2d..1a7a6e6d7 100644 --- a/gajim/chat_control.py +++ b/gajim/chat_control.py @@ -630,30 +630,9 @@ class ChatControl(ChatControlBase): jid = contact.jid # Set banner image - img_32 = app.interface.roster.get_appropriate_state_images(jid, - size='32', icon_name=show) - img_16 = app.interface.roster.get_appropriate_state_images(jid, - icon_name=show) - if show in img_32 and img_32[show].get_pixbuf(): - # we have 32x32! use it! - banner_image = img_32[show] - use_size_32 = True - else: - banner_image = img_16[show] - use_size_32 = False - + icon = gtkgui_helpers.get_iconset_name_for(show) banner_status_img = self.xml.get_object('banner_status_image') - if banner_image.get_storage_type() == Gtk.ImageType.ANIMATION: - banner_status_img.set_from_animation(banner_image.get_animation()) - else: - pix = banner_image.get_pixbuf() - if pix is not None: - if use_size_32: - banner_status_img.set_from_pixbuf(pix) - else: # we need to scale 16x16 to 32x32 - scaled_pix = pix.scale_simple(32, 32, - GdkPixbuf.InterpType.BILINEAR) - banner_status_img.set_from_pixbuf(scaled_pix) + banner_status_img.set_from_icon_name(icon, Gtk.IconSize.DND) def draw_banner_text(self): """ @@ -1040,9 +1019,11 @@ class ChatControl(ChatControlBase): jid = self.contact.jid if app.config.get('show_avatar_in_tabs'): - avatar_pixbuf = app.contacts.get_avatar(self.account, jid, size=16) - if avatar_pixbuf is not None: - return avatar_pixbuf + scale = self.parent_win.window.get_scale_factor() + surface = app.contacts.get_avatar( + self.account, jid, AvatarSize.TAB, scale) + if surface is not None: + return surface if count_unread: num_unread = len(app.events.get_events(self.account, jid, @@ -1273,18 +1254,19 @@ class ChatControl(ChatControlBase): if not app.config.get('show_avatar_in_chat'): return + scale = self.parent_win.window.get_scale_factor() if self.TYPE_ID == message_control.TYPE_CHAT: - pixbuf = app.contacts.get_avatar( - self.account, self.contact.jid, AvatarSize.CHAT) + surface = app.contacts.get_avatar( + self.account, self.contact.jid, AvatarSize.CHAT, scale) else: - pixbuf = app.interface.get_avatar( - self.gc_contact.avatar_sha, AvatarSize.CHAT) + surface = app.interface.get_avatar( + self.gc_contact.avatar_sha, AvatarSize.CHAT, scale) image = self.xml.get_object('avatar_image') - if pixbuf is None: + if surface is None: image.set_from_icon_name('avatar-default', Gtk.IconSize.DIALOG) else: - image.set_from_pixbuf(pixbuf) + image.set_from_surface(surface) def _nec_update_avatar(self, obj): if obj.account != self.account: diff --git a/gajim/chat_control_base.py b/gajim/chat_control_base.py index 9bcc14317..e557c59fd 100644 --- a/gajim/chat_control_base.py +++ b/gajim/chat_control_base.py @@ -474,17 +474,16 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): return state def set_encryption_menu_icon(self): - for child in self.encryption_menu.get_children(): - if isinstance(child, Gtk.Image): - image = child - break - + image = self.encryption_menu.get_image() + if image is None: + image = Gtk.Image() + self.encryption_menu.set_image(image) if not self.encryption: - icon = gtkgui_helpers.get_icon_pixmap( - 'channel-insecure-symbolic', color=[Color.BLACK]) + image.set_from_icon_name('channel-insecure-symbolic', + Gtk.IconSize.MENU) else: - icon = gtkgui_helpers.get_icon_pixmap('channel-secure-symbolic') - image.set_from_pixbuf(icon) + image.set_from_icon_name('channel-secure-symbolic', + Gtk.IconSize.MENU) def set_speller(self): if not app.HAVE_SPELL or not app.config.get('use_speller'): diff --git a/gajim/common/const.py b/gajim/common/const.py index 5f48810d6..fab57d935 100644 --- a/gajim/common/const.py +++ b/gajim/common/const.py @@ -29,6 +29,7 @@ class OptionType(IntEnum): DIALOG = 4 class AvatarSize(IntEnum): + TAB = 16 ROSTER = 32 CHAT = 48 NOTIFICATION = 48 diff --git a/gajim/common/contacts.py b/gajim/common/contacts.py index fc8dcdd7f..8452f9c2a 100644 --- a/gajim/common/contacts.py +++ b/gajim/common/contacts.py @@ -197,8 +197,8 @@ class GC_Contact(CommonContact): def get_shown_name(self): return self.name - def get_avatar(self, size=None): - return common.app.interface.get_avatar(self.avatar_sha, size) + def get_avatar(self, *args, **kwargs): + return common.app.interface.get_avatar(self.avatar_sha, *args, **kwargs) def as_contact(self): """ @@ -310,8 +310,8 @@ class LegacyContactsAPI: def get_contact(self, account, jid, resource=None): return self._accounts[account].contacts.get_contact(jid, resource=resource) - def get_avatar(self, account, jid, size=None): - return self._accounts[account].contacts.get_avatar(jid, size) + def get_avatar(self, account, *args, **kwargs): + return self._accounts[account].contacts.get_avatar(*args, **kwargs) def get_avatar_sha(self, account, jid): return self._accounts[account].contacts.get_avatar_sha(jid) @@ -509,14 +509,15 @@ class Contacts(): return c return self._contacts[jid][0] - def get_avatar(self, jid, size=None): + def get_avatar(self, jid, size=None, scale=None): if jid not in self._contacts: return None for resource in self._contacts[jid]: if resource.avatar_sha is None: continue - avatar = common.app.interface.get_avatar(resource.avatar_sha, size) + avatar = common.app.interface.get_avatar( + resource.avatar_sha, size, scale) if avatar is None: self.set_avatar(jid, None) return avatar diff --git a/gajim/data/gui/chat_control.ui b/gajim/data/gui/chat_control.ui index 613eba6e6..43223d675 100644 --- a/gajim/data/gui/chat_control.ui +++ b/gajim/data/gui/chat_control.ui @@ -801,11 +801,7 @@ audio-mic-volume-low Choose an encryption none - - True - False - channel-secure-symbolic - +