[gtk/matthiasc/for-master: 2/8] inspector: Drop the recorder Private struct
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/for-master: 2/8] inspector: Drop the recorder Private struct
- Date: Sat, 18 Jul 2020 03:19:19 +0000 (UTC)
commit cb906c80eb584a3362f8581f3b5341d893583d00
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jul 17 22:37:24 2020 -0400
inspector: Drop the recorder Private struct
gtk/inspector/recorder.c | 118 ++++++++++++++++++++++-------------------------
gtk/inspector/recorder.h | 16 +------
2 files changed, 56 insertions(+), 78 deletions(-)
---
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index 01ba208b66..a8a536f2af 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -52,8 +52,10 @@
#include "renderrecording.h"
#include "startrecording.h"
-struct _GtkInspectorRecorderPrivate
+struct _GtkInspectorRecorder
{
+ GtkWidget parent;
+
GListModel *recordings;
GtkTreeListModel *render_node_model;
GListStore *render_node_root_model;
@@ -71,6 +73,12 @@ struct _GtkInspectorRecorderPrivate
gboolean debug_nodes;
};
+typedef struct _GtkInspectorRecorderClass
+{
+ GtkWidgetClass parent;
+} GtkInspectorRecorderClass;
+
+
enum
{
PROP_0,
@@ -81,7 +89,7 @@ enum
static GParamSpec *props[LAST_PROP] = { NULL, };
-G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorRecorder, gtk_inspector_recorder, GTK_TYPE_WIDGET)
+G_DEFINE_TYPE (GtkInspectorRecorder, gtk_inspector_recorder, GTK_TYPE_WIDGET)
static GListModel *
create_render_node_list_model (GskRenderNode **nodes,
@@ -201,9 +209,7 @@ static void
recordings_clear_all (GtkButton *button,
GtkInspectorRecorder *recorder)
{
- GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
-
- g_list_store_remove_all (G_LIST_STORE (priv->recordings));
+ g_list_store_remove_all (G_LIST_STORE (recorder->recordings));
}
static const char *
@@ -361,11 +367,10 @@ 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));
+ recording = g_list_model_get_item (recorder->recordings, gtk_list_box_row_get_index (row));
else
recording = NULL;
@@ -378,18 +383,18 @@ recordings_list_row_selected (GtkListBox *box,
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);
+ gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), paintable);
- g_list_store_splice (priv->render_node_root_model,
- 0, g_list_model_get_n_items (G_LIST_MODEL (priv->render_node_root_model)),
+ g_list_store_splice (recorder->render_node_root_model,
+ 0, g_list_model_get_n_items (G_LIST_MODEL (recorder->render_node_root_model)),
(gpointer[1]) { paintable },
1);
g_object_unref (paintable);
}
else
{
- gtk_picture_set_paintable (GTK_PICTURE (priv->render_node_view), NULL);
- g_list_store_remove_all (priv->render_node_root_model);
+ gtk_picture_set_paintable (GTK_PICTURE (recorder->render_node_view), NULL);
+ g_list_store_remove_all (recorder->render_node_root_model);
}
if (recording)
@@ -906,12 +911,11 @@ 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;
GdkPaintable *paintable;
GskRenderNode *node;
- row_item = gtk_single_selection_get_selected_item (priv->render_node_selection);
+ row_item = gtk_single_selection_get_selected_item (recorder->render_node_selection);
if (row_item == NULL)
return NULL;
@@ -927,21 +931,20 @@ render_node_list_selection_changed (GtkListBox *list,
GtkListBoxRow *row,
GtkInspectorRecorder *recorder)
{
- GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
GskRenderNode *node;
GdkPaintable *paintable;
GtkTreeListRow *row_item;
- row_item = gtk_single_selection_get_selected_item (priv->render_node_selection);
+ row_item = gtk_single_selection_get_selected_item (recorder->render_node_selection);
if (row_item == NULL)
return;
paintable = gtk_tree_list_row_get_item (row_item);
- gtk_widget_set_sensitive (priv->render_node_save_button, TRUE);
- gtk_picture_set_paintable (GTK_PICTURE (priv->render_node_view), paintable);
+ gtk_widget_set_sensitive (recorder->render_node_save_button, TRUE);
+ gtk_picture_set_paintable (GTK_PICTURE (recorder->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);
+ populate_render_node_properties (GTK_LIST_STORE (recorder->render_node_properties), node);
g_object_unref (paintable);
}
@@ -1077,7 +1080,6 @@ node_property_activated (GtkTreeView *tv,
GtkTreeViewColumn *col,
GtkInspectorRecorder *recorder)
{
- GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
GtkTreeIter iter;
GdkRectangle rect;
GdkTexture *texture;
@@ -1085,8 +1087,8 @@ node_property_activated (GtkTreeView *tv,
GtkWidget *popover;
GtkWidget *image;
- gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->render_node_properties), &iter, path);
- gtk_tree_model_get (GTK_TREE_MODEL (priv->render_node_properties), &iter,
+ gtk_tree_model_get_iter (GTK_TREE_MODEL (recorder->render_node_properties), &iter, path);
+ gtk_tree_model_get (GTK_TREE_MODEL (recorder->render_node_properties), &iter,
2, &visible,
3, &texture,
-1);
@@ -1120,16 +1122,15 @@ gtk_inspector_recorder_get_property (GObject *object,
GParamSpec *pspec)
{
GtkInspectorRecorder *recorder = GTK_INSPECTOR_RECORDER (object);
- GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
switch (param_id)
{
case PROP_RECORDING:
- g_value_set_boolean (value, priv->recording != NULL);
+ g_value_set_boolean (value, recorder->recording != NULL);
break;
case PROP_DEBUG_NODES:
- g_value_set_boolean (value, priv->debug_nodes);
+ g_value_set_boolean (value, recorder->debug_nodes);
break;
default:
@@ -1166,11 +1167,10 @@ 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_clear_object (&priv->render_node_root_model);
- g_clear_object (&priv->render_node_selection);
+ g_clear_object (&recorder->render_node_model);
+ g_clear_object (&recorder->render_node_root_model);
+ g_clear_object (&recorder->render_node_selection);
G_OBJECT_CLASS (gtk_inspector_recorder_parent_class)->dispose (object);
}
@@ -1202,12 +1202,12 @@ gtk_inspector_recorder_class_init (GtkInspectorRecorderClass *klass)
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_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);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, recordings);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, recordings_list);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, render_node_view);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, render_node_list);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, render_node_save_button);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorRecorder, node_property_tree);
gtk_widget_class_bind_template_callback (widget_class, recordings_clear_all);
gtk_widget_class_bind_template_callback (widget_class, recordings_list_row_selected);
@@ -1220,66 +1220,61 @@ gtk_inspector_recorder_class_init (GtkInspectorRecorderClass *klass)
static void
gtk_inspector_recorder_init (GtkInspectorRecorder *recorder)
{
- GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
GtkListItemFactory *factory;
gtk_widget_init_template (GTK_WIDGET (recorder));
- gtk_list_box_bind_model (GTK_LIST_BOX (priv->recordings_list),
- priv->recordings,
+ gtk_list_box_bind_model (GTK_LIST_BOX (recorder->recordings_list),
+ recorder->recordings,
gtk_inspector_recorder_recordings_list_create_widget,
recorder,
NULL);
- priv->render_node_root_model = g_list_store_new (GDK_TYPE_PAINTABLE);
- priv->render_node_model = gtk_tree_list_model_new (FALSE,
- G_LIST_MODEL (priv->render_node_root_model),
+ recorder->render_node_root_model = g_list_store_new (GDK_TYPE_PAINTABLE);
+ recorder->render_node_model = gtk_tree_list_model_new (FALSE,
+ G_LIST_MODEL (recorder->render_node_root_model),
TRUE,
create_list_model_for_render_node_paintable,
NULL, NULL);
- priv->render_node_selection = gtk_single_selection_new (G_LIST_MODEL (priv->render_node_model));
- g_signal_connect (priv->render_node_selection, "notify::selected-item", G_CALLBACK
(render_node_list_selection_changed), recorder);
+ recorder->render_node_selection = gtk_single_selection_new (G_LIST_MODEL (recorder->render_node_model));
+ g_signal_connect (recorder->render_node_selection, "notify::selected-item", G_CALLBACK
(render_node_list_selection_changed), recorder);
factory = gtk_signal_list_item_factory_new ();
g_signal_connect (factory, "setup", G_CALLBACK (setup_widget_for_render_node), NULL);
g_signal_connect (factory, "bind", G_CALLBACK (bind_widget_for_render_node), NULL);
- gtk_list_view_set_factory (GTK_LIST_VIEW (priv->render_node_list), factory);
+ gtk_list_view_set_factory (GTK_LIST_VIEW (recorder->render_node_list), factory);
g_object_unref (factory);
- gtk_list_view_set_model (GTK_LIST_VIEW (priv->render_node_list),
- G_LIST_MODEL (priv->render_node_selection));
+ gtk_list_view_set_model (GTK_LIST_VIEW (recorder->render_node_list),
+ G_LIST_MODEL (recorder->render_node_selection));
- 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);
+ recorder->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 (recorder->node_property_tree), recorder->render_node_properties);
+ g_object_unref (recorder->render_node_properties);
}
static void
gtk_inspector_recorder_add_recording (GtkInspectorRecorder *recorder,
GtkInspectorRecording *recording)
{
- GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
-
- g_list_store_append (G_LIST_STORE (priv->recordings), recording);
+ g_list_store_append (G_LIST_STORE (recorder->recordings), recording);
}
void
gtk_inspector_recorder_set_recording (GtkInspectorRecorder *recorder,
gboolean recording)
{
- GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
-
if (gtk_inspector_recorder_is_recording (recorder) == recording)
return;
if (recording)
{
- priv->recording = gtk_inspector_start_recording_new ();
- gtk_inspector_recorder_add_recording (recorder, priv->recording);
+ recorder->recording = gtk_inspector_start_recording_new ();
+ gtk_inspector_recorder_add_recording (recorder, recorder->recording);
}
else
{
- g_clear_object (&priv->recording);
+ g_clear_object (&recorder->recording);
}
g_object_notify_by_pspec (G_OBJECT (recorder), props[PROP_RECORDING]);
@@ -1288,9 +1283,7 @@ gtk_inspector_recorder_set_recording (GtkInspectorRecorder *recorder,
gboolean
gtk_inspector_recorder_is_recording (GtkInspectorRecorder *recorder)
{
- GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
-
- return priv->recording != NULL;
+ return recorder->recording != NULL;
}
void
@@ -1324,13 +1317,12 @@ void
gtk_inspector_recorder_set_debug_nodes (GtkInspectorRecorder *recorder,
gboolean debug_nodes)
{
- GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
guint flags;
- if (priv->debug_nodes == debug_nodes)
+ if (recorder->debug_nodes == debug_nodes)
return;
- priv->debug_nodes = debug_nodes;
+ recorder->debug_nodes = debug_nodes;
flags = gtk_get_debug_flags ();
diff --git a/gtk/inspector/recorder.h b/gtk/inspector/recorder.h
index 0d86641de6..925aa3eeb5 100644
--- a/gtk/inspector/recorder.h
+++ b/gtk/inspector/recorder.h
@@ -22,23 +22,9 @@
#define GTK_TYPE_INSPECTOR_RECORDER (gtk_inspector_recorder_get_type())
#define GTK_INSPECTOR_RECORDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),
GTK_TYPE_INSPECTOR_RECORDER, GtkInspectorRecorder))
-#define GTK_INSPECTOR_RECORDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),
GTK_TYPE_INSPECTOR_RECORDER, GtkInspectorRecorderClass))
#define GTK_INSPECTOR_IS_RECORDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),
GTK_TYPE_INSPECTOR_RECORDER))
-#define GTK_INSPECTOR_IS_RECORDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),
GTK_TYPE_INSPECTOR_RECORDER))
-#define GTK_INSPECTOR_RECORDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),
GTK_TYPE_INSPECTOR_RECORDER, GtkInspectorRecorderClass))
-
-typedef struct _GtkInspectorRecorderPrivate GtkInspectorRecorderPrivate;
-
-typedef struct _GtkInspectorRecorder
-{
- GtkWidget parent;
-} GtkInspectorRecorder;
-
-typedef struct _GtkInspectorRecorderClass
-{
- GtkWidgetClass parent;
-} GtkInspectorRecorderClass;
+typedef struct _GtkInspectorRecorder GtkInspectorRecorder;
G_BEGIN_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]