recorder: save recorded video as recent item

Often the first thing a user wants to do after making a recording
is post it somewhere.

This commit adds the video to recently used items, so that it shows
up prominently in open file choosers.

https://bugzilla.gnome.org/show_bug.cgi?id=680647
This commit is contained in:
Ray Strode 2012-10-25 17:26:17 -04:00
parent fbeb446ed7
commit eb09f34114
3 changed files with 30 additions and 4 deletions

View File

@ -52,7 +52,7 @@ AC_MSG_CHECKING([for GStreamer (needed for recording functionality)])
if $PKG_CONFIG --exists gstreamer-1.0 '>=' $GSTREAMER_MIN_VERSION ; then
AC_MSG_RESULT(yes)
build_recorder=true
recorder_modules="gstreamer-1.0 gstreamer-base-1.0 x11"
recorder_modules="gstreamer-1.0 gstreamer-base-1.0 x11 gtk+-3.0"
PKG_CHECK_MODULES(TEST_SHELL_RECORDER, $recorder_modules clutter-1.0 xfixes gl)
else
AC_MSG_RESULT(no)

View File

@ -11,6 +11,8 @@
#define GST_USE_UNSTABLE_API
#include <gst/gst.h>
#include <gtk/gtk.h>
#include "shell-recorder-src.h"
#include "shell-recorder.h"
#include "shell-screen-grabber.h"
@ -90,6 +92,7 @@ struct _RecorderPipeline
GstElement *pipeline;
GstElement *src;
int outfile;
char *filename;
};
static void recorder_set_stage (ShellRecorder *recorder,
@ -1137,7 +1140,8 @@ get_absolute_path (char *maybe_relative)
* be opened.
*/
static int
recorder_open_outfile (ShellRecorder *recorder)
recorder_open_outfile (ShellRecorder *recorder,
char **outfilename)
{
const char *pattern;
int flags;
@ -1218,8 +1222,12 @@ recorder_open_outfile (ShellRecorder *recorder)
{
g_printerr ("Recording to %s\n", path);
g_string_free (filename, TRUE);
if (outfilename != NULL)
*outfilename = path;
else
g_free (path);
g_string_free (filename, TRUE);
goto out;
}
@ -1257,7 +1265,8 @@ recorder_pipeline_add_sink (RecorderPipeline *pipeline)
return TRUE;
}
pipeline->outfile = recorder_open_outfile (pipeline->recorder);
pipeline->outfile = recorder_open_outfile (pipeline->recorder,
&pipeline->filename);
if (pipeline->outfile == -1)
goto out;
@ -1332,6 +1341,8 @@ recorder_pipeline_free (RecorderPipeline *pipeline)
if (pipeline->outfile != -1)
close (pipeline->outfile);
g_free (pipeline->filename);
g_clear_object (&pipeline->recorder);
g_free (pipeline);
@ -1383,6 +1394,10 @@ recorder_pipeline_closed (RecorderPipeline *pipeline)
if (pipeline->recorder)
{
GtkRecentManager *recent_manager;
GFile *file;
char *uri;
ShellRecorder *recorder = pipeline->recorder;
if (pipeline == recorder->current_pipeline)
{
@ -1391,6 +1406,15 @@ recorder_pipeline_closed (RecorderPipeline *pipeline)
shell_recorder_close (recorder);
}
recent_manager = gtk_recent_manager_get_default ();
file = g_file_new_for_path (pipeline->filename);
uri = g_file_get_uri (file);
gtk_recent_manager_add_item (recent_manager,
uri);
g_free (uri);
g_object_unref (file);
recorder->pipelines = g_slist_remove (recorder->pipelines, pipeline);
}

View File

@ -3,6 +3,7 @@
#define GST_USE_UNSTABLE_API
#include "shell-recorder.h"
#include <clutter/clutter.h>
#include <gtk/gtk.h>
#include <gst/gst.h>
/* Very simple test of the ShellRecorder class; shows some text strings
@ -57,6 +58,7 @@ int main (int argc, char **argv)
ClutterAnimation *animation;
ClutterColor red, green, blue;
gtk_init (&argc, &argv);
gst_init (&argc, &argv);
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1;