clean code and update to using GTK/PyGTK 2.8; see #2248
This commit is contained in:
parent
abcb9a35f1
commit
e9afe36ff3
|
@ -72,8 +72,7 @@ class AdvancedConfigurationWindow(object):
|
|||
renderer_text, text = 1)
|
||||
col.set_cell_data_func(renderer_text, self.cb_value_column_data)
|
||||
|
||||
if gtk.gtk_version >= (2, 8, 0) and gtk.pygtk_version >= (2, 8, 0):
|
||||
col.set_resizable(True) # there is a bug in 2.6.x series
|
||||
col.props.resizable = True
|
||||
col.set_max_width(250)
|
||||
|
||||
renderer_text = gtk.CellRendererText()
|
||||
|
|
|
@ -1,8 +1,25 @@
|
|||
'''atom_window.py - a window to display atom entries from pubsub. For now greatly simplified,
|
||||
supports only simple feeds like the one from pubsub.com. '''
|
||||
## atom_window.py - a window to display atom entries from pubsub.
|
||||
##
|
||||
## For now greatly simplified, supports only simple feeds like the
|
||||
## one from pubsub.com.
|
||||
##
|
||||
## Copyright (C) 2006-2007 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Copyright (C) 2007 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2006-2007 Liori (I think) put ur self here please
|
||||
##
|
||||
## 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 gtk
|
||||
import gtk.gdk
|
||||
import gobject
|
||||
|
||||
import gtkgui_helpers
|
||||
from common import helpers
|
||||
|
@ -11,7 +28,7 @@ class AtomWindow:
|
|||
window = None
|
||||
entries = []
|
||||
|
||||
@classmethod # python2.4 decorator
|
||||
@classmethod
|
||||
def newAtomEntry(cls, entry):
|
||||
''' Queue new entry, open window if there's no one opened. '''
|
||||
cls.entries.append(entry)
|
||||
|
@ -52,22 +69,22 @@ class AtomWindow:
|
|||
if newentry.feed_link is not None:
|
||||
self.feed_title_label.set_markup(
|
||||
u'<span foreground="blue" underline="single">%s</span>' % \
|
||||
gtkgui_helpers.escape_for_pango_markup(newentry.feed_title))
|
||||
gobject.markup_escape_text(newentry.feed_title))
|
||||
else:
|
||||
self.feed_title_label.set_markup(
|
||||
gtkgui_helpers.escape_for_pango_markup(newentry.feed_title))
|
||||
gobject.markup_escape_text(newentry.feed_title))
|
||||
|
||||
self.feed_tagline_label.set_markup(
|
||||
u'<small>%s</small>' % \
|
||||
gtkgui_helpers.escape_for_pango_markup(newentry.feed_tagline))
|
||||
gobject.markup_escape_text(newentry.feed_tagline))
|
||||
|
||||
if newentry.uri is not None:
|
||||
self.entry_title_label.set_markup(
|
||||
u'<span foreground="blue" underline="single">%s</span>' % \
|
||||
gtkgui_helpers.escape_for_pango_markup(newentry.title))
|
||||
gobject.markup_escape_text(newentry.title))
|
||||
else:
|
||||
self.entry_title_label.set_markup(
|
||||
gtkgui_helpers.escape_for_pango_markup(newentry.title))
|
||||
gobject.markup_escape_text(newentry.title))
|
||||
|
||||
self.last_modified_label.set_text(newentry.updated)
|
||||
|
||||
|
@ -97,7 +114,7 @@ class AtomWindow:
|
|||
self.displayNextEntry()
|
||||
|
||||
def on_entry_title_button_press_event(self, widget, event):
|
||||
# TODO: make it using special gtk2.10 widget
|
||||
#FIXME: make it using special gtk2.10 widget
|
||||
if event.button == 1: # left click
|
||||
uri = self.entry.uri
|
||||
if uri is not None:
|
||||
|
@ -105,7 +122,7 @@ class AtomWindow:
|
|||
return True
|
||||
|
||||
def on_feed_title_button_press_event(self, widget, event):
|
||||
# TODO: make it using special gtk2.10 widget
|
||||
#FIXME: make it using special gtk2.10 widget
|
||||
if event.button == 1: # left click
|
||||
uri = self.entry.feed_uri
|
||||
if uri is not None:
|
||||
|
|
|
@ -133,6 +133,3 @@ class CellRendererImage(gtk.GenericCellRenderer):
|
|||
(cell_area.height - calc_height - \
|
||||
self.get_property('ypad'))
|
||||
return x_offset, y_offset, calc_width, calc_height
|
||||
|
||||
if gtk.pygtk_version < (2, 8, 0):
|
||||
gobject.type_register(CellRendererImage)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## chat_control.py
|
||||
##
|
||||
## Copyright (C) 2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Copyright (C) 2006 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2006-2007 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2006 Travis Shirk <travis@pobox.com>
|
||||
## Copyright (C) 2006 Dimitur Kirov <dkirov@gmail.com>
|
||||
##
|
||||
|
@ -1033,7 +1033,7 @@ class ChatControl(ChatControlBase):
|
|||
if self.TYPE_ID == message_control.TYPE_PM:
|
||||
name = _('%(nickname)s from group chat %(room_name)s') %\
|
||||
{'nickname': name, 'room_name': self.room_name}
|
||||
name = gtkgui_helpers.escape_for_pango_markup(name)
|
||||
name = gobject.markup_escape_text(name)
|
||||
|
||||
# We know our contacts nick, but if another contact has the same nick
|
||||
# in another account we need to also display the account.
|
||||
|
@ -1048,14 +1048,14 @@ class ChatControl(ChatControlBase):
|
|||
contact_ = gajim.contacts.get_first_contact_from_jid(account, jid)
|
||||
if contact_.get_shown_name() == self.contact.get_shown_name():
|
||||
acct_info = ' (%s)' % \
|
||||
gtkgui_helpers.escape_for_pango_markup(self.account)
|
||||
gobject.markup_escape_text(self.account)
|
||||
break
|
||||
|
||||
status = contact.status
|
||||
if status is not None:
|
||||
banner_name_label.set_ellipsize(pango.ELLIPSIZE_END)
|
||||
status = helpers.reduce_chars_newlines(status, max_lines = 2)
|
||||
status_escaped = gtkgui_helpers.escape_for_pango_markup(status)
|
||||
status_escaped = gobject.markup_escape_text(status)
|
||||
|
||||
font_attrs, font_attrs_small = self.get_font_attrs()
|
||||
st = gajim.config.get('displayed_chat_state_notifications')
|
||||
|
@ -1330,7 +1330,7 @@ class ChatControl(ChatControlBase):
|
|||
name = self.contact.get_shown_name()
|
||||
if self.resource:
|
||||
name += '/' + self.resource
|
||||
label_str = gtkgui_helpers.escape_for_pango_markup(name)
|
||||
label_str = gobject.markup_escape_text(name)
|
||||
if num_unread: # if unread, text in the label becomes bold
|
||||
label_str = '<b>' + unread + label_str + '</b>'
|
||||
return (label_str, color)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
##
|
||||
## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Copyright (C) 2003-2004 Vincent Hanquez <tab@snarc.org>
|
||||
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005-2007 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005 Dimitur Kirov <dkirov@gmail.com>
|
||||
## Copyright (C) 2005-2006 Travis Shirk <travis@pobox.com>
|
||||
## Copyright (C) 2005 Norman Rasmussen <norman@rasmussen.co.za>
|
||||
|
@ -768,8 +768,7 @@ class AboutDialog:
|
|||
|
||||
dlg.set_authors(authors)
|
||||
|
||||
if gtk.pygtk_version >= (2, 8, 0) and gtk.gtk_version >= (2, 8, 0):
|
||||
dlg.props.wrap_license = True
|
||||
dlg.props.wrap_license = True
|
||||
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(
|
||||
gajim.DATA_DIR, 'pixmaps', 'gajim_about.png'))
|
||||
|
@ -1855,7 +1854,7 @@ class PrivacyListWindow:
|
|||
|
||||
self.privacy_lists_title_label.set_label(
|
||||
_('Privacy List <b><i>%s</i></b>') % \
|
||||
gtkgui_helpers.escape_for_pango_markup(self.privacy_list_name))
|
||||
gobject.markup_escape_text(self.privacy_list_name))
|
||||
|
||||
if len(gajim.connections) > 1:
|
||||
title = _('Privacy List for %s') % self.account
|
||||
|
|
10
src/disco.py
10
src/disco.py
|
@ -2,7 +2,7 @@
|
|||
## config.py
|
||||
##
|
||||
## Copyright (C) 2005-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005-2007 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005-2006 Stéphan Kochen <stephan@kochen.nl>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
|
@ -41,6 +41,7 @@ import inspect
|
|||
import weakref
|
||||
import gobject
|
||||
import gtk
|
||||
import gobject
|
||||
import pango
|
||||
|
||||
import dialogs
|
||||
|
@ -497,10 +498,7 @@ _('Without a connection, you can not browse available services'))
|
|||
title_text = _('Service Discovery using account %s') % self.account
|
||||
self.window.set_title(title_text)
|
||||
self._set_window_banner_text(_('Service Discovery'))
|
||||
if gtk.gtk_version >= (2, 8, 0) and gtk.pygtk_version >= (2, 8, 0):
|
||||
self.banner_icon.clear()
|
||||
else:
|
||||
self.banner_icon.set_from_file(None)
|
||||
self.banner_icon.clear()
|
||||
self.banner_icon.hide() # Just clearing it doesn't work
|
||||
|
||||
def _set_window_banner_text(self, text, text_after = None):
|
||||
|
@ -1730,7 +1728,7 @@ class DiscussionGroupsBrowser(AgentBrowser):
|
|||
dunno = True
|
||||
subscribed = False
|
||||
|
||||
name = gtkgui_helpers.escape_for_pango_markup(name)
|
||||
name = gobject.markup_escape_text(name)
|
||||
name = '<b>%s</b>' % name
|
||||
|
||||
model.append((jid, node, name, dunno, subscribed))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## filetransfers_window.py
|
||||
##
|
||||
## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005-2007 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005
|
||||
## Dimitur Kirov <dkirov@gmail.com>
|
||||
## Travis Shirk <travis@pobox.com>
|
||||
|
@ -575,7 +575,7 @@ _('Connection with peer cannot be established.'))
|
|||
(file_path, file_name) = os.path.split(file_props['file-name'])
|
||||
else:
|
||||
file_name = file_props['name']
|
||||
text_props = gtkgui_helpers.escape_for_pango_markup(file_name) + '\n'
|
||||
text_props = gobject.markup_escape_text(file_name) + '\n'
|
||||
text_props += contact.get_shown_name()
|
||||
self.model.set(iter, 1, text_labels, 2, text_props, C_SID,
|
||||
file_props['type'] + file_props['sid'])
|
||||
|
|
25
src/gajim.py
25
src/gajim.py
|
@ -122,12 +122,12 @@ except RuntimeError, msg:
|
|||
print >> sys.stderr, _('Gajim needs X server to run. Quiting...')
|
||||
sys.exit()
|
||||
pritext = ''
|
||||
if gtk.pygtk_version < (2, 6, 0):
|
||||
pritext = _('Gajim needs PyGTK 2.6 or above')
|
||||
sectext = _('Gajim needs PyGTK 2.6 or above to run. Quiting...')
|
||||
elif gtk.gtk_version < (2, 6, 0):
|
||||
pritext = _('Gajim needs GTK 2.6 or above')
|
||||
sectext = _('Gajim needs GTK 2.6 or above to run. Quiting...')
|
||||
if gtk.pygtk_version < (2, 8, 0):
|
||||
pritext = _('Gajim needs PyGTK 2.8 or above')
|
||||
sectext = _('Gajim needs PyGTK 2.8 or above to run. Quiting...')
|
||||
elif gtk.gtk_version < (2, 8, 0):
|
||||
pritext = _('Gajim needs GTK 2.8 or above')
|
||||
sectext = _('Gajim needs GTK 2.8 or above to run. Quiting...')
|
||||
|
||||
try:
|
||||
import gtk.glade # check if user has libglade (in pygtk and in gtk)
|
||||
|
@ -340,10 +340,9 @@ class GlibIdleQueue(idlequeue.IdleQueue):
|
|||
''' this method is called at the end of class constructor.
|
||||
Creates a dict, which maps file/pipe/sock descriptor to glib event id'''
|
||||
self.events = {}
|
||||
if gtk.pygtk_version >= (2, 8, 0):
|
||||
# time() is already called in glib, we just get the last value
|
||||
# overrides IdleQueue.current_time()
|
||||
self.current_time = lambda: gobject.get_current_time()
|
||||
# time() is already called in glib, we just get the last value
|
||||
# overrides IdleQueue.current_time()
|
||||
self.current_time = lambda: gobject.get_current_time()
|
||||
|
||||
def add_idle(self, fd, flags):
|
||||
''' this method is called when we plug a new idle object.
|
||||
|
@ -2107,9 +2106,9 @@ class Interface:
|
|||
else:
|
||||
gajim.log.setLevel(None)
|
||||
|
||||
# pygtk2.8 on win, breaks io_add_watch. We use good old select.select()
|
||||
if os.name == 'nt' and (gtk.pygtk_version > (2, 8, 0) or
|
||||
gtk.gtk_version > (2, 8, 0)):
|
||||
# pygtk2.8+ on win, breaks io_add_watch.
|
||||
# We use good old select.select()
|
||||
if os.name == 'nt':
|
||||
gajim.idlequeue = idlequeue.SelectIdleQueue()
|
||||
else:
|
||||
# in a nongui implementation, just call:
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
## Vincent Hanquez <tab@snarc.org>
|
||||
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Vincent Hanquez <tab@snarc.org>
|
||||
## Nikos Kouremenos <kourem@gmail.com>
|
||||
## Dimitur Kirov <dkirov@gmail.com>
|
||||
## Travis Shirk <travis@pobox.com>
|
||||
## Norman Rasmussen <norman@rasmussen.co.za>
|
||||
## Copyright (C) 2006 Travis Shirk <travis@pobox.com>
|
||||
## Copyright (C) 2005-2007 Nikos Kouremenos <kourem@gmail.com>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published
|
||||
|
@ -460,7 +460,7 @@ class GroupchatControl(ChatControlBase):
|
|||
text = '<span %s>%s</span>' % (font_attrs, self.room_jid)
|
||||
if self.subject:
|
||||
subject = helpers.reduce_chars_newlines(self.subject, max_lines = 2)
|
||||
subject = gtkgui_helpers.escape_for_pango_markup(subject)
|
||||
subject = gobject.markup_escape_text(subject)
|
||||
text += '\n<span %s>%s</span>' % (font_attrs_small, subject)
|
||||
|
||||
# tooltip must always hold ALL the subject
|
||||
|
@ -778,7 +778,7 @@ class GroupchatControl(ChatControlBase):
|
|||
else:
|
||||
image = state_images[gc_contact.show]
|
||||
|
||||
name = gtkgui_helpers.escape_for_pango_markup(gc_contact.name)
|
||||
name = gobject.markup_escape_text(gc_contact.name)
|
||||
status = gc_contact.status
|
||||
# add status msg, if not empty, under contact name in the treeview
|
||||
if status and gajim.config.get('show_status_msgs_in_roster'):
|
||||
|
@ -790,7 +790,7 @@ class GroupchatControl(ChatControlBase):
|
|||
selected, focus)
|
||||
colorstring = "#%04x%04x%04x" % (color.red, color.green, color.blue)
|
||||
name += '\n' '<span size="small" style="italic" foreground="%s">%s</span>'\
|
||||
% (colorstring, gtkgui_helpers.escape_for_pango_markup(status))
|
||||
% (colorstring, gobject.markup_escape_text(status))
|
||||
|
||||
model[iter][C_IMG] = image
|
||||
model[iter][C_TEXT] = name
|
||||
|
|
|
@ -172,19 +172,6 @@ def get_default_font():
|
|||
|
||||
return None
|
||||
|
||||
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, {"'": ''',
|
||||
'"': '"'})
|
||||
|
||||
return escaped_str
|
||||
|
||||
def autodetect_browser_mailer():
|
||||
# recognize the environment and set appropriate browser/mailer
|
||||
if user_runs_gnome():
|
||||
|
@ -354,8 +341,7 @@ def parse_server_xml(path_to_file):
|
|||
def set_unset_urgency_hint(window, unread_messages_no):
|
||||
'''sets/unsets urgency hint in window argument
|
||||
depending if we have unread messages or not'''
|
||||
if gtk.gtk_version >= (2, 8, 0) and gtk.pygtk_version >= (2, 8, 0) and \
|
||||
gajim.config.get('use_urgency_hint'):
|
||||
if gajim.config.get('use_urgency_hint'):
|
||||
if unread_messages_no > 0:
|
||||
window.props.urgency_hint = True
|
||||
else:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
## history_manager.py
|
||||
##
|
||||
## Copyright (C) 2006 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2006-2007 Nikos Kouremenos <kourem@gmail.com>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published
|
||||
|
@ -21,6 +21,7 @@ import sys
|
|||
import os
|
||||
import signal
|
||||
import gtk
|
||||
import gobject
|
||||
import time
|
||||
import locale
|
||||
|
||||
|
@ -337,7 +338,7 @@ class HistoryManager:
|
|||
if color:
|
||||
message_ += ' foreground="%s"' % color
|
||||
message_ += '>%s</span>' % \
|
||||
gtkgui_helpers.escape_for_pango_markup(message)
|
||||
gobject.markup_escape_text(message)
|
||||
self.logs_liststore.append((log_line_id, jid_id, time_, message_,
|
||||
subject, nickname))
|
||||
|
||||
|
@ -399,8 +400,7 @@ class HistoryManager:
|
|||
dlg = xml.get_widget('filechooserdialog')
|
||||
dlg.set_title(_('Exporting History Logs...'))
|
||||
dlg.set_current_folder(gajim.HOME_DIR)
|
||||
if gtk.pygtk_version > (2, 8, 0):
|
||||
dlg.props.do_overwrite_confirmation = True
|
||||
dlg.props.do_overwrite_confirmation = True
|
||||
response = dlg.run()
|
||||
|
||||
if response == gtk.RESPONSE_OK: # user want us to export ;)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
### Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
"""
|
||||
'''
|
||||
A gtk.TextView-based renderer for XHTML-IM, as described in:
|
||||
http://www.jabber.org/jeps/jep-0071.html
|
||||
|
||||
|
@ -26,7 +26,7 @@ I (Santiago Gala) am trying to make it more compatible
|
|||
with the markup that docutils generate, and also more
|
||||
modular.
|
||||
|
||||
"""
|
||||
'''
|
||||
|
||||
import gobject
|
||||
import pango
|
||||
|
@ -47,8 +47,8 @@ import tooltips
|
|||
|
||||
__all__ = ['HtmlTextView']
|
||||
|
||||
whitespace_rx = re.compile("\\s+")
|
||||
allwhitespace_rx = re.compile("^\\s*$")
|
||||
whitespace_rx = re.compile('\\s+')
|
||||
allwhitespace_rx = re.compile('^\\s*$')
|
||||
|
||||
# pixels = points * display_resolution
|
||||
display_resolution = 0.3514598*(gtk.gdk.screen_height() /
|
||||
|
@ -84,7 +84,7 @@ element_styles['b'] = element_styles['strong']
|
|||
class_styles = {
|
||||
}
|
||||
|
||||
"""
|
||||
'''
|
||||
==========
|
||||
JEP-0071
|
||||
==========
|
||||
|
@ -154,7 +154,7 @@ Common.extra
|
|||
# ( structural = br | span )
|
||||
#Param/Legacy param, font, basefont, center, s, strike, u, dir, menu, isindex
|
||||
#
|
||||
"""
|
||||
'''
|
||||
|
||||
BLOCK_HEAD = set(( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', ))
|
||||
BLOCK_PHRASAL = set(( 'address', 'blockquote', 'pre', ))
|
||||
|
@ -223,7 +223,7 @@ def build_patterns(view, config, interface):
|
|||
|
||||
def _parse_css_color(color):
|
||||
'''_parse_css_color(css_color) -> gtk.gdk.Color'''
|
||||
if color.startswith("rgb(") and color.endswith(')'):
|
||||
if color.startswith('rgb(') and color.endswith(')'):
|
||||
r, g, b = [int(c)*257 for c in color[4:-1].split(',')]
|
||||
return gtk.gdk.Color(r, g, b)
|
||||
else:
|
||||
|
@ -246,15 +246,15 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
|
||||
def _parse_style_color(self, tag, value):
|
||||
color = _parse_css_color(value)
|
||||
tag.set_property("foreground-gdk", color)
|
||||
tag.set_property('foreground-gdk', color)
|
||||
|
||||
def _parse_style_background_color(self, tag, value):
|
||||
color = _parse_css_color(value)
|
||||
tag.set_property("background-gdk", color)
|
||||
if gtk.gtk_version >= (2, 8):
|
||||
tag.set_property("paragraph-background-gdk", color)
|
||||
tag.set_property('background-gdk', color)
|
||||
tag.set_property('paragraph-background-gdk', color)
|
||||
|
||||
|
||||
#FIXME: when we migrate to 2.10 rm this
|
||||
if gtk.gtk_version >= (2, 8, 5) or gobject.pygtk_version >= (2, 8, 1):
|
||||
|
||||
def _get_current_attributes(self):
|
||||
|
@ -270,7 +270,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
def _get_current_style_attr(self, propname, comb_oper=None):
|
||||
tags = [tag for tag in self.styles if tag is not None]
|
||||
tags.reverse()
|
||||
is_set_name = propname + "-set"
|
||||
is_set_name = propname + '-set'
|
||||
value = None
|
||||
for tag in tags:
|
||||
if tag.get_property(is_set_name):
|
||||
|
@ -283,15 +283,15 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
return value
|
||||
|
||||
class _FakeAttrs(object):
|
||||
__slots__ = ("font", "font_scale")
|
||||
__slots__ = ('font', 'font_scale')
|
||||
|
||||
def _get_current_attributes(self):
|
||||
attrs = self._FakeAttrs()
|
||||
attrs.font_scale = self._get_current_style_attr("scale",
|
||||
attrs.font_scale = self._get_current_style_attr('scale',
|
||||
operator.mul)
|
||||
if attrs.font_scale is None:
|
||||
attrs.font_scale = 1.0
|
||||
attrs.font = self._get_current_style_attr("font-desc")
|
||||
attrs.font = self._get_current_style_attr('font-desc')
|
||||
if attrs.font is None:
|
||||
attrs.font = self.textview.style.font_desc
|
||||
return attrs
|
||||
|
@ -311,14 +311,14 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
font_size = attrs.font.get_size() / pango.SCALE
|
||||
callback(frac*display_resolution*font_size, *args)
|
||||
else:
|
||||
# CSS says "Percentage values: refer to width of the closest
|
||||
# block-level ancestor"
|
||||
# CSS says 'Percentage values: refer to width of the closest
|
||||
# block-level ancestor'
|
||||
# This is difficult/impossible to implement, so we use
|
||||
# textview width instead; a reasonable approximation..
|
||||
alloc = self.textview.get_allocation()
|
||||
self.__parse_length_frac_size_allocate(self.textview, alloc,
|
||||
frac, callback, args)
|
||||
self.textview.connect("size-allocate",
|
||||
self.textview.connect('size-allocate',
|
||||
self.__parse_length_frac_size_allocate,
|
||||
frac, callback, args)
|
||||
|
||||
|
@ -341,10 +341,10 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
callback(int(value[:-2]), *args)
|
||||
|
||||
else:
|
||||
warnings.warn("Unable to parse length value '%s'" % value)
|
||||
warnings.warn('Unable to parse length value '%s'' % value)
|
||||
|
||||
def __parse_font_size_cb(length, tag):
|
||||
tag.set_property("size-points", length/display_resolution)
|
||||
tag.set_property('size-points', length/display_resolution)
|
||||
__parse_font_size_cb = staticmethod(__parse_font_size_cb)
|
||||
|
||||
def _parse_style_display(self, tag, value):
|
||||
|
@ -355,39 +355,39 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
def _parse_style_font_size(self, tag, value):
|
||||
try:
|
||||
scale = {
|
||||
"xx-small": pango.SCALE_XX_SMALL,
|
||||
"x-small": pango.SCALE_X_SMALL,
|
||||
"small": pango.SCALE_SMALL,
|
||||
"medium": pango.SCALE_MEDIUM,
|
||||
"large": pango.SCALE_LARGE,
|
||||
"x-large": pango.SCALE_X_LARGE,
|
||||
"xx-large": pango.SCALE_XX_LARGE,
|
||||
'xx-small': pango.SCALE_XX_SMALL,
|
||||
'x-small': pango.SCALE_X_SMALL,
|
||||
'small': pango.SCALE_SMALL,
|
||||
'medium': pango.SCALE_MEDIUM,
|
||||
'large': pango.SCALE_LARGE,
|
||||
'x-large': pango.SCALE_X_LARGE,
|
||||
'xx-large': pango.SCALE_XX_LARGE,
|
||||
} [value]
|
||||
except KeyError:
|
||||
pass
|
||||
else:
|
||||
attrs = self._get_current_attributes()
|
||||
tag.set_property("scale", scale / attrs.font_scale)
|
||||
tag.set_property('scale', scale / attrs.font_scale)
|
||||
return
|
||||
if value == 'smaller':
|
||||
tag.set_property("scale", pango.SCALE_SMALL)
|
||||
tag.set_property('scale', pango.SCALE_SMALL)
|
||||
return
|
||||
if value == 'larger':
|
||||
tag.set_property("scale", pango.SCALE_LARGE)
|
||||
tag.set_property('scale', pango.SCALE_LARGE)
|
||||
return
|
||||
self._parse_length(value, True, self.__parse_font_size_cb, tag)
|
||||
|
||||
def _parse_style_font_style(self, tag, value):
|
||||
try:
|
||||
style = {
|
||||
"normal": pango.STYLE_NORMAL,
|
||||
"italic": pango.STYLE_ITALIC,
|
||||
"oblique": pango.STYLE_OBLIQUE,
|
||||
'normal': pango.STYLE_NORMAL,
|
||||
'italic': pango.STYLE_ITALIC,
|
||||
'oblique': pango.STYLE_OBLIQUE,
|
||||
} [value]
|
||||
except KeyError:
|
||||
warnings.warn("unknown font-style %s" % value)
|
||||
warnings.warn('unknown font-style %s' % value)
|
||||
else:
|
||||
tag.set_property("style", style)
|
||||
tag.set_property('style', style)
|
||||
|
||||
def __frac_length_tag_cb(self,length, tag, propname):
|
||||
styles = self._get_style_tags()
|
||||
|
@ -398,11 +398,11 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
|
||||
def _parse_style_margin_left(self, tag, value):
|
||||
self._parse_length(value, False, self.__frac_length_tag_cb,
|
||||
tag, "left-margin")
|
||||
tag, 'left-margin')
|
||||
|
||||
def _parse_style_margin_right(self, tag, value):
|
||||
self._parse_length(value, False, self.__frac_length_tag_cb,
|
||||
tag, "right-margin")
|
||||
tag, 'right-margin')
|
||||
|
||||
def _parse_style_font_weight(self, tag, value):
|
||||
# TODO: missing 'bolder' and 'lighter'
|
||||
|
@ -421,12 +421,12 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
'bold': pango.WEIGHT_BOLD,
|
||||
} [value]
|
||||
except KeyError:
|
||||
warnings.warn("unknown font-style %s" % value)
|
||||
warnings.warn('unknown font-style %s' % value)
|
||||
else:
|
||||
tag.set_property("weight", weight)
|
||||
tag.set_property('weight', weight)
|
||||
|
||||
def _parse_style_font_family(self, tag, value):
|
||||
tag.set_property("family", value)
|
||||
tag.set_property('family', value)
|
||||
|
||||
def _parse_style_text_align(self, tag, value):
|
||||
try:
|
||||
|
@ -437,47 +437,47 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
'justify': gtk.JUSTIFY_FILL,
|
||||
} [value]
|
||||
except KeyError:
|
||||
warnings.warn("Invalid text-align:%s requested" % value)
|
||||
warnings.warn('Invalid text-align:%s requested' % value)
|
||||
else:
|
||||
tag.set_property("justification", align)
|
||||
tag.set_property('justification', align)
|
||||
|
||||
def _parse_style_text_decoration(self, tag, value):
|
||||
if value == "none":
|
||||
tag.set_property("underline", pango.UNDERLINE_NONE)
|
||||
tag.set_property("strikethrough", False)
|
||||
elif value == "underline":
|
||||
tag.set_property("underline", pango.UNDERLINE_SINGLE)
|
||||
tag.set_property("strikethrough", False)
|
||||
elif value == "overline":
|
||||
warnings.warn("text-decoration:overline not implemented")
|
||||
tag.set_property("underline", pango.UNDERLINE_NONE)
|
||||
tag.set_property("strikethrough", False)
|
||||
elif value == "line-through":
|
||||
tag.set_property("underline", pango.UNDERLINE_NONE)
|
||||
tag.set_property("strikethrough", True)
|
||||
elif value == "blink":
|
||||
warnings.warn("text-decoration:blink not implemented")
|
||||
if value == 'none':
|
||||
tag.set_property('underline', pango.UNDERLINE_NONE)
|
||||
tag.set_property('strikethrough', False)
|
||||
elif value == 'underline':
|
||||
tag.set_property('underline', pango.UNDERLINE_SINGLE)
|
||||
tag.set_property('strikethrough', False)
|
||||
elif value == 'overline':
|
||||
warnings.warn('text-decoration:overline not implemented')
|
||||
tag.set_property('underline', pango.UNDERLINE_NONE)
|
||||
tag.set_property('strikethrough', False)
|
||||
elif value == 'line-through':
|
||||
tag.set_property('underline', pango.UNDERLINE_NONE)
|
||||
tag.set_property('strikethrough', True)
|
||||
elif value == 'blink':
|
||||
warnings.warn('text-decoration:blink not implemented')
|
||||
else:
|
||||
warnings.warn("text-decoration:%s not implemented" % value)
|
||||
warnings.warn('text-decoration:%s not implemented' % value)
|
||||
|
||||
def _parse_style_white_space(self, tag, value):
|
||||
if value == 'pre':
|
||||
tag.set_property("wrap_mode", gtk.WRAP_NONE)
|
||||
tag.set_property('wrap_mode', gtk.WRAP_NONE)
|
||||
elif value == 'normal':
|
||||
tag.set_property("wrap_mode", gtk.WRAP_WORD)
|
||||
tag.set_property('wrap_mode', gtk.WRAP_WORD)
|
||||
elif value == 'nowrap':
|
||||
tag.set_property("wrap_mode", gtk.WRAP_NONE)
|
||||
tag.set_property('wrap_mode', gtk.WRAP_NONE)
|
||||
|
||||
|
||||
# build a dictionary mapping styles to methods, for greater speed
|
||||
__style_methods = dict()
|
||||
for style in ["background-color", "color", "font-family", "font-size",
|
||||
"font-style", "font-weight", "margin-left", "margin-right",
|
||||
"text-align", "text-decoration", "white-space", 'display' ]:
|
||||
for style in ['background-color', 'color', 'font-family', 'font-size',
|
||||
'font-style', 'font-weight', 'margin-left', 'margin-right',
|
||||
'text-align', 'text-decoration', 'white-space', 'display' ]:
|
||||
try:
|
||||
method = locals()["_parse_style_%s" % style.replace('-', '_')]
|
||||
method = locals()['_parse_style_%s' % style.replace('-', '_')]
|
||||
except KeyError:
|
||||
warnings.warn("Style attribute '%s' not yet implemented" % style)
|
||||
warnings.warn('Style attribute '%s' not yet implemented' % style)
|
||||
else:
|
||||
__style_methods[style] = method
|
||||
del style
|
||||
|
@ -515,8 +515,8 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
try:
|
||||
method = self.__style_methods[attr]
|
||||
except KeyError:
|
||||
warnings.warn("Style attribute '%s' requested "
|
||||
"but not yet implemented" % attr)
|
||||
warnings.warn('Style attribute '%s' requested '
|
||||
'but not yet implemented' % attr)
|
||||
else:
|
||||
method(self, tag, val)
|
||||
self.styles.append(tag)
|
||||
|
@ -547,11 +547,11 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
text = text.replace('\n', ' ')
|
||||
self.handle_specials(whitespace_rx.sub(' ', text))
|
||||
else:
|
||||
self._insert_text(text.strip("\n"))
|
||||
self._insert_text(text.strip('\n'))
|
||||
|
||||
def _anchor_event(self, tag, textview, event, iter, href, type_):
|
||||
if event.type == gtk.gdk.BUTTON_PRESS:
|
||||
self.textview.emit("url-clicked", href, type_)
|
||||
self.textview.emit('url-clicked', href, type_)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -585,7 +585,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
if special_text.startswith('/'): # it's explicit italics
|
||||
self.startElement('i', {})
|
||||
elif special_text.startswith('_'): # it's explicit underline
|
||||
self.startElement("u", {})
|
||||
self.startElement('u', {})
|
||||
if se: self._insert_text(special_text[0])
|
||||
self.handle_specials(special_text[1:-1])
|
||||
if se: self._insert_text(special_text[0])
|
||||
|
@ -670,7 +670,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
li_head = unichr(0x2022)
|
||||
else:
|
||||
self.list_counters[-1] += 1
|
||||
li_head = "%i." % self.list_counters[-1]
|
||||
li_head = '%i.' % self.list_counters[-1]
|
||||
self.text = ' '*len(self.list_counters)*4 + li_head + ' '
|
||||
self._flush_text()
|
||||
self.starting = True
|
||||
|
@ -692,7 +692,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
except Exception, ex:
|
||||
gajim.log.debug(str('Error loading image'+ex))
|
||||
pixbuf = None
|
||||
alt = attrs.get('alt', "Broken image")
|
||||
alt = attrs.get('alt', 'Broken image')
|
||||
try:
|
||||
loader.close()
|
||||
except: pass
|
||||
|
@ -709,7 +709,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
self.textbuf.apply_tag(tag, start, self.iter)
|
||||
self.textbuf.delete_mark(tmpmark)
|
||||
else:
|
||||
self._insert_text("[IMG: %s]" % alt)
|
||||
self._insert_text('[IMG: %s]' % alt)
|
||||
elif name == 'body' or name == 'html':
|
||||
pass
|
||||
elif name == 'a':
|
||||
|
@ -717,7 +717,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
elif name in INLINE:
|
||||
pass
|
||||
else:
|
||||
warnings.warn("Unhandled element '%s'" % name)
|
||||
warnings.warn('Unhandled element '%s'' % name)
|
||||
|
||||
def endElement(self, name):
|
||||
endPreserving = False
|
||||
|
@ -729,10 +729,10 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
self._jump_line()
|
||||
try:
|
||||
self.textbuf.insert_pixbuf(self.iter, self.textview.focus_out_line_pixbuf)
|
||||
#self._insert_text(u"\u2550"*40)
|
||||
#self._insert_text(u'\u2550'*40)
|
||||
self._jump_line()
|
||||
except Exception, e:
|
||||
gajim.log.debug(str("Error in hr"+e))
|
||||
gajim.log.debug(str('Error in hr'+e))
|
||||
elif name in LIST_ELEMS:
|
||||
self.list_counters.pop()
|
||||
elif name == 'li':
|
||||
|
@ -751,7 +751,7 @@ class HtmlHandler(xml.sax.handler.ContentHandler):
|
|||
if name == 'pre':
|
||||
endPreserving = True
|
||||
else:
|
||||
warnings.warn("Unhandled element '%s'" % name)
|
||||
warnings.warn('Unhandled element '%s'' % name)
|
||||
self._flush_text()
|
||||
if endPreserving:
|
||||
self.preserve = False
|
||||
|
@ -772,9 +772,9 @@ class HtmlTextView(gtk.TextView):
|
|||
self.set_wrap_mode(gtk.WRAP_CHAR)
|
||||
self.set_editable(False)
|
||||
self._changed_cursor = False
|
||||
self.connect("motion-notify-event", self.__motion_notify_event)
|
||||
self.connect("leave-notify-event", self.__leave_event)
|
||||
self.connect("enter-notify-event", self.__motion_notify_event)
|
||||
self.connect('motion-notify-event', self.__motion_notify_event)
|
||||
self.connect('leave-notify-event', self.__leave_event)
|
||||
self.connect('enter-notify-event', self.__motion_notify_event)
|
||||
self.get_buffer().create_tag('eol', scale = pango.SCALE_XX_SMALL)
|
||||
self.tooltip = tooltips.BaseTooltip()
|
||||
self.config = gajim.config
|
||||
|
@ -842,10 +842,8 @@ class HtmlTextView(gtk.TextView):
|
|||
parser.parse(StringIO(html))
|
||||
|
||||
#if not eob.starts_line():
|
||||
# buffer.insert(eob, "\n")
|
||||
# buffer.insert(eob, '\n')
|
||||
|
||||
if gobject.pygtk_version < (2, 8):
|
||||
gobject.type_register(HtmlTextView)
|
||||
|
||||
change_cursor = None
|
||||
|
||||
|
@ -900,25 +898,25 @@ if __name__ == '__main__':
|
|||
' <img src="http://images.slashdot.org/topics/topicsoftware.gif"/><br/>\n'
|
||||
' <span style="font-size: 500%; font-family: serif">World</span>\n'
|
||||
'</div>\n')
|
||||
htmlview.display_html("<hr />")
|
||||
htmlview.display_html("""
|
||||
htmlview.display_html('<hr />')
|
||||
htmlview.display_html('''
|
||||
<p style='font-size:large'>
|
||||
<span style='font-style: italic'>O<span style='font-size:larger'>M</span>G</span>,
|
||||
I'm <span style='color:green'>green</span>
|
||||
with <span style='font-weight: bold'>envy</span>!
|
||||
</p>
|
||||
""")
|
||||
htmlview.display_html("<hr />")
|
||||
htmlview.display_html("""
|
||||
''')
|
||||
htmlview.display_html('<hr />')
|
||||
htmlview.display_html('''
|
||||
<body xmlns='http://www.w3.org/1999/xhtml'>
|
||||
<p>As Emerson said in his essay <span style='font-style: italic; background-color:cyan'>Self-Reliance</span>:</p>
|
||||
<p style='margin-left: 5px; margin-right: 2%'>
|
||||
"A foolish consistency is the hobgoblin of little minds."
|
||||
</p>
|
||||
</body>
|
||||
""")
|
||||
htmlview.display_html("<hr />")
|
||||
htmlview.display_html("""
|
||||
''')
|
||||
htmlview.display_html('<hr />')
|
||||
htmlview.display_html('''
|
||||
<body xmlns='http://www.w3.org/1999/xhtml'>
|
||||
<p style='text-align:center'>Hey, are you licensed to <a href='http://www.jabber.org/'>Jabber</a>?</p>
|
||||
<p style='text-align:right'><img src='http://www.jabber.org/images/psa-license.jpg'
|
||||
|
@ -926,9 +924,9 @@ if __name__ == '__main__':
|
|||
height='261'
|
||||
width='537'/></p>
|
||||
</body>
|
||||
""")
|
||||
htmlview.display_html("<hr />")
|
||||
htmlview.display_html("""
|
||||
''')
|
||||
htmlview.display_html('<hr />')
|
||||
htmlview.display_html('''
|
||||
<body xmlns='http://www.w3.org/1999/xhtml'>
|
||||
<ul style='background-color:rgb(120,140,100)'>
|
||||
<li> One </li>
|
||||
|
@ -938,12 +936,12 @@ if __name__ == '__main__':
|
|||
def faciter(n,acc):
|
||||
if n==0: return acc
|
||||
return faciter(n-1, acc*n)
|
||||
if n<0: raise ValueError("Must be non-negative")
|
||||
if n<0: raise ValueError('Must be non-negative')
|
||||
return faciter(n,1)</pre>
|
||||
</body>
|
||||
""")
|
||||
htmlview.display_html("<hr />")
|
||||
htmlview.display_html("""
|
||||
''')
|
||||
htmlview.display_html('<hr />')
|
||||
htmlview.display_html('''
|
||||
<body xmlns='http://www.w3.org/1999/xhtml'>
|
||||
<ol style='background-color:rgb(120,140,100)'>
|
||||
<li> One </li>
|
||||
|
@ -954,12 +952,12 @@ if __name__ == '__main__':
|
|||
</ul></li>
|
||||
<li> Three </li></ol>
|
||||
</body>
|
||||
""")
|
||||
''')
|
||||
htmlview.show()
|
||||
sw = gtk.ScrolledWindow()
|
||||
sw.set_property("hscrollbar-policy", gtk.POLICY_AUTOMATIC)
|
||||
sw.set_property("vscrollbar-policy", gtk.POLICY_AUTOMATIC)
|
||||
sw.set_property("border-width", 0)
|
||||
sw.set_property('hscrollbar-policy', gtk.POLICY_AUTOMATIC)
|
||||
sw.set_property('vscrollbar-policy', gtk.POLICY_AUTOMATIC)
|
||||
sw.set_property('border-width', 0)
|
||||
sw.add(htmlview)
|
||||
sw.show()
|
||||
frame = gtk.Frame()
|
||||
|
@ -970,5 +968,5 @@ if __name__ == '__main__':
|
|||
w.add(frame)
|
||||
w.set_default_size(400, 300)
|
||||
w.show_all()
|
||||
w.connect("destroy", lambda w: gtk.main_quit())
|
||||
w.connect('destroy', lambda w: gtk.main_quit())
|
||||
gtk.main()
|
||||
|
|
|
@ -62,9 +62,6 @@ class MessageTextView(gtk.TextView):
|
|||
start, end = buffer.get_bounds()
|
||||
buffer.delete(start, end)
|
||||
|
||||
if gobject.pygtk_version < (2, 8, 0):
|
||||
gobject.type_register(MessageTextView)
|
||||
|
||||
|
||||
# We register depending on keysym and modifier some bindings
|
||||
# but we also pass those as param so we can construct fake Event
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## notify.py
|
||||
##
|
||||
## Copyright (C) 2005-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005-2007 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005-2006 Andrew Sayman <lorien420@myrealbox.com>
|
||||
##
|
||||
## Notification daemon connection via D-Bus code:
|
||||
|
@ -20,6 +20,7 @@
|
|||
import os
|
||||
import time
|
||||
import dialogs
|
||||
import gobject
|
||||
import gtkgui_helpers
|
||||
|
||||
from common import gajim
|
||||
|
@ -280,8 +281,8 @@ def popup(event_type, jid, account, msg_type = '', path_to_image = None,
|
|||
'''Notifies a user of an event. It first tries to a valid implementation of
|
||||
the Desktop Notification Specification. If that fails, then we fall back to
|
||||
the older style PopupNotificationWindow method.'''
|
||||
text = gtkgui_helpers.escape_for_pango_markup(text)
|
||||
title = gtkgui_helpers.escape_for_pango_markup(title)
|
||||
text = gobject.markup_escape_text(text)
|
||||
title = gobject.markup_escape_text(title)
|
||||
|
||||
if gajim.config.get('use_notif_daemon') and dbus_support.supported:
|
||||
try:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
## roster_window.py
|
||||
##
|
||||
## Copyright (C) 2003-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005-2007 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005-2006 Dimitur Kirov <dkirov@gmail.com>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
|
@ -182,7 +182,7 @@ class RosterWindow:
|
|||
our_jid = gajim.get_jid_from_account(account)
|
||||
|
||||
model.append(None, [self.jabber_state_images['16'][show],
|
||||
gtkgui_helpers.escape_for_pango_markup(account),
|
||||
gobject.markup_escape_text(account),
|
||||
'account', our_jid, account, tls_pixbuf])
|
||||
|
||||
def draw_account(self, account):
|
||||
|
@ -350,7 +350,7 @@ class RosterWindow:
|
|||
IterAcct = self.get_account_iter(account)
|
||||
iterG = model.append(IterAcct, [
|
||||
self.jabber_state_images['16']['closed'],
|
||||
gtkgui_helpers.escape_for_pango_markup(group), 'group',
|
||||
gobject.markup_escape_text(group), 'group',
|
||||
group, account, None])
|
||||
self.draw_group(group, account)
|
||||
if model.iter_n_children(IterAcct) == 1: # We added the first one
|
||||
|
@ -396,7 +396,7 @@ class RosterWindow:
|
|||
accounts = accounts, groups = [group])
|
||||
text += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total))
|
||||
model = self.tree.get_model()
|
||||
model.set_value(iter, 1 , gtkgui_helpers.escape_for_pango_markup(text))
|
||||
model.set_value(iter, 1 , gobject.markup_escape_text(text))
|
||||
|
||||
def add_to_not_in_the_roster(self, account, jid, nick = ''):
|
||||
''' add jid to group "not in the roster", he MUST not be in roster yet,
|
||||
|
@ -558,7 +558,7 @@ class RosterWindow:
|
|||
contact_instances)
|
||||
if not contact:
|
||||
return
|
||||
name = gtkgui_helpers.escape_for_pango_markup(contact.get_shown_name())
|
||||
name = gobject.markup_escape_text(contact.get_shown_name())
|
||||
|
||||
nb_connected_contact = 0
|
||||
for c in contact_instances:
|
||||
|
@ -599,7 +599,7 @@ class RosterWindow:
|
|||
colorstring = "#%04x%04x%04x" % (color.red, color.green, color.blue)
|
||||
name += \
|
||||
'\n<span size="small" style="italic" foreground="%s">%s</span>' \
|
||||
% (colorstring, gtkgui_helpers.escape_for_pango_markup(status))
|
||||
% (colorstring, gobject.markup_escape_text(status))
|
||||
|
||||
iter = iters[0] # choose the icon with the first iter
|
||||
icon_name = helpers.get_icon_name_to_show(contact, account)
|
||||
|
|
|
@ -225,9 +225,7 @@ class Systray:
|
|||
|
||||
sounds_mute_menuitem.set_active(not gajim.config.get('sounds_on'))
|
||||
|
||||
if os.name == 'nt':
|
||||
# see http://bugzilla.gnome.org/show_bug.cgi?id=377349
|
||||
#FIXME: until it is fixed, put under mouse coordinates
|
||||
if os.name == 'nt':
|
||||
if gtk.pygtk_version >= (2, 10, 0) and gtk.gtk_version >= (2, 10, 0):
|
||||
if self.added_hide_menuitem is False:
|
||||
self.systray_context_menu.prepend(gtk.SeparatorMenuItem())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## tooltips.py
|
||||
##
|
||||
## Copyright (C) 2005-2006 Dimitur Kirov <dkirov@gmail.com>
|
||||
## Copyright (C) 2005-2006 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005-2007 Nikos Kouremenos <kourem@gmail.com>
|
||||
## Copyright (C) 2005-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
|
@ -178,8 +178,8 @@ class StatusTable:
|
|||
status = unicode(status, encoding='utf-8')
|
||||
# reduce to 100 chars, 1 line
|
||||
status = helpers.reduce_chars_newlines(status, 100, 1)
|
||||
str_status = gtkgui_helpers.escape_for_pango_markup(str_status)
|
||||
status = gtkgui_helpers.escape_for_pango_markup(status)
|
||||
str_status = gobject.markup_escape_text(str_status)
|
||||
status = gobject.markup_escape_text(status)
|
||||
str_status += ' - <i>' + status + '</i>'
|
||||
return str_status
|
||||
|
||||
|
@ -233,7 +233,7 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
|||
if isinstance(message, str):
|
||||
message = unicode(message, encoding = 'utf-8')
|
||||
message = helpers.reduce_chars_newlines(message, 100, 1)
|
||||
message = gtkgui_helpers.escape_for_pango_markup(message)
|
||||
message = gobject.markup_escape_text(message)
|
||||
if gajim.con_types.has_key(acct['name']) and \
|
||||
gajim.con_types[acct['name']] in ('tls', 'ssl'):
|
||||
show_lock = True
|
||||
|
@ -241,11 +241,11 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
|||
show_lock = False
|
||||
if message:
|
||||
self.add_status_row(file_path, acct['show'],
|
||||
gtkgui_helpers.escape_for_pango_markup(acct['name']) + \
|
||||
gobject.markup_escape_text(acct['name']) + \
|
||||
' - ' + message, show_lock=show_lock)
|
||||
else:
|
||||
self.add_status_row(file_path, acct['show'],
|
||||
gtkgui_helpers.escape_for_pango_markup(acct['name'])
|
||||
gobject.markup_escape_text(acct['name'])
|
||||
, show_lock=show_lock)
|
||||
|
||||
def populate(self, data):
|
||||
|
@ -259,7 +259,7 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
|
|||
self.table.set_property('column-spacing', 1)
|
||||
|
||||
text = helpers.get_notification_icon_tooltip_text()
|
||||
text = gtkgui_helpers.escape_for_pango_markup(text)
|
||||
text = gobject.markup_escape_text(text)
|
||||
|
||||
self.add_text_row(text)
|
||||
self.hbox.add(self.table)
|
||||
|
@ -288,7 +288,7 @@ class GCTooltip(BaseTooltip):
|
|||
properties = []
|
||||
|
||||
nick_markup = '<b>' + \
|
||||
gtkgui_helpers.escape_for_pango_markup(contact.get_shown_name()) \
|
||||
gobject.markup_escape_text(contact.get_shown_name()) \
|
||||
+ '</b>'
|
||||
properties.append((nick_markup, None))
|
||||
|
||||
|
@ -298,7 +298,7 @@ class GCTooltip(BaseTooltip):
|
|||
# escape markup entities
|
||||
status = helpers.reduce_chars_newlines(status, 100, 5)
|
||||
status = '<i>' +\
|
||||
gtkgui_helpers.escape_for_pango_markup(status) + '</i>'
|
||||
gobject.markup_escape_text(status) + '</i>'
|
||||
properties.append((status, None))
|
||||
else: # no status message, show SHOW instead
|
||||
show = helpers.get_uf_show(contact.show)
|
||||
|
@ -310,7 +310,7 @@ class GCTooltip(BaseTooltip):
|
|||
|
||||
if hasattr(contact, 'resource') and contact.resource.strip() != '':
|
||||
properties.append((_('Resource: '),
|
||||
gtkgui_helpers.escape_for_pango_markup(contact.resource) ))
|
||||
gobject.markup_escape_text(contact.resource) ))
|
||||
if contact.affiliation != 'none':
|
||||
uf_affiliation = helpers.get_uf_affiliation(contact.affiliation)
|
||||
affiliation_str = \
|
||||
|
@ -411,7 +411,7 @@ class RosterTooltip(NotificationAreaTooltip):
|
|||
properties = []
|
||||
|
||||
name_markup = u'<span weight="bold">' + \
|
||||
gtkgui_helpers.escape_for_pango_markup(prim_contact.get_shown_name())\
|
||||
gobject.markup_escape_text(prim_contact.get_shown_name())\
|
||||
+ '</span>'
|
||||
properties.append((name_markup, None))
|
||||
|
||||
|
@ -485,7 +485,7 @@ class RosterTooltip(NotificationAreaTooltip):
|
|||
# (no more than 100 chars on line and no more than 5 lines)
|
||||
status = helpers.reduce_chars_newlines(status, 100, 5)
|
||||
# escape markup entities.
|
||||
status = gtkgui_helpers.escape_for_pango_markup(status)
|
||||
status = gobject.markup_escape_text(status)
|
||||
properties.append(('<i>%s</i>' % status, None))
|
||||
properties.append((show, None))
|
||||
|
||||
|
@ -494,13 +494,13 @@ class RosterTooltip(NotificationAreaTooltip):
|
|||
# contact has only one ressource
|
||||
if num_resources == 1 and contact.resource:
|
||||
properties.append((_('Resource: '),
|
||||
gtkgui_helpers.escape_for_pango_markup(contact.resource) +\
|
||||
gobject.markup_escape_text(contact.resource) +\
|
||||
' (' + unicode(contact.priority) + ')'))
|
||||
|
||||
if prim_contact.sub and prim_contact.sub != 'both':
|
||||
# ('both' is the normal sub so we don't show it)
|
||||
properties.append(( _('Subscription: '),
|
||||
gtkgui_helpers.escape_for_pango_markup(helpers.get_uf_sub(prim_contact.sub))))
|
||||
gobject.markup_escape_text(helpers.get_uf_sub(prim_contact.sub))))
|
||||
|
||||
if prim_contact.keyID:
|
||||
keyID = None
|
||||
|
@ -510,7 +510,7 @@ class RosterTooltip(NotificationAreaTooltip):
|
|||
keyID = prim_contact.keyID[8:]
|
||||
if keyID:
|
||||
properties.append((_('OpenPGP: '),
|
||||
gtkgui_helpers.escape_for_pango_markup(keyID)))
|
||||
gobject.markup_escape_text(keyID)))
|
||||
|
||||
while properties:
|
||||
property = properties.pop(0)
|
||||
|
@ -561,7 +561,7 @@ class FileTransfersTooltip(BaseTooltip):
|
|||
else:
|
||||
file_name = file_props['name']
|
||||
properties.append((_('Name: '),
|
||||
gtkgui_helpers.escape_for_pango_markup(file_name)))
|
||||
gobject.markup_escape_text(file_name)))
|
||||
if file_props['type'] == 'r':
|
||||
type = _('Download')
|
||||
actor = _('Sender: ')
|
||||
|
@ -577,7 +577,7 @@ class FileTransfersTooltip(BaseTooltip):
|
|||
else:
|
||||
name = receiver.split('/')[0]
|
||||
properties.append((_('Type: '), type))
|
||||
properties.append((actor, gtkgui_helpers.escape_for_pango_markup(name)))
|
||||
properties.append((actor, gobject.markup_escape_text(name)))
|
||||
|
||||
transfered_len = 0
|
||||
if file_props.has_key('received-len'):
|
||||
|
|
Loading…
Reference in New Issue