2007-09-04 Don Allingham <don@gramps-project.org>

* src/DataViews/_MediaView.py (MediaView.drag_data_received): handle 
	multiple images in a drag-n-drop



svn: r8927
This commit is contained in:
Don Allingham 2007-09-05 03:56:32 +00:00
parent febd6e9ed5
commit fe0b7ef7a4
2 changed files with 24 additions and 18 deletions

View File

@ -1,3 +1,7 @@
2007-09-04 Don Allingham <don@gramps-project.org>
* src/DataViews/_MediaView.py (MediaView.drag_data_received): handle
multiple images in a drag-n-drop
2007-09-04 Brian Matherly <brian@gramps-project.org> 2007-09-04 Brian Matherly <brian@gramps-project.org>
* src/ReportBase/__init__.py: Add MenuOptions * src/ReportBase/__init__.py: Add MenuOptions
* src/ReportBase/_MenuOptions.py: Added * src/ReportBase/_MenuOptions.py: Added

View File

@ -163,25 +163,27 @@ class MediaView(PageView.ListView):
If the selection data is define, extract the value from sel_data.data, If the selection data is define, extract the value from sel_data.data,
and decide if this is a move or a reorder. and decide if this is a move or a reorder.
""" """
if sel_data and sel_data.data: if sel_data and sel_data.data:
d = Utils.fix_encoding(sel_data.data.replace('\0',' ').strip()) cleaned_string = sel_data.data.replace('\0',' ')
protocol, site, mfile, j, k, l = urlparse.urlparse(d) cleaned_string = cleaned_string.replace("\r"," ").strip()
if protocol == "file": data_list = Utils.fix_encoding(cleaned_string).split('\n')
name = Utils.fix_encoding(mfile) for d in [item.strip() for item in data_list]:
mime = Mime.get_type(name) protocol, site, mfile, j, k, l = urlparse.urlparse(d)
if not Mime.is_valid_type(mime): if protocol == "file":
return name = Utils.fix_encoding(mfile)
photo = RelLib.MediaObject() mime = Mime.get_type(name)
photo.set_path(name) if not Mime.is_valid_type(mime):
photo.set_mime_type(mime) return
basename = os.path.basename(name) photo = RelLib.MediaObject()
(root, ext) = os.path.splitext(basename) photo.set_path(name)
photo.set_description(root) photo.set_mime_type(mime)
trans = self.dbstate.db.transaction_begin() basename = os.path.basename(name)
self.dbstate.db.add_object(photo, trans) (root, ext) = os.path.splitext(basename)
self.dbstate.db.transaction_commit(trans, photo.set_description(root)
_("Drag Media Object")) trans = self.dbstate.db.transaction_begin()
self.dbstate.db.add_object(photo, trans)
self.dbstate.db.transaction_commit(trans,
_("Drag Media Object"))
widget.emit_stop_by_name('drag_data_received') widget.emit_stop_by_name('drag_data_received')
def get_bookmarks(self): def get_bookmarks(self):