diff options
author | Benjamin Otte <otte@redhat.com> | 2016-11-20 01:41:43 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2016-11-20 03:54:43 +0100 |
commit | 32adb3142829fd869b72cc1647fc4b475d61f711 (patch) | |
tree | e835fee8975fadec9140cdcee03b0aa5a3c61fd0 /gtk/inspector | |
parent | b404ecf294e84a2079a5277d6c8f5f0c65eb10f3 (diff) | |
download | gtk+-32adb3142829fd869b72cc1647fc4b475d61f711.tar.gz |
inspector: Record a "start" event whenever we start recording
Diffstat (limited to 'gtk/inspector')
-rw-r--r-- | gtk/inspector/Makefile.inc | 2 | ||||
-rw-r--r-- | gtk/inspector/recorder.c | 84 | ||||
-rw-r--r-- | gtk/inspector/startrecording.c | 58 | ||||
-rw-r--r-- | gtk/inspector/startrecording.h | 59 |
4 files changed, 172 insertions, 31 deletions
diff --git a/gtk/inspector/Makefile.inc b/gtk/inspector/Makefile.inc index d98d547ab7..d01e9838a6 100644 --- a/gtk/inspector/Makefile.inc +++ b/gtk/inspector/Makefile.inc @@ -28,6 +28,7 @@ inspector_c_sources = \ inspector/selector.c \ inspector/signals-list.c \ inspector/size-groups.c \ + inspector/startrecording.c \ inspector/statistics.c \ inspector/strv-editor.c \ inspector/treewalk.c \ @@ -63,6 +64,7 @@ inspector_h_sources = \ inspector/selector.h \ inspector/signals-list.h \ inspector/size-groups.h \ + inspector/startrecording.h \ inspector/statistics.h \ inspector/strv-editor.h \ inspector/treewalk.h \ diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c index d3f2aedd95..0d3a61bf9e 100644 --- a/gtk/inspector/recorder.c +++ b/gtk/inspector/recorder.c @@ -31,6 +31,7 @@ #include "recording.h" #include "rendernodeview.h" #include "renderrecording.h" +#include "startrecording.h" struct _GtkInspectorRecorderPrivate { @@ -43,7 +44,7 @@ struct _GtkInspectorRecorderPrivate GtkWidget *node_property_tree; GtkTreeModel *render_node_properties; - guint recording : 1; + GtkInspectorRecording *recording; /* start recording if recording or NULL if not */ }; enum { @@ -82,9 +83,12 @@ recordings_list_row_selected (GtkListBox *box, 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 (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), @@ -232,11 +236,21 @@ gtk_inspector_recorder_recordings_list_create_widget (gpointer item, GtkWidget *widget; char *str; - str = g_strdup_printf ("Frame at %lld", (long long) gtk_inspector_recording_get_timestamp (recording)); - widget = gtk_label_new (str); - g_free (str); - gtk_label_set_xalign (GTK_LABEL (widget), 0); - gtk_widget_show_all (widget); + if (GTK_INSPECTOR_IS_RENDER_RECORDING (recording)) + { + str = g_strdup_printf ("Frame at %lld", (long long) gtk_inspector_recording_get_timestamp (recording)); + widget = gtk_label_new (str); + g_free (str); + gtk_label_set_xalign (GTK_LABEL (widget), 0); + gtk_widget_show_all (widget); + } + else + { + widget = gtk_label_new ("Start Recording"); + gtk_label_set_xalign (GTK_LABEL (widget), 0); + gtk_widget_show_all (widget); + + } return widget; } @@ -253,7 +267,7 @@ gtk_inspector_recorder_get_property (GObject *object, switch (param_id) { case PROP_RECORDING: - g_value_set_boolean (value, priv->recording); + g_value_set_boolean (value, priv->recording != NULL); break; default: @@ -338,28 +352,6 @@ gtk_inspector_recorder_init (GtkInspectorRecorder *recorder) g_object_unref (priv->render_node_properties); } -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; -} - static void gtk_inspector_recorder_add_recording (GtkInspectorRecorder *recorder, GtkInspectorRecording *recording) @@ -386,6 +378,36 @@ gtk_inspector_recorder_add_recording (GtkInspectorRecorder *recorder, } 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); + } + else + { + g_clear_object (&priv->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 != NULL; +} + +void gtk_inspector_recorder_record_render (GtkInspectorRecorder *recorder, GtkWidget *widget, GdkWindow *window, diff --git a/gtk/inspector/startrecording.c b/gtk/inspector/startrecording.c new file mode 100644 index 0000000000..3496b168e2 --- /dev/null +++ b/gtk/inspector/startrecording.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "config.h" +#include <glib/gi18n-lib.h> + +#include "startrecording.h" + +G_DEFINE_TYPE (GtkInspectorStartRecording, gtk_inspector_start_recording, GTK_TYPE_INSPECTOR_RECORDING) + +static void +gtk_inspector_start_recording_finalize (GObject *object) +{ + //GtkInspectorStartRecording *recording = GTK_INSPECTOR_START_RECORDING (object); + + G_OBJECT_CLASS (gtk_inspector_start_recording_parent_class)->finalize (object); +} + +static void +gtk_inspector_start_recording_class_init (GtkInspectorStartRecordingClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = gtk_inspector_start_recording_finalize; +} + +static void +gtk_inspector_start_recording_init (GtkInspectorStartRecording *vis) +{ +} + +GtkInspectorRecording * +gtk_inspector_start_recording_new (void) +{ + GtkInspectorStartRecording *recording; + + recording = g_object_new (GTK_TYPE_INSPECTOR_START_RECORDING, + "timestamp", (gint64) 0, + NULL); + + return GTK_INSPECTOR_RECORDING (recording); +} + +// vim: set et sw=2 ts=2: diff --git a/gtk/inspector/startrecording.h b/gtk/inspector/startrecording.h new file mode 100644 index 0000000000..24cc9774b8 --- /dev/null +++ b/gtk/inspector/startrecording.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef _GTK_INSPECTOR_START_RECORDING_H_ +#define _GTK_INSPECTOR_START_RECORDING_H_ + +#include <gdk/gdk.h> +#include <gsk/gsk.h> + +#include "inspector/recording.h" + +G_BEGIN_DECLS + +#define GTK_TYPE_INSPECTOR_START_RECORDING (gtk_inspector_start_recording_get_type()) +#define GTK_INSPECTOR_START_RECORDING(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INSPECTOR_START_RECORDING, GtkInspectorStartRecording)) +#define GTK_INSPECTOR_START_RECORDING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INSPECTOR_START_RECORDING, GtkInspectorStartRecordingClass)) +#define GTK_INSPECTOR_IS_START_RECORDING(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INSPECTOR_START_RECORDING)) +#define GTK_INSPECTOR_IS_START_RECORDING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_INSPECTOR_START_RECORDING)) +#define GTK_INSPECTOR_START_RECORDING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INSPECTOR_START_RECORDING, GtkInspectorStartRecordingClass)) + + +typedef struct _GtkInspectorStartRecordingPrivate GtkInspectorStartRecordingPrivate; + +typedef struct _GtkInspectorStartRecording +{ + GtkInspectorRecording parent; + +} GtkInspectorStartRecording; + +typedef struct _GtkInspectorStartRecordingClass +{ + GtkInspectorRecordingClass parent; +} GtkInspectorStartRecordingClass; + +GType gtk_inspector_start_recording_get_type (void); + +GtkInspectorRecording * + gtk_inspector_start_recording_new (void); + + +G_END_DECLS + +#endif // _GTK_INSPECTOR_START_RECORDING_H_ + +// vim: set et sw=2 ts=2: |