From c97aeb0f1a5e2e69941d7ed01a3796b03640c601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Rapinat?= Date: Fri, 12 Dec 2014 09:42:46 +0100 Subject: [PATCH] 6934: backport environment for better managing custom attributes on Media, new MediaAttrEmbedList class --- po/POTFILES.skip | 1 + src/gui/editors/displaytabs/__init__.py | 1 + .../editors/displaytabs/mediaattrembedlist.py | 43 +++++++++++++++++++ src/gui/editors/editmedia.py | 4 +- src/gui/editors/editmediaref.py | 6 +-- 5 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 src/gui/editors/displaytabs/mediaattrembedlist.py diff --git a/po/POTFILES.skip b/po/POTFILES.skip index c66f388ed..28abef6e4 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -234,6 +234,7 @@ src/gui/editors/displaytabs/grampstab.py src/gui/editors/displaytabs/groupembeddedlist.py src/gui/editors/displaytabs/ldsmodel.py src/gui/editors/displaytabs/locationmodel.py +src/gui/editors/displaytabs/mediaattrembedlist.py src/gui/editors/displaytabs/mediabackreflist.py src/gui/editors/displaytabs/notebackreflist.py src/gui/editors/displaytabs/personrefmodel.py diff --git a/src/gui/editors/displaytabs/__init__.py b/src/gui/editors/displaytabs/__init__.py index 9cfe0b3e2..ddb923907 100644 --- a/src/gui/editors/displaytabs/__init__.py +++ b/src/gui/editors/displaytabs/__init__.py @@ -47,6 +47,7 @@ from familyldsembedlist import FamilyLdsEmbedList from gallerytab import GalleryTab from ldsembedlist import LdsEmbedList from locationembedlist import LocationEmbedList +from mediaattrembedlist import MediaAttrEmbedList from mediabackreflist import MediaBackRefList from nameembedlist import NameEmbedList from notebackreflist import NoteBackRefList diff --git a/src/gui/editors/displaytabs/mediaattrembedlist.py b/src/gui/editors/displaytabs/mediaattrembedlist.py new file mode 100644 index 000000000..e16554360 --- /dev/null +++ b/src/gui/editors/displaytabs/mediaattrembedlist.py @@ -0,0 +1,43 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2014 Nick Hall +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +#------------------------------------------------------------------------- +# +# Gramps classes +# +#------------------------------------------------------------------------- +from attrembedlist import AttrEmbedList + +#------------------------------------------------------------------------- +# +# MediaAttrEmbedList +# +#------------------------------------------------------------------------- +class MediaAttrEmbedList(AttrEmbedList): + + def __init__(self, dbstate, uistate, track, data): + AttrEmbedList.__init__(self, dbstate, uistate, track, data) + + def get_editor(self): + from .. import EditAttribute + return EditAttribute + + def get_user_values(self): + return self.dbstate.db.get_media_attribute_types() diff --git a/src/gui/editors/editmedia.py b/src/gui/editors/editmedia.py index 830c86038..37c9892e1 100644 --- a/src/gui/editors/editmedia.py +++ b/src/gui/editors/editmedia.py @@ -51,7 +51,7 @@ import Utils from editprimary import EditPrimary from gui.widgets import (MonitoredDate, MonitoredEntry, PrivacyButton, MonitoredTagList) -from displaytabs import (CitationEmbedList, AttrEmbedList, NoteTab, +from displaytabs import (CitationEmbedList, MediaAttrEmbedList, NoteTab, MediaBackRefList) from addmedia import AddMediaObject from QuestionDialog import ErrorDialog @@ -200,7 +200,7 @@ class EditMedia(EditPrimary): self._add_tab(notebook, self.citation_tab) self.track_ref_for_deletion("citation_tab") - self.attr_tab = AttrEmbedList(self.dbstate, + self.attr_tab = MediaAttrEmbedList(self.dbstate, self.uistate, self.track, self.obj.get_attribute_list()) diff --git a/src/gui/editors/editmediaref.py b/src/gui/editors/editmediaref.py index 408fc61e1..3f7b53f60 100644 --- a/src/gui/editors/editmediaref.py +++ b/src/gui/editors/editmediaref.py @@ -51,7 +51,7 @@ import Utils from gen.lib import NoteType from gen.db import DbTxn from glade import Glade -from displaytabs import (CitationEmbedList, AttrEmbedList, MediaBackRefList, +from displaytabs import (CitationEmbedList, MediaAttrEmbedList, MediaBackRefList, NoteTab) from gui.widgets import (MonitoredSpinButton, MonitoredEntry, PrivacyButton, MonitoredDate, MonitoredTagList) @@ -615,7 +615,7 @@ class EditMediaRef(EditReference): self._add_tab(notebook_ref, self.srcref_list) self.track_ref_for_deletion("srcref_list") - self.attr_list = AttrEmbedList(self.dbstate,self.uistate,self.track, + self.attr_list = MediaAttrEmbedList(self.dbstate,self.uistate,self.track, self.source_ref.get_attribute_list()) self._add_tab(notebook_ref, self.attr_list) self.track_ref_for_deletion("attr_list") @@ -640,7 +640,7 @@ class EditMediaRef(EditReference): self._add_tab(notebook_src, self.src_srcref_list) self.track_ref_for_deletion("src_srcref_list") - self.src_attr_list = AttrEmbedList(self.dbstate,self.uistate,self.track, + self.src_attr_list = MediaAttrEmbedList(self.dbstate,self.uistate,self.track, self.source.get_attribute_list()) self._add_tab(notebook_src, self.src_attr_list) self.track_ref_for_deletion("src_attr_list")