Replace MediaReferences gramplet with Backlinks gramplets

svn: r17010
This commit is contained in:
Nick Hall 2011-03-31 19:58:28 +00:00
parent 22bd8d318c
commit f01cf2c700
5 changed files with 144 additions and 195 deletions

View File

@ -260,12 +260,12 @@ src/plugins/gramplet/AgeOnDateGramplet.py
src/plugins/gramplet/AgeStats.py
src/plugins/gramplet/Attributes.py
src/plugins/gramplet/AttributesGramplet.py
src/plugins/gramplet/Backlinks.py
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

View File

@ -10,10 +10,12 @@ pkgdata_PYTHON = \
AgeStats.py \
Attributes.py \
AttributesGramplet.py \
Backlinks.py \
bottombar.gpr.py \
CalendarGramplet.py \
Children.py \
DescendGramplet.py \
Exif.py \
FanChartGramplet.py \
FaqGramplet.py \
Filter.py \
@ -21,11 +23,9 @@ pkgdata_PYTHON = \
GivenNameGramplet.py \
gramplet.gpr.py \
MediaPreview.py \
MediaReferences.py \
Notes.py \
PedigreeGramplet.py \
PersonDetails.py \
Exif.py \
PersonResidence.py \
PlaceDetails.py \
PluginManagerGramplet.py\

View File

@ -1,140 +0,0 @@
# 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.3",
gramps_target_version="3.4",
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.3",
gramps_target_version="3.4",
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.3",
gramps_target_version="3.4",
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.3",
gramps_target_version="3.4",
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.3.0",
gramps_target_version = "3.4.0",
status = STABLE,
fname = "Exif.py",
height = 200,
@ -92,27 +92,12 @@ 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.3",
gramps_target_version="3.4",
status = STABLE,
fname="PersonResidence.py",
height=200,
@ -125,7 +110,7 @@ register(GRAMPLET,
name=_("Person Gallery Gramplet"),
description = _("Gramplet showing media objects for a person"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Gallery.py",
height=200,
@ -138,7 +123,7 @@ register(GRAMPLET,
name=_("Event Gallery Gramplet"),
description = _("Gramplet showing media objects for an event"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Gallery.py",
height=200,
@ -151,7 +136,7 @@ register(GRAMPLET,
name=_("Place Gallery Gramplet"),
description = _("Gramplet showing media objects for a place"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Gallery.py",
height=200,
@ -164,7 +149,7 @@ register(GRAMPLET,
name=_("Source Gallery Gramplet"),
description = _("Gramplet showing media objects for a source"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Gallery.py",
height=200,
@ -177,7 +162,7 @@ register(GRAMPLET,
name=_("Person Attributes Gramplet"),
description = _("Gramplet showing the attributes of a person"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Attributes.py",
height=200,
@ -190,7 +175,7 @@ register(GRAMPLET,
name=_("Event Attributes Gramplet"),
description = _("Gramplet showing the attributes of an event"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Attributes.py",
height=200,
@ -203,7 +188,7 @@ register(GRAMPLET,
name=_("Family Attributes Gramplet"),
description = _("Gramplet showing the attributes of a family"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Attributes.py",
height=200,
@ -216,7 +201,7 @@ register(GRAMPLET,
name=_("Media Attributes Gramplet"),
description = _("Gramplet showing the attributes of a media object"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Attributes.py",
height=200,
@ -229,7 +214,7 @@ register(GRAMPLET,
name=_("Person Notes Gramplet"),
description = _("Gramplet showing the notes for a person"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Notes.py",
height=200,
@ -242,7 +227,7 @@ register(GRAMPLET,
name=_("Event Notes Gramplet"),
description = _("Gramplet showing the notes for an event"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Notes.py",
height=200,
@ -255,7 +240,7 @@ register(GRAMPLET,
name=_("Family Notes Gramplet"),
description = _("Gramplet showing the notes for a family"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Notes.py",
height=200,
@ -268,7 +253,7 @@ register(GRAMPLET,
name=_("Place Notes Gramplet"),
description = _("Gramplet showing the notes for a place"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Notes.py",
height=200,
@ -281,7 +266,7 @@ register(GRAMPLET,
name=_("Source Notes Gramplet"),
description = _("Gramplet showing the notes for a source"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Notes.py",
height=200,
@ -294,7 +279,7 @@ register(GRAMPLET,
name=_("Repository Notes Gramplet"),
description = _("Gramplet showing the notes for a repository"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Notes.py",
height=200,
@ -307,7 +292,7 @@ register(GRAMPLET,
name=_("Media Notes Gramplet"),
description = _("Gramplet showing the notes for a media object"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Notes.py",
height=200,
@ -320,7 +305,7 @@ register(GRAMPLET,
name=_("Person Sources Gramplet"),
description = _("Gramplet showing the sources for a person"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Sources.py",
height=200,
@ -333,7 +318,7 @@ register(GRAMPLET,
name=_("Event Sources Gramplet"),
description = _("Gramplet showing the sources for an event"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Sources.py",
height=200,
@ -346,7 +331,7 @@ register(GRAMPLET,
name=_("Family Sources Gramplet"),
description = _("Gramplet showing the sources for a family"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Sources.py",
height=200,
@ -359,7 +344,7 @@ register(GRAMPLET,
name=_("Place Sources Gramplet"),
description = _("Gramplet showing the sources for a place"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Sources.py",
height=200,
@ -372,7 +357,7 @@ register(GRAMPLET,
name=_("Media Sources Gramplet"),
description = _("Gramplet showing the sources for a media object"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Sources.py",
height=200,
@ -385,7 +370,7 @@ register(GRAMPLET,
name=_("Person Children Gramplet"),
description = _("Gramplet showing the children of a person"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Children.py",
height=200,
@ -398,7 +383,7 @@ register(GRAMPLET,
name=_("Family Children Gramplet"),
description = _("Gramplet showing the children of a family"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Children.py",
height=200,
@ -406,12 +391,116 @@ 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.3",
gramps_target_version="3.4",
status = STABLE,
fname="Filter.py",
height=200,
@ -424,7 +513,7 @@ register(GRAMPLET,
name=_("Family Filter Gramplet"),
description = _("Gramplet providing a family filter"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Filter.py",
height=200,
@ -437,7 +526,7 @@ register(GRAMPLET,
name=_("Event Filter Gramplet"),
description = _("Gramplet providing an event filter"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Filter.py",
height=200,
@ -450,7 +539,7 @@ register(GRAMPLET,
name=_("Source Filter Gramplet"),
description = _("Gramplet providing a source filter"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Filter.py",
height=200,
@ -463,7 +552,7 @@ register(GRAMPLET,
name=_("Place Filter Gramplet"),
description = _("Gramplet providing a place filter"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Filter.py",
height=200,
@ -476,7 +565,7 @@ register(GRAMPLET,
name=_("Media Filter Gramplet"),
description = _("Gramplet providing a media filter"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Filter.py",
height=200,
@ -489,7 +578,7 @@ register(GRAMPLET,
name=_("Repository Filter Gramplet"),
description = _("Gramplet providing a repository filter"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
status = STABLE,
fname="Filter.py",
height=200,
@ -502,7 +591,7 @@ register(GRAMPLET,
name=_("Note Filter Gramplet"),
description = _("Gramplet providing a note filter"),
version="1.0.0",
gramps_target_version="3.3",
gramps_target_version="3.4",
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 References Gramplet"))
"Media Backlinks Gramplet"))