gtkgui_helpers have func to escape pango markup
This commit is contained in:
parent
3aa0363a2a
commit
688fb66979
6 changed files with 42 additions and 16 deletions
|
@ -1,4 +1,4 @@
|
||||||
## common/check_for_new_version.py
|
## check_for_new_version.py
|
||||||
##
|
##
|
||||||
## Gajim Team:
|
## Gajim Team:
|
||||||
## - Yann Le Boulanger <asterix@lagaule.org>
|
## - Yann Le Boulanger <asterix@lagaule.org>
|
||||||
|
|
|
@ -62,6 +62,7 @@ class Logger:
|
||||||
|
|
||||||
if not msg:
|
if not msg:
|
||||||
msg = ''
|
msg = ''
|
||||||
|
|
||||||
msg = helpers.to_one_line(msg)
|
msg = helpers.to_one_line(msg)
|
||||||
if len(jid.split('/')) > 1:
|
if len(jid.split('/')) > 1:
|
||||||
ji, nick = jid.split('/', 1)
|
ji, nick = jid.split('/', 1)
|
||||||
|
|
|
@ -22,6 +22,8 @@ import gtk.glade
|
||||||
import gobject
|
import gobject
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import gtkgui_helpers.py
|
||||||
|
|
||||||
from vcard import VcardWindow
|
from vcard import VcardWindow
|
||||||
from gajim_themes_window import GajimThemesWindow
|
from gajim_themes_window import GajimThemesWindow
|
||||||
from advanced import AdvancedConfigurationWindow
|
from advanced import AdvancedConfigurationWindow
|
||||||
|
@ -592,12 +594,8 @@ class RosterTooltip(gtk.Window):
|
||||||
str_status += ' - ' + status
|
str_status += ' - ' + status
|
||||||
status_label = gtk.Label(str_status)
|
status_label = gtk.Label(str_status)
|
||||||
status_label.set_alignment(00, 0)
|
status_label.set_alignment(00, 0)
|
||||||
self.table.attach(status_label, 3, 4, self.current_row, self.current_row + 1,
|
self.table.attach(status_label, 3, 4, self.current_row,
|
||||||
gtk.EXPAND | gtk.FILL, 0, 0, 0)
|
self.current_row + 1, gtk.EXPAND | gtk.FILL, 0, 0, 0)
|
||||||
|
|
||||||
def escape_entities(self, text):
|
|
||||||
# escapes markup entities
|
|
||||||
return text.replace('&', '&').replace('>','>').replace('<','<')
|
|
||||||
|
|
||||||
def populate(self, contacts):
|
def populate(self, contacts):
|
||||||
if not contacts or len(contacts) == 0:
|
if not contacts or len(contacts) == 0:
|
||||||
|
@ -645,9 +643,9 @@ class RosterTooltip(gtk.Window):
|
||||||
|
|
||||||
info = '<span size="large" weight="bold">' + prim_contact.jid + '</span>'
|
info = '<span size="large" weight="bold">' + prim_contact.jid + '</span>'
|
||||||
info += '\n<span weight="bold">' + _('Name: ') + '</span>' + \
|
info += '\n<span weight="bold">' + _('Name: ') + '</span>' + \
|
||||||
self.escape_entities(prim_contact.name)
|
gtkgui_helpers.escape_for_pango_markup(prim_contact.name)
|
||||||
info += '\n<span weight="bold">' + _('Subscription: ') + '</span>' + \
|
info += '\n<span weight="bold">' + _('Subscription: ') + '</span>' + \
|
||||||
self.escape_entities(prim_contact.sub)
|
gtkgui_helpers.escape_for_pango_markup(prim_contact.sub)
|
||||||
|
|
||||||
if prim_contact.keyID:
|
if prim_contact.keyID:
|
||||||
keyID = None
|
keyID = None
|
||||||
|
@ -657,7 +655,7 @@ class RosterTooltip(gtk.Window):
|
||||||
keyID = prim_contact.keyID[8:]
|
keyID = prim_contact.keyID[8:]
|
||||||
if keyID:
|
if keyID:
|
||||||
info += '\n<span weight="bold">' + _('OpenPGP: ') + \
|
info += '\n<span weight="bold">' + _('OpenPGP: ') + \
|
||||||
'</span>' + self.escape_entities(keyID )
|
'</span>' + gtkgui_helpers.escape_for_pango_markup(keyID)
|
||||||
|
|
||||||
single_line, resource_str, multiple_resource= '', '', False
|
single_line, resource_str, multiple_resource= '', '', False
|
||||||
num_resources = 0
|
num_resources = 0
|
||||||
|
@ -676,7 +674,7 @@ class RosterTooltip(gtk.Window):
|
||||||
else: # only one resource
|
else: # only one resource
|
||||||
if contact.resource:
|
if contact.resource:
|
||||||
info += '\n<span weight="bold">' + _('Resource: ') + \
|
info += '\n<span weight="bold">' + _('Resource: ') + \
|
||||||
'</span>' + self.escape_entities(contact.resource) + ' (' + str(contact.priority) + ')'
|
'</span>' + gtkgui_helpers.escape_for_pango_markup(contact.resource) + ' (' + str(contact.priority) + ')'
|
||||||
if contact.show:
|
if contact.show:
|
||||||
info += '\n<span weight="bold">' + _('Status: ') + \
|
info += '\n<span weight="bold">' + _('Status: ') + \
|
||||||
'</span>' + helpers.get_uf_show(contact.show)
|
'</span>' + helpers.get_uf_show(contact.show)
|
||||||
|
@ -684,7 +682,7 @@ class RosterTooltip(gtk.Window):
|
||||||
status = contact.status.strip()
|
status = contact.status.strip()
|
||||||
if status != '':
|
if status != '':
|
||||||
# escape markup entities. Is it posible to have markup in status?
|
# escape markup entities. Is it posible to have markup in status?
|
||||||
info += ' - ' + self.escape_entities(status)
|
info += ' - ' + gtkgui_helpers.escape_for_pango_markup(status)
|
||||||
|
|
||||||
self.account.set_markup(info)
|
self.account.set_markup(info)
|
||||||
|
|
||||||
|
|
|
@ -10008,8 +10008,8 @@ Custom</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="banner_name_label">
|
<widget class="GtkLabel" id="banner_name_label">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label"><span weight="heavy" size="large">Contact: name</span>
|
<property name="label"><span weight="heavy" size="large">Contact name</span>
|
||||||
JID: whatever@jabber.org</property>
|
Status message</property>
|
||||||
<property name="use_underline">False</property>
|
<property name="use_underline">False</property>
|
||||||
<property name="use_markup">True</property>
|
<property name="use_markup">True</property>
|
||||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||||
|
|
|
@ -1,3 +1,27 @@
|
||||||
|
## gtkgui_helpers.py
|
||||||
|
##
|
||||||
|
## Gajim Team:
|
||||||
|
## - Yann Le Boulanger <asterix@lagaule.org>
|
||||||
|
## - Vincent Hanquez <tab@snarc.org>
|
||||||
|
## - Nikos Kouremenos <kourem@gmail.com>
|
||||||
|
## - Dimitur Kirov <dkirov@gmail.com>
|
||||||
|
##
|
||||||
|
## This file was initially written by Dimitur Kirov
|
||||||
|
##
|
||||||
|
## Copyright (C) 2003-2005 Gajim Team
|
||||||
|
##
|
||||||
|
## This program is free software; you can redistribute it and/or modify
|
||||||
|
## it under the terms of the GNU General Public License as published
|
||||||
|
## by the Free Software Foundation; version 2 only.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful,
|
||||||
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
## GNU General Public License for more details.
|
||||||
|
##
|
||||||
|
|
||||||
|
import cgi
|
||||||
|
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
|
||||||
def get_contact_instances_from_jid(account, jid):
|
def get_contact_instances_from_jid(account, jid):
|
||||||
|
@ -12,3 +36,7 @@ def get_first_contact_instance_from_jid(account, jid):
|
||||||
def get_contact_name_from_jid(account, jid):
|
def get_contact_name_from_jid(account, jid):
|
||||||
contact_instances = get_contact_instances_from_jid(account, jid)
|
contact_instances = get_contact_instances_from_jid(account, jid)
|
||||||
return contact_instances[0].name
|
return contact_instances[0].name
|
||||||
|
|
||||||
|
def escape_for_pango_markup(string):
|
||||||
|
# escapes chars for pango markup not to break
|
||||||
|
return cgi.escape(string)
|
||||||
|
|
|
@ -113,8 +113,7 @@ class TabbedChatWindow(chat.Chat):
|
||||||
houses the status icon, name, jid, and avatar'''
|
houses the status icon, name, jid, and avatar'''
|
||||||
# this is the text for the big brown bar
|
# this is the text for the big brown bar
|
||||||
# some chars need to be escaped..
|
# some chars need to be escaped..
|
||||||
name = contact.name.replace('&', '&').replace('>','>').replace(
|
name = gtkgui_helpers.escape_for_pango_markup(contact.name)
|
||||||
'<','<')
|
|
||||||
|
|
||||||
jid = contact.jid
|
jid = contact.jid
|
||||||
status = contact.status
|
status = contact.status
|
||||||
|
|
Loading…
Add table
Reference in a new issue