[gnome-terminal/wip/newsearch] Add new search widget
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal/wip/newsearch] Add new search widget
- Date: Tue, 13 Mar 2012 19:13:16 +0000 (UTC)
commit c123ede0c9dbbf72a6814e03d55ecb1cb47ee4ec
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Tue Mar 13 17:47:18 2012 +0100
Add new search widget
src/Makefile.am | 11 +-
src/gedit-animatable.c | 103 +++++
src/gedit-animatable.h | 57 +++
src/gedit-animated-overlay.c | 172 +++++++++
src/gedit-animated-overlay.h | 64 ++++
src/gedit-floating-slider.c | 396 ++++++++++++++++++++
src/gedit-floating-slider.h | 67 ++++
src/terminal-screen-container.c | 128 +++++++-
src/terminal-screen-container.h | 2 +
src/terminal-window.c | 18 +-
src/theatrics/Makefile.am | 52 +++
src/theatrics/gedit-theatrics-actor.c | 279 ++++++++++++++
src/theatrics/gedit-theatrics-actor.h | 90 +++++
src/theatrics/gedit-theatrics-choreographer.c | 85 +++++
src/theatrics/gedit-theatrics-choreographer.h | 74 ++++
.../gedit-theatrics-enum-types.c.template | 39 ++
.../gedit-theatrics-enum-types.h.template | 27 ++
src/theatrics/gedit-theatrics-marshal.list | 1 +
src/theatrics/gedit-theatrics-stage.c | 310 +++++++++++++++
src/theatrics/gedit-theatrics-stage.h | 87 +++++
src/theatrics/gedit-theatrics-utils.h | 48 +++
21 files changed, 2094 insertions(+), 16 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 789e48d..26f908d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS = theatrics
+
NULL =
bin_PROGRAMS = gnome-terminal
@@ -12,6 +14,12 @@ BUILT_SOURCES = \
gnome_terminal_SOURCES= \
eggshell.c \
eggshell.h \
+ gedit-animatable.c \
+ gedit-animatable.h \
+ gedit-animated-overlay.c \
+ gedit-animated-overlay.h \
+ gedit-floating-slider.c \
+ gedit-floating-slider.h \
profile-editor.c \
profile-editor.h \
terminal.c \
@@ -77,7 +85,8 @@ gnome_terminal_CFLAGS = \
gnome_terminal_LDFLAGS =
gnome_terminal_LDADD = \
- $(TERM_LIBS)
+ $(TERM_LIBS) \
+ theatrics/libtheatrics.la
if WITH_SMCLIENT
gnome_terminal_SOURCES += \
diff --git a/src/gedit-animatable.c b/src/gedit-animatable.c
new file mode 100644
index 0000000..d2aec96
--- /dev/null
+++ b/src/gedit-animatable.c
@@ -0,0 +1,103 @@
+/*
+ * gedit-animatable.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2011 - Ignacio Casal Quinteiro
+ *
+ * gedit is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * gedit 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "gedit-animatable.h"
+#include "theatrics/gedit-theatrics-choreographer.h"
+#include "theatrics/gedit-theatrics-enum-types.h"
+
+G_DEFINE_INTERFACE(GeditAnimatable, gedit_animatable, GTK_TYPE_WIDGET)
+
+void
+gedit_animatable_default_init (GeditAnimatableInterface *iface)
+{
+ static gboolean initialized = FALSE;
+
+ if (!initialized)
+ {
+ g_object_interface_install_property (iface,
+ g_param_spec_enum ("easing",
+ "Easing",
+ "The Easing",
+ GEDIT_TYPE_THEATRICS_CHOREOGRAPHER_EASING,
+ GEDIT_THEATRICS_CHOREOGRAPHER_EASING_LINEAR,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_enum ("blocking",
+ "Blocking",
+ "The Blocking",
+ GEDIT_TYPE_THEATRICS_CHOREOGRAPHER_BLOCKING,
+ GEDIT_THEATRICS_CHOREOGRAPHER_BLOCKING_DOWNSTAGE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_enum ("animation-state",
+ "Animation State",
+ "The Animation State",
+ GEDIT_TYPE_THEATRICS_ANIMATION_STATE,
+ GEDIT_THEATRICS_ANIMATION_STATE_COMING,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_uint ("duration",
+ "Duration",
+ "The duration",
+ 0,
+ G_MAXUINT,
+ 300,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_double ("percent",
+ "Percent",
+ "The percent",
+ 0.0,
+ G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_interface_install_property (iface,
+ g_param_spec_double ("bias",
+ "Bias",
+ "The bias",
+ 0.0,
+ G_MAXDOUBLE,
+ 1.0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ initialized = TRUE;
+ }
+}
+
+/* XXX: too lazy to add the methods, should we or can we survive only with props? */
+
+/* ex:set ts=8 noet: */
diff --git a/src/gedit-animatable.h b/src/gedit-animatable.h
new file mode 100644
index 0000000..e2e0a5a
--- /dev/null
+++ b/src/gedit-animatable.h
@@ -0,0 +1,57 @@
+/*
+ * gedit-animatable.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2011 - Ignacio Casal Quinteiro
+ *
+ * gedit is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * gedit 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GEDIT_ANIMATABLE_H__
+#define __GEDIT_ANIMATABLE_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GEDIT_TYPE_ANIMATABLE (gedit_animatable_get_type ())
+#define GEDIT_ANIMATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_ANIMATABLE, GeditAnimatable))
+#define GEDIT_ANIMATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GEDIT_TYPE_ANIMATABLE, GeditAnimatableInterface))
+#define GEDIT_IS_ANIMATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_ANIMATABLE))
+#define GEDIT_ANIMATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEDIT_TYPE_ANIMATABLE, GeditAnimatableInterface))
+
+typedef struct _GeditAnimatable GeditAnimatable; /* dummy typedef */
+typedef struct _GeditAnimatableInterface GeditAnimatableInterface;
+
+struct _GeditAnimatableInterface
+{
+ GTypeInterface g_iface;
+
+ /* Virtual public methods */
+};
+
+/*
+ * Public methods
+ */
+GType gedit_animatable_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GEDIT_ANIMATABLE_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/src/gedit-animated-overlay.c b/src/gedit-animated-overlay.c
new file mode 100644
index 0000000..173148d
--- /dev/null
+++ b/src/gedit-animated-overlay.c
@@ -0,0 +1,172 @@
+/*
+ * gedit-animated-overlay.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2011 - Ignacio Casal Quinteiro
+ *
+ * Based on Mike KrÃger <mkrueger novell com> work.
+ *
+ * gedit is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * gedit 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "gedit-animated-overlay.h"
+#include "theatrics/gedit-theatrics-stage.h"
+
+struct _GeditAnimatedOverlayPrivate
+{
+ GeditTheatricsStage *stage;
+};
+
+G_DEFINE_TYPE (GeditAnimatedOverlay, gedit_animated_overlay, GTK_TYPE_OVERLAY)
+
+static void
+gedit_animated_overlay_dispose (GObject *object)
+{
+ GeditAnimatedOverlayPrivate *priv = GEDIT_ANIMATED_OVERLAY (object)->priv;
+
+ g_clear_object (&priv->stage);
+
+ G_OBJECT_CLASS (gedit_animated_overlay_parent_class)->dispose (object);
+}
+
+static void
+gedit_animated_overlay_class_init (GeditAnimatedOverlayClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = gedit_animated_overlay_dispose;
+
+ g_type_class_add_private (object_class, sizeof (GeditAnimatedOverlayPrivate));
+}
+
+static void
+on_actor_step (GeditTheatricsStage *stage,
+ GeditTheatricsActor *actor,
+ GeditAnimatedOverlay *overlay)
+{
+ GeditTheatricsAnimationState animation_state;
+ GObject *anim_widget;
+ guint duration;
+
+ anim_widget = gedit_theatrics_actor_get_target (actor);
+ g_assert (GEDIT_IS_ANIMATABLE (anim_widget));
+
+ g_object_get (anim_widget, "animation-state", &animation_state,
+ "duration", &duration, NULL);
+
+ switch (animation_state)
+ {
+ case GEDIT_THEATRICS_ANIMATION_STATE_COMING:
+ gtk_widget_queue_draw (GTK_WIDGET (anim_widget));
+
+ g_object_set (anim_widget, "percent",
+ gedit_theatrics_actor_get_percent (actor),
+ NULL);
+
+ if (gedit_theatrics_actor_get_expired (actor))
+ {
+ g_object_set (anim_widget, "animation-state",
+ GEDIT_THEATRICS_ANIMATION_STATE_IDLE, NULL);
+ }
+ break;
+ case GEDIT_THEATRICS_ANIMATION_STATE_INTENDING_TO_GO:
+ g_object_set (anim_widget,
+ "animation-state", GEDIT_THEATRICS_ANIMATION_STATE_GOING,
+ "bias", gedit_theatrics_actor_get_percent (actor),
+ NULL);
+ gedit_theatrics_actor_reset (actor, duration * gedit_theatrics_actor_get_percent (actor));
+ break;
+ case GEDIT_THEATRICS_ANIMATION_STATE_GOING:
+ gtk_widget_queue_draw (GTK_WIDGET (anim_widget));
+
+ g_object_set (anim_widget, "percent",
+ 1.0 - gedit_theatrics_actor_get_percent (actor),
+ NULL);
+
+ if (gedit_theatrics_actor_get_expired (actor))
+ {
+ g_object_set (anim_widget, "animation-state",
+ GEDIT_THEATRICS_ANIMATION_STATE_IDLE, NULL);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+gedit_animated_overlay_init (GeditAnimatedOverlay *overlay)
+{
+ overlay->priv = G_TYPE_INSTANCE_GET_PRIVATE (overlay,
+ GEDIT_TYPE_ANIMATED_OVERLAY,
+ GeditAnimatedOverlayPrivate);
+
+ overlay->priv->stage = gedit_theatrics_stage_new ();
+
+ g_signal_connect (overlay->priv->stage,
+ "actor-step",
+ G_CALLBACK (on_actor_step),
+ overlay);
+}
+
+static void
+on_animation_state_changed (GeditAnimatable *animatable,
+ GParamSpec *pspec,
+ GeditAnimatedOverlay *overlay)
+{
+ GeditTheatricsAnimationState animation_state;
+ guint duration;
+
+ g_object_get (G_OBJECT (animatable),
+ "animation-state", &animation_state,
+ "duration", &duration, NULL);
+
+ if (animation_state == GEDIT_THEATRICS_ANIMATION_STATE_COMING ||
+ animation_state == GEDIT_THEATRICS_ANIMATION_STATE_INTENDING_TO_GO)
+ {
+ gedit_theatrics_stage_add_with_duration (overlay->priv->stage,
+ G_OBJECT (animatable),
+ duration);
+ }
+}
+
+/**
+ * gedit_animated_overlay_new:
+ *
+ * Creates a new #GeditAnimatedOverlay.
+ *
+ * Returns: a new #GeditAnimatedOverlay object.
+ */
+GtkWidget *
+gedit_animated_overlay_new (void)
+{
+ return g_object_new (GEDIT_TYPE_ANIMATED_OVERLAY, NULL);
+}
+
+void
+gedit_animated_overlay_add_animated_overlay (GeditAnimatedOverlay *overlay,
+ GeditAnimatable *animatable)
+{
+ g_return_if_fail (GEDIT_IS_ANIMATED_OVERLAY (overlay));
+ g_return_if_fail (GEDIT_IS_ANIMATABLE (animatable));
+
+ gtk_overlay_add_overlay (GTK_OVERLAY (overlay),
+ GTK_WIDGET (animatable));
+
+ g_signal_connect (animatable,
+ "notify::animation-state",
+ G_CALLBACK (on_animation_state_changed),
+ overlay);
+}
diff --git a/src/gedit-animated-overlay.h b/src/gedit-animated-overlay.h
new file mode 100644
index 0000000..748b074
--- /dev/null
+++ b/src/gedit-animated-overlay.h
@@ -0,0 +1,64 @@
+/*
+ * gedit-animated-overlay.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2011 - Ignacio Casal Quinteiro
+ *
+ * gedit is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * gedit 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GEDIT_ANIMATED_OVERLAY_H__
+#define __GEDIT_ANIMATED_OVERLAY_H__
+
+#include <gtk/gtk.h>
+#include "gedit-animatable.h"
+#include "theatrics/gedit-theatrics-choreographer.h"
+
+G_BEGIN_DECLS
+
+#define GEDIT_TYPE_ANIMATED_OVERLAY (gedit_animated_overlay_get_type ())
+#define GEDIT_ANIMATED_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_ANIMATED_OVERLAY, GeditAnimatedOverlay))
+#define GEDIT_ANIMATED_OVERLAY_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_ANIMATED_OVERLAY, GeditAnimatedOverlay const))
+#define GEDIT_ANIMATED_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_ANIMATED_OVERLAY, GeditAnimatedOverlayClass))
+#define GEDIT_IS_ANIMATED_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_ANIMATED_OVERLAY))
+#define GEDIT_IS_ANIMATED_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_ANIMATED_OVERLAY))
+#define GEDIT_ANIMATED_OVERLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_ANIMATED_OVERLAY, GeditAnimatedOverlayClass))
+
+typedef struct _GeditAnimatedOverlay GeditAnimatedOverlay;
+typedef struct _GeditAnimatedOverlayClass GeditAnimatedOverlayClass;
+typedef struct _GeditAnimatedOverlayPrivate GeditAnimatedOverlayPrivate;
+
+struct _GeditAnimatedOverlay
+{
+ GtkOverlay parent;
+
+ GeditAnimatedOverlayPrivate *priv;
+};
+
+struct _GeditAnimatedOverlayClass
+{
+ GtkOverlayClass parent_class;
+};
+
+GType gedit_animated_overlay_get_type (void) G_GNUC_CONST;
+
+GtkWidget *gedit_animated_overlay_new (void);
+
+void gedit_animated_overlay_add_animated_overlay (GeditAnimatedOverlay *overlay,
+ GeditAnimatable *animatable);
+
+G_END_DECLS
+
+#endif /* __GEDIT_ANIMATED_OVERLAY_H__ */
diff --git a/src/gedit-floating-slider.c b/src/gedit-floating-slider.c
new file mode 100644
index 0000000..ba2eeb3
--- /dev/null
+++ b/src/gedit-floating-slider.c
@@ -0,0 +1,396 @@
+/*
+ * gedit-floating-slider.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Ignacio Casal Quinteiro
+ *
+ * Based on Scott Peterson <lunchtimemama gmail com> work.
+ *
+ * gedit 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit 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 gedit; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include "gedit-floating-slider.h"
+#include "gedit-animatable.h"
+
+struct _GeditFloatingSliderPrivate
+{
+ GtkAllocation widget_alloc;
+ GtkAllocation child_alloc;
+ GeditTheatricsChoreographerEasing easing;
+ GeditTheatricsChoreographerBlocking blocking;
+ GeditTheatricsAnimationState animation_state;
+ GtkOrientation orientation;
+ guint duration;
+ gdouble bias;
+ gdouble percent;
+};
+
+struct _GeditFloatingSliderClassPrivate
+{
+ GtkCssProvider *css;
+};
+
+enum
+{
+ PROP_0,
+ PROP_EASING,
+ PROP_BLOCKING,
+ PROP_ANIMATION_STATE,
+ PROP_DURATION,
+ PROP_PERCENT,
+ PROP_BIAS,
+ PROP_ORIENTATION
+};
+
+G_DEFINE_TYPE_WITH_CODE (GeditFloatingSlider, gedit_floating_slider, GTK_TYPE_BIN,
+ g_type_add_class_private (g_define_type_id, sizeof (GeditFloatingSliderClassPrivate));
+ G_IMPLEMENT_INTERFACE (GEDIT_TYPE_ANIMATABLE,
+ NULL)
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE,
+ NULL))
+
+static void
+gedit_floating_slider_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gedit_floating_slider_parent_class)->finalize (object);
+}
+
+static void
+gedit_floating_slider_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GeditFloatingSliderPrivate *priv = GEDIT_FLOATING_SLIDER (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_EASING:
+ g_value_set_enum (value, priv->easing);
+ break;
+ case PROP_BLOCKING:
+ g_value_set_enum (value, priv->blocking);
+ break;
+ case PROP_ANIMATION_STATE:
+ g_value_set_enum (value, priv->animation_state);
+ break;
+ case PROP_DURATION:
+ g_value_set_uint (value, priv->duration);
+ break;
+ case PROP_PERCENT:
+ g_value_set_double (value, priv->percent);
+ break;
+ case PROP_BIAS:
+ g_value_set_double (value, priv->bias);
+ break;
+ case PROP_ORIENTATION:
+ g_value_set_enum (value, priv->orientation);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gedit_floating_slider_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GeditFloatingSliderPrivate *priv = GEDIT_FLOATING_SLIDER (object)->priv;
+
+ switch (prop_id)
+ {
+ case PROP_EASING:
+ priv->easing = g_value_get_enum (value);
+ break;
+ case PROP_BLOCKING:
+ priv->blocking = g_value_get_enum (value);
+ break;
+ case PROP_ANIMATION_STATE:
+ priv->animation_state = g_value_get_enum (value);
+ break;
+ case PROP_DURATION:
+ priv->duration = g_value_get_uint (value);
+ break;
+ case PROP_PERCENT:
+ priv->percent = g_value_get_double (value);
+ gtk_widget_queue_resize_no_redraw (GTK_WIDGET (object));
+
+ /* Make the widget visibility automagic */
+ if (priv->percent > 0 && !gtk_widget_get_visible (GTK_WIDGET (object)))
+ {
+ gtk_widget_show (GTK_WIDGET (object));
+ }
+ else if (priv->percent == 0 && gtk_widget_get_visible (GTK_WIDGET (object)))
+ {
+ gtk_widget_hide (GTK_WIDGET (object));
+ }
+ break;
+ case PROP_BIAS:
+ priv->bias = g_value_get_double (value);
+ break;
+ case PROP_ORIENTATION:
+ priv->orientation = g_value_get_enum (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gedit_floating_slider_get_preferred_width (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ GeditFloatingSliderPrivate *priv = GEDIT_FLOATING_SLIDER (widget)->priv;
+ GtkWidget *child;
+ gint width;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+
+ if (child != NULL)
+ {
+ GtkStyleContext *context;
+ GtkBorder padding;
+ gint child_min, child_nat;
+
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
+
+ priv->child_alloc.width = child_nat;
+
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL,
+ &padding);
+
+ priv->widget_alloc.width = child_nat + padding.left + padding.right;
+ }
+
+
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ width = gedit_theatrics_choreographer_pixel_compose (priv->percent,
+ priv->widget_alloc.width,
+ priv->easing);
+ }
+ else
+ {
+ width = priv->widget_alloc.width;
+ }
+
+ *minimum = *natural = width;
+}
+
+static void
+gedit_floating_slider_get_preferred_height (GtkWidget *widget,
+ gint *minimum,
+ gint *natural)
+{
+ GeditFloatingSliderPrivate *priv = GEDIT_FLOATING_SLIDER (widget)->priv;
+ GtkWidget *child;
+ gint height;
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+
+ if (child != NULL)
+ {
+ GtkStyleContext *context;
+ GtkBorder padding;
+ gint child_min, child_nat;
+
+ gtk_widget_get_preferred_height (child, &child_min, &child_nat);
+
+ priv->child_alloc.height = child_nat;
+
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL,
+ &padding);
+
+ priv->widget_alloc.height = child_nat + padding.top + padding.bottom;
+ }
+
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ height = priv->widget_alloc.height;
+ }
+ else
+ {
+ height = gedit_theatrics_choreographer_pixel_compose (priv->percent,
+ priv->widget_alloc.height,
+ priv->easing);
+ }
+
+ *minimum = *natural = height;
+}
+
+static void
+gedit_floating_slider_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ GeditFloatingSliderPrivate *priv = GEDIT_FLOATING_SLIDER (widget)->priv;
+ GtkWidget *child;
+
+ GTK_WIDGET_CLASS (gedit_floating_slider_parent_class)->size_allocate (widget, allocation);
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
+
+ if (child != NULL)
+ {
+ GtkStyleContext *context;
+ GtkBorder padding;
+ GtkAllocation child_alloc;
+
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL,
+ &padding);
+
+ child_alloc = priv->child_alloc;
+
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ child_alloc.y = padding.top;
+ child_alloc.x = padding.left;
+
+ if (priv->blocking == GEDIT_THEATRICS_CHOREOGRAPHER_BLOCKING_DOWNSTAGE)
+ {
+ child_alloc.x = allocation->width - priv->child_alloc.width - padding.right;
+ }
+ }
+ else
+ {
+ child_alloc.y = padding.top;
+ child_alloc.x = padding.left;
+
+ if (priv->blocking == GEDIT_THEATRICS_CHOREOGRAPHER_BLOCKING_DOWNSTAGE)
+ {
+ child_alloc.y = allocation->height - priv->child_alloc.height - padding.bottom;
+ }
+ }
+
+ if (child_alloc.height > 0 && child_alloc.width > 0)
+ {
+ gtk_widget_size_allocate (child, &child_alloc);
+ }
+ }
+}
+
+static gboolean
+gedit_floating_slider_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GtkStyleContext *context;
+
+ context = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context,
+ gtk_widget_get_state_flags (widget));
+
+ gtk_render_background (context, cr, 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+
+ gtk_render_frame (context, cr, 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+
+ gtk_style_context_restore (context);
+
+ return GTK_WIDGET_CLASS (gedit_floating_slider_parent_class)->draw (widget, cr);
+}
+
+static void
+gedit_floating_slider_class_init (GeditFloatingSliderClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ static const gchar style[] =
+ "* {"
+ "background-color: @theme_base_color;\n"
+
+ "padding: 6px;\n"
+ "border-color: shade (@notebook_tab_gradient_b, 0.80);\n"
+
+ "border-radius: 0 0 3px 3px;\n"
+ "border-width: 0 1px 1px 1px;\n"
+ "border-style: solid;\n"
+ "}";
+
+ object_class->finalize = gedit_floating_slider_finalize;
+ object_class->get_property = gedit_floating_slider_get_property;
+ object_class->set_property = gedit_floating_slider_set_property;
+
+ widget_class->get_preferred_width = gedit_floating_slider_get_preferred_width;
+ widget_class->get_preferred_height = gedit_floating_slider_get_preferred_height;
+ widget_class->size_allocate = gedit_floating_slider_size_allocate;
+ widget_class->draw = gedit_floating_slider_draw;
+
+ g_object_class_override_property (object_class, PROP_EASING,
+ "easing");
+
+ g_object_class_override_property (object_class, PROP_BLOCKING,
+ "blocking");
+
+ g_object_class_override_property (object_class, PROP_ANIMATION_STATE,
+ "animation-state");
+
+ g_object_class_override_property (object_class, PROP_DURATION,
+ "duration");
+
+ g_object_class_override_property (object_class, PROP_PERCENT,
+ "percent");
+
+ g_object_class_override_property (object_class, PROP_BIAS,
+ "bias");
+
+ g_object_class_override_property (object_class, PROP_ORIENTATION,
+ "orientation");
+
+ g_type_class_add_private (object_class, sizeof (GeditFloatingSliderPrivate));
+
+ klass->priv = G_TYPE_CLASS_GET_PRIVATE (klass, GEDIT_TYPE_FLOATING_SLIDER,
+ GeditFloatingSliderClassPrivate);
+
+ klass->priv->css = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (klass->priv->css, style, -1, NULL);
+}
+
+static void
+gedit_floating_slider_init (GeditFloatingSlider *slider)
+{
+ GtkStyleContext *context;
+
+ slider->priv = G_TYPE_INSTANCE_GET_PRIVATE (slider,
+ GEDIT_TYPE_FLOATING_SLIDER,
+ GeditFloatingSliderPrivate);
+
+ slider->priv->orientation = GTK_ORIENTATION_VERTICAL;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (slider));
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (GEDIT_FLOATING_SLIDER_GET_CLASS (slider)->priv->css),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+}
+
+GtkWidget *
+gedit_floating_slider_new (void)
+{
+ return g_object_new (GEDIT_TYPE_FLOATING_SLIDER, NULL);
+}
+
+/* ex:set ts=8 noet: */
diff --git a/src/gedit-floating-slider.h b/src/gedit-floating-slider.h
new file mode 100644
index 0000000..3da4e65
--- /dev/null
+++ b/src/gedit-floating-slider.h
@@ -0,0 +1,67 @@
+/*
+ * gedit-floating-slider.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Ignacio Casal Quinteiro
+ *
+ * Based on Scott Peterson <lunchtimemama gmail com> work.
+ *
+ * gedit 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit 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 gedit; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GEDIT_FLOATING_SLIDER_H__
+#define __GEDIT_FLOATING_SLIDER_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include "theatrics/gedit-theatrics-choreographer.h"
+
+G_BEGIN_DECLS
+
+#define GEDIT_TYPE_FLOATING_SLIDER (gedit_floating_slider_get_type ())
+#define GEDIT_FLOATING_SLIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_FLOATING_SLIDER, GeditFloatingSlider))
+#define GEDIT_FLOATING_SLIDER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_FLOATING_SLIDER, GeditFloatingSlider const))
+#define GEDIT_FLOATING_SLIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_FLOATING_SLIDER, GeditFloatingSliderClass))
+#define GEDIT_IS_FLOATING_SLIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_FLOATING_SLIDER))
+#define GEDIT_IS_FLOATING_SLIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_FLOATING_SLIDER))
+#define GEDIT_FLOATING_SLIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_FLOATING_SLIDER, GeditFloatingSliderClass))
+
+typedef struct _GeditFloatingSlider GeditFloatingSlider;
+typedef struct _GeditFloatingSliderClass GeditFloatingSliderClass;
+typedef struct _GeditFloatingSliderPrivate GeditFloatingSliderPrivate;
+typedef struct _GeditFloatingSliderClassPrivate GeditFloatingSliderClassPrivate;
+
+struct _GeditFloatingSlider
+{
+ GtkBin parent;
+
+ GeditFloatingSliderPrivate *priv;
+};
+
+struct _GeditFloatingSliderClass
+{
+ GtkBinClass parent_class;
+
+ GeditFloatingSliderClassPrivate *priv;
+};
+
+GType gedit_floating_slider_get_type (void) G_GNUC_CONST;
+
+GtkWidget *gedit_floating_slider_new (void);
+
+G_END_DECLS
+
+#endif /* __GEDIT_FLOATING_SLIDER_H__ */
diff --git a/src/terminal-screen-container.c b/src/terminal-screen-container.c
index 2781b59..44c3d84 100644
--- a/src/terminal-screen-container.c
+++ b/src/terminal-screen-container.c
@@ -22,13 +22,23 @@
#include "terminal-screen-container.h"
#include "terminal-debug.h"
#include "terminal-intl.h"
+#include "gedit-animated-overlay.h"
+#include "gedit-floating-slider.h"
#include <gtk/gtk.h>
+#define SEARCH_POPUP_MARGIN 20
+
#define TERMINAL_SCREEN_CONTAINER_GET_PRIVATE(screen_container)(G_TYPE_INSTANCE_GET_PRIVATE ((screen_container), TERMINAL_TYPE_SCREEN_CONTAINER, TerminalScreenContainerPrivate))
struct _TerminalScreenContainerPrivate
{
+ GtkWidget *overlay;
+ GtkWidget *slider;
+ GtkWidget *search_entry;
+ GtkWidget *go_up_button;
+ GtkWidget *go_down_button;
+
TerminalScreen *screen;
#ifdef USE_SCROLLED_WINDOW
GtkWidget *scrolled_window;
@@ -141,6 +151,9 @@ terminal_screen_container_constructor (GType type,
g_assert (priv->screen != NULL);
+ priv->overlay = gedit_animated_overlay_new ();
+ gtk_widget_show (priv->overlay);
+
#ifdef USE_SCROLLED_WINDOW
#if GTK_CHECK_VERSION (2, 91, 2)
priv->scrolled_window = gtk_scrolled_window_new (gtk_scrollable_get_hadjustment(GTK_SCROLLABLE(priv->screen)),
@@ -156,9 +169,10 @@ terminal_screen_container_constructor (GType type,
GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (priv->scrolled_window), GTK_WIDGET (priv->screen));
gtk_widget_show (GTK_WIDGET (priv->screen));
- gtk_box_pack_end (GTK_BOX (container), priv->scrolled_window, TRUE, TRUE, 0);
gtk_widget_show (priv->scrolled_window);
+ gtk_container_add (GTK_CONTAINER (priv->overlay), priv->scrolled_window);
+
#ifdef GNOME_ENABLE_DEBUG
g_signal_connect (priv->scrolled_window, "size-request", G_CALLBACK (size_request_cb), container);
#endif
@@ -176,12 +190,34 @@ terminal_screen_container_constructor (GType type,
gtk_box_pack_start (GTK_BOX (priv->hbox), GTK_WIDGET (priv->screen), TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (priv->hbox), priv->vscrollbar, FALSE, FALSE, 0);
- gtk_box_pack_end (GTK_BOX (container), priv->hbox, TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (priv->overlay), priv->hbox);
gtk_widget_show_all (priv->hbox);
#endif /* USE_SCROLLED_WINDOW */
+ gtk_box_pack_end (GTK_BOX (container), priv->overlay, TRUE, TRUE, 0);
+
_terminal_screen_update_scrollbar (priv->screen);
+ /* Add slider */
+ priv->slider = gedit_floating_slider_new ();
+ gtk_widget_set_name (priv->slider, "search-slider");
+ gtk_widget_set_halign (priv->slider, GTK_ALIGN_END);
+ gtk_widget_set_valign (priv->slider, GTK_ALIGN_START);
+
+ if (gtk_widget_get_direction (priv->slider) == GTK_TEXT_DIR_LTR)
+ gtk_widget_set_margin_right (priv->slider, SEARCH_POPUP_MARGIN);
+ else
+ gtk_widget_set_margin_left (priv->slider, SEARCH_POPUP_MARGIN);
+
+ g_object_set (G_OBJECT (priv->slider),
+ "easing", GEDIT_THEATRICS_CHOREOGRAPHER_EASING_EXPONENTIAL_IN_OUT,
+ "blocking", GEDIT_THEATRICS_CHOREOGRAPHER_BLOCKING_DOWNSTAGE,
+ "orientation", GTK_ORIENTATION_VERTICAL,
+ NULL);
+
+ gedit_animated_overlay_add_animated_overlay (GEDIT_ANIMATED_OVERLAY (priv->overlay),
+ GEDIT_ANIMATABLE (priv->slider));
+
return object;
}
@@ -305,6 +341,75 @@ terminal_screen_container_class_init (TerminalScreenContainerClass *klass)
G_PARAM_STATIC_STRINGS));
}
+static GtkWidget *
+create_button_from_symbolic (const gchar *icon_name)
+{
+ GtkWidget *button;
+
+ button = gtk_button_new ();
+ gtk_widget_set_can_focus (button, FALSE);
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_icon_name (icon_name,
+ GTK_ICON_SIZE_MENU));
+
+ return button;
+}
+
+static GtkWidget *
+create_search_widget (TerminalScreenContainer *container)
+{
+ TerminalScreenContainerPrivate *priv = container->priv;
+ GtkWidget *search_widget;
+ GtkStyleContext *context;
+
+ search_widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+ context = gtk_widget_get_style_context (search_widget);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED);
+
+ gtk_widget_show (search_widget);
+
+ /* add entry */
+ priv->search_entry = gtk_entry_new ();
+ gtk_widget_show (priv->search_entry);
+
+ gtk_entry_set_width_chars (GTK_ENTRY (priv->search_entry), 25);
+
+ /*g_signal_connect (frame->priv->search_entry, "populate-popup",
+ G_CALLBACK (search_entry_populate_popup),
+ frame);
+ g_signal_connect (frame->priv->search_entry, "icon-release",
+ G_CALLBACK (search_entry_icon_release),
+ frame);
+ g_signal_connect (priv->search_entry, "activate",
+ G_CALLBACK (search_entry_activate),
+ container);*/
+
+ gtk_container_add (GTK_CONTAINER (search_widget),
+ priv->search_entry);
+
+ /* Up/Down buttons */
+ priv->go_up_button = create_button_from_symbolic ("go-up-symbolic");
+ gtk_widget_show (priv->go_up_button);
+ gtk_box_pack_start (GTK_BOX (search_widget), priv->go_up_button,
+ FALSE, FALSE, 0);
+ /*g_signal_connect (frame->priv->go_up_button,
+ "clicked",
+ G_CALLBACK (on_go_up_button_clicked),
+ frame);*/
+
+ priv->go_down_button = create_button_from_symbolic ("go-down-symbolic");
+ gtk_widget_show (priv->go_down_button);
+ gtk_box_pack_start (GTK_BOX (search_widget), priv->go_down_button,
+ FALSE, FALSE, 0);
+ /*g_signal_connect (frame->priv->go_down_button,
+ "clicked",
+ G_CALLBACK (on_go_down_button_clicked),
+ frame);*/
+
+ return search_widget;
+}
+
/* public API */
/**
@@ -416,3 +521,22 @@ terminal_screen_container_set_placement (TerminalScreenContainer *container,
terminal_screen_container_set_placement_internal (container, corner);
terminal_screen_container_set_placement_set (container, TRUE);
}
+
+void
+terminal_screen_container_present_search (TerminalScreenContainer *container)
+{
+ TerminalScreenContainerPrivate *priv;
+
+ g_return_if_fail (TERMINAL_IS_SCREEN_CONTAINER (container));
+
+ priv = container->priv;
+
+ if (gtk_bin_get_child (GTK_BIN (priv->slider)) == NULL)
+ gtk_container_add (GTK_CONTAINER (priv->slider),
+ create_search_widget (container));
+
+ /* To slide in we set the right animation state in the animatable */
+ g_object_set (G_OBJECT (priv->slider),
+ "animation-state", GEDIT_THEATRICS_ANIMATION_STATE_COMING,
+ NULL);
+}
diff --git a/src/terminal-screen-container.h b/src/terminal-screen-container.h
index 31e4859..710b371 100644
--- a/src/terminal-screen-container.h
+++ b/src/terminal-screen-container.h
@@ -64,6 +64,8 @@ void terminal_screen_container_set_policy (TerminalScreenContainer *container,
void terminal_screen_container_set_placement (TerminalScreenContainer *container,
GtkCornerType corner);
+void terminal_screen_container_present_search (TerminalScreenContainer *container);
+
G_END_DECLS
#endif /* TERMINAL_SCREEN_CONTAINER_H */
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 3eb7d88..33c4867 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -3737,21 +3737,13 @@ search_find_callback (GtkAction *action,
TerminalWindow *window)
{
TerminalWindowPrivate *priv = window->priv;
+ GtkWidget *container;
+ gint page_num;
- if (!priv->search_find_dialog) {
- GtkWidget *dialog;
-
- dialog = priv->search_find_dialog = terminal_search_dialog_new (GTK_WINDOW (window));
-
- g_signal_connect (dialog, "destroy",
- G_CALLBACK (gtk_widget_destroyed), &priv->search_find_dialog);
- g_signal_connect (dialog, "response",
- G_CALLBACK (search_find_response_callback), window);
- g_signal_connect (dialog, "delete-event",
- G_CALLBACK (search_dialog_delete_event_cb), NULL);
- }
+ page_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook));
+ container = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), page_num);
- terminal_search_dialog_present (priv->search_find_dialog);
+ terminal_screen_container_present_search (TERMINAL_SCREEN_CONTAINER (container));
}
static void
diff --git a/src/theatrics/Makefile.am b/src/theatrics/Makefile.am
new file mode 100644
index 0000000..201479a
--- /dev/null
+++ b/src/theatrics/Makefile.am
@@ -0,0 +1,52 @@
+INCLUDES = \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ -I$(top_srcdir)/gedit \
+ -I$(top_builddir)/gedit \
+ $(GEDIT_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED_CFLAGS)
+
+noinst_LTLIBRARIES = libtheatrics.la
+
+BUILT_SOURCES = \
+ gedit-theatrics-enum-types.h \
+ gedit-theatrics-enum-types.c \
+ gedit-theatrics-marshal.h \
+ gedit-theatrics-marshal.c
+
+libtheatrics_la_SOURCES = \
+ gedit-theatrics-actor.h \
+ gedit-theatrics-actor.c \
+ gedit-theatrics-choreographer.h \
+ gedit-theatrics-choreographer.c \
+ gedit-theatrics-stage.h \
+ gedit-theatrics-stage.c \
+ gedit-theatrics-utils.h \
+ gedit-theatrics-utils.c \
+ $(BUILT_SOURCES)
+
+ENUM_TYPES = \
+ gedit-theatrics-choreographer.h
+
+gedit-theatrics-enum-types.h: gedit-theatrics-enum-types.h.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template gedit-theatrics-enum-types.h.template $(ENUM_TYPES)) > $@
+
+gedit-theatrics-enum-types.c: gedit-theatrics-enum-types.c.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template gedit-theatrics-enum-types.c.template $(ENUM_TYPES)) > $@
+
+gedit-theatrics-marshal.h: gedit-theatrics-marshal.list $(GLIB_GENMARSHAL)
+ $(AM_V_GEN) $(GLIB_GENMARSHAL) $< --header --prefix=gedit_theatrics_marshal > $@
+
+gedit-theatrics-marshal.c: gedit-theatrics-marshal.list $(GLIB_GENMARSHAL)
+ $(AM_V_GEN) echo "#include \"gedit-theatrics-marshal.h\"" > $@ && \
+ $(GLIB_GENMARSHAL) $< --body --prefix=gedit_theatrics_marshal >> $@
+
+EXTRA_DIST = \
+ gedit-theatrics-marshal.list \
+ gedit-theatrics-enum-types.h.template \
+ gedit-theatrics-enum-types.c.template
+
+CLEANFILES = $(BUILT_SOURCES)
+
+-include $(top_srcdir)/git.mk
diff --git a/src/theatrics/gedit-theatrics-actor.c b/src/theatrics/gedit-theatrics-actor.c
new file mode 100644
index 0000000..9ef4ebc
--- /dev/null
+++ b/src/theatrics/gedit-theatrics-actor.c
@@ -0,0 +1,279 @@
+/*
+ * gedit-theatrics-actor.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Ignacio Casal Quinteiro
+ *
+ * Based on Aaron Bockover <abockover novell com> work.
+ *
+ * gedit 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit 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 gedit; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include "gedit-theatrics-actor.h"
+
+
+#define GEDIT_THEATRICS_ACTOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GEDIT_TYPE_THEATRICS_ACTOR, GeditTheatricsActorPrivate))
+
+struct _GeditTheatricsActorPrivate
+{
+ GObject *target;
+
+ guint duration;
+ gdouble frames;
+ gdouble percent;
+
+ GTimeVal start_time;
+
+ guint can_expire : 1;
+};
+
+enum
+{
+ PROP_0,
+ PROP_TARGET,
+ PROP_DURATION
+};
+
+G_DEFINE_TYPE (GeditTheatricsActor, gedit_theatrics_actor, G_TYPE_OBJECT)
+
+static void
+gedit_theatrics_actor_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gedit_theatrics_actor_parent_class)->finalize (object);
+}
+
+static void
+gedit_theatrics_actor_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GeditTheatricsActor *actor = GEDIT_THEATRICS_ACTOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_TARGET:
+ g_value_set_object (value, actor->priv->target);
+ break;
+ case PROP_DURATION:
+ g_value_set_uint (value, actor->priv->duration);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gedit_theatrics_actor_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GeditTheatricsActor *actor = GEDIT_THEATRICS_ACTOR (object);
+
+ switch (prop_id)
+ {
+ case PROP_TARGET:
+ {
+ GObject *target;
+
+ target = g_value_get_object (value);
+
+ if (target != NULL)
+ {
+ actor->priv->target = target;
+ }
+
+ break;
+ }
+ case PROP_DURATION:
+ actor->priv->duration = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gedit_theatrics_actor_class_init (GeditTheatricsActorClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = gedit_theatrics_actor_finalize;
+ object_class->get_property = gedit_theatrics_actor_get_property;
+ object_class->set_property = gedit_theatrics_actor_set_property;
+
+ g_object_class_install_property (object_class, PROP_TARGET,
+ g_param_spec_object ("target",
+ "Target",
+ "The Target",
+ G_TYPE_OBJECT,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (object_class, PROP_DURATION,
+ g_param_spec_uint ("duration",
+ "Duration",
+ "The duration",
+ 0,
+ G_MAXUINT,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_type_class_add_private (object_class, sizeof (GeditTheatricsActorPrivate));
+}
+
+static void
+gedit_theatrics_actor_init (GeditTheatricsActor *actor)
+{
+ actor->priv = GEDIT_THEATRICS_ACTOR_GET_PRIVATE (actor);
+
+ actor->priv->can_expire = TRUE;
+
+ gedit_theatrics_actor_reset (actor, actor->priv->duration);
+}
+
+GeditTheatricsActor *
+gedit_theatrics_actor_new (GObject *target,
+ guint duration)
+{
+ return g_object_new (GEDIT_TYPE_THEATRICS_ACTOR,
+ "target", target,
+ "duration", duration,
+ NULL);
+}
+
+/* Use duration = -1 to not set a new duration */
+void
+gedit_theatrics_actor_reset (GeditTheatricsActor *actor,
+ guint duration)
+{
+ g_return_if_fail (GEDIT_IS_THEATRICS_ACTOR (actor));
+
+ g_get_current_time (&actor->priv->start_time);
+ actor->priv->frames = 0.0;
+ actor->priv->percent = 0.0;
+
+ if (duration > -1)
+ {
+ actor->priv->duration = duration;
+ }
+}
+
+void
+gedit_theatrics_actor_step (GeditTheatricsActor *actor)
+{
+ GTimeVal now;
+ gdouble now_num, start_time;
+
+ g_return_if_fail (GEDIT_IS_THEATRICS_ACTOR (actor));
+
+ if (!actor->priv->can_expire && actor->priv->percent >= 1.0)
+ {
+ gedit_theatrics_actor_reset (actor, actor->priv->duration);
+ }
+
+ g_get_current_time (&now);
+
+ now_num = now.tv_sec * 1000 + now.tv_usec / 1000;
+ start_time = actor->priv->start_time.tv_sec * 1000 + actor->priv->start_time.tv_usec / 1000;
+
+ actor->priv->percent = ((now_num - start_time) / actor->priv->duration);
+
+ actor->priv->frames++;
+}
+
+GObject *
+gedit_theatrics_actor_get_target (GeditTheatricsActor *actor)
+{
+ g_return_val_if_fail (GEDIT_IS_THEATRICS_ACTOR (actor), NULL);
+
+ return actor->priv->target;
+}
+
+gboolean
+gedit_theatrics_actor_get_expired (GeditTheatricsActor *actor)
+{
+ g_return_val_if_fail (GEDIT_IS_THEATRICS_ACTOR (actor), FALSE);
+
+ return (actor->priv->can_expire && actor->priv->percent >= 1.0);
+}
+
+gboolean
+gedit_theatrics_actor_get_can_expire (GeditTheatricsActor *actor)
+{
+ g_return_val_if_fail (GEDIT_IS_THEATRICS_ACTOR (actor), FALSE);
+
+ return actor->priv->can_expire;
+}
+
+void
+gedit_theatrics_actor_set_can_expire (GeditTheatricsActor *actor,
+ gboolean can_expire)
+{
+ g_return_if_fail (GEDIT_IS_THEATRICS_ACTOR (actor));
+
+ actor->priv->can_expire = can_expire;
+}
+
+guint
+gedit_theatrics_actor_get_duration (GeditTheatricsActor *actor)
+{
+ g_return_val_if_fail (GEDIT_IS_THEATRICS_ACTOR (actor), 0.0);
+
+ return actor->priv->duration;
+}
+
+GTimeVal
+gedit_theatrics_actor_get_start_time (GeditTheatricsActor *actor)
+{
+ GTimeVal r = {0, };
+
+ g_return_val_if_fail (GEDIT_IS_THEATRICS_ACTOR (actor), r);
+
+ return actor->priv->start_time;
+}
+
+gdouble
+gedit_theatrics_actor_get_frames (GeditTheatricsActor *actor)
+{
+ g_return_val_if_fail (GEDIT_IS_THEATRICS_ACTOR (actor), 0.0);
+
+ return actor->priv->frames;
+}
+
+gdouble
+gedit_theatrics_actor_get_frames_per_second (GeditTheatricsActor *actor)
+{
+ g_return_val_if_fail (GEDIT_IS_THEATRICS_ACTOR (actor), 0.0);
+
+ return (actor->priv->frames / (actor->priv->duration / 1000.0));
+}
+
+gdouble
+gedit_theatrics_actor_get_percent (GeditTheatricsActor *actor)
+{
+ g_return_val_if_fail (GEDIT_IS_THEATRICS_ACTOR (actor), 0.0);
+
+ return MAX (0.0, MIN (1.0, actor->priv->percent));
+}
+
+/* ex:set ts=8 noet: */
diff --git a/src/theatrics/gedit-theatrics-actor.h b/src/theatrics/gedit-theatrics-actor.h
new file mode 100644
index 0000000..c5f2f83
--- /dev/null
+++ b/src/theatrics/gedit-theatrics-actor.h
@@ -0,0 +1,90 @@
+/*
+ * gedit-theatrics-actor.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Ignacio Casal Quinteiro
+ *
+ * Based on Aaron Bockover <abockover novell com> work.
+ *
+ * gedit 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit 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 gedit; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GEDIT_THEATRICS_ACTOR_H__
+#define __GEDIT_THEATRICS_ACTOR_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GEDIT_TYPE_THEATRICS_ACTOR (gedit_theatrics_actor_get_type ())
+#define GEDIT_THEATRICS_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_THEATRICS_ACTOR, GeditTheatricsActor))
+#define GEDIT_THEATRICS_ACTOR_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_THEATRICS_ACTOR, GeditTheatricsActor const))
+#define GEDIT_THEATRICS_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_THEATRICS_ACTOR, GeditTheatricsActorClass))
+#define GEDIT_IS_THEATRICS_ACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_THEATRICS_ACTOR))
+#define GEDIT_IS_THEATRICS_ACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_THEATRICS_ACTOR))
+#define GEDIT_THEATRICS_ACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_THEATRICS_ACTOR, GeditTheatricsActorClass))
+
+typedef struct _GeditTheatricsActor GeditTheatricsActor;
+typedef struct _GeditTheatricsActorClass GeditTheatricsActorClass;
+typedef struct _GeditTheatricsActorPrivate GeditTheatricsActorPrivate;
+
+struct _GeditTheatricsActor
+{
+ GObject parent;
+
+ GeditTheatricsActorPrivate *priv;
+};
+
+struct _GeditTheatricsActorClass
+{
+ GObjectClass parent_class;
+};
+
+GType gedit_theatrics_actor_get_type (void) G_GNUC_CONST;
+
+GeditTheatricsActor *gedit_theatrics_actor_new (GObject *target,
+ guint duration);
+
+void gedit_theatrics_actor_reset (GeditTheatricsActor *actor,
+ guint duration);
+
+void gedit_theatrics_actor_step (GeditTheatricsActor *actor);
+
+GObject *gedit_theatrics_actor_get_target (GeditTheatricsActor *actor);
+
+gboolean gedit_theatrics_actor_get_expired (GeditTheatricsActor *actor);
+
+gboolean gedit_theatrics_actor_get_can_expire (GeditTheatricsActor *actor);
+
+void gedit_theatrics_actor_set_can_expire (GeditTheatricsActor *actor,
+ gboolean can_expire);
+
+guint gedit_theatrics_actor_get_duration (GeditTheatricsActor *actor);
+
+GTimeVal gedit_theatrics_actor_get_start_time (GeditTheatricsActor *actor);
+
+gdouble gedit_theatrics_actor_get_frames (GeditTheatricsActor *actor);
+
+gdouble gedit_theatrics_actor_get_frames_per_second
+ (GeditTheatricsActor *actor);
+
+gdouble gedit_theatrics_actor_get_percent (GeditTheatricsActor *actor);
+
+G_END_DECLS
+
+#endif /* __GEDIT_THEATRICS_ACTOR_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/src/theatrics/gedit-theatrics-choreographer.c b/src/theatrics/gedit-theatrics-choreographer.c
new file mode 100644
index 0000000..02525f4
--- /dev/null
+++ b/src/theatrics/gedit-theatrics-choreographer.c
@@ -0,0 +1,85 @@
+/*
+ * gedit-theatrics-choreographer.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Ignacio Casal Quinteiro
+ *
+ * Based on Scott Peterson <lunchtimemama gmail com> work.
+ *
+ * gedit 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit 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 gedit; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include <math.h>
+#include "gedit-theatrics-choreographer.h"
+
+gint
+gedit_theatrics_choreographer_pixel_compose (gdouble percent,
+ gint size,
+ GeditTheatricsChoreographerEasing easing)
+{
+ return (gint)round (gedit_theatrics_choreographer_compose_with_scale (percent, size, easing));
+}
+
+gdouble
+gedit_theatrics_choreographer_compose_with_scale (gdouble percent,
+ gdouble scale,
+ GeditTheatricsChoreographerEasing easing)
+{
+ return scale * gedit_theatrics_choreographer_compose (percent, easing);
+}
+
+gdouble
+gedit_theatrics_choreographer_compose (gdouble percent,
+ GeditTheatricsChoreographerEasing easing)
+{
+ g_return_val_if_fail (percent >= 0.0 && percent <= 1.0, 0.0);
+
+ switch (easing)
+ {
+ case GEDIT_THEATRICS_CHOREOGRAPHER_EASING_QUADRATIC_IN:
+ return percent * percent;
+
+ case GEDIT_THEATRICS_CHOREOGRAPHER_EASING_QUADRATIC_OUT:
+ return -1.0 * percent * (percent - 2.0);
+
+ case GEDIT_THEATRICS_CHOREOGRAPHER_EASING_QUADRATIC_IN_OUT:
+ percent *= 2.0;
+ return percent < 1.0
+ ? percent * percent * 0.5
+ : -0.5 * ((percent - 1.0) * (percent - 2.0) - 1.0);
+
+ case GEDIT_THEATRICS_CHOREOGRAPHER_EASING_EXPONENTIAL_IN:
+ return pow (2.0, 10.0 * (percent - 1.0));
+
+ case GEDIT_THEATRICS_CHOREOGRAPHER_EASING_EXPONENTIAL_OUT:
+ return -pow (2.0, -10.0 * percent) + 1.0;
+
+ case GEDIT_THEATRICS_CHOREOGRAPHER_EASING_EXPONENTIAL_IN_OUT:
+ percent *= 2.0;
+ return percent < 1.0
+ ? 0.5 * pow (2.0, 10.0 * (percent - 1.0))
+ : 0.5 * (-pow (2.0, -10.0 * (percent - 1.0)) + 2.0);
+
+ case GEDIT_THEATRICS_CHOREOGRAPHER_EASING_SINE:
+ return sin (percent * G_PI);
+
+ case GEDIT_THEATRICS_CHOREOGRAPHER_EASING_LINEAR:
+ default:
+ return percent;
+ }
+}
+
+/* ex:set ts=8 noet: */
diff --git a/src/theatrics/gedit-theatrics-choreographer.h b/src/theatrics/gedit-theatrics-choreographer.h
new file mode 100644
index 0000000..5883940
--- /dev/null
+++ b/src/theatrics/gedit-theatrics-choreographer.h
@@ -0,0 +1,74 @@
+/*
+ * gedit-theatrics-choreographer.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Ignacio Casal Quinteiro
+ *
+ * Based on Scott Peterson <lunchtimemama gmail com> work.
+ *
+ * gedit 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit 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 gedit; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GEDIT_THEATRICS_CHOREOGRAPHER_H__
+#define __GEDIT_THEATRICS_CHOREOGRAPHER_H__
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+ GEDIT_THEATRICS_ANIMATION_STATE_COMING,
+ GEDIT_THEATRICS_ANIMATION_STATE_IDLE,
+ GEDIT_THEATRICS_ANIMATION_STATE_INTENDING_TO_GO,
+ GEDIT_THEATRICS_ANIMATION_STATE_GOING
+} GeditTheatricsAnimationState;
+
+typedef enum
+{
+ GEDIT_THEATRICS_CHOREOGRAPHER_BLOCKING_UPSTAGE,
+ GEDIT_THEATRICS_CHOREOGRAPHER_BLOCKING_DOWNSTAGE
+} GeditTheatricsChoreographerBlocking;
+
+typedef enum
+{
+ GEDIT_THEATRICS_CHOREOGRAPHER_EASING_LINEAR,
+ GEDIT_THEATRICS_CHOREOGRAPHER_EASING_QUADRATIC_IN,
+ GEDIT_THEATRICS_CHOREOGRAPHER_EASING_QUADRATIC_OUT,
+ GEDIT_THEATRICS_CHOREOGRAPHER_EASING_QUADRATIC_IN_OUT,
+ GEDIT_THEATRICS_CHOREOGRAPHER_EASING_EXPONENTIAL_IN,
+ GEDIT_THEATRICS_CHOREOGRAPHER_EASING_EXPONENTIAL_OUT,
+ GEDIT_THEATRICS_CHOREOGRAPHER_EASING_EXPONENTIAL_IN_OUT,
+ GEDIT_THEATRICS_CHOREOGRAPHER_EASING_SINE
+} GeditTheatricsChoreographerEasing;
+
+gint gedit_theatrics_choreographer_pixel_compose (gdouble percent,
+ gint size,
+ GeditTheatricsChoreographerEasing easing);
+
+gdouble gedit_theatrics_choreographer_compose_with_scale (gdouble percent,
+ gdouble scale,
+ GeditTheatricsChoreographerEasing easing);
+
+gdouble gedit_theatrics_choreographer_compose (gdouble percent,
+ GeditTheatricsChoreographerEasing easing);
+
+G_END_DECLS
+
+#endif /* __GEDIT_THEATRICS_CHOREOGRAPHER_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/src/theatrics/gedit-theatrics-enum-types.c.template b/src/theatrics/gedit-theatrics-enum-types.c.template
new file mode 100644
index 0000000..9d53bbc
--- /dev/null
+++ b/src/theatrics/gedit-theatrics-enum-types.c.template
@@ -0,0 +1,39 @@
+/*** BEGIN file-header ***/
+#include "gedit-theatrics-enum-types.h"
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+#include "@filename@"
+
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+ enum_name@_get_type (void)
+{
+ static GType the_type = 0;
+
+ if (the_type == 0)
+ {
+ static const G Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@,
+ "@VALUENAME@",
+ "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+ };
+ the_type = g_ type@_register_static (
+ g_intern_static_string ("@EnumName@"),
+ values);
+ }
+ return the_type;
+}
+
+/*** END value-tail ***/
diff --git a/src/theatrics/gedit-theatrics-enum-types.h.template b/src/theatrics/gedit-theatrics-enum-types.h.template
new file mode 100644
index 0000000..4eb11eb
--- /dev/null
+++ b/src/theatrics/gedit-theatrics-enum-types.h.template
@@ -0,0 +1,27 @@
+/*** BEGIN file-header ***/
+#ifndef __GEDIT_THEATRICS_ENUM_TYPES_H__
+#define __GEDIT_THEATRICS_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* Enumerations from "@filename@" */
+
+/*** END file-production ***/
+
+/*** BEGIN enumeration-production ***/
+#define GEDIT_TYPE_ ENUMSHORT@ (@enum_name _get_type())
+GType @enum_name _get_type (void) G_GNUC_CONST;
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __GEDIT_ENUM_TYPES_H__ */
+/*** END file-tail ***/
+
diff --git a/src/theatrics/gedit-theatrics-marshal.list b/src/theatrics/gedit-theatrics-marshal.list
new file mode 100644
index 0000000..38076d6
--- /dev/null
+++ b/src/theatrics/gedit-theatrics-marshal.list
@@ -0,0 +1 @@
+VOID:OBJECT,OBJECT
diff --git a/src/theatrics/gedit-theatrics-stage.c b/src/theatrics/gedit-theatrics-stage.c
new file mode 100644
index 0000000..5520e95
--- /dev/null
+++ b/src/theatrics/gedit-theatrics-stage.c
@@ -0,0 +1,310 @@
+/*
+ * gedit-theatrics-stage.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Ignacio Casal Quinteiro
+ *
+ * Based on Aaron Bockover <abockover novell com> work.
+ *
+ * gedit 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit 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 gedit; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include "gedit-theatrics-stage.h"
+
+
+#define DEFAULT_UPDATE_FREQUENCY 30
+#define DEFAULT_DURATION 1000
+
+#define GEDIT_THEATRICS_STAGE_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GEDIT_TYPE_THEATRICS_STAGE, GeditTheatricsStagePrivate))
+
+struct _GeditTheatricsStagePrivate
+{
+ GHashTable *actors;
+ guint timeout_id;
+ guint update_frequency;
+ guint actor_duration;
+
+ guint playing : 1;
+};
+
+enum
+{
+ PROP_0,
+ PROP_ACTOR_DURATION
+};
+
+enum
+{
+ ACTOR_STEP,
+ ITERATION,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (GeditTheatricsStage, gedit_theatrics_stage, G_TYPE_OBJECT)
+
+static void
+gedit_theatrics_stage_dispose (GObject *object)
+{
+ GeditTheatricsStage *stage = GEDIT_THEATRICS_STAGE (object);
+
+ if (stage->priv->timeout_id != 0)
+ {
+ g_source_remove (stage->priv->timeout_id);
+ stage->priv->timeout_id = 0;
+ }
+
+ G_OBJECT_CLASS (gedit_theatrics_stage_parent_class)->dispose (object);
+}
+
+static void
+gedit_theatrics_stage_finalize (GObject *object)
+{
+ GeditTheatricsStage *stage = GEDIT_THEATRICS_STAGE (object);
+
+ g_hash_table_destroy (stage->priv->actors);
+
+ G_OBJECT_CLASS (gedit_theatrics_stage_parent_class)->finalize (object);
+}
+
+static void
+gedit_theatrics_stage_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GeditTheatricsStage *stage = GEDIT_THEATRICS_STAGE (object);
+
+ switch (prop_id)
+ {
+ case PROP_ACTOR_DURATION:
+ g_value_set_uint (value, stage->priv->actor_duration);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gedit_theatrics_stage_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GeditTheatricsStage *stage = GEDIT_THEATRICS_STAGE (object);
+
+ switch (prop_id)
+ {
+ case PROP_ACTOR_DURATION:
+ stage->priv->actor_duration = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gedit_theatrics_stage_class_init (GeditTheatricsStageClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = gedit_theatrics_stage_dispose;
+ object_class->finalize = gedit_theatrics_stage_finalize;
+ object_class->get_property = gedit_theatrics_stage_get_property;
+ object_class->set_property = gedit_theatrics_stage_set_property;
+
+ g_object_class_install_property (object_class, PROP_ACTOR_DURATION,
+ g_param_spec_uint ("actor-duration",
+ "Actor Duration",
+ "The actor duration",
+ 0,
+ G_MAXUINT,
+ DEFAULT_DURATION,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ signals[ACTOR_STEP] =
+ g_signal_new ("actor-step",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GeditTheatricsStageClass, actor_step),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1,
+ GEDIT_TYPE_THEATRICS_ACTOR);
+
+ signals[ITERATION] =
+ g_signal_new ("iteration",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GeditTheatricsStageClass, iteration),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ g_type_class_add_private (object_class, sizeof (GeditTheatricsStagePrivate));
+}
+
+static void
+gedit_theatrics_stage_init (GeditTheatricsStage *stage)
+{
+ stage->priv = GEDIT_THEATRICS_STAGE_GET_PRIVATE (stage);
+
+ stage->priv->update_frequency = DEFAULT_UPDATE_FREQUENCY;
+ stage->priv->actor_duration = DEFAULT_DURATION;
+ stage->priv->playing = TRUE;
+
+ stage->priv->actors = g_hash_table_new (g_direct_hash,
+ g_direct_equal);
+}
+
+static gboolean
+iterate_actors (gpointer key,
+ gpointer value,
+ GeditTheatricsStage *stage)
+{
+ GeditTheatricsActor *actor = GEDIT_THEATRICS_ACTOR (value);
+
+ gedit_theatrics_actor_step (actor);
+
+ g_signal_emit (G_OBJECT (stage), signals[ACTOR_STEP], 0, actor);
+
+ return gedit_theatrics_actor_get_expired (actor);
+}
+
+static gboolean
+on_timeout (GeditTheatricsStage *stage)
+{
+ if (!stage->priv->playing || g_hash_table_size (stage->priv->actors) == 0)
+ {
+ stage->priv->timeout_id = 0;
+ return FALSE;
+ }
+
+ g_hash_table_foreach_remove (stage->priv->actors,
+ (GHRFunc)iterate_actors,
+ stage);
+
+ g_signal_emit (G_OBJECT (stage), signals[ITERATION], 0);
+
+ return TRUE;
+}
+
+static void
+check_timeout (GeditTheatricsStage *stage)
+{
+ if ((!stage->priv->playing ||
+ g_hash_table_size (stage->priv->actors) == 0) &&
+ stage->priv->timeout_id)
+ {
+ g_source_remove (stage->priv->timeout_id);
+ stage->priv->timeout_id = 0;
+ }
+ else if ((stage->priv->playing &&
+ g_hash_table_size (stage->priv->actors) > 0) &&
+ stage->priv->timeout_id <= 0)
+ {
+ stage->priv->timeout_id = g_timeout_add (stage->priv->update_frequency,
+ (GSourceFunc) on_timeout,
+ stage);
+ }
+}
+
+GeditTheatricsStage *
+gedit_theatrics_stage_new ()
+{
+ return g_object_new (GEDIT_TYPE_THEATRICS_STAGE, NULL);
+}
+
+GeditTheatricsStage *
+gedit_theatrics_stage_new_with_duration (guint actor_duration)
+{
+ return g_object_new (GEDIT_TYPE_THEATRICS_STAGE,
+ "actor-duration", actor_duration,
+ NULL);
+}
+
+GeditTheatricsActor *
+gedit_theatrics_stage_add (GeditTheatricsStage *stage,
+ GObject *target)
+{
+ g_return_val_if_fail (GEDIT_IS_THEATRICS_STAGE (stage), NULL);
+
+ return gedit_theatrics_stage_add_with_duration (stage, target,
+ stage->priv->actor_duration);
+}
+
+GeditTheatricsActor *
+gedit_theatrics_stage_add_with_duration (GeditTheatricsStage *stage,
+ GObject *target,
+ guint duration)
+{
+ GeditTheatricsActor *actor;
+
+ g_return_val_if_fail (GEDIT_IS_THEATRICS_STAGE (stage), NULL);
+
+ actor = g_hash_table_lookup (stage->priv->actors,
+ target);
+
+ if (actor != NULL)
+ {
+ g_warning ("Stage already contains this actor");
+ return NULL;
+ }
+
+ actor = gedit_theatrics_actor_new (target, duration);
+
+ g_hash_table_insert (stage->priv->actors,
+ target, actor);
+
+ check_timeout (stage);
+
+ return actor;
+}
+
+void
+gedit_theatrics_stage_remove (GeditTheatricsStage *stage,
+ GObject *target)
+{
+ g_return_if_fail (GEDIT_IS_THEATRICS_STAGE (stage));
+
+ g_hash_table_remove (stage->priv->actors, target);
+}
+
+void
+gedit_theatrics_stage_set_playing (GeditTheatricsStage *stage,
+ gboolean playing)
+{
+ g_return_if_fail (GEDIT_IS_THEATRICS_STAGE (stage));
+
+ stage->priv->playing = playing;
+}
+
+gboolean
+gedit_theatrics_stage_get_playing (GeditTheatricsStage *stage)
+{
+ g_return_val_if_fail (GEDIT_IS_THEATRICS_STAGE (stage), FALSE);
+
+ return stage->priv->playing;
+}
+
+/* ex:set ts=8 noet: */
diff --git a/src/theatrics/gedit-theatrics-stage.h b/src/theatrics/gedit-theatrics-stage.h
new file mode 100644
index 0000000..3f88b89
--- /dev/null
+++ b/src/theatrics/gedit-theatrics-stage.h
@@ -0,0 +1,87 @@
+/*
+ * gedit-theatrics-stage.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Ignacio Casal Quinteiro
+ *
+ * Based on Aaron Bockover <abockover novell com> work.
+ *
+ * gedit 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit 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 gedit; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GEDIT_THEATRICS_STAGE_H__
+#define __GEDIT_THEATRICS_STAGE_H__
+
+#include <glib-object.h>
+#include "gedit-theatrics-actor.h"
+
+G_BEGIN_DECLS
+
+#define GEDIT_TYPE_THEATRICS_STAGE (gedit_theatrics_stage_get_type ())
+#define GEDIT_THEATRICS_STAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_THEATRICS_STAGE, GeditTheatricsStage))
+#define GEDIT_THEATRICS_STAGE_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_THEATRICS_STAGE, GeditTheatricsStage const))
+#define GEDIT_THEATRICS_STAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_THEATRICS_STAGE, GeditTheatricsStageClass))
+#define GEDIT_IS_THEATRICS_STAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_THEATRICS_STAGE))
+#define GEDIT_IS_THEATRICS_STAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_THEATRICS_STAGE))
+#define GEDIT_THEATRICS_STAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_THEATRICS_STAGE, GeditTheatricsStageClass))
+
+typedef struct _GeditTheatricsStage GeditTheatricsStage;
+typedef struct _GeditTheatricsStageClass GeditTheatricsStageClass;
+typedef struct _GeditTheatricsStagePrivate GeditTheatricsStagePrivate;
+
+struct _GeditTheatricsStage
+{
+ GObject parent;
+
+ GeditTheatricsStagePrivate *priv;
+};
+
+struct _GeditTheatricsStageClass
+{
+ GObjectClass parent_class;
+
+ void (* actor_step) (GeditTheatricsStage *stage,
+ GeditTheatricsActor *actor);
+
+ void (* iteration) (GeditTheatricsStage *stage);
+};
+
+GType gedit_theatrics_stage_get_type (void) G_GNUC_CONST;
+
+GeditTheatricsStage *gedit_theatrics_stage_new (void);
+
+GeditTheatricsStage *gedit_theatrics_stage_new_with_duration(guint actor_duration);
+
+GeditTheatricsActor *gedit_theatrics_stage_add (GeditTheatricsStage *stage,
+ GObject *target);
+
+GeditTheatricsActor *gedit_theatrics_stage_add_with_duration(GeditTheatricsStage *stage,
+ GObject *target,
+ guint duration);
+
+void gedit_theatrics_stage_remove (GeditTheatricsStage *stage,
+ GObject *target);
+
+void gedit_theatrics_stage_set_playing (GeditTheatricsStage *stage,
+ gboolean playing);
+
+gboolean gedit_theatrics_stage_get_playing (GeditTheatricsStage *stage);
+
+G_END_DECLS
+
+#endif /* __GEDIT_THEATRICS_STAGE_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/src/theatrics/gedit-theatrics-utils.h b/src/theatrics/gedit-theatrics-utils.h
new file mode 100644
index 0000000..c2a9677
--- /dev/null
+++ b/src/theatrics/gedit-theatrics-utils.h
@@ -0,0 +1,48 @@
+/*
+ * gedit-theatrics-utils.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2010 - Ignacio Casal Quinteiro
+ *
+ * Based on Mike KrÃger <mkrueger novell com> work.
+ *
+ * gedit 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit 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 gedit; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GEDIT_THEATRICS_UTILS_H__
+#define __GEDIT_THEATRICS_UTILS_H__
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+void gedit_theatrics_utils_draw_round_rectangle (cairo_t *cr,
+ gboolean top_left_round,
+ gboolean top_right_round,
+ gboolean bottom_left_round,
+ gboolean bottom_right_round,
+ gdouble x,
+ gdouble y,
+ gdouble r,
+ gdouble w,
+ gdouble h);
+
+G_END_DECLS
+
+#endif /* __GEDIT_THEATRICS_UTILS_H__ */
+
+/* ex:set ts=8 noet: */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]