From 80132c03f9553dd38b55b0b1b196d1389ded703b Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 19 Oct 2001 02:13:23 +0000 Subject: [PATCH] URL drag/drop svn: r493 --- src/ImageSelect.py | 17 +++++++++++++---- src/utils.py | 8 ++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/ImageSelect.py b/src/ImageSelect.py index 4fd5bff37..0ab756381 100644 --- a/src/ImageSelect.py +++ b/src/ImageSelect.py @@ -254,18 +254,27 @@ class Gallery(ImageSelect): elif protocol != "": import urllib u = urllib.URLopener() - tfile,headers = u.retrieve(d) + try: + tfile,headers = u.retrieve(d) + except IOError, msg: + t = _("Counld not import %s") % d + + GnomeErrorDialog("%s\n%s %d" % (t,msg[0],msg[1])) + return mime = utils.get_mime_type(tfile) photo = Photo() photo.setMimeType(mime) photo.setDescription(d) photo.setLocal(1) + photo.setPath(tfile) self.savephoto(photo) try: name = RelImage.import_media_object(tfile,self.path,photo.getId()) - photo.setPath(name) + if name != None and name != "": + photo.setPath(name) except: - GnomeErrorDialog(_("Could not import %s") % d) + photo.setPath(tfile) + w.drag_finish(context, TRUE, FALSE, time) return utils.modified() else: @@ -274,7 +283,7 @@ class Gallery(ImageSelect): for p in self.dataobj.getPhotoList(): if data.data == p.getReference().getId(): if index == icon_index or icon_index == -1: - w.drag_finish(context, TRUE, FALSE, time) + w.drag_finish(context, FALSE, FALSE, time) return else: w.drag_finish(context, TRUE, FALSE, time) diff --git a/src/utils.py b/src/utils.py index 7df0dc9b5..e56b47ccd 100644 --- a/src/utils.py +++ b/src/utils.py @@ -20,6 +20,7 @@ import gtk import gnome.mime +import gnome.util from gnome.ui import * import string import os @@ -389,8 +390,11 @@ def thumb_path(dir,mobj): type = mobj.getMimeType() if type[0:5] == "image": thumb = "%s/.thumb/%s.jpg" % (dir,mobj.getId()) - RelImage.check_thumb(mobj.getPath(),thumb,const.thumbScale) - return thumb + try: + RelImage.check_thumb(mobj.getPath(),thumb,const.thumbScale) + return thumb + except: + return find_icon(type) else: return find_icon(type)