From 249a3180f0280bea71e4e636b717b7337bb74884 Mon Sep 17 00:00:00 2001 From: Benedikt Werner <1benediktwerner@gmail.com> Date: Thu, 6 May 2021 17:17:30 +0200 Subject: [PATCH] Set new media as active (#1191) --- gramps/gui/editors/editmedia.py | 1 + gramps/plugins/view/mediaview.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/gramps/gui/editors/editmedia.py b/gramps/gui/editors/editmedia.py index cc58b9489..933fd3213 100644 --- a/gramps/gui/editors/editmedia.py +++ b/gramps/gui/editors/editmedia.py @@ -326,6 +326,7 @@ class EditMedia(EditPrimary): with DbTxn(_("Add Media Object (%s)") % self.obj.get_description(), self.db) as trans: self.db.add_media(self.obj, trans) + self.uistate.set_active(self.obj.handle, "Media") else: if self.data_has_changed(): with DbTxn(_("Edit Media Object (%s)") % self.obj.get_description(), diff --git a/gramps/plugins/view/mediaview.py b/gramps/plugins/view/mediaview.py index 015d42c09..582321e05 100644 --- a/gramps/plugins/view/mediaview.py +++ b/gramps/plugins/view/mediaview.py @@ -169,7 +169,10 @@ class MediaView(ListView): """ if not sel_data: return + files = sel_data.get_uris() + photo = None + for file in files: protocol, site, mfile, j, k, l = urlparse(file) if protocol == "file": @@ -191,6 +194,10 @@ class MediaView(ListView): photo.set_description(root) with DbTxn(_("Drag Media Object"), self.dbstate.db) as trans: self.dbstate.db.add_media(photo, trans) + + if photo: + self.uistate.set_active(photo.handle, "Media") + widget.emit_stop_by_name('drag_data_received') def define_actions(self):