add new option to show avatar in chat tabs and window icons instead of status icon. Fixes #8320
This commit is contained in:
parent
991df175d7
commit
997e686d57
6 changed files with 56 additions and 15 deletions
|
@ -531,6 +531,22 @@
|
||||||
<property name="top_attach">0</property>
|
<property name="top_attach">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="show_avatar_in_tabs_checkbutton">
|
||||||
|
<property name="label" translatable="yes">Show avatar in chat tabs</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<signal name="toggled" handler="on_show_avatar_in_tabs_checkbutton_toggled" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">7</property>
|
||||||
|
<property name="width">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child type="label">
|
<child type="label">
|
||||||
|
|
|
@ -2591,6 +2591,14 @@ class ChatControl(ChatControlBase):
|
||||||
jid = self.contact.get_full_jid()
|
jid = self.contact.get_full_jid()
|
||||||
else:
|
else:
|
||||||
jid = self.contact.jid
|
jid = self.contact.jid
|
||||||
|
|
||||||
|
if gajim.config.get('show_avatar_in_tabs'):
|
||||||
|
avatar_pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(jid)
|
||||||
|
if avatar_pixbuf not in ('ask', None):
|
||||||
|
avatar_pixbuf = gtkgui_helpers.get_scaled_pixbuf_by_size(
|
||||||
|
avatar_pixbuf, 16, 16)
|
||||||
|
return avatar_pixbuf
|
||||||
|
|
||||||
if count_unread:
|
if count_unread:
|
||||||
num_unread = len(gajim.events.get_events(self.account, jid,
|
num_unread = len(gajim.events.get_events(self.account, jid,
|
||||||
['printed_' + self.type_id, self.type_id]))
|
['printed_' + self.type_id, self.type_id]))
|
||||||
|
|
|
@ -317,6 +317,7 @@ class Config:
|
||||||
'ignore_incoming_attention': [opt_bool, False, _('If True, Gajim will ignore incoming attention requestd ("wizz").')],
|
'ignore_incoming_attention': [opt_bool, False, _('If True, Gajim will ignore incoming attention requestd ("wizz").')],
|
||||||
'remember_opened_chat_controls': [ opt_bool, True, _('If enabled, Gajim will reopen chat windows that were opened last time Gajim was closed.')],
|
'remember_opened_chat_controls': [ opt_bool, True, _('If enabled, Gajim will reopen chat windows that were opened last time Gajim was closed.')],
|
||||||
'positive_184_ack': [ opt_bool, False, _('If enabled, Gajim will show an icon to show that sent message has been received by your contact')],
|
'positive_184_ack': [ opt_bool, False, _('If enabled, Gajim will show an icon to show that sent message has been received by your contact')],
|
||||||
|
'show_avatar_in_tabs': [ opt_bool, False, _('Show a mini avatar in chat window tabs and in window icon')],
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
__options_per_key = {
|
__options_per_key = {
|
||||||
|
|
|
@ -209,6 +209,10 @@ class PreferencesWindow:
|
||||||
st = gajim.config.get('positive_184_ack')
|
st = gajim.config.get('positive_184_ack')
|
||||||
self.xml.get_object('positive_184_ack_checkbutton').set_active(st)
|
self.xml.get_object('positive_184_ack_checkbutton').set_active(st)
|
||||||
|
|
||||||
|
# Show avatar in tabs
|
||||||
|
st = gajim.config.get('show_avatar_in_tabs')
|
||||||
|
self.xml.get_object('show_avatar_in_tabs_checkbutton').set_active(st)
|
||||||
|
|
||||||
### Style tab ###
|
### Style tab ###
|
||||||
# Themes
|
# Themes
|
||||||
theme_combobox = self.xml.get_object('theme_combobox')
|
theme_combobox = self.xml.get_object('theme_combobox')
|
||||||
|
@ -763,6 +767,9 @@ class PreferencesWindow:
|
||||||
def on_positive_184_ack_checkbutton_toggled(self, widget):
|
def on_positive_184_ack_checkbutton_toggled(self, widget):
|
||||||
self.on_checkbutton_toggled(widget, 'positive_184_ack')
|
self.on_checkbutton_toggled(widget, 'positive_184_ack')
|
||||||
|
|
||||||
|
def on_show_avatar_in_tabs_checkbutton_toggled(self, widget):
|
||||||
|
self.on_checkbutton_toggled(widget, 'show_avatar_in_tabs')
|
||||||
|
|
||||||
def on_theme_combobox_changed(self, widget):
|
def on_theme_combobox_changed(self, widget):
|
||||||
model = widget.get_model()
|
model = widget.get_model()
|
||||||
active = widget.get_active()
|
active = widget.get_active()
|
||||||
|
|
|
@ -434,7 +434,7 @@ def get_pixbuf_from_data(file_data, want_type = False):
|
||||||
pixbuf = pixbufloader.get_pixbuf()
|
pixbuf = pixbufloader.get_pixbuf()
|
||||||
except GLib.GError: # 'unknown image format'
|
except GLib.GError: # 'unknown image format'
|
||||||
pixbufloader.close()
|
pixbufloader.close()
|
||||||
|
|
||||||
# try to open and convert this image to png using pillow (if available)
|
# try to open and convert this image to png using pillow (if available)
|
||||||
log.debug("loading avatar using pixbufloader directly failed, trying to convert avatar image using pillow (if available)")
|
log.debug("loading avatar using pixbufloader directly failed, trying to convert avatar image using pillow (if available)")
|
||||||
pixbufloader = GdkPixbuf.PixbufLoader()
|
pixbufloader = GdkPixbuf.PixbufLoader()
|
||||||
|
@ -570,18 +570,7 @@ def get_fade_color(treeview, selected, focused):
|
||||||
return Gdk.RGBA(bg.red*p + fg.red*q, bg.green*p + fg.green*q,
|
return Gdk.RGBA(bg.red*p + fg.red*q, bg.green*p + fg.green*q,
|
||||||
bg.blue*p + fg.blue*q)
|
bg.blue*p + fg.blue*q)
|
||||||
|
|
||||||
def get_scaled_pixbuf(pixbuf, kind):
|
def get_scaled_pixbuf_by_size(pixbuf, width, height):
|
||||||
"""
|
|
||||||
Return scaled pixbuf, keeping ratio etc or None kind is either "chat",
|
|
||||||
"roster", "notification", "tooltip", "vcard"
|
|
||||||
"""
|
|
||||||
# resize to a width / height for the avatar not to have distortion
|
|
||||||
# (keep aspect ratio)
|
|
||||||
width = gajim.config.get(kind + '_avatar_width')
|
|
||||||
height = gajim.config.get(kind + '_avatar_height')
|
|
||||||
if width < 1 or height < 1:
|
|
||||||
return None
|
|
||||||
|
|
||||||
# Pixbuf size
|
# Pixbuf size
|
||||||
pix_width = pixbuf.get_width()
|
pix_width = pixbuf.get_width()
|
||||||
pix_height = pixbuf.get_height()
|
pix_height = pixbuf.get_height()
|
||||||
|
@ -599,6 +588,20 @@ def get_scaled_pixbuf(pixbuf, kind):
|
||||||
scaled_buf = pixbuf.scale_simple(w, h, GdkPixbuf.InterpType.HYPER)
|
scaled_buf = pixbuf.scale_simple(w, h, GdkPixbuf.InterpType.HYPER)
|
||||||
return scaled_buf
|
return scaled_buf
|
||||||
|
|
||||||
|
def get_scaled_pixbuf(pixbuf, kind):
|
||||||
|
"""
|
||||||
|
Return scaled pixbuf, keeping ratio etc or None kind is either "chat",
|
||||||
|
"roster", "notification", "tooltip", "vcard"
|
||||||
|
"""
|
||||||
|
# resize to a width / height for the avatar not to have distortion
|
||||||
|
# (keep aspect ratio)
|
||||||
|
width = gajim.config.get(kind + '_avatar_width')
|
||||||
|
height = gajim.config.get(kind + '_avatar_height')
|
||||||
|
if width < 1 or height < 1:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return get_scaled_pixbuf_by_size(pixbuf, width, height)
|
||||||
|
|
||||||
def get_avatar_pixbuf_from_cache(fjid, use_local=True):
|
def get_avatar_pixbuf_from_cache(fjid, use_local=True):
|
||||||
"""
|
"""
|
||||||
Check if jid has cached avatar and if that avatar is valid image (can be
|
Check if jid has cached avatar and if that avatar is valid image (can be
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
from gi.repository import Gdk
|
from gi.repository import Gdk
|
||||||
|
from gi.repository import GdkPixbuf
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
import time
|
import time
|
||||||
|
@ -480,7 +481,10 @@ class MessageWindow(object):
|
||||||
# chat, pm
|
# chat, pm
|
||||||
icon = gtkgui_helpers.load_icon('online')
|
icon = gtkgui_helpers.load_icon('online')
|
||||||
if icon:
|
if icon:
|
||||||
self.window.set_icon(icon.get_pixbuf())
|
if isinstance(icon, GdkPixbuf.Pixbuf):
|
||||||
|
self.window.set_icon(icon)
|
||||||
|
else:
|
||||||
|
self.window.set_icon(icon.get_pixbuf())
|
||||||
|
|
||||||
def show_title(self, urgent=True, control=None):
|
def show_title(self, urgent=True, control=None):
|
||||||
"""
|
"""
|
||||||
|
@ -658,7 +662,9 @@ class MessageWindow(object):
|
||||||
|
|
||||||
tab_img = ctrl.get_tab_image()
|
tab_img = ctrl.get_tab_image()
|
||||||
if tab_img:
|
if tab_img:
|
||||||
if tab_img.get_storage_type() == Gtk.ImageType.ANIMATION:
|
if isinstance(tab_img, GdkPixbuf.Pixbuf):
|
||||||
|
status_img.set_from_pixbuf(tab_img)
|
||||||
|
elif tab_img.get_storage_type() == Gtk.ImageType.ANIMATION:
|
||||||
status_img.set_from_animation(tab_img.get_animation())
|
status_img.set_from_animation(tab_img.get_animation())
|
||||||
else:
|
else:
|
||||||
status_img.set_from_pixbuf(tab_img.get_pixbuf())
|
status_img.set_from_pixbuf(tab_img.get_pixbuf())
|
||||||
|
|
Loading…
Add table
Reference in a new issue