Gtk-Message: GtkDialog mapped without a transient parent

How should dialogs be opened to avoid this error?

When finding examples of the error, how may the source module be hacked to verify the problem and submit a tested patch? [Answer: contribute where the impacted dialog is called in the GUI as a note in MetaBug 8128.]

For instance, when creating a filter via the Context Menu option for an object in the Clipboard.py, a “Define Filter” dialog is created that is not correctly added to the Windows menu and returns the console warning: “Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged.

Most new developers seem to have to discover how to create windows in Gramps without generating the error. And to correctly add them to the “Windows” menu (not referring to the Windoze OS) instead of having no item added to that menu. Or having it appear as "Undefined Submenu -> Undefined Menu...’

Can a “Useful snippet” be added to the developer API docs?

There is a bug report for this error:
https://gramps-project.org/bugs/view.php?id=8128

1 Like

We have been trying to stomp these issues for quite a while now. What it means is that the newly opened dialog might get ‘confused’ if the windows have to be redrawn due to minimization, overlaid etc. The confusion would involve the stacking order (which window goes on top of which).

The missing parameter is in the calling module, which should be supplying a reference to itself as the parent.

After doing a bit of debugging, I was unable to recreate the trasient parent issue you mentioned. I did see the “Unknown Menu” issue.

The “Unknown Menu” issue is caused by not using the ManagedWindow class correctly. When using that class to implement a class such as DefineFilter (in gramps/gui/editors/filtereditor.py around line 810) there should have been method defined “build_menu_names”. This is used to fill out the ‘Windows’ menu.

I tested a quick fix to this issue and the diff to the code is attached below.

diff --git a/gramps/gui/editors/filtereditor.py b/gramps/gui/editors/filtereditor.py
index 431b4b05d..56b642e22 100644
--- a/gramps/gui/editors/filtereditor.py
+++ b/gramps/gui/editors/filtereditor.py
@@ -697,6 +697,9 @@ class EditRule(ManagedWindow):
         self.get_widget('hpaned1').set_position(panepos)
         self.show()

+    def build_menu_names(self, obj):
+        return (_("Edit Rule"), _("Edit Rule"))
+
     def select_iter(self, data):
         """
         Workaround to get self.selection to move to iter row.
@@ -867,6 +870,9 @@ class EditFilter(ManagedWindow):
         self._set_size()
         self.show()

+    def build_menu_names(self, obj):
+        return (_("Define filter"), _("Define filter"))
+
     def on_help_clicked(self, obj):
         """Display the relevant portion of Gramps manual"""
         display_help(webpage=WIKI_HELP_PAGE,`Preformatted text`
2 Likes

@prculley
Could you re-check this patch? I have two places where this “Define Filters” dialog is invoked. And both now are added to the Windows menus in weird way and different ways.

  • the built-in Clipboard called from that Context menu. Instead of layering it into the Clipboard, it adds a submenu and menu item that are named the same:
    image

  • The other is an experimental add-on that calls from a button in the dialog. And still does the doubled name at submenu and menu name but pushes it down a level deeper:
    image

In that bug report, it points to an eMail about the commit where the “GtkDialog: Warn about lack of transient parents” message was added to the gtk/gtkdialog.c module in 2014.

That message is not very actionable. It does not identify the actual dialog triggering the warning. And since it is merely a warning rather than an error, the user won’t see the message in a timely manner. (Or at all if they are not running from the console.) So they are unlikely to recall which action triggered the warning.

Further, several contributors have noted that Gtk is outside their expertise. And they need some guidance to avoid or correct common errors.

Is it viable to add a targeted bug species extermination feature to the Logging module? Have it watch for specific common GTK errors and supplement the standard error message with information that make it more actionable? Such as the active module and a URL with a forum discussion of the corrective action?

What common warnings are there:

  • GtkDialog mapped without a transient parent. This is discouraged.

Kari often sees something like:

/usr/lib/python3.11/site-packages/gi/overrides/Gio.py:42: Warning: unable to set property 'weight-set' of type 'gboolean' from value of type 'gchararray'
  return Gio.Application.run(self, *args, **kwargs)

Note: The 8128 metabug has been “related to” a number of reports with extended discussions about resolving the warning. And it is covered again in this thread. This seems like re-inventing the wheel. Are these recurring issues in a developer doc that is similar to the User Manual’s Appendix E: Error and Warning Reference ?