gajim-plural/src/gtkgui_helpers.py

38 lines
1.1 KiB
Python
Raw Normal View History

## 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 xml.sax.saxutils
import gtk
def escape_for_pango_markup(string):
# escapes < > & \ "
# for pango markup not to break
if string is None:
return
if gtk.pygtk_version >= (2, 8, 0) and gtk.gtk_version >= (2, 8, 0):
escaped_str = gobject.markup_escape_text(string)
else:
escaped_str =xml.sax.saxutils.escape(string, {'\\': '&apos;',
'"': '&quot;'})
return escaped_str