diff options
author | js <js-gajim@webkeks.org> | 2008-07-23 20:27:06 +0400 |
---|---|---|
committer | js <js-gajim@webkeks.org> | 2008-07-23 20:27:06 +0400 |
commit | c5b7f356a9d469708516f8bc9927e463afcf1072 (patch) | |
tree | 27329ab581ce418b150db7e84e10688338a81365 | |
parent | 8abacfdb8f393e3c9099f997960e1a3fada7ecce (diff) |
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.
-rw-r--r-- | src/chat_control.py | 58 | ||||
-rw-r--r-- | src/dialogs.py | 2 |
2 files changed, 43 insertions, 17 deletions
diff --git a/src/chat_control.py b/src/chat_control.py index 31cf20ef9..9f637ab00 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -55,6 +55,8 @@ try: except: HAS_GTK_SPELL = False +HAVE_MARKUP_TOOLTIPS = gtk.pygtk_version >= (2, 12, 0) + # the next script, executed in the "po" directory, # generates the following list. ##!/bin/sh @@ -1089,6 +1091,11 @@ class ChatControl(ChatControlBase): self._activity_image = self.xml.get_widget('activity_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_tune() @@ -1197,14 +1204,16 @@ class ChatControl(ChatControlBase): def update_mood(self): if self.contact.mood.has_key('mood'): - mood = gobject.markup_escape_text( - self.contact.mood['mood']) + mood = self.contact.mood['mood'] + if HAVE_MARKUP_TOOLTIPS: + mood = gobject.markup_escape_text(mood) else: mood = None if self.contact.mood.has_key('text'): - text = gobject.markup_escape_text( - self.contact.mood['text']) + text = self.contact.mood['text'] + if HAVE_MARKUP_TOOLTIPS: + text = gobject.markup_escape_text(text) else: text = '' @@ -1220,8 +1229,14 @@ class ChatControl(ChatControlBase): gtkgui_helpers.load_mood_icon( 'unknown').get_pixbuf()) - self._mood_image.set_tooltip_markup('<b>%s</b>%s%s' % - (mood, '\n' if text is not '' else '', text)) + if HAVE_MARKUP_TOOLTIPS: + 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() else: self._mood_image.hide() @@ -1232,24 +1247,35 @@ class ChatControl(ChatControlBase): source = None if self.contact.tune.has_key('artist'): - artist = gobject.markup_escape_text( - self.contact.tune['artist'].strip()) + artist = self.contact.tune['artist'].strip() + if HAVE_MARKUP_TOOLTIPS: + artist = gobject.markup_escape_text(artist) if self.contact.tune.has_key('title'): - title = gobject.markup_escape_text( - self.contact.tune['title'].strip()) + title = self.contact.tune['title'].strip() + if HAVE_MARKUP_TOOLTIPS: + title = gobject.markup_escape_text(title) if self.contact.tune.has_key('source'): - title = gobject.markup_escape_text( - self.contact.tune['source'].strip()) + source = self.contact.tune['source'].strip() + if HAVE_MARKUP_TOOLTIPS: + source = gobject.markup_escape_text(source) if artist or title: artist = artist if artist else _('Unknown Artist') title = title if title else _('Unknown Title') source = source if source else _('Unknown Source') - self._tune_image.set_tooltip_markup(_( - '<b>"%(title)s"</b> by <i>%(artist)s</i>\n' + - 'from <i>%(source)s</i>') % {'title': title, - 'artist': artist, 'source': source}) + if HAVE_MARKUP_TOOLTIPS: + self._tune_image.set_tooltip_markup( + _('<b>"%(title)s"</b> by ' + + '<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() else: self._tune_image.hide() diff --git a/src/dialogs.py b/src/dialogs.py index b9bd50ea4..c1f36b13d 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -472,7 +472,7 @@ class ChangeMoodDialog: self.mood_buttons[mood].add( gtkgui_helpers.load_mood_icon(mood)) 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('_', ' '))) self.mood_buttons[mood].connect('clicked', self.on_mood_button_clicked, mood) |