update banner font also in groupchat
This commit is contained in:
parent
cb02ad7f18
commit
08b67c346e
|
@ -59,6 +59,31 @@ GTKGUI_GLADE = 'gtkgui.glade'
|
||||||
class ChatControlBase(MessageControl):
|
class ChatControlBase(MessageControl):
|
||||||
'''A base class containing a banner, ConversationTextview, MessageTextView
|
'''A base class containing a banner, ConversationTextview, MessageTextView
|
||||||
'''
|
'''
|
||||||
|
def get_font_attrs(self):
|
||||||
|
''' get pango font attributes for banner from theme settings '''
|
||||||
|
theme = gajim.config.get('roster_theme')
|
||||||
|
bannerfont = gajim.config.get_per('themes', theme, 'bannerfont')
|
||||||
|
bannerfontattrs = gajim.config.get_per('themes', theme, 'bannerfontattrs')
|
||||||
|
|
||||||
|
if bannerfont:
|
||||||
|
font = pango.FontDescription(bannerfont)
|
||||||
|
else:
|
||||||
|
font = pango.FontDescription('Normal')
|
||||||
|
if bannerfontattrs:
|
||||||
|
# B attribute is set by default
|
||||||
|
if 'B' in bannerfontattrs:
|
||||||
|
font.set_weight(pango.WEIGHT_HEAVY)
|
||||||
|
if 'I' in bannerfontattrs:
|
||||||
|
font.set_style(pango.STYLE_ITALIC)
|
||||||
|
|
||||||
|
font_attrs = 'font_desc="%s"' % font.to_string()
|
||||||
|
|
||||||
|
# in case there is no font specified we use x-large font size
|
||||||
|
if font.get_size() == 0:
|
||||||
|
font_attrs = '%s size="x-large"' % font_attrs
|
||||||
|
font.set_weight(pango.WEIGHT_NORMAL)
|
||||||
|
font_attrs_small = 'font_desc="%s" size="small"' % font.to_string()
|
||||||
|
return (font_attrs, font_attrs_small)
|
||||||
|
|
||||||
def draw_banner(self):
|
def draw_banner(self):
|
||||||
self._paint_banner()
|
self._paint_banner()
|
||||||
|
@ -862,33 +887,9 @@ class ChatControl(ChatControlBase):
|
||||||
# fulljid += '/' + self.contacts[jid].resource
|
# fulljid += '/' + self.contacts[jid].resource
|
||||||
#label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \
|
#label_text = '<span weight="heavy" size="x-large">%s</span>\n%s' \
|
||||||
# % (name, fulljid)
|
# % (name, fulljid)
|
||||||
|
font_attrs, font_attrs_small = self.get_font_attrs()
|
||||||
# get banner font settings
|
|
||||||
theme = gajim.config.get('roster_theme')
|
|
||||||
bannerfont = gajim.config.get_per('themes', theme, 'bannerfont')
|
|
||||||
bannerfontattrs = gajim.config.get_per('themes', theme, 'bannerfontattrs')
|
|
||||||
|
|
||||||
if bannerfont:
|
|
||||||
font = pango.FontDescription(bannerfont)
|
|
||||||
else:
|
|
||||||
font = pango.FontDescription('Normal')
|
|
||||||
if bannerfontattrs:
|
|
||||||
# B is attribute set by default
|
|
||||||
if 'B' in bannerfontattrs:
|
|
||||||
font.set_weight(pango.WEIGHT_HEAVY)
|
|
||||||
if 'I' in bannerfontattrs:
|
|
||||||
font.set_style(pango.STYLE_ITALIC)
|
|
||||||
|
|
||||||
font_attrs = 'font_desc="%s"' % font.to_string()
|
|
||||||
font_size = font.get_size()
|
|
||||||
|
|
||||||
# in case there is no font specified we use x-large font size
|
|
||||||
if font_size == 0:
|
|
||||||
font_attrs = '%s size="x-large"' % font_attrs
|
|
||||||
|
|
||||||
st = gajim.config.get('chat_state_notifications')
|
st = gajim.config.get('chat_state_notifications')
|
||||||
cs = contact.chatstate
|
cs = contact.chatstate
|
||||||
font.set_weight(pango.WEIGHT_NORMAL)
|
|
||||||
if cs and st in ('composing_only', 'all'):
|
if cs and st in ('composing_only', 'all'):
|
||||||
if contact.show == 'offline':
|
if contact.show == 'offline':
|
||||||
chatstate = ''
|
chatstate = ''
|
||||||
|
@ -903,18 +904,16 @@ class ChatControl(ChatControlBase):
|
||||||
elif chatstate is None:
|
elif chatstate is None:
|
||||||
chatstate = helpers.get_uf_chatstate(cs)
|
chatstate = helpers.get_uf_chatstate(cs)
|
||||||
|
|
||||||
label_text = \
|
label_text = '<span %s>%s</span><span %s>%s %s</span>' % \
|
||||||
'<span %s>%s</span><span font_desc="%s" size="small">%s %s</span>' % \
|
(font_attrs, name, font_attrs_small, acct_info, chatstate)
|
||||||
(font_attrs, name, font.to_string(), acct_info, chatstate)
|
|
||||||
else:
|
else:
|
||||||
# weight="heavy" size="x-large"
|
# weight="heavy" size="x-large"
|
||||||
label_text = \
|
label_text = '<span %s>%s</span><span %s>%s</span>' % \
|
||||||
'<span %s>%s</span><span font_desc="%s" size="small">%s</span>' % \
|
(font_attrs, name, font_attrs_small, acct_info)
|
||||||
(font_attrs, name, font.to_string(), acct_info)
|
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
label_text += '\n<span font_desc="%s" size="small">%s</span>' %\
|
label_text += '\n<span %s>%s</span>' %\
|
||||||
(font.to_string(), status)
|
(font_attrs_small, status)
|
||||||
|
|
||||||
# setup the label that holds name and jid
|
# setup the label that holds name and jid
|
||||||
banner_name_label.set_markup(label_text)
|
banner_name_label.set_markup(label_text)
|
||||||
|
|
|
@ -560,10 +560,10 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.name_label.set_ellipsize(pango.ELLIPSIZE_END)
|
self.name_label.set_ellipsize(pango.ELLIPSIZE_END)
|
||||||
subject = gtkgui_helpers.reduce_chars_newlines(subject, 0, 2)
|
subject = gtkgui_helpers.reduce_chars_newlines(subject, 0, 2)
|
||||||
subject = gtkgui_helpers.escape_for_pango_markup(subject)
|
subject = gtkgui_helpers.escape_for_pango_markup(subject)
|
||||||
text = '<span weight="heavy" size="x-large">%s</span>' % \
|
font_attrs, font_attrs_small = self.get_font_attrs()
|
||||||
self.room_jid
|
text = '<span %s>%s</span>' % (font_attrs, self.room_jid)
|
||||||
if subject:
|
if subject:
|
||||||
text += '\n%s' % subject
|
text += '\n<span %s>%s</span>' % (font_attrs_small, subject)
|
||||||
self.name_label.set_markup(text)
|
self.name_label.set_markup(text)
|
||||||
event_box = self.name_label.get_parent()
|
event_box = self.name_label.get_parent()
|
||||||
if subject == '':
|
if subject == '':
|
||||||
|
|
Loading…
Reference in New Issue