shell-recorder: Optionally return the filename of the recording

It is currently not always possible to predict the actual output filename
of a recording - the file-template does not necessarily use an absolute
path and may contain %d and %t escape sequences.
This is OK for fire-and-forget uses like the existing keyboard shortcut,
but we will soon expose the functionality on DBus and consumers of that
API might very well need to access the file after the recording. So do
the same as our screenshot API and add an optional (out) parameter to
record().

https://bugzilla.gnome.org/show_bug.cgi?id=696247
This commit is contained in:
Florian Müllner 2013-05-07 00:11:57 +02:00
parent 990f68375e
commit 3b95560d32
3 changed files with 9 additions and 3 deletions

View File

@ -1708,6 +1708,7 @@ shell_recorder_set_pipeline (ShellRecorder *recorder,
/**
* shell_recorder_record:
* @recorder: the #ShellRecorder
* @filename_used: (out) (allow-none): actual filename used for recording
*
* Starts recording, Starting the recording may fail if the output file
* cannot be opened, or if the output stream cannot be created
@ -1724,7 +1725,8 @@ shell_recorder_set_pipeline (ShellRecorder *recorder,
* Return value: %TRUE if recording was succesfully started
*/
gboolean
shell_recorder_record (ShellRecorder *recorder)
shell_recorder_record (ShellRecorder *recorder,
char **filename_used)
{
g_return_val_if_fail (SHELL_IS_RECORDER (recorder), FALSE);
g_return_val_if_fail (recorder->stage != NULL, FALSE);
@ -1733,6 +1735,9 @@ shell_recorder_record (ShellRecorder *recorder)
if (!recorder_open_pipeline (recorder))
return FALSE;
if (filename_used)
*filename_used = g_strdup (recorder->current_pipeline->filename);
recorder_connect_stage_callbacks (recorder);
recorder->start_time = get_wall_time();

View File

@ -36,7 +36,8 @@ void shell_recorder_set_file_template (ShellRecorder *recorder,
const char *file_template);
void shell_recorder_set_pipeline (ShellRecorder *recorder,
const char *pipeline);
gboolean shell_recorder_record (ShellRecorder *recorder);
gboolean shell_recorder_record (ShellRecorder *recorder,
char **filename_used);
void shell_recorder_close (ShellRecorder *recorder);
void shell_recorder_pause (ShellRecorder *recorder);
gboolean shell_recorder_is_recording (ShellRecorder *recorder);

View File

@ -48,7 +48,7 @@ on_stage_realized (ClutterActor *stage,
{
recorder = shell_recorder_new (CLUTTER_STAGE (stage));
shell_recorder_set_file_template (recorder, "test-recorder.webm");
shell_recorder_record (recorder);
shell_recorder_record (recorder, NULL);
}
int main (int argc, char **argv)