[gimp/wip/animation: 138/197] plug-ins: add an export button.



commit 2559054563deb660a99d16623e8532a61945ada2
Author: Jehan <jehan girinstud io>
Date:   Mon May 22 11:26:13 2017 +0200

    plug-ins: add an export button.
    
    This first version is more a proof of concept. You can't yet choose the
    format (video, image sequence, file format…) nor even the file path.

 plug-ins/animation-play/core/animation-playback.c  |   40 ++++++++++++++++++++
 plug-ins/animation-play/core/animation-playback.h  |    1 +
 plug-ins/animation-play/widgets/animation-dialog.c |   25 ++++++++++++
 3 files changed, 66 insertions(+), 0 deletions(-)
---
diff --git a/plug-ins/animation-play/core/animation-playback.c 
b/plug-ins/animation-play/core/animation-playback.c
index b4b2da3..37e44a4 100644
--- a/plug-ins/animation-play/core/animation-playback.c
+++ b/plug-ins/animation-play/core/animation-playback.c
@@ -548,6 +548,46 @@ animation_playback_get_stop (AnimationPlayback *playback)
   return playback->priv->stop;
 }
 
+void
+animation_playback_export (AnimationPlayback *playback)
+{
+  AnimationRenderer *renderer;
+  GeglNode          *graph;
+  GeglNode          *export;
+  GeglNode          *input;
+  gint               duration;
+  gint               i;
+
+  renderer = ANIMATION_RENDERER (playback->priv->renderer);
+  duration = animation_get_duration (playback->priv->animation);
+  graph  = gegl_node_new ();
+  export = gegl_node_new_child (graph,
+                                "operation", "gegl:ff-save",
+                                "path", "bla.ogv",
+                                NULL);
+  input = gegl_node_new_child (graph,
+                               "operation", "gegl:buffer-source",
+                               NULL);
+  gegl_node_set (export, "frame-rate", 24.0, NULL);
+  gegl_node_set (export, "video-bufsize", 0, NULL);
+  gegl_node_set (export, "video-bit-rate", 0, NULL);
+  gegl_node_link_many (input, export, NULL);
+
+  for (i = 0; i < duration; i++)
+    {
+      GeglBuffer *buffer;
+
+      g_signal_emit_by_name (playback->priv->animation, "loading",
+                             (gdouble) i / ((gdouble) duration - 0.999));
+      buffer = animation_renderer_get_buffer (renderer, i);
+      gegl_node_set (input, "buffer", buffer, NULL);
+      gegl_node_process (export);
+      g_object_unref (buffer);
+    }
+  g_object_unref (graph);
+  g_signal_emit_by_name (playback->priv->animation, "loaded");
+}
+
 /************ Private Functions ****************/
 
 static void
diff --git a/plug-ins/animation-play/core/animation-playback.h 
b/plug-ins/animation-play/core/animation-playback.h
index 145ac57..e257c26 100644
--- a/plug-ins/animation-play/core/animation-playback.h
+++ b/plug-ins/animation-play/core/animation-playback.h
@@ -87,4 +87,5 @@ void          animation_playback_set_stop      (AnimationPlayback   *playback,
                                                 gint                 index);
 gint          animation_playback_get_stop      (AnimationPlayback   *playback);
 
+void          animation_playback_export        (AnimationPlayback   *playback);
 #endif  /*  __ANIMATION_PLAYBACK_H__  */
diff --git a/plug-ins/animation-play/widgets/animation-dialog.c 
b/plug-ins/animation-play/widgets/animation-dialog.c
index 275e15e..f954456 100755
--- a/plug-ins/animation-play/widgets/animation-dialog.c
+++ b/plug-ins/animation-play/widgets/animation-dialog.c
@@ -79,6 +79,7 @@ struct _AnimationDialogPrivate
   GtkWidget         *upper_bar;
   GtkWidget         *zoomcombo;
   GtkWidget         *refresh;
+  GtkWidget         *export;
 
   GtkWidget         *scrolled_drawing_area;
   GtkWidget         *drawing_area;
@@ -153,6 +154,8 @@ static gboolean    on_dialog_expose                (GtkWidget      *widget,
 static void        update_ui_sensitivity     (AnimationDialog  *dialog);
 
 /* UI callbacks */
+static void        export_callback           (GtkAction        *action,
+                                              AnimationDialog  *dialog);
 static void        close_callback            (GtkAction        *action,
                                               AnimationDialog  *dialog);
 static void        help_callback             (GtkAction        *action,
@@ -633,6 +636,15 @@ animation_dialog_constructed (GObject *object)
   gtk_box_pack_start (GTK_BOX (priv->upper_bar), priv->zoomcombo, FALSE, FALSE, 0);
   gtk_widget_show (priv->zoomcombo);
 
+  /* Export. */
+  priv->export = GTK_WIDGET (gtk_tool_button_new (NULL, N_("Export the animation")));
+
+  gtk_activatable_set_related_action (GTK_ACTIVATABLE (priv->export),
+                                      gtk_action_group_get_action (priv->various_actions, "export"));
+
+  gtk_box_pack_end (GTK_BOX (priv->upper_bar), priv->export, FALSE, FALSE, 0);
+  gtk_widget_show (priv->export);
+
   /* Refresh. */
   priv->refresh = GTK_WIDGET (gtk_tool_button_new (NULL, N_("Reload the image")));
 
@@ -1055,6 +1067,10 @@ ui_manager_new (AnimationDialog *dialog)
 
   static GtkActionEntry various_entries[] =
   {
+    { "export", GIMP_ICON_DOCUMENT_SAVE,
+      NULL, "<control>e", N_("Export the video"),
+      G_CALLBACK (export_callback) },
+
     { "help", "help-browser",
       N_("About the animation plug-in"), "question", NULL,
       G_CALLBACK (help_callback) },
@@ -1455,6 +1471,15 @@ update_ui_sensitivity (AnimationDialog *dialog)
 /**** UI CALLBACKS ****/
 
 static void
+export_callback (GtkAction       *action,
+                 AnimationDialog *dialog)
+{
+  AnimationDialogPrivate *priv = GET_PRIVATE (dialog);
+
+  animation_playback_export (priv->playback);
+}
+
+static void
 close_callback (GtkAction       *action,
                 AnimationDialog *dialog)
 {


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