[gnome-shell] recorder: save recorded video as recent item



commit eb09f3411497e863a1920a9b3f153bb4791fe3b2
Author: Ray Strode <rstrode redhat com>
Date:   Thu Oct 25 17:26:17 2012 -0400

    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

 configure.ac         |    2 +-
 src/shell-recorder.c |   30 +++++++++++++++++++++++++++---
 src/test-recorder.c  |    2 ++
 3 files changed, 30 insertions(+), 4 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 41fc672..9eb3a02 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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)
diff --git a/src/shell-recorder.c b/src/shell-recorder.c
index dbcd0ce..6a11343 100644
--- a/src/shell-recorder.c
+++ b/src/shell-recorder.c
@@ -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);
 
+          if (outfilename != NULL)
+            *outfilename = path;
+          else
+            g_free (path);
           g_string_free (filename, TRUE);
-          g_free (path);
+
           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);
     }
 
diff --git a/src/test-recorder.c b/src/test-recorder.c
index caba5dc..ec2b05e 100644
--- a/src/test-recorder.c
+++ b/src/test-recorder.c
@@ -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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]