From a1be214c1561e0f3748844b41aa8375c43ea276f Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 30 Nov 2001 16:09:53 +0000 Subject: [PATCH] Handling of drag/drop on media view, make sure to popup global properties editor if necessary. svn: r599 --- src/Config.py | 6 +----- src/MediaView.py | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/Config.py b/src/Config.py index 1459cad2d..e9ba922e5 100644 --- a/src/Config.py +++ b/src/Config.py @@ -163,11 +163,7 @@ def loadConfig(call): global usetabs global calendar global usevc - global iprefix - global fprefix - global pprefix - global oprefix - global sprefix + global iprefix, fprefix, pprefix, oprefix, sprefix global vc_comment global uncompress global id_visible diff --git a/src/MediaView.py b/src/MediaView.py index 959be532d..c7621a456 100644 --- a/src/MediaView.py +++ b/src/MediaView.py @@ -284,10 +284,13 @@ class MediaView: selection_data.set(selection_data.target, 8, id) def on_drag_data_received(self,w, context, x, y, data, info, time): + import urlparse if data and data.format == 8: d = string.strip(string.replace(data.data,'\0',' ')) - if d[0:5] == "file:": - name = d[5:] + protocol,site,file, j,k,l = urlparse.urlparse(d) + print protocol,site,file,j,k,l + if protocol == "file": + name = file mime = utils.get_mime_type(name) photo = Photo() photo.setPath(name) @@ -298,6 +301,46 @@ class MediaView: utils.modified() w.drag_finish(context, 1, 0, time) self.load_media() + if Config.mediaref == 0: + name = RelImage.import_media_object(name, + self.db.getSavePath(), + photo.getId()) + photo.setPath(name) + photo.setLocal(1) + utils.modified() + if Config.globalprop: + ImageSelect.GlobalMediaProperties(self.db,photo,self.load_media) + elif protocol != "": + import urllib + u = urllib.URLopener() + try: + tfile,headers = u.retrieve(d) + except IOError, msg: + t = _("Could not import %s") % d + + gnome.ui.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.db.addObject(photo) + oref = ObjectRef() + oref.setReference(photo) + try: + id = photo.getId() + name = RelImage.import_media_object(tfile,self.path,id) + if name != None and name != "": + photo.setPath(name) + except: + photo.setPath(tfile) + w.drag_finish(context, 1, 0, time) + return + utils.modified() + if Config.globalprop: + ImageSelect.GlobalMediaProperties(self.db,photo,None) else: w.drag_finish(context, 0, 0, time)