From 4673318028dca5620960b171ddb4d07fa2c71a52 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 1 Nov 2016 01:21:02 +0100 Subject: [PATCH] inspector: Add list of render nodes to recorder And make it possible to view the actually selected node in the view. --- gtk/inspector/Makefile.inc | 2 + gtk/inspector/gtktreemodelrendernode.c | 474 +++++++++++++++++++++++++ gtk/inspector/gtktreemodelrendernode.h | 80 +++++ gtk/inspector/recorder.c | 97 +++-- gtk/inspector/recorder.ui | 61 +++- gtk/inspector/renderrecording.c | 6 + gtk/inspector/renderrecording.h | 2 + 7 files changed, 701 insertions(+), 21 deletions(-) create mode 100644 gtk/inspector/gtktreemodelrendernode.c create mode 100644 gtk/inspector/gtktreemodelrendernode.h diff --git a/gtk/inspector/Makefile.inc b/gtk/inspector/Makefile.inc index b30204ba75..d98d547ab7 100644 --- a/gtk/inspector/Makefile.inc +++ b/gtk/inspector/Makefile.inc @@ -10,6 +10,7 @@ inspector_c_sources = \ inspector/graphdata.c \ inspector/gtkstackcombo.c \ inspector/gtktreemodelcssnode.c \ + inspector/gtktreemodelrendernode.c \ inspector/init.c \ inspector/inspect-button.c \ inspector/magnifier.c \ @@ -45,6 +46,7 @@ inspector_h_sources = \ inspector/graphdata.h \ inspector/gtkstackcombo.h \ inspector/gtktreemodelcssnode.h \ + inspector/gtktreemodelrendernode.h \ inspector/init.h \ inspector/magnifier.h \ inspector/menu.h \ diff --git a/gtk/inspector/gtktreemodelrendernode.c b/gtk/inspector/gtktreemodelrendernode.c new file mode 100644 index 0000000000..701f74bad4 --- /dev/null +++ b/gtk/inspector/gtktreemodelrendernode.c @@ -0,0 +1,474 @@ +/* gtktreestore.c + * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library. If not, see . + */ + +#include "config.h" + +#include "gtktreemodelrendernode.h" + +struct _GtkTreeModelRenderNodePrivate +{ + GtkTreeModelRenderNodeGetFunc get_func; + gint n_columns; + GType *column_types; + + GskRenderNode *root; +}; + +static void gtk_tree_model_render_node_tree_model_init (GtkTreeModelIface *iface); + +G_DEFINE_TYPE_WITH_CODE (GtkTreeModelRenderNode, gtk_tree_model_render_node, G_TYPE_OBJECT, + G_ADD_PRIVATE (GtkTreeModelRenderNode) + G_IMPLEMENT_INTERFACE (GTK_TYPE_TREE_MODEL, + gtk_tree_model_render_node_tree_model_init)) + +static GskRenderNode * +get_nth_child (GskRenderNode *node, + gint i) +{ + for (node = gsk_render_node_get_first_child (node); + node != NULL && i > 0; + node = gsk_render_node_get_next_sibling (node)) + i--; + + return node; +} + +static int +get_node_index (GskRenderNode *node) +{ + int result = 0; + + while ((node = gsk_render_node_get_previous_sibling (node))) + result++; + + return result; +} + +static GtkTreeModelFlags +gtk_tree_model_render_node_get_flags (GtkTreeModel *tree_model) +{ + return GTK_TREE_MODEL_ITERS_PERSIST; +} + +static gint +gtk_tree_model_render_node_get_n_columns (GtkTreeModel *tree_model) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GtkTreeModelRenderNodePrivate *priv = nodemodel->priv; + + return priv->n_columns; +} + +static GType +gtk_tree_model_render_node_get_column_type (GtkTreeModel *tree_model, + gint column) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GtkTreeModelRenderNodePrivate *priv = nodemodel->priv; + + g_return_val_if_fail (column < priv->n_columns, G_TYPE_INVALID); + + return priv->column_types[column]; +} + +static gboolean +gtk_tree_model_render_node_get_iter (GtkTreeModel *tree_model, + GtkTreeIter *iter, + GtkTreePath *path) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GtkTreeModelRenderNodePrivate *priv = nodemodel->priv; + GskRenderNode *node; + int *indices; + int depth, i; + + if (priv->root == NULL) + return FALSE; + + indices = gtk_tree_path_get_indices (path); + depth = gtk_tree_path_get_depth (path); + + if (depth < 1 || indices[0] != 0) + return FALSE; + + node = priv->root; + for (i = 1; i < depth; i++) + { + node = get_nth_child (node, indices[i]); + if (node == NULL) + return FALSE; + } + + gtk_tree_model_render_node_get_iter_from_node (nodemodel, iter, node); + return TRUE; +} + +static GtkTreePath * +gtk_tree_model_render_node_get_path (GtkTreeModel *tree_model, + GtkTreeIter *iter) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GtkTreeModelRenderNodePrivate *priv = nodemodel->priv; + GskRenderNode *node; + GtkTreePath *path; + + g_return_val_if_fail (priv->root != NULL, NULL); + + path = gtk_tree_path_new (); + node = gtk_tree_model_render_node_get_node_from_iter (nodemodel, iter); + + while (node != priv->root) + { + gtk_tree_path_prepend_index (path, get_node_index (node)); + node = gsk_render_node_get_parent (node); + } + + gtk_tree_path_prepend_index (path, 0); + + return path; +} + +static void +gtk_tree_model_render_node_get_value (GtkTreeModel *tree_model, + GtkTreeIter *iter, + gint column, + GValue *value) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GtkTreeModelRenderNodePrivate *priv = nodemodel->priv; + + g_value_init (value, priv->column_types[column]); + priv->get_func (nodemodel, + gtk_tree_model_render_node_get_node_from_iter (nodemodel, iter), + column, + value); +} + +static gboolean +gtk_tree_model_render_node_iter_next (GtkTreeModel *tree_model, + GtkTreeIter *iter) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GtkTreeModelRenderNodePrivate *priv = nodemodel->priv; + GskRenderNode *node; + + node = gtk_tree_model_render_node_get_node_from_iter (nodemodel, iter); + if (node == priv->root) + return FALSE; + + node = gsk_render_node_get_next_sibling (node); + if (node == NULL) + return FALSE; + + gtk_tree_model_render_node_get_iter_from_node (nodemodel, iter, node); + return TRUE; +} + +static gboolean +gtk_tree_model_render_node_iter_previous (GtkTreeModel *tree_model, + GtkTreeIter *iter) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GtkTreeModelRenderNodePrivate *priv = nodemodel->priv; + GskRenderNode *node; + + node = gtk_tree_model_render_node_get_node_from_iter (nodemodel, iter); + if (node == priv->root) + return FALSE; + + node = gsk_render_node_get_previous_sibling (node); + if (node == NULL) + return FALSE; + + gtk_tree_model_render_node_get_iter_from_node (nodemodel, iter, node); + return TRUE; +} + +static gboolean +gtk_tree_model_render_node_iter_children (GtkTreeModel *tree_model, + GtkTreeIter *iter, + GtkTreeIter *parent) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GtkTreeModelRenderNodePrivate *priv = nodemodel->priv; + GskRenderNode *node; + + if (parent == NULL) + { + node = priv->root; + } + else + { + node = gtk_tree_model_render_node_get_node_from_iter (nodemodel, parent); + node = gsk_render_node_get_first_child (node); + } + if (node == NULL) + return FALSE; + + gtk_tree_model_render_node_get_iter_from_node (nodemodel, iter, node); + return TRUE; +} + +static gboolean +gtk_tree_model_render_node_iter_has_child (GtkTreeModel *tree_model, + GtkTreeIter *iter) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GskRenderNode *node; + + node = gtk_tree_model_render_node_get_node_from_iter (nodemodel, iter); + + return gsk_render_node_get_first_child (node) != NULL; +} + +static gint +gtk_tree_model_render_node_iter_n_children (GtkTreeModel *tree_model, + GtkTreeIter *iter) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GtkTreeModelRenderNodePrivate *priv = nodemodel->priv; + GskRenderNode *node; + + if (iter == NULL) + return priv->root ? 1 : 0; + + node = gtk_tree_model_render_node_get_node_from_iter (nodemodel, iter); + + node = gsk_render_node_get_last_child (node); + if (node == NULL) + return 0; + + return get_node_index (node) + 1; +} + +static gboolean +gtk_tree_model_render_node_iter_nth_child (GtkTreeModel *tree_model, + GtkTreeIter *iter, + GtkTreeIter *parent, + gint n) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GtkTreeModelRenderNodePrivate *priv = nodemodel->priv; + GskRenderNode *node; + + if (parent == NULL) + { + if (n > 0) + return FALSE; + + node = priv->root; + } + else + { + node = gtk_tree_model_render_node_get_node_from_iter (nodemodel, parent); + node = get_nth_child (node, n); + } + + if (node == NULL) + return FALSE; + + gtk_tree_model_render_node_get_iter_from_node (nodemodel, iter, node); + return TRUE; +} + +static gboolean +gtk_tree_model_render_node_iter_parent (GtkTreeModel *tree_model, + GtkTreeIter *iter, + GtkTreeIter *child) +{ + GtkTreeModelRenderNode *nodemodel = GTK_TREE_MODEL_RENDER_NODE (tree_model); + GtkTreeModelRenderNodePrivate *priv = nodemodel->priv; + GskRenderNode *node; + + node = gtk_tree_model_render_node_get_node_from_iter (nodemodel, child); + if (node == priv->root) + return FALSE; + + node = gsk_render_node_get_parent (node); + + gtk_tree_model_render_node_get_iter_from_node (nodemodel, iter, node); + return TRUE; +} + +static void +gtk_tree_model_render_node_tree_model_init (GtkTreeModelIface *iface) +{ + iface->get_flags = gtk_tree_model_render_node_get_flags; + iface->get_n_columns = gtk_tree_model_render_node_get_n_columns; + iface->get_column_type = gtk_tree_model_render_node_get_column_type; + iface->get_iter = gtk_tree_model_render_node_get_iter; + iface->get_path = gtk_tree_model_render_node_get_path; + iface->get_value = gtk_tree_model_render_node_get_value; + iface->iter_next = gtk_tree_model_render_node_iter_next; + iface->iter_previous = gtk_tree_model_render_node_iter_previous; + iface->iter_children = gtk_tree_model_render_node_iter_children; + iface->iter_has_child = gtk_tree_model_render_node_iter_has_child; + iface->iter_n_children = gtk_tree_model_render_node_iter_n_children; + iface->iter_nth_child = gtk_tree_model_render_node_iter_nth_child; + iface->iter_parent = gtk_tree_model_render_node_iter_parent; +} + +static void +gtk_tree_model_render_node_finalize (GObject *object) +{ + GtkTreeModelRenderNode *model = GTK_TREE_MODEL_RENDER_NODE (object); + GtkTreeModelRenderNodePrivate *priv = model->priv; + + g_clear_pointer (&priv->root, gsk_render_node_unref); + + G_OBJECT_CLASS (gtk_tree_model_render_node_parent_class)->finalize (object); +} + +static void +gtk_tree_model_render_node_class_init (GtkTreeModelRenderNodeClass *class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (class); + + object_class->finalize = gtk_tree_model_render_node_finalize; +} + +static void +gtk_tree_model_render_node_init (GtkTreeModelRenderNode *nodemodel) +{ + nodemodel->priv = gtk_tree_model_render_node_get_instance_private (nodemodel); +} + +GtkTreeModel * +gtk_tree_model_render_node_new (GtkTreeModelRenderNodeGetFunc get_func, + gint n_columns, + ...) +{ + GtkTreeModel *result; + va_list args; + GType *types; + gint i; + + g_return_val_if_fail (get_func != NULL, NULL); + g_return_val_if_fail (n_columns > 0, NULL); + + types = g_new (GType, n_columns); + va_start (args, n_columns); + + for (i = 0; i < n_columns; i++) + { + types[i] = va_arg (args, GType); + } + + va_end (args); + + result = gtk_tree_model_render_node_newv (get_func, n_columns, types); + + g_free (types); + + return result; +} + +GtkTreeModel * +gtk_tree_model_render_node_newv (GtkTreeModelRenderNodeGetFunc get_func, + gint n_columns, + GType *types) +{ + GtkTreeModelRenderNode *result; + GtkTreeModelRenderNodePrivate *priv; + + g_return_val_if_fail (get_func != NULL, NULL); + g_return_val_if_fail (n_columns > 0, NULL); + g_return_val_if_fail (types != NULL, NULL); + + result = g_object_new (GTK_TYPE_TREE_MODEL_RENDER_NODE, NULL); + priv = result->priv; + + priv->get_func = get_func; + priv->n_columns = n_columns; + priv->column_types = g_memdup (types, sizeof (GType) * n_columns); + + return GTK_TREE_MODEL (result); +} + +void +gtk_tree_model_render_node_set_root_node (GtkTreeModelRenderNode *model, + GskRenderNode *node) +{ + GtkTreeModelRenderNodePrivate *priv; + GtkTreePath *path; + + g_return_if_fail (GTK_IS_TREE_MODEL_RENDER_NODE (model)); + g_return_if_fail (node == NULL || GSK_IS_RENDER_NODE (node)); + + priv = model->priv; + + if (priv->root == node) + return; + + if (priv->root) + { + path = gtk_tree_path_new_first (); + gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path); + gtk_tree_path_free (path); + + gsk_render_node_unref (priv->root); + } + + priv->root = node; + + if (node) + { + GtkTreeIter iter; + + gsk_render_node_ref (node); + + gtk_tree_model_render_node_get_iter_from_node (model, &iter, node); + path = gtk_tree_path_new_first (); + gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter); + if (gsk_render_node_get_first_child (node)) + gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model), path, &iter); + gtk_tree_path_free (path); + } +} + +GskRenderNode * +gtk_tree_model_render_node_get_root_node (GtkTreeModelRenderNode *model) +{ + g_return_val_if_fail (GTK_IS_TREE_MODEL_RENDER_NODE (model), NULL); + + return model->priv->root; +} + +GskRenderNode * +gtk_tree_model_render_node_get_node_from_iter (GtkTreeModelRenderNode *model, + GtkTreeIter *iter) +{ + g_return_val_if_fail (GTK_IS_TREE_MODEL_RENDER_NODE (model), NULL); + g_return_val_if_fail (iter != NULL, NULL); + g_return_val_if_fail (iter->user_data == model, NULL); + g_return_val_if_fail (GSK_IS_RENDER_NODE (iter->user_data2), NULL); + + return iter->user_data2; +} + +void +gtk_tree_model_render_node_get_iter_from_node (GtkTreeModelRenderNode *model, + GtkTreeIter *iter, + GskRenderNode *node) +{ + g_return_if_fail (GTK_IS_TREE_MODEL_RENDER_NODE (model)); + g_return_if_fail (iter != NULL); + g_return_if_fail (GSK_IS_RENDER_NODE (node)); + + iter->user_data = model; + iter->user_data2 = node; +} diff --git a/gtk/inspector/gtktreemodelrendernode.h b/gtk/inspector/gtktreemodelrendernode.h new file mode 100644 index 0000000000..a0f448aeec --- /dev/null +++ b/gtk/inspector/gtktreemodelrendernode.h @@ -0,0 +1,80 @@ +/* gtktreestore.h + * Copyright (C) 2014 Benjamin Otte + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library. If not, see . + */ + +#ifndef __GTK_TREE_MODEL_RENDER_NODE_H__ +#define __GTK_TREE_MODEL_RENDER_NODE_H__ + +#include + +#include + + +G_BEGIN_DECLS + + +#define GTK_TYPE_TREE_MODEL_RENDER_NODE (gtk_tree_model_render_node_get_type ()) +#define GTK_TREE_MODEL_RENDER_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TREE_MODEL_RENDER_NODE, GtkTreeModelRenderNode)) +#define GTK_TREE_MODEL_RENDER_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TREE_MODEL_RENDER_NODE, GtkTreeModelRenderNodeClass)) +#define GTK_IS_TREE_MODEL_RENDER_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TREE_MODEL_RENDER_NODE)) +#define GTK_IS_TREE_MODEL_RENDER_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TREE_MODEL_RENDER_NODE)) +#define GTK_TREE_MODEL_RENDER_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TREE_MODEL_RENDER_NODE, GtkTreeModelRenderNodeClass)) + +typedef struct _GtkTreeModelRenderNode GtkTreeModelRenderNode; +typedef struct _GtkTreeModelRenderNodeClass GtkTreeModelRenderNodeClass; +typedef struct _GtkTreeModelRenderNodePrivate GtkTreeModelRenderNodePrivate; + +typedef void (* GtkTreeModelRenderNodeGetFunc) (GtkTreeModelRenderNode *model, + GskRenderNode *node, + int column, + GValue *value); + +struct _GtkTreeModelRenderNode +{ + GObject parent; + + GtkTreeModelRenderNodePrivate *priv; +}; + +struct _GtkTreeModelRenderNodeClass +{ + GObjectClass parent_class; +}; + + +GType gtk_tree_model_render_node_get_type (void) G_GNUC_CONST; + +GtkTreeModel *gtk_tree_model_render_node_new (GtkTreeModelRenderNodeGetFunc get_func, + gint n_columns, + ...); +GtkTreeModel *gtk_tree_model_render_node_newv (GtkTreeModelRenderNodeGetFunc get_func, + gint n_columns, + GType *types); + +void gtk_tree_model_render_node_set_root_node (GtkTreeModelRenderNode *model, + GskRenderNode *node); +GskRenderNode*gtk_tree_model_render_node_get_root_node (GtkTreeModelRenderNode *model); +GskRenderNode*gtk_tree_model_render_node_get_node_from_iter (GtkTreeModelRenderNode *model, + GtkTreeIter *iter); +void gtk_tree_model_render_node_get_iter_from_node (GtkTreeModelRenderNode *model, + GtkTreeIter *iter, + GskRenderNode *node); + + +G_END_DECLS + + +#endif /* __GTK_TREE_MODEL_RENDER_NODE_H__ */ diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c index ad5b778179..5c189fe03c 100644 --- a/gtk/inspector/recorder.c +++ b/gtk/inspector/recorder.c @@ -22,7 +22,10 @@ #include #include +#include +#include +#include "gtktreemodelrendernode.h" #include "recording.h" #include "rendernodeview.h" #include "renderrecording.h" @@ -30,8 +33,18 @@ struct _GtkInspectorRecorderPrivate { GListModel *recordings; + GtkTreeModel *render_node_model; + GtkWidget *recordings_list; GtkWidget *render_node_view; + GtkWidget *render_node_tree; +}; + +enum { + COLUMN_NODE_NAME, + COLUMN_NODE_VISIBLE, + /* add more */ + N_NODE_COLUMNS }; G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorRecorder, gtk_inspector_recorder, GTK_TYPE_BIN) @@ -52,11 +65,55 @@ recordings_list_row_selected (GtkListBox *box, gtk_inspector_render_recording_get_node (GTK_INSPECTOR_RENDER_RECORDING (recording))); gtk_render_node_view_set_clip_region (GTK_RENDER_NODE_VIEW (priv->render_node_view), gtk_inspector_render_recording_get_clip_region (GTK_INSPECTOR_RENDER_RECORDING (recording))); + gtk_render_node_view_set_viewport (GTK_RENDER_NODE_VIEW (priv->render_node_view), + gtk_inspector_render_recording_get_area (GTK_INSPECTOR_RENDER_RECORDING (recording))); + gtk_tree_model_render_node_set_root_node (GTK_TREE_MODEL_RENDER_NODE (priv->render_node_model), + gtk_inspector_render_recording_get_node (GTK_INSPECTOR_RENDER_RECORDING (recording))); } else { gtk_render_node_view_set_render_node (GTK_RENDER_NODE_VIEW (priv->render_node_view), NULL); + gtk_tree_model_render_node_set_root_node (GTK_TREE_MODEL_RENDER_NODE (priv->render_node_model), NULL); } + + gtk_tree_view_expand_all (GTK_TREE_VIEW (priv->render_node_tree)); +} + +static void +render_node_list_get_value (GtkTreeModelRenderNode *model, + GskRenderNode *node, + int column, + GValue *value) +{ + switch (column) + { + case COLUMN_NODE_NAME: + g_value_set_string (value, gsk_render_node_get_name (node)); + break; + + case COLUMN_NODE_VISIBLE: + g_value_set_boolean (value, !gsk_render_node_is_hidden (node)); + break; + + default: + g_assert_not_reached (); + break; + } +} + +static void +render_node_list_selection_changed (GtkTreeSelection *selection, + GtkInspectorRecorder *recorder) +{ + GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder); + GskRenderNode *node; + GtkTreeIter iter; + + if (!gtk_tree_selection_get_selected (selection, NULL, &iter)) + return; + + node = gtk_tree_model_render_node_get_node_from_iter (GTK_TREE_MODEL_RENDER_NODE (priv->render_node_model), &iter); + gtk_render_node_view_set_render_node (GTK_RENDER_NODE_VIEW (priv->render_node_view), node); } static GtkWidget * @@ -75,42 +132,42 @@ gtk_inspector_recorder_recordings_list_create_widget (gpointer item, return widget; } -static void -gtk_inspector_recorder_constructed (GObject *object) -{ - GtkInspectorRecorder *recorder = GTK_INSPECTOR_RECORDER (object); - GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder); - - G_OBJECT_CLASS (gtk_inspector_recorder_parent_class)->constructed (object); - - gtk_list_box_bind_model (GTK_LIST_BOX (priv->recordings_list), - priv->recordings, - gtk_inspector_recorder_recordings_list_create_widget, - NULL, - NULL); -} - static void gtk_inspector_recorder_class_init (GtkInspectorRecorderClass *klass) { GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->constructed = gtk_inspector_recorder_constructed; gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/recorder.ui"); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorRecorder, recordings); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorRecorder, recordings_list); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorRecorder, render_node_view); + gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorRecorder, render_node_tree); gtk_widget_class_bind_template_callback (widget_class, recordings_list_row_selected); + gtk_widget_class_bind_template_callback (widget_class, render_node_list_selection_changed); } static void -gtk_inspector_recorder_init (GtkInspectorRecorder *vis) +gtk_inspector_recorder_init (GtkInspectorRecorder *recorder) { - gtk_widget_init_template (GTK_WIDGET (vis)); + GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder); + + gtk_widget_init_template (GTK_WIDGET (recorder)); + + gtk_list_box_bind_model (GTK_LIST_BOX (priv->recordings_list), + priv->recordings, + gtk_inspector_recorder_recordings_list_create_widget, + NULL, + NULL); + + priv->render_node_model = gtk_tree_model_render_node_new (render_node_list_get_value, + N_NODE_COLUMNS, + G_TYPE_STRING, + G_TYPE_BOOLEAN); + gtk_tree_view_set_model (GTK_TREE_VIEW (priv->render_node_tree), priv->render_node_model); + g_object_unref (priv->render_node_model); + } void diff --git a/gtk/inspector/recorder.ui b/gtk/inspector/recorder.ui index 18c9ff80c8..9ab46a4d69 100644 --- a/gtk/inspector/recorder.ui +++ b/gtk/inspector/recorder.ui @@ -11,6 +11,7 @@ True horizontal + 300 True @@ -24,11 +25,69 @@ + + False + False + - + True + horizontal + 100 + + + True + True + automatic + automatic + 100 + + + True + 0 + 0 + vertical + + + + + + + + True + Name + + + + 0 + 1 + + + + + + + + + False + False + + + + + True + + + False + True + + + + False + True + diff --git a/gtk/inspector/renderrecording.c b/gtk/inspector/renderrecording.c index 7686e3205d..761f5bdce9 100644 --- a/gtk/inspector/renderrecording.c +++ b/gtk/inspector/renderrecording.c @@ -77,4 +77,10 @@ gtk_inspector_render_recording_get_clip_region (GtkInspectorRenderRecording *rec return recording->clip; } +const cairo_rectangle_int_t * +gtk_inspector_render_recording_get_area (GtkInspectorRenderRecording *recording) +{ + return &recording->area; +} + // vim: set et sw=2 ts=2: diff --git a/gtk/inspector/renderrecording.h b/gtk/inspector/renderrecording.h index c4d67d8660..c9b14a1928 100644 --- a/gtk/inspector/renderrecording.h +++ b/gtk/inspector/renderrecording.h @@ -60,6 +60,8 @@ GtkInspectorRecording * GskRenderNode * gtk_inspector_render_recording_get_node (GtkInspectorRenderRecording *recording); const cairo_region_t * gtk_inspector_render_recording_get_clip_region (GtkInspectorRenderRecording *recording); +const cairo_rectangle_int_t * + gtk_inspector_render_recording_get_area (GtkInspectorRenderRecording *recording); G_END_DECLS