Added MediaReferences to the mediaview bottombar set of gramplets.

svn: r17008
This commit is contained in:
Rob G. Healey 2011-03-31 15:53:33 +00:00
parent 691759f7fc
commit 22bd8d318c
5 changed files with 195 additions and 142 deletions

View File

@ -264,11 +264,12 @@ src/plugins/gramplet/bottombar.gpr.py
src/plugins/gramplet/CalendarGramplet.py
src/plugins/gramplet/Children.py
src/plugins/gramplet/DescendGramplet.py
src/plugins/gramplet/Exif.py
src/plugins/gramplet/MediaReferences.py
src/plugins/gramplet/FanChartGramplet.py
src/plugins/gramplet/FaqGramplet.py
src/plugins/gramplet/GivenNameGramplet.py
src/plugins/gramplet/gramplet.gpr.py
src/plugins/gramplet/Exif.py
src/plugins/gramplet/Notes.py
src/plugins/gramplet/PedigreeGramplet.py
src/plugins/gramplet/PersonDetails.py

View File

@ -21,6 +21,7 @@ pkgdata_PYTHON = \
GivenNameGramplet.py \
gramplet.gpr.py \
MediaPreview.py \
MediaReferences.py \
Notes.py \
PedigreeGramplet.py \
PersonDetails.py \

View File

@ -0,0 +1,140 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2011 Rob G. Healey <robhealey1@gmail.com>
#
# 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
#
# $Id: MediaReferences.py 17002 2011-03-31 04:24:17Z robhealey1 $
#
from gen.plug import Gramplet
from ListModel import ListModel, NOSORT
from gen.ggettext import gettext as _
import Utils
import gtk
from gen.display.name import displayer as _nd
from DateHandler import displayer as _dd
class MediaReferences(Gramplet):
"""
Displays the Media Back References for this media object...
"""
def init(self):
self.gui.WIDGET = self.build_gui()
self.gui.get_container_widget().remove(self.gui.textview)
self.gui.get_container_widget().add_with_viewport(self.gui.WIDGET)
self.gui.WIDGET.show()
self.connect_signal('Media', self.update)
def build_gui(self):
"""
Build the GUI interface.
"""
top = gtk.TreeView()
titles = [(_('Object'), 1, 100),
(_('Title'), 2, 250),
(_("Gramps ID"), 3, 90)]
self.model = ListModel(top, titles)
return top
def db_changed(self):
self.dbstate.db.connect('media-update', self.update)
self.dbstate.db.connect("media-rebuild", self.update)
self.update()
def main(self):
active_handle = self.get_active('Media')
if not active_handle:
return
media = self.dbstate.db.get_object_from_handle(active_handle)
if not media:
return
self.model.clear()
self.__display_media_references(media)
def __display_media_references(self, media):
"""
Load the primary image if it exists.
"""
db = self.dbstate.db
handles = db.find_backlink_handles(media.get_handle(),
include_classes = ["Person", "Family", "Event", "Place", "Source"])
for (classname, handle) in handles:
obj_ = False
title = False
# Person link
if classname == "Person":
person = db.get_person_from_handle(handle)
if person:
person_name = _nd.display(person)
gid = person.get_gramps_id()
self.model.add((classname, person_name, gid))
# Family link
elif classname == "Family":
husband = False
spouse = False
family = db.get_family_from_handle(handle)
if family:
gid = family.get_gramps_id()
husband_handle = family.get_father_handle()
spouse_handle = family.get_mother_handle()
husband = db.get_person_from_handle(husband_handle)
spouse = db.get_person_from_handle(spouse_handle)
if husband:
husband_name = _nd.display(husband)
if spouse:
spouse_name = _nd.display(spouse)
if husband and spouse:
self.model.add((classname, husband_name + " + ", gid))
self.model.add(("", spouse_name, "", ""))
elif husband:
self.model.add((classname, husband_name, gid))
elif spouse:
self.model.add((classname, spouse_name, gid))
# Event link
elif classname == "Event":
event = db.get_event_from_handle(handle)
if event:
gid = event.get_gramps_id()
self.model.add((classname, str(event.get_type()), gid))
# Place link
elif classname == "Place":
place = db.get_place_from_handle(handle)
if place:
gid = place.get_gramps_id()
self.model.add((classname, place.get_title(), gid))
# Source link
elif classname == "Source":
source = db.get_source_from_handle(handle)
if source:
gid = source.get_gramps_id()
self.model.add((classname, source.get_title(), gid))

View File

