From ab60c316291b702ebf808ebe241dccccc9cb2c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 8 May 2013 19:52:16 +0200 Subject: [PATCH] shell-recorder: Make drawing the cursor optional As with screenshots, showing the cursor in a recording may not be desirable, so add a property to control whether the cursor is drawn or not. https://bugzilla.gnome.org/show_bug.cgi?id=696247 --- src/shell-recorder.c | 45 ++++++++++++++++++++++++++++++++++++++++++-- src/shell-recorder.h | 2 ++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/shell-recorder.c b/src/shell-recorder.c index 7c7fe8539..aa8b477c1 100644 --- a/src/shell-recorder.c +++ b/src/shell-recorder.c @@ -68,6 +68,7 @@ struct _ShellRecorder { CoglHandle recording_icon; /* icon shown while playing */ + gboolean draw_cursor; cairo_surface_t *cursor_image; int cursor_hot_x; int cursor_hot_y; @@ -112,6 +113,8 @@ static void recorder_set_pipeline (ShellRecorder *recorder, const char *pipeline); static void recorder_set_file_template (ShellRecorder *recorder, const char *file_template); +static void recorder_set_draw_cursor (ShellRecorder *recorder, + gboolean draw_cursor); static void recorder_pipeline_set_caps (RecorderPipeline *pipeline); static void recorder_pipeline_closed (RecorderPipeline *pipeline); @@ -121,7 +124,8 @@ enum { PROP_STAGE, PROP_FRAMERATE, PROP_PIPELINE, - PROP_FILE_TEMPLATE + PROP_FILE_TEMPLATE, + PROP_DRAW_CURSOR }; G_DEFINE_TYPE(ShellRecorder, shell_recorder, G_TYPE_OBJECT); @@ -275,6 +279,7 @@ shell_recorder_init (ShellRecorder *recorder) recorder->state = RECORDER_STATE_CLOSED; recorder->framerate = DEFAULT_FRAMES_PER_SECOND; + recorder->draw_cursor = TRUE; } static void @@ -575,7 +580,8 @@ recorder_record_frame (ShellRecorder *recorder) GST_BUFFER_PTS(buffer) = now - recorder->start_time; - recorder_draw_cursor (recorder, buffer); + if (recorder->draw_cursor) + recorder_draw_cursor (recorder, buffer); shell_recorder_src_add_buffer (SHELL_RECORDER_SRC (recorder->current_pipeline->src), buffer); gst_buffer_unref (buffer); @@ -1017,6 +1023,18 @@ recorder_set_file_template (ShellRecorder *recorder, g_object_notify (G_OBJECT (recorder), "file-template"); } +static void +recorder_set_draw_cursor (ShellRecorder *recorder, + gboolean draw_cursor) +{ + if (draw_cursor == recorder->draw_cursor) + return; + + recorder->draw_cursor = draw_cursor; + + g_object_notify (G_OBJECT (recorder), "draw-cursor"); +} + static void shell_recorder_set_property (GObject *object, guint prop_id, @@ -1039,6 +1057,9 @@ shell_recorder_set_property (GObject *object, case PROP_FILE_TEMPLATE: recorder_set_file_template (recorder, g_value_get_string (value)); break; + case PROP_DRAW_CURSOR: + recorder_set_draw_cursor (recorder, g_value_get_boolean (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1067,6 +1088,9 @@ shell_recorder_get_property (GObject *object, case PROP_FILE_TEMPLATE: g_value_set_string (value, recorder->file_template); break; + case PROP_DRAW_CURSOR: + g_value_set_boolean (value, recorder->draw_cursor); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1115,6 +1139,14 @@ shell_recorder_class_init (ShellRecorderClass *klass) "The filename template to use for output files", NULL, G_PARAM_READWRITE)); + + g_object_class_install_property (gobject_class, + PROP_DRAW_CURSOR, + g_param_spec_boolean ("draw-cursor", + "Draw Cursor", + "Whether to record the cursor", + TRUE, + G_PARAM_READWRITE)); } /* Sets the GstCaps (video format, in this case) on the stream @@ -1689,6 +1721,15 @@ shell_recorder_set_file_template (ShellRecorder *recorder, } +void +shell_recorder_set_draw_cursor (ShellRecorder *recorder, + gboolean draw_cursor) +{ + g_return_if_fail (SHELL_IS_RECORDER (recorder)); + + recorder_set_draw_cursor (recorder, draw_cursor); +} + /** * shell_recorder_set_pipeline: * @recorder: the #ShellRecorder diff --git a/src/shell-recorder.h b/src/shell-recorder.h index f2fb12e37..c761125e7 100644 --- a/src/shell-recorder.h +++ b/src/shell-recorder.h @@ -36,6 +36,8 @@ void shell_recorder_set_file_template (ShellRecorder *recorder, const char *file_template); void shell_recorder_set_pipeline (ShellRecorder *recorder, const char *pipeline); +void shell_recorder_set_draw_cursor (ShellRecorder *recorder, + gboolean draw_cursor); void shell_recorder_set_area (ShellRecorder *recorder, int x, int y,