gtkexcepthook only for those that run svn versions; release user should not be bugged with TBs as they should be minor to overall functionality and he should not care. if he is advanced he knows how to find out what is wrong (how to get to see a traceback etc); also moving get_avatar_pixbuf_from_cache to gtkgui_helpers (all in one commit because of import issues)

This commit is contained in:
Nikos Kouremenos 2005-11-12 21:24:54 +00:00
parent 380bce1160
commit 33e7b103c0
5 changed files with 32 additions and 24 deletions

View File

@ -24,8 +24,8 @@ import gobject
import os
import gtkgui_helpers
import vcard
from vcard import VcardWindow
from filetransfers_window import FileTransfersWindow
from gajim_themes_window import GajimThemesWindow
from advanced import AdvancedConfigurationWindow
@ -612,7 +612,7 @@ class SubscriptionRequestWindow:
gajim.interface.windows[self.account]['infos'][self.jid].window.present()
else:
gajim.interface.windows[self.account]['infos'][self.jid] = \
VcardWindow(self.jid, self.account, True)
vcard.VcardWindow(self.jid, self.account, True)
#remove the publish / retrieve buttons
vcard_xml = gajim.interface.windows[self.account]['infos'][self.jid].xml
hbuttonbox = vcard_xml.get_widget('information_hbuttonbox')

View File

@ -62,7 +62,14 @@ except ImportError:
dlg.destroy()
sys.exit()
import gtkexcepthook
path = os.getcwd()
if '.svn' in os.listdir(path):
# import gtkexcepthook only for those that run svn
# those than run with --verbose run from terminal so no need to care
# about those
import gtkexcepthook
del path
import gobject
if sys.version[:4] >= '2.4':
gobject.threads_init()
@ -75,7 +82,6 @@ import time
import base64
import gtkgui_helpers
import vcard
import notify
import common.sleepy
@ -921,22 +927,6 @@ class Interface:
def handle_event_vcard_not_published(self, account, array):
dialogs.InformationDialog(_('vCard publication failed'), _('There was an error while publishing your personal information, try again later.'))
def get_avatar_pixbuf_from_cache(self, jid):
'''checks if jid has cached avatar and if that avatar is valid image
(can be shown)
return None if there is no image in vcard
return 'ask' if vcard is too old or if we don't have the vcard'''
if jid not in os.listdir(gajim.VCARDPATH):
return 'ask'
vcard_dict = gajim.connections.values()[0].get_cached_vcard(jid)
if not vcard_dict: # This can happen if cached vcard is too old
return 'ask'
if not vcard_dict.has_key('PHOTO'):
return None
pixbuf = vcard.get_avatar_pixbuf_encoded_mime(vcard_dict['PHOTO'])[0]
return pixbuf
def read_sleepy(self):
'''Check idle status and change that status if needed'''

View File

@ -25,6 +25,8 @@ import pango
import os
import sys
import vcard
HAS_PYWIN32 = True
if os.name == 'nt':
@ -418,3 +420,19 @@ def get_scaled_pixbuf(pixbuf, type):
w = int(h * ratio)
scaled_buf = pixbuf.scale_simple(w, h, gtk.gdk.INTERP_HYPER)
return scaled_buf
def get_avatar_pixbuf_from_cache(jid):
'''checks if jid has cached avatar and if that avatar is valid image
(can be shown)
return None if there is no image in vcard
return 'ask' if vcard is too old or if we don't have the vcard'''
if jid not in os.listdir(gajim.VCARDPATH):
return 'ask'
vcard_dict = gajim.connections.values()[0].get_cached_vcard(jid)
if not vcard_dict: # This can happen if cached vcard is too old
return 'ask'
if not vcard_dict.has_key('PHOTO'):
return None
pixbuf = vcard.get_avatar_pixbuf_encoded_mime(vcard_dict['PHOTO'])[0]
return pixbuf

View File

@ -264,7 +264,7 @@ class RosterWindow:
#FIXME: here it gets called to often
# for example if we recv a message we also reset the avatar!
if gajim.config.get('show_avatars_in_roster'):
pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(jid)
pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(jid)
if pixbuf in ('ask', None):
scaled_pixbuf = None
else:

View File

@ -133,7 +133,7 @@ class TabbedChatWindow(chat.Chat):
real_jid = gajim.get_real_jid_from_fjid(self.account, jid)
if not real_jid: # this can happend if we're in a moderate room
return
avatar_pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(real_jid)
avatar_pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(real_jid)
avatar_w = avatar_pixbuf.get_width()
avatar_h = avatar_pixbuf.get_height()
@ -160,7 +160,7 @@ class TabbedChatWindow(chat.Chat):
real_jid = gajim.get_real_jid_from_fjid(self.account, jid)
if not real_jid: # this can happend if we're in a moderate room
return
avatar_pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(real_jid)
avatar_pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(real_jid)
screen_w = gtk.gdk.screen_width()
screen_h = gtk.gdk.screen_height()
avatar_w = avatar_pixbuf.get_width()
@ -303,7 +303,7 @@ class TabbedChatWindow(chat.Chat):
real_jid = gajim.get_real_jid_from_fjid(self.account, jid)
pixbuf = None
if real_jid:
pixbuf = gajim.interface.get_avatar_pixbuf_from_cache(real_jid)
pixbuf = gtkgui_helpers.get_avatar_pixbuf_from_cache(real_jid)
if not real_jid or pixbuf == 'ask':
# we don't have the vcard or it's pm and we don't have the real jid
gajim.connections[self.account].request_vcard(jid_with_resource)