@ -30,7 +30,7 @@ register(GRAMPLET,
name=_("Person Details Gramplet"),
description = _("Gramplet showing details of a person"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="PersonDetails.py",
height=200,
@ -43,7 +43,7 @@ register(GRAMPLET,
name=_("Repository Details Gramplet"),
description = _("Gramplet showing details of a repository"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="RepositoryDetails.py",
height=200,
@ -56,7 +56,7 @@ register(GRAMPLET,
name=_("Place Details Gramplet"),
description = _("Gramplet showing details of a place"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="PlaceDetails.py",
height=200,
@ -69,7 +69,7 @@ register(GRAMPLET,
name=_("Media Preview Gramplet"),
description = _("Gramplet showing a preview of a media object"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="MediaPreview.py",
height=200,
@ -82,7 +82,7 @@ register(GRAMPLET,
name = _("Exif Viewer Gramplet"),
description = _("Gramplet showing exif tags for a media object"),
version = "1.0.0",
gramps_target_version = "3.4.0",
gramps_target_version = "3.3.0",
status = STABLE,
fname = "Exif.py",
height = 200,
@ -92,12 +92,27 @@ register(GRAMPLET,
authors_email = ["robhealey1@gmail.com"],
)
register(GRAMPLET,
id = "Media References Gramplet",
name = _("Media References Gramplet"),
description = _("Gramplet showing all of the references to this media object"),
version = "1.0.0",
gramps_target_version = "3.3.0",
status = STABLE,
fname = "MediaReferences.py",
height = 200,
gramplet = "MediaReferences",
gramplet_title = _("References"),
authors = ["Rob G. Healey"],
authors_email = ["robhealey1@gmail.com"],
)
register(GRAMPLET,
id="Person Residence Gramplet",
name=_("Person Residence Gramplet"),
description = _("Gramplet showing residence events for a person"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="PersonResidence.py",
height=200,
@ -110,7 +125,7 @@ register(GRAMPLET,
name=_("Person Gallery Gramplet"),
description = _("Gramplet showing media objects for a person"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Gallery.py",
height=200,
@ -123,7 +138,7 @@ register(GRAMPLET,
name=_("Event Gallery Gramplet"),
description = _("Gramplet showing media objects for an event"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Gallery.py",
height=200,
@ -136,7 +151,7 @@ register(GRAMPLET,
name=_("Place Gallery Gramplet"),
description = _("Gramplet showing media objects for a place"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Gallery.py",
height=200,
@ -149,7 +164,7 @@ register(GRAMPLET,
name=_("Source Gallery Gramplet"),
description = _("Gramplet showing media objects for a source"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Gallery.py",
height=200,
@ -162,7 +177,7 @@ register(GRAMPLET,
name=_("Person Attributes Gramplet"),
description = _("Gramplet showing the attributes of a person"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Attributes.py",
height=200,
@ -175,7 +190,7 @@ register(GRAMPLET,
name=_("Event Attributes Gramplet"),
description = _("Gramplet showing the attributes of an event"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Attributes.py",
height=200,
@ -188,7 +203,7 @@ register(GRAMPLET,
name=_("Family Attributes Gramplet"),
description = _("Gramplet showing the attributes of a family"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Attributes.py",
height=200,
@ -201,7 +216,7 @@ register(GRAMPLET,
name=_("Media Attributes Gramplet"),
description = _("Gramplet showing the attributes of a media object"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Attributes.py",
height=200,
@ -214,7 +229,7 @@ register(GRAMPLET,
name=_("Person Notes Gramplet"),
description = _("Gramplet showing the notes for a person"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Notes.py",
height=200,
@ -227,7 +242,7 @@ register(GRAMPLET,
name=_("Event Notes Gramplet"),
description = _("Gramplet showing the notes for an event"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Notes.py",
height=200,
@ -240,7 +255,7 @@ register(GRAMPLET,
name=_("Family Notes Gramplet"),
description = _("Gramplet showing the notes for a family"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Notes.py",
height=200,
@ -253,7 +268,7 @@ register(GRAMPLET,
name=_("Place Notes Gramplet"),
description = _("Gramplet showing the notes for a place"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Notes.py",
height=200,
@ -266,7 +281,7 @@ register(GRAMPLET,
name=_("Source Notes Gramplet"),
description = _("Gramplet showing the notes for a source"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Notes.py",
height=200,
@ -279,7 +294,7 @@ register(GRAMPLET,
name=_("Repository Notes Gramplet"),
description = _("Gramplet showing the notes for a repository"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Notes.py",
height=200,
@ -292,7 +307,7 @@ register(GRAMPLET,
name=_("Media Notes Gramplet"),
description = _("Gramplet showing the notes for a media object"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Notes.py",
height=200,
@ -305,7 +320,7 @@ register(GRAMPLET,
name=_("Person Sources Gramplet"),
description = _("Gramplet showing the sources for a person"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Sources.py",
height=200,
@ -318,7 +333,7 @@ register(GRAMPLET,
name=_("Event Sources Gramplet"),
description = _("Gramplet showing the sources for an event"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Sources.py",
height=200,
@ -331,7 +346,7 @@ register(GRAMPLET,
name=_("Family Sources Gramplet"),
description = _("Gramplet showing the sources for a family"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Sources.py",
height=200,
@ -344,7 +359,7 @@ register(GRAMPLET,
name=_("Place Sources Gramplet"),
description = _("Gramplet showing the sources for a place"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Sources.py",
height=200,
@ -357,7 +372,7 @@ register(GRAMPLET,
name=_("Media Sources Gramplet"),
description = _("Gramplet showing the sources for a media object"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Sources.py",
height=200,
@ -370,7 +385,7 @@ register(GRAMPLET,
name=_("Person Children Gramplet"),
description = _("Gramplet showing the children of a person"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Children.py",
height=200,
@ -383,7 +398,7 @@ register(GRAMPLET,
name=_("Family Children Gramplet"),
description = _("Gramplet showing the children of a family"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Children.py",
height=200,
@ -391,116 +406,12 @@ register(GRAMPLET,
gramplet_title=_("Children"),
)
register(GRAMPLET,
id="Person Backlinks Gramplet",
name=_("Person Backlinks Gramplet"),
description = _("Gramplet showing the backlinks for a person"),
version="1.0.0",
gramps_target_version="3.4",
status = STABLE,
fname="Backlinks.py",
height=200,
gramplet = 'PersonBacklinks',
gramplet_title=_("References"),
)
register(GRAMPLET,
id="Event Backlinks Gramplet",
name=_("Event Backlinks Gramplet"),
description = _("Gramplet showing the backlinks for an event"),
version="1.0.0",
gramps_target_version="3.4",
status = STABLE,
fname="Backlinks.py",
height=200,
gramplet = 'EventBacklinks',
gramplet_title=_("References"),
)
register(GRAMPLET,
id="Family Backlinks Gramplet",
name=_("Family Backlinks Gramplet"),
description = _("Gramplet showing the backlinks for a family"),
version="1.0.0",
gramps_target_version="3.4",
status = STABLE,
fname="Backlinks.py",
height=200,
gramplet = 'FamilyBacklinks',
gramplet_title=_("References"),
)
register(GRAMPLET,
id="Place Backlinks Gramplet",
name=_("Place Backlinks Gramplet"),
description = _("Gramplet showing the backlinks for a place"),
version="1.0.0",
gramps_target_version="3.4",
status = STABLE,
fname="Backlinks.py",
height=200,
gramplet = 'PlaceBacklinks',
gramplet_title=_("References"),
)
register(GRAMPLET,
id="Source Backlinks Gramplet",
name=_("Source Backlinks Gramplet"),
description = _("Gramplet showing the backlinks for a source"),
version="1.0.0",
gramps_target_version="3.4",
status = STABLE,
fname="Backlinks.py",
height=200,
gramplet = 'SourceBacklinks',
gramplet_title=_("References"),
)
register(GRAMPLET,
id="Repository Backlinks Gramplet",
name=_("Repository Backlinks Gramplet"),
description = _("Gramplet showing the backlinks for a repository"),
version="1.0.0",
gramps_target_version="3.4",
status = STABLE,
fname="Backlinks.py",
height=200,
gramplet = 'RepositoryBacklinks',
gramplet_title=_("References"),
)
register(GRAMPLET,
id="Media Backlinks Gramplet",
name=_("Media Backlinks Gramplet"),
description = _("Gramplet showing the backlinks for a media object"),
version="1.0.0",
gramps_target_version="3.4",
status = STABLE,
fname="Backlinks.py",
height=200,
gramplet = 'MediaBacklinks',
gramplet_title=_("References"),
)
register(GRAMPLET,
id="Note Backlinks Gramplet",
name=_("Note Backlinks Gramplet"),
description = _("Gramplet showing the backlinks for a note"),
version="1.0.0",
gramps_target_version="3.4",
status = STABLE,
fname="Backlinks.py",
height=200,
gramplet = 'NoteBacklinks',
gramplet_title=_("References"),
)
register(GRAMPLET,
id="Person Filter Gramplet",
name=_("Person Filter Gramplet"),
description = _("Gramplet providing a person filter"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Filter.py",
height=200,
@ -513,7 +424,7 @@ register(GRAMPLET,
name=_("Family Filter Gramplet"),
description = _("Gramplet providing a family filter"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Filter.py",
height=200,
@ -526,7 +437,7 @@ register(GRAMPLET,
name=_("Event Filter Gramplet"),
description = _("Gramplet providing an event filter"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Filter.py",
height=200,
@ -539,7 +450,7 @@ register(GRAMPLET,
name=_("Source Filter Gramplet"),
description = _("Gramplet providing a source filter"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Filter.py",
height=200,
@ -552,7 +463,7 @@ register(GRAMPLET,
name=_("Place Filter Gramplet"),
description = _("Gramplet providing a place filter"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Filter.py",
height=200,
@ -565,7 +476,7 @@ register(GRAMPLET,
name=_("Media Filter Gramplet"),
description = _("Gramplet providing a media filter"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Filter.py",
height=200,
@ -578,7 +489,7 @@ register(GRAMPLET,
name=_("Repository Filter Gramplet"),
description = _("Gramplet providing a repository filter"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Filter.py",
height=200,
@ -591,7 +502,7 @@ register(GRAMPLET,
name=_("Note Filter Gramplet"),
description = _("Gramplet providing a note filter"),
version="1.0.0",
gramps_target_version="3.4",
gramps_target_version="3.3",
status = STABLE,
fname="Filter.py",
height=200,

View File

@ -441,4 +441,4 @@ class MediaView(ListView):
"Media Sources Gramplet",
"Media Notes Gramplet",
"Media Attributes Gramplet",
"Media Backlinks Gramplet"))
"Media References Gramplet"))