[gimp/wip/animation: 145/197] plug-ins: add a new widget to handle track titles.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/wip/animation: 145/197] plug-ins: add a new widget to handle track titles.
- Date: Sat, 7 Oct 2017 03:10:38 +0000 (UTC)
commit 3d4a41ed291c294aea64d05a38b2d9b28ce5725a
Author: Jehan <jehan girinstud io>
Date: Sun May 28 23:16:51 2017 +0200
plug-ins: add a new widget to handle track titles.
This is salvaged from old code of mine for an editable label widget.
plug-ins/animation-play/Makefile.am | 4 +
.../widgets/animation-editable-label-string.c | 205 +++++++++++++
.../widgets/animation-editable-label-string.h | 54 ++++
.../widgets/animation-editable-label.c | 304 ++++++++++++++++++++
.../widgets/animation-editable-label.h | 62 ++++
plug-ins/animation-play/widgets/animation-xsheet.c | 139 +++++-----
6 files changed, 694 insertions(+), 74 deletions(-)
---
diff --git a/plug-ins/animation-play/Makefile.am b/plug-ins/animation-play/Makefile.am
index 8ba0acf..58a9f7a 100644
--- a/plug-ins/animation-play/Makefile.am
+++ b/plug-ins/animation-play/Makefile.am
@@ -59,6 +59,10 @@ animation_play_SOURCES = \
widgets/animation-dialog.c \
widgets/animation-dialog-export.h \
widgets/animation-dialog-export.c \
+ widgets/animation-editable-label.h \
+ widgets/animation-editable-label.c \
+ widgets/animation-editable-label-string.h \
+ widgets/animation-editable-label-string.c \
widgets/animation-keyframe-view.h \
widgets/animation-keyframe-view.c \
widgets/animation-layer-view.h \
diff --git a/plug-ins/animation-play/widgets/animation-editable-label-string.c
b/plug-ins/animation-play/widgets/animation-editable-label-string.c
new file mode 100644
index 0000000..d492474
--- /dev/null
+++ b/plug-ins/animation-play/widgets/animation-editable-label-string.c
@@ -0,0 +1,205 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * Editable label with entry
+ * Copyright (C) 2015-2017 Jehan <jehan gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gdk/gdkkeysyms.h>
+
+#include "animation-editable-label.h"
+#include "animation-editable-label-string.h"
+
+struct _AnimationEditableLabelStringPrivate
+{
+ GtkWidget *editing_widget;
+};
+
+static void animation_editable_label_constructed (GObject *object);
+static void animation_editable_label_icon_clicked (GtkWidget *widget,
+ GtkEntryIconPosition icon_pos,
+ GdkEvent *event,
+ gpointer user_data);
+static void animation_editable_label_activate (GtkWidget *widget,
+ gpointer user_data);
+static gboolean animation_editable_label_focus_out (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+static gboolean animation_editable_label_key_press (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+static void animation_editable_label_prepare_editing (GtkWidget *widget,
+ gpointer user_data);
+static void animation_editable_label_editing (GtkWidget *widget,
+ gpointer user_data);
+
+G_DEFINE_TYPE (AnimationEditableLabelString, animation_editable_label_string, ANIMATION_TYPE_EDITABLE_LABEL)
+
+#define parent_class animation_editable_label_string_parent_class
+
+static void
+animation_editable_label_string_class_init (AnimationEditableLabelStringClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructed = animation_editable_label_constructed;
+
+ g_type_class_add_private (klass, sizeof (AnimationEditableLabelStringPrivate));
+}
+
+static void
+animation_editable_label_string_init (AnimationEditableLabelString *label)
+{
+ label->priv = G_TYPE_INSTANCE_GET_PRIVATE (label,
+ ANIMATION_TYPE_EDITABLE_LABEL_STRING,
+ AnimationEditableLabelStringPrivate);
+}
+
+static void
+animation_editable_label_constructed (GObject *object)
+{
+ AnimationEditableLabel *label = ANIMATION_EDITABLE_LABEL (object);
+
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ /* The editing widget. */
+ gtk_widget_set_can_focus (label->editing_widget, TRUE);
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (label->editing_widget),
+ GTK_ENTRY_ICON_SECONDARY,
+ "gtk-apply");
+ if (animation_editable_label_get_text (label))
+ gtk_entry_set_text (GTK_ENTRY (label->editing_widget),
+ animation_editable_label_get_text (label));
+ g_signal_connect (label->editing_widget, "icon-release",
+ G_CALLBACK (animation_editable_label_icon_clicked),
+ label);
+ g_signal_connect (label->editing_widget, "activate",
+ G_CALLBACK (animation_editable_label_activate),
+ label);
+ g_signal_connect (label->editing_widget, "focus-out-event",
+ G_CALLBACK (animation_editable_label_focus_out),
+ label);
+ g_signal_connect (label->editing_widget, "key-press-event",
+ G_CALLBACK (animation_editable_label_key_press),
+ label);
+ gtk_widget_show (label->editing_widget);
+
+ g_signal_connect (label, "prepare-editing",
+ G_CALLBACK (animation_editable_label_prepare_editing),
+ NULL);
+ g_signal_connect (label, "editing",
+ G_CALLBACK (animation_editable_label_editing),
+ NULL);
+}
+
+GtkWidget *
+animation_editable_label_string_new (const gchar *default_text)
+{
+ GtkWidget *widget;
+ GtkWidget *entry;
+
+ entry = gtk_entry_new ();
+ widget = g_object_new (ANIMATION_TYPE_EDITABLE_LABEL_STRING,
+ "text", default_text,
+ "editing-widget", entry,
+ NULL);
+
+ return widget;
+}
+
+static void
+animation_editable_label_icon_clicked (GtkWidget *widget,
+ GtkEntryIconPosition icon_pos,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ animation_editable_label_activate (widget, user_data);
+}
+
+static void
+animation_editable_label_activate (GtkWidget *widget,
+ gpointer user_data)
+{
+ AnimationEditableLabel *label = ANIMATION_EDITABLE_LABEL (user_data);
+ GtkEntry *entry = GTK_ENTRY (widget);
+
+ g_object_set (label,
+ "text", gtk_entry_get_text (entry),
+ NULL);
+ g_signal_handlers_block_by_func (label->editing_widget,
+ G_CALLBACK (animation_editable_label_focus_out),
+ label);
+ animation_editable_label_set_editing (label, FALSE);
+ g_signal_handlers_unblock_by_func (label->editing_widget,
+ G_CALLBACK (animation_editable_label_focus_out),
+ label);
+}
+
+static gboolean
+animation_editable_label_focus_out (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ animation_editable_label_activate (widget, user_data);
+
+ /* Return FALSE because GtkEntry is expecting for this signal. */
+ return FALSE;
+}
+
+static gboolean
+animation_editable_label_key_press (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ AnimationEditableLabel *label = ANIMATION_EDITABLE_LABEL (user_data);
+ GdkEventKey *event_key = (GdkEventKey*) event;
+
+ if (event_key->keyval == GDK_KEY_Escape)
+ {
+ /* Discard entry contents and revert to read-only label. */
+ g_signal_handlers_block_by_func (label->editing_widget,
+ G_CALLBACK (animation_editable_label_focus_out),
+ label);
+ animation_editable_label_set_editing (label, FALSE);
+ g_signal_handlers_unblock_by_func (label->editing_widget,
+ G_CALLBACK (animation_editable_label_focus_out),
+ label);
+ }
+
+ return FALSE;
+}
+
+static void
+animation_editable_label_prepare_editing (GtkWidget *widget,
+ gpointer user_data)
+{
+ AnimationEditableLabel *label = ANIMATION_EDITABLE_LABEL (widget);
+
+ gtk_entry_set_text (GTK_ENTRY (label->editing_widget),
+ animation_editable_label_get_text (label));
+}
+
+static void
+animation_editable_label_editing (GtkWidget *widget,
+ gpointer user_data)
+{
+ AnimationEditableLabel *label = ANIMATION_EDITABLE_LABEL (widget);
+
+ gtk_widget_grab_focus (GTK_WIDGET (label->editing_widget));
+ gtk_editable_set_position (GTK_EDITABLE (label->editing_widget), -1);
+}
diff --git a/plug-ins/animation-play/widgets/animation-editable-label-string.h
b/plug-ins/animation-play/widgets/animation-editable-label-string.h
new file mode 100644
index 0000000..69046e6
--- /dev/null
+++ b/plug-ins/animation-play/widgets/animation-editable-label-string.h
@@ -0,0 +1,54 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * Editable label with entry
+ * Copyright (C) 2015-2017 Jehan <jehan gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __ANIMATION_EDITABLE_LABEL_STRING_H__
+#define __ANIMATION_EDITABLE_LABEL_STRING_H__
+
+#include <gtk/gtk.h>
+
+#define ANIMATION_TYPE_EDITABLE_LABEL_STRING (animation_editable_label_string_get_type ())
+#define ANIMATION_EDITABLE_LABEL_STRING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
ANIMATION_TYPE_EDITABLE_LABEL_STRING, AnimationEditableLabelString))
+#define ANIMATION_IS_EDITABLE_LABEL_STRING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
ANIMATION_TYPE_EDITABLE_LABEL_STRING))
+#define ANIMATION_EDITABLE_LABEL_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
ANIMATION_TYPE_EDITABLE_LABEL_STRING, AnimationEditableLabelStringClass))
+#define ANIMATION_IS_EDITABLE_LABEL_STRING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
ANIMATION_TYPE_EDITABLE_LABEL_STRING))
+#define ANIMATION_EDITABLE_LABEL_STRING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
ANIMATION_TYPE_EDITABLE_LABEL_STRING, AnimationEditableLabelStringClass))
+
+typedef struct _AnimationEditableLabelString AnimationEditableLabelString;
+typedef struct _AnimationEditableLabelStringClass AnimationEditableLabelStringClass;
+typedef struct _AnimationEditableLabelStringPrivate AnimationEditableLabelStringPrivate;
+
+struct _AnimationEditableLabelString
+{
+ AnimationEditableLabel parent_instance;
+
+ AnimationEditableLabelStringPrivate *priv;
+};
+
+struct _AnimationEditableLabelStringClass
+{
+ AnimationEditableLabelClass parent_class;
+};
+
+GType animation_editable_label_string_get_type (void);
+
+GtkWidget * animation_editable_label_string_new (const gchar *default_text);
+
+#endif /* __ANIMATION_EDITABLE_LABEL_STRING_H__ */
diff --git a/plug-ins/animation-play/widgets/animation-editable-label.c
b/plug-ins/animation-play/widgets/animation-editable-label.c
new file mode 100644
index 0000000..91efdd3
--- /dev/null
+++ b/plug-ins/animation-play/widgets/animation-editable-label.c
@@ -0,0 +1,304 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * Editable label base class
+ * Copyright (C) 2015 Jehan <jehan gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <libgimp/gimp.h>
+#include <libgimp/gimpui.h>
+
+#include "animation-editable-label.h"
+
+enum
+{
+ PROP_0,
+ PROP_TEXT,
+ PROP_EDITING_WIDGET
+};
+
+enum
+{
+ PREPARE_EDITING,
+ EDITING,
+ LAST_SIGNAL
+};
+
+struct _AnimationEditableLabelPrivate
+{
+ gchar *text;
+
+ GtkWidget *viewing_widget;
+ GtkWidget *label;
+
+ gboolean is_editing;
+
+ GtkWidget *image;
+ gboolean show_icon;
+};
+
+static void animation_editable_label_constructed (GObject *object);
+static void animation_editable_label_finalize (GObject *object);
+static void animation_editable_label_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void animation_editable_label_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static gboolean animation_editable_label_clicked (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data);
+
+G_DEFINE_TYPE (AnimationEditableLabel, animation_editable_label, GTK_TYPE_FRAME)
+
+#define parent_class animation_editable_label_parent_class
+
+static guint animation_editable_label_signals[LAST_SIGNAL] = { 0 };
+
+static void
+animation_editable_label_class_init (AnimationEditableLabelClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ animation_editable_label_signals[PREPARE_EDITING] =
+ g_signal_new ("prepare-editing",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE,
+ 0);
+ animation_editable_label_signals[EDITING] =
+ g_signal_new ("editing",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ NULL,
+ G_TYPE_NONE,
+ 0);
+
+ object_class->constructed = animation_editable_label_constructed;
+ object_class->finalize = animation_editable_label_finalize;
+ object_class->set_property = animation_editable_label_set_property;
+ object_class->get_property = animation_editable_label_get_property;
+
+ g_object_class_install_property (object_class, PROP_TEXT,
+ g_param_spec_string ("text",
+ NULL, NULL,
+ "",
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_EDITING_WIDGET,
+ g_param_spec_object ("editing-widget",
+ NULL, NULL,
+ GTK_TYPE_WIDGET,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_type_class_add_private (klass, sizeof (AnimationEditableLabelPrivate));
+}
+
+static void
+animation_editable_label_init (AnimationEditableLabel *label)
+{
+ label->priv = G_TYPE_INSTANCE_GET_PRIVATE (label,
+ ANIMATION_TYPE_EDITABLE_LABEL,
+ AnimationEditableLabelPrivate);
+}
+
+static void
+animation_editable_label_constructed (GObject *object)
+{
+ AnimationEditableLabel *label = ANIMATION_EDITABLE_LABEL (object);
+ GtkWidget *box;
+ GtkWidget *event_box;
+
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ /* The viewing widget. */
+ event_box = gtk_event_box_new ();
+ gtk_widget_add_events (GTK_WIDGET (event_box),
+ GDK_BUTTON_PRESS_MASK);
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
+
+ label->priv->label = gtk_label_new (label->priv->text? label->priv->text : "");
+ gtk_label_set_justify (GTK_LABEL (label->priv->label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start (GTK_BOX (box),
+ label->priv->label,
+ TRUE, TRUE,
+ 2.0);
+ gtk_widget_show (label->priv->label);
+
+ label->priv->image = gtk_image_new_from_icon_name ("gtk-edit", GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (box),
+ label->priv->image,
+ FALSE,
+ FALSE,
+ 2.0);
+ gtk_widget_show (box);
+
+ gtk_container_add (GTK_CONTAINER (event_box), box);
+ gtk_container_add (GTK_CONTAINER (label),
+ event_box);
+ gtk_widget_show (event_box);
+ label->priv->viewing_widget = event_box;
+ label->priv->is_editing = FALSE;
+ label->priv->show_icon = FALSE;
+
+ g_signal_connect (event_box, "button-press-event",
+ G_CALLBACK (animation_editable_label_clicked),
+ label);
+}
+
+static void
+animation_editable_label_finalize (GObject *object)
+{
+ AnimationEditableLabel *label = ANIMATION_EDITABLE_LABEL (object);
+
+ if (label->priv->text)
+ g_free (label->priv->text);
+ if (label->priv->is_editing)
+ gtk_widget_destroy (label->priv->viewing_widget);
+ else
+ gtk_widget_destroy (label->editing_widget);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+animation_editable_label_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ AnimationEditableLabel *label = ANIMATION_EDITABLE_LABEL (object);
+
+ switch (property_id)
+ {
+ case PROP_TEXT:
+ if (label->priv->text)
+ g_free (label->priv->text);
+ label->priv->text = g_value_dup_string (value);
+ if (label->priv->label)
+ gtk_label_set_text (GTK_LABEL (label->priv->label),
+ label->priv->text);
+ break;
+ case PROP_EDITING_WIDGET:
+ label->editing_widget = g_value_get_object (value);
+ gtk_widget_show (label->editing_widget);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+animation_editable_label_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ AnimationEditableLabel *label = ANIMATION_EDITABLE_LABEL (object);
+
+ switch (property_id)
+ {
+ case PROP_TEXT:
+ g_value_set_string (value, label->priv->text);
+ break;
+ case PROP_EDITING_WIDGET:
+ g_value_set_object (value, label->editing_widget);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static gboolean
+animation_editable_label_clicked (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer user_data)
+{
+ AnimationEditableLabel *label = ANIMATION_EDITABLE_LABEL (user_data);
+
+ g_signal_emit (label, animation_editable_label_signals[PREPARE_EDITING],
+ 0, NULL);
+ animation_editable_label_set_editing (label, TRUE);
+ g_signal_emit (label, animation_editable_label_signals[EDITING],
+ 0, NULL);
+
+ return TRUE;
+}
+
+void
+animation_editable_label_set_editing (AnimationEditableLabel *label,
+ gboolean editing)
+{
+ if (label->priv->is_editing != editing)
+ {
+ GtkWidget *current_widget;
+ GtkWidget *new_widget;
+
+ if (editing)
+ {
+ current_widget = label->priv->viewing_widget;
+ new_widget = label->editing_widget;
+ }
+ else
+ {
+ current_widget = label->editing_widget;
+ new_widget = label->priv->viewing_widget;
+ }
+ g_object_ref (current_widget);
+ gtk_container_remove (GTK_CONTAINER (label),
+ current_widget);
+ gtk_container_add (GTK_CONTAINER (label),
+ new_widget);
+
+ label->priv->is_editing = editing;
+ }
+}
+
+void
+animation_editable_label_show_icon (AnimationEditableLabel *label,
+ gboolean show_icon)
+{
+ if (label->priv->show_icon != show_icon)
+ {
+ if (show_icon)
+ gtk_widget_show (label->priv->image);
+ else
+ gtk_widget_hide (label->priv->image);
+ label->priv->show_icon = show_icon;
+ }
+}
+
+const gchar *
+animation_editable_label_get_text (AnimationEditableLabel *label)
+{
+ return label->priv->text;
+}
+
diff --git a/plug-ins/animation-play/widgets/animation-editable-label.h
b/plug-ins/animation-play/widgets/animation-editable-label.h
new file mode 100644
index 0000000..630e4ef
--- /dev/null
+++ b/plug-ins/animation-play/widgets/animation-editable-label.h
@@ -0,0 +1,62 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * Editable label base class
+ * Copyright (C) 2015-2017 Jehan <jehan gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef __ANIMATION_EDITABLE_LABEL_H__
+#define __ANIMATION_EDITABLE_LABEL_H__
+
+#include <gtk/gtk.h>
+
+#define ANIMATION_TYPE_EDITABLE_LABEL (animation_editable_label_get_type ())
+#define ANIMATION_EDITABLE_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
ANIMATION_TYPE_EDITABLE_LABEL, AnimationEditableLabel))
+#define ANIMATION_IS_EDITABLE_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
ANIMATION_TYPE_EDITABLE_LABEL))
+#define ANIMATION_EDITABLE_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
ANIMATION_TYPE_EDITABLE_LABEL, AnimationEditableLabelClass))
+#define ANIMATION_IS_EDITABLE_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
ANIMATION_TYPE_EDITABLE_LABEL))
+#define ANIMATION_EDITABLE_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
ANIMATION_TYPE_EDITABLE_LABEL, AnimationEditableLabelClass))
+
+typedef struct _AnimationEditableLabel AnimationEditableLabel;
+typedef struct _AnimationEditableLabelClass AnimationEditableLabelClass;
+typedef struct _AnimationEditableLabelPrivate AnimationEditableLabelPrivate;
+
+struct _AnimationEditableLabel
+{
+ GtkFrame parent_instance;
+
+ AnimationEditableLabelPrivate *priv;
+
+ /* Protected variable to be used by the child classes. */
+ GtkWidget *editing_widget;
+};
+
+struct _AnimationEditableLabelClass
+{
+ GtkFrameClass parent_class;
+};
+
+GType animation_editable_label_get_type (void);
+
+void animation_editable_label_set_editing (AnimationEditableLabel *label,
+ gboolean editing);
+void animation_editable_label_show_icon (AnimationEditableLabel *label,
+ gboolean show_icon);
+
+const gchar * animation_editable_label_get_text (AnimationEditableLabel *label);
+
+#endif /* __ANIMATION_EDITABLE_LABEL_H__ */
diff --git a/plug-ins/animation-play/widgets/animation-xsheet.c
b/plug-ins/animation-play/widgets/animation-xsheet.c
index 9fc58bb..8651baa 100755
--- a/plug-ins/animation-play/widgets/animation-xsheet.c
+++ b/plug-ins/animation-play/widgets/animation-xsheet.c
@@ -33,6 +33,8 @@
#include "core/animation-playback.h"
#include "core/animation-celanimation.h"
+#include "animation-editable-label.h"
+#include "animation-editable-label-string.h"
#include "animation-keyframe-view.h"
#include "animation-layer-view.h"
#include "animation-menus.h"
@@ -170,61 +172,61 @@ static void on_layer_selection (AnimationLayerView *view,
AnimationXSheet *xsheet);
/* UI Signals */
-static void animation_xsheet_suite_do (GtkWidget *button,
- AnimationXSheet *xsheet);
-static void animation_xsheet_suite_cancelled (GtkWidget *button,
- AnimationXSheet *xsheet);
-static gboolean animation_xsheet_effect_clicked (GtkWidget *button,
- GdkEvent *event,
- AnimationXSheet *xsheet);
-static gboolean animation_xsheet_frame_clicked (GtkWidget *button,
- GdkEvent *event,
- AnimationXSheet *xsheet);
-static gboolean animation_xsheet_cel_clicked (GtkWidget *button,
- GdkEventButton *event,
- AnimationXSheet *xsheet);
-static void animation_xsheet_track_title_updated (GtkEntryBuffer *buffer,
- GParamSpec *param_spec,
- AnimationXSheet *xsheet);
-static void animation_xsheet_comment_changed (GtkTextBuffer *text_buffer,
- AnimationXSheet *xsheet);
-static gboolean animation_xsheet_comment_keypress (GtkWidget *entry,
- GdkEventKey *event,
- AnimationXSheet *xsheet);
-
-static void on_track_add_clicked (GtkToolButton *button,
- AnimationXSheet *xsheet);
-static void on_track_delete_clicked (GtkToolButton *button,
- AnimationXSheet *xsheet);
-static void on_track_left_clicked (GtkToolButton *toolbutton,
- AnimationXSheet *xsheet);
-static void on_track_right_clicked (GtkToolButton *toolbutton,
- AnimationXSheet *xsheet);
+static void animation_xsheet_suite_do (GtkWidget *button,
+ AnimationXSheet *xsheet);
+static void animation_xsheet_suite_cancelled (GtkWidget *button,
+ AnimationXSheet *xsheet);
+static gboolean animation_xsheet_effect_clicked (GtkWidget *button,
+ GdkEvent *event,
+ AnimationXSheet *xsheet);
+static gboolean animation_xsheet_frame_clicked (GtkWidget *button,
+ GdkEvent *event,
+ AnimationXSheet *xsheet);
+static gboolean animation_xsheet_cel_clicked (GtkWidget *button,
+ GdkEventButton *event,
+ AnimationXSheet *xsheet);
+static void animation_xsheet_track_title_updated (AnimationEditableLabel *buffer,
+ GParamSpec *param_spec,
+ AnimationXSheet *xsheet);
+static void animation_xsheet_comment_changed (GtkTextBuffer *text_buffer,
+ AnimationXSheet *xsheet);
+static gboolean animation_xsheet_comment_keypress (GtkWidget *entry,
+ GdkEventKey *event,
+ AnimationXSheet *xsheet);
+
+static void on_track_add_clicked (GtkToolButton *button,
+ AnimationXSheet *xsheet);
+static void on_track_delete_clicked (GtkToolButton *button,
+ AnimationXSheet *xsheet);
+static void on_track_left_clicked (GtkToolButton *toolbutton,
+ AnimationXSheet *xsheet);
+static void on_track_right_clicked (GtkToolButton *toolbutton,
+ AnimationXSheet *xsheet);
/* Utils */
-static void animation_xsheet_rename_cel (AnimationXSheet *xsheet,
- GtkWidget *cel,
- gboolean recursively,
- gint stop_position);
-static void animation_xsheet_jump (AnimationXSheet *xsheet,
- gint position);
-static void animation_xsheet_attach_cel (AnimationXSheet *xsheet,
- GtkWidget *cel,
- gint track,
- gint pos);
-static void animation_xsheet_extract_layer_suite (AnimationXSheet *xsheet,
- GTree **suite,
- gboolean same_numbering,
- const gchar *prefix,
- const gchar *suffix,
- const gint *lower_key);
-static gboolean create_suite (gint *key,
- GList *layers,
- CreateData *data);
-static gboolean merge_suites (gint *key,
- GList *layers,
- MergeData *data);
-static gint compare_keys (gint *key1,
- gint *key2);
+static void animation_xsheet_rename_cel (AnimationXSheet *xsheet,
+ GtkWidget *cel,
+ gboolean recursively,
+ gint stop_position);
+static void animation_xsheet_jump (AnimationXSheet *xsheet,
+ gint position);
+static void animation_xsheet_attach_cel (AnimationXSheet *xsheet,
+ GtkWidget *cel,
+ gint track,
+ gint pos);
+static void animation_xsheet_extract_layer_suite (AnimationXSheet *xsheet,
+ GTree **suite,
+ gboolean same_numbering,
+ const gchar *prefix,
+ const gchar *suffix,
+ const gint *lower_key);
+static gboolean create_suite (gint *key,
+ GList *layers,
+ CreateData *data);
+static gboolean merge_suites (gint *key,
+ GList *layers,
+ MergeData *data);
+static gint compare_keys (gint *key1,
+ gint *key2);
G_DEFINE_TYPE (AnimationXSheet, animation_xsheet, GTK_TYPE_SCROLLED_WINDOW)
@@ -460,9 +462,7 @@ animation_xsheet_add_headers (AnimationXSheet *xsheet,
gint level)
{
const gchar *title;
- GtkEntryBuffer *entry_buffer;
GtkWidget *frame;
- GtkWidget *label;
GtkWidget *toolbar;
GtkWidget *image;
GtkToolItem *item;
@@ -471,24 +471,19 @@ animation_xsheet_add_headers (AnimationXSheet *xsheet,
level);
/* Adding a title. */
- frame = gtk_frame_new (NULL);
+ frame = animation_editable_label_string_new (title);;
xsheet->priv->titles = g_list_insert (xsheet->priv->titles,
frame, level);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
gtk_table_attach (GTK_TABLE (xsheet->priv->track_layout),
frame, level * 9 + 2, level * 9 + 11, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
- 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",
+ g_object_set_data (G_OBJECT (frame), "track-num",
GINT_TO_POINTER (level));
- g_signal_connect (entry_buffer,
+ g_signal_connect (frame,
"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);
/* Adding a add-track [+] button. */
@@ -1079,14 +1074,10 @@ animation_xsheet_move_tracks (AnimationXSheet *xsheet,
track = g_list_nth (xsheet->priv->titles, level);
for (j = level, iter = track; iter; iter = iter->next, j++)
{
- GtkWidget *frame;
- GtkWidget *entry;
- GtkEntryBuffer *buffer;
+ GtkWidget *frame;
frame = g_object_ref (iter->data);
- entry = gtk_bin_get_child (GTK_BIN (frame));
- buffer = gtk_entry_get_buffer (GTK_ENTRY (entry));
- g_object_set_data (G_OBJECT (buffer), "track-num",
+ g_object_set_data (G_OBJECT (frame), "track-num",
GINT_TO_POINTER (j));
gtk_container_remove (GTK_CONTAINER (xsheet->priv->track_layout),
@@ -1783,16 +1774,16 @@ animation_xsheet_cel_clicked (GtkWidget *button,
}
static void
-animation_xsheet_track_title_updated (GtkEntryBuffer *buffer,
- GParamSpec *param_spec,
- AnimationXSheet *xsheet)
+animation_xsheet_track_title_updated (AnimationEditableLabel *buffer,
+ GParamSpec *param_spec,
+ AnimationXSheet *xsheet)
{
const gchar *title;
GList *iter;
gpointer track_num;
track_num = g_object_get_data (G_OBJECT (buffer), "track-num");
- title = gtk_entry_buffer_get_text (buffer);
+ title = animation_editable_label_get_text (buffer);
animation_cel_animation_set_track_title (xsheet->priv->animation,
GPOINTER_TO_INT (track_num),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]