How can Gramps determine which View category, mode and splitbar is running a Gramplet?

When my Statusbar started alerting that a Gramplet (not a Gramplet of my own creation and NOT in the active view) was encountering errors, Gramps slowed down to a crawl. I needed to find the Gramplet, in whatever splitbar it lived, and remove it.

However, with 12 view categories, 35 view modes, and 103 possible .ini files for the panels of the view modes; it was very tedious to discover WHERE the gramplet was active. Particularly when dialogs were constantly popping up warnings about Gramps not being responsive.

It there an API call to discover where a gramplet is running?

Or to generate a list signals and callbacks being monitored by all active Gramplets ?

Maybe running Gramps with the environment variable GTK_DEBUG=interactive could help. It has a Statistics tab which requires using GOBJECT_DEBUG=instance-count. It also says “GLib must be configured with --enable-debug“ and that’s as far as I got with it, so I don’t know what statistics it provides.

2 Likes

Don’t know about an API but here is a quick-and-dirty Supertool script that tries to list all active gramplets.

[Gramps SuperTool script file]
version=1

[title]
list_gramplets

[description]
List all active gramplets.

[category]
Dashboard

[initial_statements]
result.set_headers(["View", "Position", "Gramplet"])

def list_gramplets(grampletbar, viewname, position):
    for n in range(grampletbar.get_n_pages()):
        g = grampletbar.get_nth_page(n)
        if hasattr(g, "title"):
            result.add_row([viewname, position, g.title])
        for g in grampletbar.detached_gramplets:
            result.add_row([viewname, "detached", g.title])

for page in uistate.viewmanager.pages:
    viewname = page.get_title()
    if page.sidebar:
        list_gramplets(page.sidebar, viewname, "sidebar")
    if page.bottombar:
        list_gramplets(page.bottombar, viewname, "bottombar")
    if page.top: # DashBoard
        if hasattr(page.top, "gramplet_map"):
            for title, g in page.top.gramplet_map.items():
                if g in page.top.detached_gramplets:
                    pos = "detached"
                else:
                    pos = "pane"
                result.add_row([viewname, pos, g.title])

[statements]

[filter]

[expressions]

[scope]
selected

[unwind_lists]
False

[commit_changes]
False

[summary_only]
True

The result might look something like this:

You can sort the list by clicking the headers so you should be able to find the gramplet if you know its name.

This can be run in any category although it was written for the Dashboard category.

1 Like

Thank you. This IS very close. But it is limited to listing only the view modes that have been active in the current session.

How could it be expanded to iterate through all Categories and all View Modes within each category?

Here’s a Python Evaluation script that will list all the gramplets available in each category. Not simply the ones that are in the splitbar, as prompted.

(This was the 1st working version of what ChatGPT from GitHub provided in response to this subject. Unfortunately, it missed the mark badly. But still has potential uses.)

"""
List all registered Gramplets with:
- Gramplet Title
- View Category (navtype)
- Pane (Sidebar/Main – inferred)

Outputs a SimpleDoc-style table.
"""
"""
List all registered Gramplets with:
- Gramplet Title
- View Category (navtype)
- Pane (Sidebar/Main – inferred)

Outputs a Markdown table.
"""

# Full-path imports (required for Python Evaluation shell)
from gramps.gui.widgets.grampletpane import AVAILABLE_GRAMPLETS
from gramps.gui.widgets.grampletpane import GET_AVAILABLE_GRAMPLETS

from gramps.gen.const import GRAMPS_LOCALE as glocale

_ = glocale.translation.gettext

# -------------------------------------------------------------
# Collect gramplet data
# -------------------------------------------------------------

rows = []

for gid in AVAILABLE_GRAMPLETS():
    opts = GET_AVAILABLE_GRAMPLETS(gid)
    if not opts:
        continue

    title = opts.get("title", gid)
    navtypes = opts.get("navtypes", [])
    height = int(opts.get("height", 0))

    # Determine view category
    if not navtypes:
        view_categories = ["All Views"]
    else:
        view_categories = navtypes

    # Infer pane (heuristic)
    # Sidebar gramplets typically have smaller heights
    pane = "Sidebar" if height <= 250 else "Bottombar"

    for view in view_categories:
        rows.append((title, view, pane))

# Sort for readability
rows.sort(key=lambda x: (str(x[1]), str(x[0])))

# -------------------------------------------------------------
# Output Markdown table
# -------------------------------------------------------------

print("## Gramplets by View Category ")
print("")
print("| Gramplet Name | View Category | Pane |")
print("|---|---|---|")

for title, view, pane in rows:
    print(f"| {title} | {view} | {pane} |")

print("")
print(f"Total Gramplets: {len(set([r[0] for r in rows]))}")

Gramplets by View Category

Gramplet Name View Category Pane
Age Stats All Views Sidebar
Age on Date All Views Sidebar
Anniversaries All Views Sidebar
Beta What’s Next? All Views Bottombar
sample output
MultiMergeGramplet Source Sidebar
Notes Source Sidebar
Notes2 Source Sidebar
References Source Sidebar
References Source Sidebar
To Do Source Sidebar
Virtual Keyboard Source Bottombar
WebSearch Source Sidebar

Total Gramplets: 104