gtkgui_helpers have func to escape pango markup

This commit is contained in:
Nikos Kouremenos 2005-07-21 21:39:47 +00:00
parent 3aa0363a2a
commit 688fb66979
6 changed files with 42 additions and 16 deletions

View File

@ -1,4 +1,4 @@
## common/check_for_new_version.py
## check_for_new_version.py
##
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>

View File

@ -62,6 +62,7 @@ class Logger:
if not msg:
msg = ''
msg = helpers.to_one_line(msg)
if len(jid.split('/')) > 1:
ji, nick = jid.split('/', 1)

View File

@ -22,6 +22,8 @@ import gtk.glade
import gobject
import os
import gtkgui_helpers.py
from vcard import VcardWindow
from gajim_themes_window import GajimThemesWindow
from advanced import AdvancedConfigurationWindow
@ -592,12 +594,8 @@ class RosterTooltip(gtk.Window):
str_status += ' - ' + status
status_label = gtk.Label(str_status)
status_label.set_alignment(00, 0)
self.table.attach(status_label, 3, 4, self.current_row, self.current_row + 1,
gtk.EXPAND | gtk.FILL, 0, 0, 0)
def escape_entities(self, text):
# escapes markup entities
return text.replace('&', '&amp;').replace('>','&gt;').replace('<','&lt;')
self.table.attach(status_label, 3, 4, self.current_row,
self.current_row + 1, gtk.EXPAND | gtk.FILL, 0, 0, 0)
def populate(self, contacts):
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 += '\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>' + \
self.escape_entities(prim_contact.sub)
gtkgui_helpers.escape_for_pango_markup(prim_contact.sub)
if prim_contact.keyID:
keyID = None
@ -657,7 +655,7 @@ class RosterTooltip(gtk.Window):
keyID = prim_contact.keyID[8:]
if keyID:
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
num_resources = 0
@ -676,7 +674,7 @@ class RosterTooltip(gtk.Window):
else: # only one resource
if contact.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:
info += '\n<span weight="bold">' + _('Status: ') + \
'</span>' + helpers.get_uf_show(contact.show)
@ -684,7 +682,7 @@ class RosterTooltip(gtk.Window):
status = contact.status.strip()
if 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)

View File

@ -10008,8 +10008,8 @@ Custom</property>
<child>
<widget class="GtkLabel" id="banner_name_label">
<property name="visible">True</property>
<property name="label">&lt;span weight=&quot;heavy&quot; size=&quot;large&quot;&gt;Contact: name&lt;/span&gt;
JID: whatever@jabber.org</property>
<property name="label">&lt;span weight=&quot;heavy&quot; size=&quot;large&quot;&gt;Contact name&lt;/span&gt;
Status message</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>

View File

@ -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
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):
contact_instances = get_contact_instances_from_jid(account, jid)
return contact_instances[0].name
def escape_for_pango_markup(string):
# escapes chars for pango markup not to break
return cgi.escape(string)

View File

@ -113,8 +113,7 @@ class TabbedChatWindow(chat.Chat):
houses the status icon, name, jid, and avatar'''
# this is the text for the big brown bar
# some chars need to be escaped..
name = contact.name.replace('&', '&amp;').replace('>','&gt;').replace(
'<','&lt;')
name = gtkgui_helpers.escape_for_pango_markup(contact.name)
jid = contact.jid
status = contact.status