forked from AuroraMiddleware/gtk
inspector: Make the render node tree use a ListBox
It used to be a treeview.
This commit is contained in:
parent
867042f88f
commit
aba76fe8e9
@ -149,3 +149,11 @@ gtk_render_node_paintable_new (GskRenderNode *node,
|
||||
|
||||
return GDK_PAINTABLE (self);
|
||||
}
|
||||
|
||||
GskRenderNode *
|
||||
gtk_render_node_paintable_get_render_node (GtkRenderNodePaintable *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_RENDER_NODE_PAINTABLE (self), NULL);
|
||||
|
||||
return self->node;
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ G_DECLARE_FINAL_TYPE (GtkRenderNodePaintable, gtk_render_node_paintable, GTK, RE
|
||||
GdkPaintable * gtk_render_node_paintable_new (GskRenderNode *node,
|
||||
const graphene_rect_t *bounds);
|
||||
|
||||
GskRenderNode * gtk_render_node_paintable_get_render_node (GtkRenderNodePaintable *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_RENDER_NODE_PAINTABLE_H__ */
|
||||
|
@ -1,671 +0,0 @@
|
||||
/* gtktreestore.c
|
||||
* Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gtktreemodelrendernode.h"
|
||||
|
||||
#include "gsk/gskrendernodeprivate.h"
|
||||
|
||||
typedef struct _TreeElement TreeElement;
|
||||
|
||||
/* This is an array of all nodes and the index of their parent. When adding a node,
|
||||
* we first add the node itself, and then all their children pointing the parent to
|
||||
* this element.
|
||||
*/
|
||||
struct _TreeElement
|
||||
{
|
||||
GskRenderNode *node;
|
||||
int parent;
|
||||
};
|
||||
|
||||
struct _GtkTreeModelRenderNodePrivate
|
||||
{
|
||||
GtkTreeModelRenderNodeGetFunc get_func;
|
||||
gint n_columns;
|
||||
GType *column_types;
|
||||
|
||||
GskRenderNode *root;
|
||||
GArray *nodes;
|
||||
};
|
||||
|
||||
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 gint
|
||||
element_from_iter (GtkTreeModelRenderNode *model,
|
||||
GtkTreeIter *iter)
|
||||
{
|
||||
return GPOINTER_TO_INT (iter->user_data2);
|
||||
}
|
||||
|
||||
static void
|
||||
iter_from_element (GtkTreeModelRenderNode *model,
|
||||
GtkTreeIter *iter,
|
||||
gint elt)
|
||||
{
|
||||
iter->user_data = model;
|
||||
iter->user_data2 = GINT_TO_POINTER (elt);
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
node_from_element (GtkTreeModelRenderNode *model,
|
||||
gint elt)
|
||||
{
|
||||
return g_array_index (model->priv->nodes, TreeElement, elt).node;
|
||||
}
|
||||
|
||||
static gint
|
||||
parent_element (GArray *nodes,
|
||||
gint idx)
|
||||
{
|
||||
return g_array_index (nodes, TreeElement, idx).parent;
|
||||
}
|
||||
|
||||
static gint
|
||||
get_nth_child (GArray *nodes,
|
||||
gint elt,
|
||||
gint nth)
|
||||
{
|
||||
guint i, count;
|
||||
|
||||
count = 0;
|
||||
for (i = elt + 1; i < nodes->len; i++)
|
||||
{
|
||||
gint parent = parent_element (nodes, i);
|
||||
|
||||
if (parent < elt)
|
||||
return FALSE;
|
||||
|
||||
if (parent != elt)
|
||||
continue;
|
||||
|
||||
if (count == nth)
|
||||
return i;
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static gint
|
||||
get_node_index (GArray *nodes,
|
||||
gint elt)
|
||||
{
|
||||
gint parent, i, idx;
|
||||
|
||||
if (elt == 0)
|
||||
return 0;
|
||||
|
||||
parent = parent_element (nodes, elt);
|
||||
idx = 0;
|
||||
|
||||
for (i = elt; i > parent; i--)
|
||||
{
|
||||
if (parent_element (nodes, i) == parent)
|
||||
idx++;
|
||||
}
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
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;
|
||||
int *indices;
|
||||
int depth, i;
|
||||
int elt;
|
||||
|
||||
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;
|
||||
|
||||
elt = 0;
|
||||
for (i = 1; i < depth; i++)
|
||||
{
|
||||
elt = get_nth_child (priv->nodes, elt, indices[i]);
|
||||
if (elt < 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
iter_from_element (nodemodel, iter, elt);
|
||||
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;
|
||||
GtkTreePath *path;
|
||||
gint elt;
|
||||
|
||||
g_return_val_if_fail (priv->root != NULL, NULL);
|
||||
|
||||
path = gtk_tree_path_new ();
|
||||
|
||||
for (elt = element_from_iter (nodemodel, iter); elt >= 0; elt = parent_element (priv->nodes, elt))
|
||||
{
|
||||
gtk_tree_path_prepend_index (path, get_node_index (priv->nodes, elt));
|
||||
}
|
||||
|
||||
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,
|
||||
node_from_element (nodemodel, element_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;
|
||||
gint i, parent;
|
||||
|
||||
i = element_from_iter (nodemodel, iter);
|
||||
parent = parent_element (priv->nodes, i);
|
||||
|
||||
if (parent < 0)
|
||||
return FALSE;
|
||||
|
||||
for (i = i + 1; i < priv->nodes->len; i++)
|
||||
{
|
||||
if (parent_element (priv->nodes, i) < parent)
|
||||
return FALSE;
|
||||
|
||||
if (parent_element (priv->nodes, i) == parent)
|
||||
{
|
||||
iter_from_element (nodemodel, iter, i);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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;
|
||||
gint i, parent;
|
||||
|
||||
i = element_from_iter (nodemodel, iter);
|
||||
parent = parent_element (priv->nodes, i);
|
||||
|
||||
if (parent < 0)
|
||||
return FALSE;
|
||||
|
||||
for (i = i - 1; i > parent; i--)
|
||||
{
|
||||
if (parent_element (priv->nodes, i) == parent)
|
||||
{
|
||||
iter_from_element (nodemodel, iter, i);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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;
|
||||
gint elt;
|
||||
|
||||
if (parent == NULL)
|
||||
{
|
||||
if (!priv->root)
|
||||
return FALSE;
|
||||
|
||||
iter_from_element (nodemodel, iter, 0);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
elt = element_from_iter (nodemodel, parent);
|
||||
if (elt + 1 >= priv->nodes->len)
|
||||
return FALSE;
|
||||
if (parent_element (priv->nodes, elt + 1) != elt)
|
||||
return FALSE;
|
||||
|
||||
iter_from_element (nodemodel, iter, elt + 1);
|
||||
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);
|
||||
GtkTreeModelRenderNodePrivate *priv = nodemodel->priv;
|
||||
gint elt;
|
||||
|
||||
elt = element_from_iter (nodemodel, iter);
|
||||
if (elt + 1 >= priv->nodes->len)
|
||||
return FALSE;
|
||||
if (parent_element (priv->nodes, elt + 1) != elt)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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;
|
||||
gint elt, i, count;
|
||||
|
||||
if (iter == NULL)
|
||||
return priv->root ? 1 : 0;
|
||||
|
||||
elt = element_from_iter (nodemodel, iter);
|
||||
count = 0;
|
||||
|
||||
for (i = elt + 1; i < priv->nodes->len; i++)
|
||||
{
|
||||
int parent = parent_element (priv->nodes, i);
|
||||
|
||||
if (parent < elt)
|
||||
break;
|
||||
|
||||
if (parent == elt)
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
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;
|
||||
gint elt;
|
||||
|
||||
if (parent == NULL)
|
||||
{
|
||||
if (n > 0)
|
||||
return FALSE;
|
||||
|
||||
iter_from_element (nodemodel, iter, 0);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
gint nth;
|
||||
|
||||
elt = element_from_iter (nodemodel, parent);
|
||||
nth = get_nth_child (priv->nodes, elt, n);
|
||||
if (nth < 0)
|
||||
return FALSE;
|
||||
|
||||
iter_from_element (nodemodel, iter, nth);
|
||||
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;
|
||||
gint elt, parent;
|
||||
|
||||
elt = element_from_iter (nodemodel, child);
|
||||
parent = parent_element (priv->nodes, elt);
|
||||
|
||||
if (parent < 0)
|
||||
return FALSE;
|
||||
|
||||
iter_from_element (nodemodel, iter, parent);
|
||||
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_clear_pointer (&priv->nodes, g_array_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);
|
||||
|
||||
nodemodel->priv->nodes = g_array_new (FALSE, FALSE, sizeof (TreeElement));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static void
|
||||
append_node (GtkTreeModelRenderNode *nodemodel,
|
||||
GskRenderNode *node,
|
||||
int parent_index)
|
||||
{
|
||||
GtkTreeModelRenderNodePrivate *priv = nodemodel->priv;
|
||||
TreeElement element = { node, parent_index };
|
||||
|
||||
g_array_append_val (priv->nodes, element);
|
||||
|
||||
switch (gsk_render_node_get_node_type (node))
|
||||
{
|
||||
default:
|
||||
case GSK_NOT_A_RENDER_NODE:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
|
||||
case GSK_CAIRO_NODE:
|
||||
case GSK_TEXT_NODE:
|
||||
case GSK_TEXTURE_NODE:
|
||||
case GSK_COLOR_NODE:
|
||||
case GSK_LINEAR_GRADIENT_NODE:
|
||||
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
||||
case GSK_BORDER_NODE:
|
||||
case GSK_INSET_SHADOW_NODE:
|
||||
case GSK_OUTSET_SHADOW_NODE:
|
||||
/* no children */
|
||||
break;
|
||||
|
||||
case GSK_OFFSET_NODE:
|
||||
append_node (nodemodel, gsk_offset_node_get_child (node), priv->nodes->len - 1);
|
||||
break;
|
||||
|
||||
case GSK_TRANSFORM_NODE:
|
||||
append_node (nodemodel, gsk_transform_node_get_child (node), priv->nodes->len - 1);
|
||||
break;
|
||||
|
||||
case GSK_OPACITY_NODE:
|
||||
append_node (nodemodel, gsk_opacity_node_get_child (node), priv->nodes->len - 1);
|
||||
break;
|
||||
|
||||
case GSK_COLOR_MATRIX_NODE:
|
||||
append_node (nodemodel, gsk_color_matrix_node_get_child (node), priv->nodes->len - 1);
|
||||
break;
|
||||
|
||||
case GSK_BLUR_NODE:
|
||||
append_node (nodemodel, gsk_blur_node_get_child (node), priv->nodes->len - 1);
|
||||
break;
|
||||
|
||||
case GSK_REPEAT_NODE:
|
||||
append_node (nodemodel, gsk_repeat_node_get_child (node), priv->nodes->len - 1);
|
||||
break;
|
||||
|
||||
case GSK_CLIP_NODE:
|
||||
append_node (nodemodel, gsk_clip_node_get_child (node), priv->nodes->len - 1);
|
||||
break;
|
||||
|
||||
case GSK_ROUNDED_CLIP_NODE:
|
||||
append_node (nodemodel, gsk_rounded_clip_node_get_child (node), priv->nodes->len - 1);
|
||||
break;
|
||||
|
||||
case GSK_SHADOW_NODE:
|
||||
append_node (nodemodel, gsk_shadow_node_get_child (node), priv->nodes->len - 1);
|
||||
break;
|
||||
|
||||
case GSK_BLEND_NODE:
|
||||
{
|
||||
int elt_index = priv->nodes->len - 1;
|
||||
|
||||
append_node (nodemodel, gsk_blend_node_get_bottom_child (node), elt_index);
|
||||
append_node (nodemodel, gsk_blend_node_get_top_child (node), elt_index);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_CROSS_FADE_NODE:
|
||||
{
|
||||
int elt_index = priv->nodes->len - 1;
|
||||
|
||||
append_node (nodemodel, gsk_cross_fade_node_get_start_child (node), elt_index);
|
||||
append_node (nodemodel, gsk_cross_fade_node_get_end_child (node), elt_index);
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_CONTAINER_NODE:
|
||||
{
|
||||
gint elt_index;
|
||||
guint i;
|
||||
|
||||
elt_index = priv->nodes->len - 1;
|
||||
for (i = 0; i < gsk_container_node_get_n_children (node); i++)
|
||||
{
|
||||
append_node (nodemodel, gsk_container_node_get_child (node, i), elt_index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GSK_DEBUG_NODE:
|
||||
append_node (nodemodel, gsk_debug_node_get_child (node), priv->nodes->len - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
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);
|
||||
g_array_set_size (priv->nodes, 0);
|
||||
}
|
||||
|
||||
priv->root = node;
|
||||
|
||||
if (node)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
|
||||
gsk_render_node_ref (node);
|
||||
append_node (model, node, -1);
|
||||
|
||||
iter_from_element (model, &iter, 0);
|
||||
path = gtk_tree_path_new_first ();
|
||||
gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
|
||||
if (priv->nodes->len > 1)
|
||||
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 (GPOINTER_TO_INT (iter->user_data2) < model->priv->nodes->len, NULL);
|
||||
|
||||
return node_from_element (model, element_from_iter (model, iter));
|
||||
}
|
||||
|
@ -1,77 +0,0 @@
|
||||
/* gtktreestore.h
|
||||
* Copyright (C) 2014 Benjamin Otte <otte@gnome.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __GTK_TREE_MODEL_RENDER_NODE_H__
|
||||
#define __GTK_TREE_MODEL_RENDER_NODE_H__
|
||||
|
||||
#include <gsk/gsk.h>
|
||||
|
||||
#include <gtk/gtktreemodel.h>
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
#endif /* __GTK_TREE_MODEL_RENDER_NODE_H__ */
|
@ -11,7 +11,6 @@ inspector_sources = files(
|
||||
'graphdata.c',
|
||||
'gtkstackcombo.c',
|
||||
'gtktreemodelcssnode.c',
|
||||
'gtktreemodelrendernode.c',
|
||||
'highlightoverlay.c',
|
||||
'init.c',
|
||||
'inspect-button.c',
|
||||
|
@ -26,7 +26,8 @@
|
||||
#include <gtk/gtkmessagedialog.h>
|
||||
#include <gtk/gtkpopover.h>
|
||||
#include <gtk/gtktogglebutton.h>
|
||||
#include <gtk/gtktreeselection.h>
|
||||
#include <gtk/gtktreelistmodel.h>
|
||||
#include <gtk/gtktreemodel.h>
|
||||
#include <gtk/gtktreeview.h>
|
||||
#include <gsk/gskrendererprivate.h>
|
||||
#include <gsk/gskrendernodeprivate.h>
|
||||
@ -35,8 +36,9 @@
|
||||
#include <glib/gi18n-lib.h>
|
||||
#include <gdk/gdktextureprivate.h>
|
||||
#include "gtk/gtkdebug.h"
|
||||
#include "gtk/gtkiconprivate.h"
|
||||
#include "gtk/gtkrendernodepaintableprivate.h"
|
||||
|
||||
#include "gtktreemodelrendernode.h"
|
||||
#include "recording.h"
|
||||
#include "rendernodeview.h"
|
||||
#include "renderrecording.h"
|
||||
@ -45,11 +47,11 @@
|
||||
struct _GtkInspectorRecorderPrivate
|
||||
{
|
||||
GListModel *recordings;
|
||||
GtkTreeModel *render_node_model;
|
||||
GtkTreeListModel *render_node_model;
|
||||
|
||||
GtkWidget *recordings_list;
|
||||
GtkWidget *render_node_view;
|
||||
GtkWidget *render_node_tree;
|
||||
GtkWidget *render_node_list;
|
||||
GtkWidget *render_node_save_button;
|
||||
GtkWidget *node_property_tree;
|
||||
GtkTreeModel *render_node_properties;
|
||||
@ -59,12 +61,6 @@ struct _GtkInspectorRecorderPrivate
|
||||
gboolean debug_nodes;
|
||||
};
|
||||
|
||||
enum {
|
||||
COLUMN_NODE_NAME,
|
||||
/* add more */
|
||||
N_NODE_COLUMNS
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
@ -77,6 +73,123 @@ static GParamSpec *props[LAST_PROP] = { NULL, };
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorRecorder, gtk_inspector_recorder, GTK_TYPE_BIN)
|
||||
|
||||
static GListModel *
|
||||
create_render_node_list_model (GskRenderNode **nodes,
|
||||
guint n_nodes)
|
||||
{
|
||||
GListStore *store;
|
||||
guint i;
|
||||
|
||||
/* can't put render nodes into list models - they're not GObjects */
|
||||
store = g_list_store_new (GDK_TYPE_PAINTABLE);
|
||||
|
||||
for (i = 0; i < n_nodes; i++)
|
||||
{
|
||||
graphene_rect_t bounds;
|
||||
|
||||
gsk_render_node_get_bounds (nodes[i], &bounds);
|
||||
GdkPaintable *paintable = gtk_render_node_paintable_new (nodes[i], &bounds);
|
||||
g_list_store_append (store, paintable);
|
||||
g_object_unref (paintable);
|
||||
}
|
||||
|
||||
return G_LIST_MODEL (store);
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
create_list_model_for_render_node (GskRenderNode *node)
|
||||
{
|
||||
switch (gsk_render_node_get_node_type (node))
|
||||
{
|
||||
default:
|
||||
case GSK_NOT_A_RENDER_NODE:
|
||||
g_assert_not_reached ();
|
||||
return NULL;
|
||||
|
||||
case GSK_CAIRO_NODE:
|
||||
case GSK_TEXT_NODE:
|
||||
case GSK_TEXTURE_NODE:
|
||||
case GSK_COLOR_NODE:
|
||||
case GSK_LINEAR_GRADIENT_NODE:
|
||||
case GSK_REPEATING_LINEAR_GRADIENT_NODE:
|
||||
case GSK_BORDER_NODE:
|
||||
case GSK_INSET_SHADOW_NODE:
|
||||
case GSK_OUTSET_SHADOW_NODE:
|
||||
/* no children */
|
||||
return NULL;
|
||||
|
||||
case GSK_OFFSET_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_offset_node_get_child (node) }, 1);
|
||||
|
||||
case GSK_TRANSFORM_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_transform_node_get_child (node) }, 1);
|
||||
|
||||
case GSK_OPACITY_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_opacity_node_get_child (node) }, 1);
|
||||
|
||||
case GSK_COLOR_MATRIX_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_color_matrix_node_get_child (node) }, 1);
|
||||
|
||||
case GSK_BLUR_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_blur_node_get_child (node) }, 1);
|
||||
|
||||
case GSK_REPEAT_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_repeat_node_get_child (node) }, 1);
|
||||
|
||||
case GSK_CLIP_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_clip_node_get_child (node) }, 1);
|
||||
|
||||
case GSK_ROUNDED_CLIP_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_rounded_clip_node_get_child (node) }, 1);
|
||||
|
||||
case GSK_SHADOW_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_shadow_node_get_child (node) }, 1);
|
||||
|
||||
case GSK_BLEND_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_blend_node_get_bottom_child (node),
|
||||
gsk_blend_node_get_top_child (node) }, 2);
|
||||
|
||||
case GSK_CROSS_FADE_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[2]) { gsk_cross_fade_node_get_start_child (node),
|
||||
gsk_cross_fade_node_get_end_child (node) }, 2);
|
||||
|
||||
case GSK_CONTAINER_NODE:
|
||||
{
|
||||
GListStore *store;
|
||||
guint i;
|
||||
|
||||
/* can't put render nodes into list models - they're not GObjects */
|
||||
store = g_list_store_new (GDK_TYPE_PAINTABLE);
|
||||
|
||||
for (i = 0; i < gsk_container_node_get_n_children (node); i++)
|
||||
{
|
||||
GskRenderNode *child = gsk_container_node_get_child (node, i);
|
||||
graphene_rect_t bounds;
|
||||
GdkPaintable *paintable;
|
||||
|
||||
gsk_render_node_get_bounds (child, &bounds);
|
||||
paintable = gtk_render_node_paintable_new (child, &bounds);
|
||||
g_list_store_append (store, paintable);
|
||||
g_object_unref (paintable);
|
||||
}
|
||||
|
||||
return G_LIST_MODEL (store);
|
||||
}
|
||||
|
||||
case GSK_DEBUG_NODE:
|
||||
return create_render_node_list_model ((GskRenderNode *[1]) { gsk_debug_node_get_child (node) }, 1);
|
||||
}
|
||||
}
|
||||
|
||||
static GListModel *
|
||||
create_list_model_for_render_node_paintable (gpointer paintable,
|
||||
gpointer unused)
|
||||
{
|
||||
GskRenderNode *node = gtk_render_node_paintable_get_render_node (paintable);
|
||||
|
||||
return create_list_model_for_render_node (node);
|
||||
}
|
||||
|
||||
static void
|
||||
recordings_clear_all (GtkButton *button,
|
||||
GtkInspectorRecorder *recorder)
|
||||
@ -86,42 +199,6 @@ recordings_clear_all (GtkButton *button,
|
||||
g_list_store_remove_all (G_LIST_STORE (priv->recordings));
|
||||
}
|
||||
|
||||
static void
|
||||
recordings_list_row_selected (GtkListBox *box,
|
||||
GtkListBoxRow *row,
|
||||
GtkInspectorRecorder *recorder)
|
||||
{
|
||||
GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
|
||||
GtkInspectorRecording *recording;
|
||||
|
||||
if (row)
|
||||
recording = g_list_model_get_item (priv->recordings, gtk_list_box_row_get_index (row));
|
||||
else
|
||||
recording = NULL;
|
||||
|
||||
if (GTK_INSPECTOR_IS_RENDER_RECORDING (recording))
|
||||
{
|
||||
gtk_render_node_view_set_render_node (GTK_RENDER_NODE_VIEW (priv->render_node_view),
|
||||
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));
|
||||
|
||||
if (recording)
|
||||
g_object_unref (recording);
|
||||
}
|
||||
|
||||
static const char *
|
||||
node_type_name (GskRenderNodeType type)
|
||||
{
|
||||
@ -223,22 +300,107 @@ node_name (GskRenderNode *node)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
render_node_list_get_value (GtkTreeModelRenderNode *model,
|
||||
GskRenderNode *node,
|
||||
int column,
|
||||
GValue *value)
|
||||
static GtkWidget *
|
||||
create_widget_for_render_node (gpointer row_item,
|
||||
gpointer unused)
|
||||
{
|
||||
switch (column)
|
||||
{
|
||||
case COLUMN_NODE_NAME:
|
||||
g_value_take_string (value, node_name (node));
|
||||
break;
|
||||
GdkPaintable *paintable;
|
||||
GskRenderNode *node;
|
||||
GtkWidget *row, *box, *child;
|
||||
char *name;
|
||||
guint depth;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
paintable = gtk_tree_list_row_get_item (row_item);
|
||||
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
|
||||
row = gtk_list_box_row_new ();
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 3);
|
||||
gtk_container_add (GTK_CONTAINER (row), box);
|
||||
|
||||
/* expander */
|
||||
depth = gtk_tree_list_row_get_depth (row_item);
|
||||
if (depth > 0)
|
||||
{
|
||||
child = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_widget_set_size_request (child, 16 * depth, 0);
|
||||
gtk_container_add (GTK_CONTAINER (box), child);
|
||||
}
|
||||
if (gtk_tree_list_row_is_expandable (row_item))
|
||||
{
|
||||
GtkWidget *title, *arrow;
|
||||
|
||||
child = g_object_new (GTK_TYPE_BOX, "css-name", "expander", NULL);
|
||||
|
||||
title = g_object_new (GTK_TYPE_TOGGLE_BUTTON, "css-name", "title", NULL);
|
||||
gtk_button_set_relief (GTK_BUTTON (title), GTK_RELIEF_NONE);
|
||||
g_object_bind_property (row_item, "expanded", title, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||
gtk_container_add (GTK_CONTAINER (child), title);
|
||||
g_object_set_data_full (G_OBJECT (row), "make-sure-its-not-unreffed", g_object_ref (row_item), g_object_unref);
|
||||
|
||||
arrow = gtk_icon_new ("arrow");
|
||||
gtk_container_add (GTK_CONTAINER (title), arrow);
|
||||
}
|
||||
else
|
||||
{
|
||||
child = gtk_image_new (); /* empty whatever */
|
||||
}
|
||||
gtk_container_add (GTK_CONTAINER (box), child);
|
||||
|
||||
name = node_name (node);
|
||||
child = gtk_label_new (name);
|
||||
g_free (name);
|
||||
gtk_container_add (GTK_CONTAINER (box), child);
|
||||
|
||||
g_object_unref (paintable);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
static void
|
||||
recordings_list_row_selected (GtkListBox *box,
|
||||
GtkListBoxRow *row,
|
||||
GtkInspectorRecorder *recorder)
|
||||
{
|
||||
GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
|
||||
GtkInspectorRecording *recording;
|
||||
|
||||
if (row)
|
||||
recording = g_list_model_get_item (priv->recordings, gtk_list_box_row_get_index (row));
|
||||
else
|
||||
recording = NULL;
|
||||
|
||||
g_clear_object (&priv->render_node_model);
|
||||
|
||||
if (GTK_INSPECTOR_IS_RENDER_RECORDING (recording))
|
||||
{
|
||||
GListModel *root_model;
|
||||
|
||||
gtk_render_node_view_set_render_node (GTK_RENDER_NODE_VIEW (priv->render_node_view),
|
||||
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)));
|
||||
|
||||
root_model = create_list_model_for_render_node (gtk_inspector_render_recording_get_node (GTK_INSPECTOR_RENDER_RECORDING (recording)));
|
||||
priv->render_node_model = gtk_tree_list_model_new (FALSE,
|
||||
root_model,
|
||||
TRUE,
|
||||
create_list_model_for_render_node_paintable,
|
||||
NULL, NULL);
|
||||
g_object_unref (root_model);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_render_node_view_set_render_node (GTK_RENDER_NODE_VIEW (priv->render_node_view), NULL);
|
||||
}
|
||||
|
||||
gtk_list_box_bind_model (GTK_LIST_BOX (priv->render_node_list),
|
||||
G_LIST_MODEL (priv->render_node_model),
|
||||
create_widget_for_render_node,
|
||||
NULL, NULL);
|
||||
|
||||
if (recording)
|
||||
g_object_unref (recording);
|
||||
}
|
||||
|
||||
static GdkTexture *
|
||||
@ -733,24 +895,46 @@ populate_render_node_properties (GtkListStore *store,
|
||||
}
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
get_selected_node (GtkInspectorRecorder *recorder)
|
||||
{
|
||||
GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
|
||||
GtkTreeListRow *row_item;
|
||||
GtkListBoxRow *row;
|
||||
GdkPaintable *paintable;
|
||||
GskRenderNode *node;
|
||||
|
||||
row = gtk_list_box_get_selected_row (GTK_LIST_BOX (priv->render_node_list));
|
||||
if (row == NULL)
|
||||
return NULL;
|
||||
|
||||
row_item = g_list_model_get_item (G_LIST_MODEL (priv->render_node_model),
|
||||
gtk_list_box_row_get_index (row));
|
||||
paintable = gtk_tree_list_row_get_item (row_item);
|
||||
node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
|
||||
g_object_unref (paintable);
|
||||
g_object_unref (row_item);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
static void
|
||||
render_node_list_selection_changed (GtkTreeSelection *selection,
|
||||
render_node_list_selection_changed (GtkListBox *list,
|
||||
GtkListBoxRow *row,
|
||||
GtkInspectorRecorder *recorder)
|
||||
{
|
||||
GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
|
||||
GskRenderNode *node;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
|
||||
node = get_selected_node (recorder);
|
||||
if (node == NULL)
|
||||
{
|
||||
gtk_widget_set_sensitive (priv->render_node_save_button, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive (priv->render_node_save_button, TRUE);
|
||||
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);
|
||||
|
||||
populate_render_node_properties (GTK_LIST_STORE (priv->render_node_properties), node);
|
||||
}
|
||||
|
||||
@ -800,17 +984,14 @@ static void
|
||||
render_node_save (GtkButton *button,
|
||||
GtkInspectorRecorder *recorder)
|
||||
{
|
||||
GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
|
||||
GskRenderNode *node;
|
||||
GtkTreeIter iter;
|
||||
GtkWidget *dialog;
|
||||
char *filename, *nodename;
|
||||
|
||||
if (!gtk_tree_selection_get_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->render_node_tree)), NULL, &iter))
|
||||
node = get_selected_node (recorder);
|
||||
if (node == NULL)
|
||||
return;
|
||||
|
||||
node = gtk_tree_model_render_node_get_node_from_iter (GTK_TREE_MODEL_RENDER_NODE (priv->render_node_model), &iter);
|
||||
|
||||
dialog = gtk_file_chooser_dialog_new ("",
|
||||
GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (recorder))),
|
||||
GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
@ -1017,6 +1198,17 @@ gtk_inspector_recorder_set_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_recorder_dispose (GObject *object)
|
||||
{
|
||||
GtkInspectorRecorder *recorder = GTK_INSPECTOR_RECORDER (object);
|
||||
GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
|
||||
|
||||
g_clear_object (&priv->render_node_model);
|
||||
|
||||
G_OBJECT_CLASS (gtk_inspector_recorder_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_inspector_recorder_class_init (GtkInspectorRecorderClass *klass)
|
||||
{
|
||||
@ -1025,6 +1217,7 @@ gtk_inspector_recorder_class_init (GtkInspectorRecorderClass *klass)
|
||||
|
||||
object_class->get_property = gtk_inspector_recorder_get_property;
|
||||
object_class->set_property = gtk_inspector_recorder_set_property;
|
||||
object_class->dispose = gtk_inspector_recorder_dispose;
|
||||
|
||||
props[PROP_RECORDING] =
|
||||
g_param_spec_boolean ("recording",
|
||||
@ -1046,7 +1239,7 @@ gtk_inspector_recorder_class_init (GtkInspectorRecorderClass *klass)
|
||||
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_child_private (widget_class, GtkInspectorRecorder, render_node_list);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorRecorder, render_node_save_button);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorRecorder, node_property_tree);
|
||||
|
||||
@ -1070,12 +1263,6 @@ gtk_inspector_recorder_init (GtkInspectorRecorder *recorder)
|
||||
recorder,
|
||||
NULL);
|
||||
|
||||
priv->render_node_model = gtk_tree_model_render_node_new (render_node_list_get_value,
|
||||
N_NODE_COLUMNS,
|
||||
G_TYPE_STRING);
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->render_node_tree), priv->render_node_model);
|
||||
g_object_unref (priv->render_node_model);
|
||||
|
||||
priv->render_node_properties = GTK_TREE_MODEL (gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, GDK_TYPE_TEXTURE));
|
||||
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->node_property_tree), priv->render_node_properties);
|
||||
g_object_unref (priv->render_node_properties);
|
||||
|
@ -81,27 +81,9 @@
|
||||
<class name="sidebar"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="render_node_tree">
|
||||
<object class="GtkListBox" id="render_node_list">
|
||||
<property name="vexpand">1</property>
|
||||
<property name="search-column">0</property>
|
||||
<property name="enable-search">0</property>
|
||||
<property name="headers-visible">0</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection">
|
||||
<signal name="changed" handler="render_node_list_selection_changed"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="render_node_name_column">
|
||||
<property name="resizable">1</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText"/>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<signal name="row-selected" handler="render_node_list_selection_changed"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
Loading…
Reference in New Issue
Block a user