Add backlink bottombar gramplets
svn: r16997
This commit is contained in:
parent
1d2ed8bf36
commit
f43d71f9ef
179
src/plugins/gramplet/Backlinks.py
Normal file
179
src/plugins/gramplet/Backlinks.py
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011 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
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#
|
||||||
|
|
||||||
|
from ListModel import ListModel, NOSORT
|
||||||
|
from Utils import navigation_label
|
||||||
|
from gen.plug import Gramplet
|
||||||
|
from gen.ggettext import gettext as _
|
||||||
|
import gtk
|
||||||
|
|
||||||
|
class Backlinks(Gramplet):
|
||||||
|
"""
|
||||||
|
Displays the back references for an 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()
|
||||||
|
|
||||||
|
def build_gui(self):
|
||||||
|
"""
|
||||||
|
Build the GUI interface.
|
||||||
|
"""
|
||||||
|
top = gtk.TreeView()
|
||||||
|
titles = [(_('Type'), 1, 100),
|
||||||
|
(_('Name'), 2, 100)]
|
||||||
|
self.model = ListModel(top, titles)
|
||||||
|
return top
|
||||||
|
|
||||||
|
def display_backlinks(self, active_handle):
|
||||||
|
"""
|
||||||
|
Display the back references for an object.
|
||||||
|
"""
|
||||||
|
for classname, handle in \
|
||||||
|
self.dbstate.db.find_backlink_handles(active_handle,
|
||||||
|
include_classes=None):
|
||||||
|
name = navigation_label(self.dbstate.db, classname, handle)[0]
|
||||||
|
self.model.add((classname, name))
|
||||||
|
|
||||||
|
class PersonBacklinks(Backlinks):
|
||||||
|
"""
|
||||||
|
Displays the back references for a person.
|
||||||
|
"""
|
||||||
|
def db_changed(self):
|
||||||
|
self.dbstate.db.connect('person-update', self.update)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def active_changed(self, handle):
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
active_handle = self.get_active('Person')
|
||||||
|
self.model.clear()
|
||||||
|
if active_handle:
|
||||||
|
self.display_backlinks(active_handle)
|
||||||
|
|
||||||
|
class EventBacklinks(Backlinks):
|
||||||
|
"""
|
||||||
|
Displays the back references for an event.
|
||||||
|
"""
|
||||||
|
def db_changed(self):
|
||||||
|
self.dbstate.db.connect('event-update', self.update)
|
||||||
|
self.connect_signal('Event', self.update)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
active_handle = self.get_active('Event')
|
||||||
|
self.model.clear()
|
||||||
|
if active_handle:
|
||||||
|
self.display_backlinks(active_handle)
|
||||||
|
|
||||||
|
class FamilyBacklinks(Backlinks):
|
||||||
|
"""
|
||||||
|
Displays the back references for a family.
|
||||||
|
"""
|
||||||
|
def db_changed(self):
|
||||||
|
self.dbstate.db.connect('family-update', self.update)
|
||||||
|
self.connect_signal('Family', self.update)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
active_handle = self.get_active('Family')
|
||||||
|
self.model.clear()
|
||||||
|
if active_handle:
|
||||||
|
self.display_backlinks(active_handle)
|
||||||
|
|
||||||
|
class PlaceBacklinks(Backlinks):
|
||||||
|
"""
|
||||||
|
Displays the back references for a place.
|
||||||
|
"""
|
||||||
|
def db_changed(self):
|
||||||
|
self.dbstate.db.connect('place-update', self.update)
|
||||||
|
self.connect_signal('Place', self.update)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
active_handle = self.get_active('Place')
|
||||||
|
self.model.clear()
|
||||||
|
if active_handle:
|
||||||
|
self.display_backlinks(active_handle)
|
||||||
|
|
||||||
|
class SourceBacklinks(Backlinks):
|
||||||
|
"""
|
||||||
|
Displays the back references for a source,.
|
||||||
|
"""
|
||||||
|
def db_changed(self):
|
||||||
|
self.dbstate.db.connect('source-update', self.update)
|
||||||
|
self.connect_signal('Source', self.update)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
active_handle = self.get_active('Source')
|
||||||
|
self.model.clear()
|
||||||
|
if active_handle:
|
||||||
|
self.display_backlinks(active_handle)
|
||||||
|
|
||||||
|
class RepositoryBacklinks(Backlinks):
|
||||||
|
"""
|
||||||
|
Displays the back references for a repository.
|
||||||
|
"""
|
||||||
|
def db_changed(self):
|
||||||
|
self.dbstate.db.connect('repository-update', self.update)
|
||||||
|
self.connect_signal('Repository', self.update)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
active_handle = self.get_active('Repository')
|
||||||
|
self.model.clear()
|
||||||
|
if active_handle:
|
||||||
|
self.display_backlinks(active_handle)
|
||||||
|
|
||||||
|
class MediaBacklinks(Backlinks):
|
||||||
|
"""
|
||||||
|
Displays the back references for a media object.
|
||||||
|
"""
|
||||||
|
def db_changed(self):
|
||||||
|
self.dbstate.db.connect('media-update', self.update)
|
||||||
|
self.connect_signal('Media', self.update)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
active_handle = self.get_active('Media')
|
||||||
|
self.model.clear()
|
||||||
|
if active_handle:
|
||||||
|
self.display_backlinks(active_handle)
|
||||||
|
|
||||||
|
class NoteBacklinks(Backlinks):
|
||||||
|
"""
|
||||||
|
Displays the back references for a note.
|
||||||
|
"""
|
||||||
|
def db_changed(self):
|
||||||
|
self.dbstate.db.connect('note-update', self.update)
|
||||||
|
self.connect_signal('Note', self.update)
|
||||||
|
self.update()
|
||||||
|
|
||||||
|
def main(self):
|
||||||
|
active_handle = self.get_active('Note')
|
||||||
|
self.model.clear()
|
||||||
|
if active_handle:
|
||||||
|
self.display_backlinks(active_handle)
|
||||||
|
|
@ -391,6 +391,110 @@ register(GRAMPLET,
|
|||||||
gramplet_title=_("Children"),
|
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,
|
register(GRAMPLET,
|
||||||
id="Person Filter Gramplet",
|
id="Person Filter Gramplet",
|
||||||
name=_("Person Filter Gramplet"),
|
name=_("Person Filter Gramplet"),
|
||||||
|
@ -451,4 +451,5 @@ class BasePersonView(ListView):
|
|||||||
"Person Residence Gramplet",
|
"Person Residence Gramplet",
|
||||||
"Person Sources Gramplet",
|
"Person Sources Gramplet",
|
||||||
"Person Notes Gramplet",
|
"Person Notes Gramplet",
|
||||||
"Person Attributes Gramplet"))
|
"Person Attributes Gramplet",
|
||||||
|
"Person Backlinks Gramplet"))
|
||||||
|
@ -429,7 +429,8 @@ class PlaceBaseView(ListView):
|
|||||||
("Place Details Gramplet",
|
("Place Details Gramplet",
|
||||||
"Place Gallery Gramplet",
|
"Place Gallery Gramplet",
|
||||||
"Place Sources Gramplet",
|
"Place Sources Gramplet",
|
||||||
"Place Notes Gramplet"))
|
"Place Notes Gramplet",
|
||||||
|
"Place Backlinks Gramplet"))
|
||||||
|
|
||||||
def make_callback(func, val):
|
def make_callback(func, val):
|
||||||
return lambda x: func(val)
|
return lambda x: func(val)
|
||||||
|
@ -293,4 +293,5 @@ class EventView(ListView):
|
|||||||
("Event Gallery Gramplet",
|
("Event Gallery Gramplet",
|
||||||
"Event Sources Gramplet",
|
"Event Sources Gramplet",
|
||||||
"Event Notes Gramplet",
|
"Event Notes Gramplet",
|
||||||
"Event Attributes Gramplet"))
|
"Event Attributes Gramplet",
|
||||||
|
"Event Backlinks Gramplet"))
|
||||||
|
@ -347,4 +347,5 @@ class FamilyView(ListView):
|
|||||||
return (("Family Filter Gramplet",),
|
return (("Family Filter Gramplet",),
|
||||||
("Family Sources Gramplet",
|
("Family Sources Gramplet",
|
||||||
"Family Notes Gramplet",
|
"Family Notes Gramplet",
|
||||||
"Family Attributes Gramplet"))
|
"Family Attributes Gramplet",
|
||||||
|
"Family Backlinks Gramplet"))
|
||||||
|
@ -440,4 +440,5 @@ class MediaView(ListView):
|
|||||||
"Exif Viewer Gramplet",
|
"Exif Viewer Gramplet",
|
||||||
"Media Sources Gramplet",
|
"Media Sources Gramplet",
|
||||||
"Media Notes Gramplet",
|
"Media Notes Gramplet",
|
||||||
"Media Attributes Gramplet"))
|
"Media Attributes Gramplet",
|
||||||
|
"Media Backlinks Gramplet"))
|
||||||
|
@ -300,4 +300,4 @@ class NoteView(ListView):
|
|||||||
Define the default gramplets for the sidebar and bottombar.
|
Define the default gramplets for the sidebar and bottombar.
|
||||||
"""
|
"""
|
||||||
return (("Note Filter Gramplet",),
|
return (("Note Filter Gramplet",),
|
||||||
())
|
("Note Backlinks Gramplet",))
|
||||||
|
@ -276,4 +276,5 @@ class RepositoryView(ListView):
|
|||||||
"""
|
"""
|
||||||
return (("Repository Filter Gramplet",),
|
return (("Repository Filter Gramplet",),
|
||||||
("Repository Details Gramplet",
|
("Repository Details Gramplet",
|
||||||
"Repository Notes Gramplet"))
|
"Repository Notes Gramplet",
|
||||||
|
"Repository Backlinks Gramplet"))
|
||||||
|
@ -253,4 +253,5 @@ class SourceView(ListView):
|
|||||||
"""
|
"""
|
||||||
return (("Source Filter Gramplet",),
|
return (("Source Filter Gramplet",),
|
||||||
("Source Gallery Gramplet",
|
("Source Gallery Gramplet",
|
||||||
"Source Notes Gramplet"))
|
"Source Notes Gramplet",
|
||||||
|
"Source Backlinks Gramplet"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user