[gtk/wip/otte/listmodel: 8/10] inspector: Use a GtkPicture to display render nodes
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/listmodel: 8/10] inspector: Use a GtkPicture to display render nodes
- Date: Wed, 12 Sep 2018 11:54:33 +0000 (UTC)
commit 77d12745c5a1f99aaff5c524935bc573feeac90b
Author: Benjamin Otte <otte redhat com>
Date: Wed Sep 5 16:40:51 2018 +0200
inspector: Use a GtkPicture to display render nodes
Instead of the outdated render node view, use modern GTK APIs.
gtk/inspector/init.c | 2 -
gtk/inspector/meson.build | 1 -
gtk/inspector/recorder.c | 40 +++--
gtk/inspector/recorder.ui | 3 +-
gtk/inspector/rendernodeview.c | 389 -----------------------------------------
gtk/inspector/rendernodeview.h | 64 -------
6 files changed, 27 insertions(+), 472 deletions(-)
---
diff --git a/gtk/inspector/init.c b/gtk/inspector/init.c
index 35038bd48b..d16c03eaf2 100644
--- a/gtk/inspector/init.c
+++ b/gtk/inspector/init.c
@@ -40,7 +40,6 @@
#include "object-tree.h"
#include "prop-list.h"
#include "recorder.h"
-#include "rendernodeview.h"
#include "resource-list.h"
#include "selector.h"
#include "signals-list.h"
@@ -85,7 +84,6 @@ gtk_inspector_init (void)
g_type_ensure (GTK_TYPE_INSPECTOR_STATISTICS);
g_type_ensure (GTK_TYPE_INSPECTOR_VISUAL);
g_type_ensure (GTK_TYPE_INSPECTOR_WINDOW);
- g_type_ensure (GTK_TYPE_RENDER_NODE_VIEW);
g_type_ensure (GTK_TYPE_STACK_COMBO);
if (extension_point == NULL)
diff --git a/gtk/inspector/meson.build b/gtk/inspector/meson.build
index 97bc8140bd..7176b92946 100644
--- a/gtk/inspector/meson.build
+++ b/gtk/inspector/meson.build
@@ -27,7 +27,6 @@ inspector_sources = files(
'recorder.c',
'recording.c',
'renderrecording.c',
- 'rendernodeview.c',
'resource-list.c',
'selector.c',
'signals-list.c',
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index 8c27ccc8d8..f5603c47f4 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -24,6 +24,7 @@
#include <gtk/gtklabel.h>
#include <gtk/gtklistbox.h>
#include <gtk/gtkmessagedialog.h>
+#include <gtk/gtkpicture.h>
#include <gtk/gtkpopover.h>
#include <gtk/gtktogglebutton.h>
#include <gtk/gtktreelistmodel.h>
@@ -40,7 +41,6 @@
#include "gtk/gtkrendernodepaintableprivate.h"
#include "recording.h"
-#include "rendernodeview.h"
#include "renderrecording.h"
#include "startrecording.h"
@@ -377,26 +377,29 @@ recordings_list_row_selected (GtkListBox *box,
if (GTK_INSPECTOR_IS_RENDER_RECORDING (recording))
{
- GListModel *root_model;
+ GListStore *root_model;
+ graphene_rect_t bounds;
+ GskRenderNode *node;
+ GdkPaintable *paintable;
- 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)));
+ node = gtk_inspector_render_recording_get_node (GTK_INSPECTOR_RENDER_RECORDING (recording));
+ gsk_render_node_get_bounds (node, &bounds);
+ paintable = gtk_render_node_paintable_new (node, &bounds);
+ gtk_picture_set_paintable (GTK_PICTURE (priv->render_node_view), paintable);
- root_model = create_list_model_for_render_node (gtk_inspector_render_recording_get_node
(GTK_INSPECTOR_RENDER_RECORDING (recording)));
+ root_model = g_list_store_new (GDK_TYPE_PAINTABLE);
+ g_list_store_append (root_model, paintable);
priv->render_node_model = gtk_tree_list_model_new (FALSE,
- root_model,
+ G_LIST_MODEL (root_model),
TRUE,
create_list_model_for_render_node_paintable,
NULL, NULL);
g_object_unref (root_model);
+ g_object_unref (paintable);
}
else
{
- gtk_render_node_view_set_render_node (GTK_RENDER_NODE_VIEW (priv->render_node_view), NULL);
+ gtk_picture_set_paintable (GTK_PICTURE (priv->render_node_view), NULL);
}
gtk_list_box_bind_model (GTK_LIST_BOX (priv->render_node_list),
@@ -930,17 +933,26 @@ render_node_list_selection_changed (GtkListBox *list,
{
GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
GskRenderNode *node;
+ GdkPaintable *paintable;
+ GtkTreeListRow *row_item;
- node = get_selected_node (recorder);
- if (node == NULL)
+ if (row == NULL)
{
gtk_widget_set_sensitive (priv->render_node_save_button, FALSE);
return;
}
+ 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);
+
gtk_widget_set_sensitive (priv->render_node_save_button, TRUE);
- gtk_render_node_view_set_render_node (GTK_RENDER_NODE_VIEW (priv->render_node_view), node);
+ gtk_picture_set_paintable (GTK_PICTURE (priv->render_node_view), paintable);
+ node = gtk_render_node_paintable_get_render_node (GTK_RENDER_NODE_PAINTABLE (paintable));
populate_render_node_properties (GTK_LIST_STORE (priv->render_node_properties), node);
+
+ g_object_unref (paintable);
+ g_object_unref (row_item);
}
static void
diff --git a/gtk/inspector/recorder.ui b/gtk/inspector/recorder.ui
index 607c3d05b5..7f3f0ccc89 100644
--- a/gtk/inspector/recorder.ui
+++ b/gtk/inspector/recorder.ui
@@ -145,8 +145,7 @@
</object>
</child>
<child>
- <object class="GtkRenderNodeView" id="render_node_view">
- <property name="visible">True</property>
+ <object class="GtkPicture" id="render_node_view">
<property name="expand">True</property>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]