[gimp/wip/animation: 246/373] plug-ins: allow updating animation track titles.



commit db912fa0fdbfbd8998ebbe86b96fa0fea08cbb91
Author: Jehan <jehan girinstud io>
Date:   Wed Aug 10 02:28:32 2016 +0200

    plug-ins: allow updating animation track titles.

 .../animation-play/core/animation-celanimation.c   |   16 ++++++++
 .../animation-play/core/animation-celanimation.h   |    3 ++
 plug-ins/animation-play/widgets/animation-xsheet.c |   38 +++++++++++++++++---
 3 files changed, 52 insertions(+), 5 deletions(-)
---
diff --git a/plug-ins/animation-play/core/animation-celanimation.c 
b/plug-ins/animation-play/core/animation-celanimation.c
index 8e2fabd..dce0783 100644
--- a/plug-ins/animation-play/core/animation-celanimation.c
+++ b/plug-ins/animation-play/core/animation-celanimation.c
@@ -288,6 +288,22 @@ animation_cel_animation_get_track_title (AnimationCelAnimation *animation,
   return title;
 }
 
+void
+animation_cel_animation_set_track_title (AnimationCelAnimation *animation,
+                                         gint                   level,
+                                         const gchar           *title)
+{
+  GList *track;
+
+  track = g_list_nth (animation->priv->tracks, level);
+
+  if (track)
+    {
+      g_free (((Track *) track->data)->title);
+      ((Track *) track->data)->title = g_strdup (title);
+    }
+}
+
 /**** Virtual methods ****/
 
 static gint
diff --git a/plug-ins/animation-play/core/animation-celanimation.h 
b/plug-ins/animation-play/core/animation-celanimation.h
index b754a90..f256d04 100644
--- a/plug-ins/animation-play/core/animation-celanimation.h
+++ b/plug-ins/animation-play/core/animation-celanimation.h
@@ -60,6 +60,9 @@ void          animation_cel_animation_set_duration    (AnimationCelAnimation *an
 
 gint          animation_cel_animation_get_levels      (AnimationCelAnimation *animation);
 
+void          animation_cel_animation_set_track_title (AnimationCelAnimation *animation,
+                                                       gint                   level,
+                                                       const gchar           *title);
 const gchar * animation_cel_animation_get_track_title (AnimationCelAnimation *animation,
                                                        gint                   level);
 
diff --git a/plug-ins/animation-play/widgets/animation-xsheet.c 
b/plug-ins/animation-play/widgets/animation-xsheet.c
index 55f00fd..c7a01d2 100755
--- a/plug-ins/animation-play/widgets/animation-xsheet.c
+++ b/plug-ins/animation-play/widgets/animation-xsheet.c
@@ -75,9 +75,12 @@ static void on_animation_loaded           (Animation       *animation,
                                            AnimationXSheet *xsheet);
 
 /* UI Signals */
-static gboolean animation_xsheet_cel_clicked  (GtkWidget       *button,
-                                               GdkEvent        *event,
-                                               AnimationXSheet *xsheet);
+static gboolean animation_xsheet_cel_clicked         (GtkWidget       *button,
+                                                      GdkEvent        *event,
+                                                      AnimationXSheet *xsheet);
+static void     animation_xsheet_track_title_updated (GtkEntryBuffer  *buffer,
+                                                      GParamSpec      *param_spec,
+                                                      AnimationXSheet *xsheet);
 
 G_DEFINE_TYPE (AnimationXSheet, animation_xsheet, GTK_TYPE_SCROLLED_WINDOW)
 
@@ -326,7 +329,8 @@ animation_xsheet_reset_layout (AnimationXSheet *xsheet)
   /* Titles. */
   for (j = 0; j < n_tracks; j++)
     {
-      const gchar *title;
+      const gchar    *title;
+      GtkEntryBuffer *entry_buffer;
 
       title = animation_cel_animation_get_track_title (xsheet->priv->animation, j);
 
@@ -335,7 +339,15 @@ animation_xsheet_reset_layout (AnimationXSheet *xsheet)
       gtk_table_attach (GTK_TABLE (xsheet->priv->track_layout),
                         frame, j + 1, j + 2, 0, 1,
                         GTK_FILL, GTK_FILL, 0, 0);
-      label = gtk_label_new (title);
+      label = gtk_entry_new ();
+      gtk_entry_set_text (GTK_ENTRY (label), title);
+      entry_buffer = gtk_entry_get_buffer (GTK_ENTRY (label));
+      g_object_set_data (G_OBJECT (entry_buffer), "track-num",
+                         GINT_TO_POINTER (j));
+      g_signal_connect (entry_buffer,
+                        "notify::text",
+                        G_CALLBACK (animation_xsheet_track_title_updated),
+                        xsheet);
       gtk_container_add (GTK_CONTAINER (frame), label);
       gtk_widget_show (label);
       gtk_widget_show (frame);
@@ -444,3 +456,19 @@ animation_xsheet_cel_clicked (GtkWidget       *button,
   /* All handled here. */
   return TRUE;
 }
+
+static void
+animation_xsheet_track_title_updated (GtkEntryBuffer  *buffer,
+                                      GParamSpec      *param_spec,
+                                      AnimationXSheet *xsheet)
+{
+  const gchar *title;
+  gpointer     track_num;
+
+  track_num = g_object_get_data (G_OBJECT (buffer), "track-num");
+  title = gtk_entry_buffer_get_text (buffer);
+
+  animation_cel_animation_set_track_title (xsheet->priv->animation,
+                                           GPOINTER_TO_INT (track_num),
+                                           title);
+}


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