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 if $PKG_CONFIG --exists gstreamer-1.0 '>=' $GSTREAMER_MIN_VERSION ; then
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
build_recorder=true 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) PKG_CHECK_MODULES(TEST_SHELL_RECORDER, $recorder_modules clutter-1.0 xfixes gl)
else else
AC_MSG_RESULT(no) AC_MSG_RESULT(no)

View File

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

View File

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