fix pixbuf saves and missing import

This commit is contained in:
Denis Fomin 2012-12-31 19:38:32 +04:00
parent 63d0c2dcf4
commit 4e16b113b3
4 changed files with 8 additions and 7 deletions

View File

@ -421,7 +421,7 @@ def get_pixbuf_from_data(file_data, want_type = False):
return None
if want_type:
typ = pixbufloader.get_format()['name']
typ = pixbufloader.get_format().get_name()
return pixbuf, typ
else:
return pixbuf
@ -828,14 +828,14 @@ def on_avatar_save_as_menuitem_activate(widget, jid, default_name=''):
# Save image
try:
pixbuf.save(file_path, image_format)
pixbuf.savev(file_path, image_format, [], [])
except Exception, e:
log.debug('Error saving avatar: %s' % str(e))
if os.path.exists(file_path):
os.remove(file_path)
new_file_path = '.'.join(file_path.split('.')[:-1]) + '.jpeg'
def on_ok(file_path, pixbuf):
pixbuf.save(file_path, 'jpeg')
pixbuf.savev(file_path, 'jpeg', [], [])
dialogs.ConfirmationDialog(_('Extension not supported'),
_('Image cannot be saved in %(type)s format. Save as '
'%(new_filename)s?') % {'type': image_format,

View File

@ -2489,7 +2489,7 @@ class Interface:
extension = '.png'
path_to_original_file = path_to_file + extension
try:
pixbuf.save(path_to_original_file, typ)
pixbuf.savev(path_to_original_file, typ, [], [])
except Exception, e:
log.error('Error writing avatar file %s: %s' % (
path_to_original_file, str(e)))
@ -2499,7 +2499,7 @@ class Interface:
path_to_normal_file = path_to_file + '_notif_size_colored' + \
extension
try:
pixbuf.save(path_to_normal_file, 'png')
pixbuf.savev(path_to_normal_file, 'png', [], [])
except Exception, e:
log.error('Error writing avatar file %s: %s' % \
(path_to_original_file, str(e)))
@ -2509,7 +2509,7 @@ class Interface:
if bwbuf:
path_to_bw_file = path_to_file + '_notif_size_bw' + extension
try:
bwbuf.save(path_to_bw_file, 'png')
bwbuf.savev(path_to_bw_file, 'png', [], [])
except Exception, e:
log.error('Error writing avatar file %s: %s' % \
(path_to_original_file, str(e)))

View File

@ -150,7 +150,7 @@ class ProfileWindow:
if scaled_pixbuf:
path_to_file = os.path.join(gajim.TMP,
'avatar_scaled.png')
scaled_pixbuf.save(path_to_file, 'png')
scaled_pixbuf.savev(path_to_file, 'png', [], [])
must_delete = True
fd = open(path_to_file, 'rb')

View File

@ -33,6 +33,7 @@
from gi.repository import Gtk
from gi.repository import GObject
from gi.repository import Gdk
import base64
import time
import locale