[gtk+] inspector: Require toggling on/off of recording
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Require toggling on/off of recording
- Date: Tue, 1 Nov 2016 17:35:30 +0000 (UTC)
commit 3741e6906e2954284ae349571fa0971d06db46fc
Author: Benjamin Otte <otte redhat com>
Date: Tue Nov 1 18:03:16 2016 +0100
inspector: Require toggling on/off of recording
This way, we don't eat up all your memory every time you start the
inspector.
gtk/inspector/recorder.c | 90 +++++++++++++++++++++++++++++++++++++++++++++
gtk/inspector/recorder.h | 16 +++++---
gtk/inspector/recorder.ui | 12 ++++++
3 files changed, 112 insertions(+), 6 deletions(-)
---
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index 5c189fe..126118f 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -38,6 +38,8 @@ struct _GtkInspectorRecorderPrivate
GtkWidget *recordings_list;
GtkWidget *render_node_view;
GtkWidget *render_node_tree;
+
+ guint recording : 1;
};
enum {
@@ -47,6 +49,15 @@ enum {
N_NODE_COLUMNS
};
+enum
+{
+ PROP_0,
+ PROP_RECORDING,
+ LAST_PROP
+};
+
+static GParamSpec *props[LAST_PROP] = { NULL, };
+
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorRecorder, gtk_inspector_recorder, GTK_TYPE_BIN)
static void
@@ -133,9 +144,63 @@ gtk_inspector_recorder_recordings_list_create_widget (gpointer item,
}
static void
+gtk_inspector_recorder_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ 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);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+gtk_inspector_recorder_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GtkInspectorRecorder *recorder = GTK_INSPECTOR_RECORDER (object);
+
+ switch (param_id)
+ {
+ case PROP_RECORDING:
+ gtk_inspector_recorder_set_recording (recorder, g_value_get_boolean (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+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->get_property = gtk_inspector_recorder_get_property;
+ object_class->set_property = gtk_inspector_recorder_set_property;
+
+ props[PROP_RECORDING] =
+ g_param_spec_boolean ("recording",
+ "Recording",
+ "Whether the recorder is currently recording",
+ FALSE,
+ G_PARAM_READWRITE);
+
+ g_object_class_install_properties (object_class, LAST_PROP, props);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/inspector/recorder.ui");
@@ -171,6 +236,28 @@ gtk_inspector_recorder_init (GtkInspectorRecorder *recorder)
}
void
+gtk_inspector_recorder_set_recording (GtkInspectorRecorder *recorder,
+ gboolean recording)
+{
+ GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
+
+ if (priv->recording == recording)
+ return;
+
+ priv->recording = recording;
+
+ g_object_notify_by_pspec (G_OBJECT (recorder), props[PROP_RECORDING]);
+}
+
+gboolean
+gtk_inspector_recorder_is_recording (GtkInspectorRecorder *recorder)
+{
+ GtkInspectorRecorderPrivate *priv = gtk_inspector_recorder_get_instance_private (recorder);
+
+ return priv->recording;
+}
+
+void
gtk_inspector_recorder_record_render (GtkInspectorRecorder *recorder,
GtkWidget *widget,
GdkWindow *window,
@@ -181,6 +268,9 @@ gtk_inspector_recorder_record_render (GtkInspectorRecorder *recorder,
GtkInspectorRecording *recording;
GdkFrameClock *frame_clock;
+ if (!gtk_inspector_recorder_is_recording (recorder))
+ return;
+
frame_clock = gtk_widget_get_frame_clock (widget);
recording = gtk_inspector_render_recording_new (gdk_frame_clock_get_frame_time (frame_clock),
diff --git a/gtk/inspector/recorder.h b/gtk/inspector/recorder.h
index 7f0980b..557bb8c 100644
--- a/gtk/inspector/recorder.h
+++ b/gtk/inspector/recorder.h
@@ -42,13 +42,17 @@ typedef struct _GtkInspectorRecorderClass
G_BEGIN_DECLS
-GType gtk_inspector_recorder_get_type (void);
+GType gtk_inspector_recorder_get_type (void);
-void gtk_inspector_recorder_record_render (GtkInspectorRecorder *recorder,
- GtkWidget *widget,
- GdkWindow *window,
- const cairo_region_t *region,
- GskRenderNode *node);
+void gtk_inspector_recorder_set_recording (GtkInspectorRecorder *recorder,
+ gboolean record);
+gboolean gtk_inspector_recorder_is_recording (GtkInspectorRecorder *recorder);
+
+void gtk_inspector_recorder_record_render (GtkInspectorRecorder *recorder,
+ GtkWidget *widget,
+ GdkWindow *window,
+ const cairo_region_t *region,
+ GskRenderNode *node);
G_END_DECLS
diff --git a/gtk/inspector/recorder.ui b/gtk/inspector/recorder.ui
index 9ab46a4..4317d04 100644
--- a/gtk/inspector/recorder.ui
+++ b/gtk/inspector/recorder.ui
@@ -8,6 +8,18 @@
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkToggleButton">
+ <property name="visible">True</property>
+ <property name="icon-name">media-record</property>
+ <property name="active" bind-source="GtkInspectorRecorder" bind-property="recording"
bind-flags="bidirectional|sync-create"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GtkPaned">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]