URL drag/drop

svn: r493
This commit is contained in:
Don Allingham 2001-10-19 02:13:23 +00:00
parent 935103f9d9
commit 80132c03f9
2 changed files with 19 additions and 6 deletions

View File

@ -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)

View File

@ -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)