inspector: Put surfaces and renderers in the tree

These are otherwise really hard to navigate to, and we already
have plenty of non-widget objects in the tree.
This commit is contained in:
Matthias Clasen
2024-11-14 16:58:44 -05:00
parent 841bd9c5c2
commit ed2716f9ce

View File

@@ -45,6 +45,7 @@
#include "gtklabel.h"
#include "gtklistitem.h"
#include "gtkpopover.h"
#include "gtknative.h"
#include "gtksettings.h"
#include "gtksingleselection.h"
#include "gtksignallistitemfactory.h"
@@ -132,6 +133,37 @@ object_tree_widget_get_children (GObject *object)
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
}
static GObject *
object_tree_window_get_parent (GObject *object)
{
return NULL;
}
static GListModel *
object_tree_native_get_children (GObject *object)
{
GtkNative *native = GTK_NATIVE (object);
GListStore *list;
GListModel *sublist;
list = g_list_store_new (G_TYPE_LIST_MODEL);
sublist = G_LIST_MODEL (g_list_store_new (G_TYPE_OBJECT));
if (gtk_native_get_surface (native))
g_list_store_append (G_LIST_STORE (sublist), gtk_native_get_surface (native));
if (gtk_native_get_renderer (native))
g_list_store_append (G_LIST_STORE (sublist), gtk_native_get_renderer (native));
g_list_store_append (list, sublist);
g_object_unref (sublist);
sublist = object_tree_widget_get_children (object);
g_list_store_append (list, sublist);
g_object_unref (sublist);
return G_LIST_MODEL (gtk_flatten_list_model_new (G_LIST_MODEL (list)));
}
static GListModel *
object_tree_tree_model_sort_get_children (GObject *object)
{
@@ -518,6 +550,16 @@ static const ObjectTreeClassFuncs object_tree_class_funcs[] = {
object_tree_widget_get_parent,
object_tree_combo_box_get_children
},
{
gtk_window_get_type,
object_tree_window_get_parent,
object_tree_native_get_children,
},
{
gtk_popover_get_type,
object_tree_widget_get_parent,
object_tree_native_get_children,
},
{
gtk_widget_get_type,
object_tree_widget_get_parent,