Be compatible with pygtk 2.10.

I'm still for kicking compatibility for everything < 2.12.0 as with
2.12.0, there are a few new APIs that obsolete old, stupid APIs.
This commit is contained in:
js 2008-07-23 16:27:06 +00:00
parent 8abacfdb8f
commit c5b7f356a9
2 changed files with 43 additions and 17 deletions

View File

@ -55,6 +55,8 @@ try:
except: except:
HAS_GTK_SPELL = False HAS_GTK_SPELL = False
HAVE_MARKUP_TOOLTIPS = gtk.pygtk_version >= (2, 12, 0)
# the next script, executed in the "po" directory, # the next script, executed in the "po" directory,
# generates the following list. # generates the following list.
##!/bin/sh ##!/bin/sh
@ -1089,6 +1091,11 @@ class ChatControl(ChatControlBase):
self._activity_image = self.xml.get_widget('activity_image') self._activity_image = self.xml.get_widget('activity_image')
self._tune_image = self.xml.get_widget('tune_image') self._tune_image = self.xml.get_widget('tune_image')
if not HAVE_MARKUP_TOOLTIPS:
self._mood_tooltip = gtk.Tooltips()
self._activity_tooltip = gtk.Tooltips()
self._tune_tooltip = gtk.Tooltips()
self.update_mood() self.update_mood()
self.update_tune() self.update_tune()
@ -1197,14 +1204,16 @@ class ChatControl(ChatControlBase):
def update_mood(self): def update_mood(self):
if self.contact.mood.has_key('mood'): if self.contact.mood.has_key('mood'):
mood = gobject.markup_escape_text( mood = self.contact.mood['mood']
self.contact.mood['mood']) if HAVE_MARKUP_TOOLTIPS:
mood = gobject.markup_escape_text(mood)
else: else:
mood = None mood = None
if self.contact.mood.has_key('text'): if self.contact.mood.has_key('text'):
text = gobject.markup_escape_text( text = self.contact.mood['text']
self.contact.mood['text']) if HAVE_MARKUP_TOOLTIPS:
text = gobject.markup_escape_text(text)
else: else:
text = '' text = ''
@ -1220,8 +1229,14 @@ class ChatControl(ChatControlBase):
gtkgui_helpers.load_mood_icon( gtkgui_helpers.load_mood_icon(
'unknown').get_pixbuf()) 'unknown').get_pixbuf())
self._mood_image.set_tooltip_markup('<b>%s</b>%s%s' % if HAVE_MARKUP_TOOLTIPS:
(mood, '\n' if text is not '' else '', text)) self._mood_image.set_tooltip_markup(
'<b>%s</b>%s%s' % (mood,
'\n' if text is not '' else '', text))
else:
self._mood_tooltip.set_tip(
self._mood_image, '%s%s%s' % (mood,
'\n' if text is not '' else '', text))
self._mood_image.show() self._mood_image.show()
else: else:
self._mood_image.hide() self._mood_image.hide()
@ -1232,24 +1247,35 @@ class ChatControl(ChatControlBase):
source = None source = None
if self.contact.tune.has_key('artist'): if self.contact.tune.has_key('artist'):
artist = gobject.markup_escape_text( artist = self.contact.tune['artist'].strip()
self.contact.tune['artist'].strip()) if HAVE_MARKUP_TOOLTIPS:
artist = gobject.markup_escape_text(artist)
if self.contact.tune.has_key('title'): if self.contact.tune.has_key('title'):
title = gobject.markup_escape_text( title = self.contact.tune['title'].strip()
self.contact.tune['title'].strip()) if HAVE_MARKUP_TOOLTIPS:
title = gobject.markup_escape_text(title)
if self.contact.tune.has_key('source'): if self.contact.tune.has_key('source'):
title = gobject.markup_escape_text( source = self.contact.tune['source'].strip()
self.contact.tune['source'].strip()) if HAVE_MARKUP_TOOLTIPS:
source = gobject.markup_escape_text(source)
if artist or title: if artist or title:
artist = artist if artist else _('Unknown Artist') artist = artist if artist else _('Unknown Artist')
title = title if title else _('Unknown Title') title = title if title else _('Unknown Title')
source = source if source else _('Unknown Source') source = source if source else _('Unknown Source')
self._tune_image.set_tooltip_markup(_( if HAVE_MARKUP_TOOLTIPS:
'<b>"%(title)s"</b> by <i>%(artist)s</i>\n' + self._tune_image.set_tooltip_markup(
'from <i>%(source)s</i>') % {'title': title, _('<b>"%(title)s"</b> by ' +
'artist': artist, 'source': source}) '<i>%(artist)s</i>\n' +
'from <i>%(source)s</i>') %
{'title': title, 'artist': artist,
'source': source})
else:
self._tune_tooltip.set_tip(self._tune_image,
_('%(title)s by %(artist)s\n' +
'from %(source)s') % {'title': title,
'artist': artist, 'source': source})
self._tune_image.show() self._tune_image.show()
else: else:
self._tune_image.hide() self._tune_image.hide()

View File

@ -472,7 +472,7 @@ class ChangeMoodDialog:
self.mood_buttons[mood].add( self.mood_buttons[mood].add(
gtkgui_helpers.load_mood_icon(mood)) gtkgui_helpers.load_mood_icon(mood))
self.mood_buttons[mood].set_relief(gtk.RELIEF_NONE) self.mood_buttons[mood].set_relief(gtk.RELIEF_NONE)
self.mood_buttons[mood].set_tooltip_text( gtk.Tooltips().set_tip(self.mood_buttons[mood],
_(mood.replace('_', ' '))) _(mood.replace('_', ' ')))
self.mood_buttons[mood].connect('clicked', self.mood_buttons[mood].connect('clicked',
self.on_mood_button_clicked, mood) self.on_mood_button_clicked, mood)