Unit Testing GTK+ libraries: has_default GtkWidget property

For my GTK+ based library, I use Vala and Glade to create templates for custom widgets with Unit Testing. For some reason I set can_default and has_default to true, this throws a warning message:

Gtk-WARNING **: /build/gtk+3.0-z20Lwo/gtk+3.0-3.20.7/./gtk/gtkwidget.c:8550: widget not within a GtkWindow

That 8550 line is related to method gtk_widget_grab_default, when you create your new custom Gtk.Grid derived widget, before to add it to a Gtk.Window, it calls this method before it has a top level window, sending this warning.

Now, for general GTK+ applications this is not a problem; but for GTK+ libraries trying to add a kind of Unit Testing. GTest will fail your test case, when any warning is raised, then you can’t continue until you fix it.

This is to help any one with same issue and for me for future developments.

Hope to share some of my work to create a custom GTK+ Window widget for custom widget testing usingĀ  GTest; stay tuned.

 

Author: despinosa

Linux and GNOME user, full time, since 2001. Actual maintainer of GXml and contributor to other projects mainly on GObject Introspection support.

Leave a Reply

Your email address will not be published. Required fields are marked *