Enhanced Citations gramplet

Though I’m not a python developer, sometimes I feel sufficiently brave and foolish to try my own hacks, and so I share my limited experience in case it helps others who want to dabble.

Here is what I did to a copy of the Citations gramplet so that it would show more information, in case anyone else find this useful. I was inspired by this feature request.

Instead of the column Source/Citation (where “citation” means Volume/Page), this version has a column Source/Date, a separate column for Volume/Page, and a new column for Confidence Level. The other columns for Author and Publisher remain as they were. You might prefer to do it differently, for example keep Source/Citation as it is and add a new column for Date.

Caution: python is sensitive to indentation, and that may not have come across correctly in the formatting of this post!

In the list of imported Gramps modules, I added these lines:

from gramps.gen.utils.string import conf_strings
from gramps.gen.datehandler._dateutils import get_date

In build_gui.self() I made these changes:

I changed the following lines:

    titles = [('', NOSORT, 50,),
              (_('Source/Citation'), 1, 350),
              (_('Author'), 2, 200),
              (_('Publisher'), 3, 150)]

to look like this:

    titles = [('', NOSORT, 50,),
              (_('Source/Date'), 1, 350),
              (_('Volume/Page'), 2, 150),
              (_('Confidence Level'), 3, 150),
              (_('Author'), 4, 200),
              (_('Publisher'), 5, 150)]

I changed add_citation_ref() as follows:

def add_citation_ref(self, citation_handle):
    Add a citation to the model.
    self.callman.register_handles({'citation': [citation_handle]})
    citation = self.dbstate.db.get_citation_from_handle(citation_handle)
    page = citation.get_page()
    if not page:

I changed the following line:

       page = _('<No Citation>')

to look like this:

        page = _('<No Volume/Page>')

    source_handle = citation.get_reference_handle()
    source = self.dbstate.db.get_source_from_handle(source_handle)
    title = source.get_title()
    author = source.get_author()
    publisher = source.get_publication_info()

I added the following two lines:

    confidence = citation.get_confidence_level()
    date = citation.get_date_object()

    if source_handle not in self.source_nodes:

I changed the following line:

       node = self.model.add([source_handle, title, author, publisher])

to look like this:

        node = self.model.add([source_handle, title, '', '', author, publisher])

        self.source_nodes[source_handle] = node

I changed the following line:

    self.model.add([citation_handle, page, '', ''],

to look like this:

    self.model.add([citation_handle, get_date(citation), page, _(conf_strings[confidence]), '', ''],


Something to investigate further: use a list structure instead of a tree structure, for more flexible sorting (e.g. by date overall rather than by date within source).

If you feel inclined to try this yourself, I suggest using the same approach of making a copy of the gramplet and giving it a new name, rather than changing the original gramplet, not only for safety’s safe, but also so that you can more easily compare the results with the original gramplet. It just means you also need to create an appropriate .gpr file for the new gramplet. Even so, be very careful, test on a separate database, etc.

1 Like