aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorXan Lopez <xan@gnome.org>2011-02-12 05:54:43 +0800
committerXan Lopez <xan@gnome.org>2011-02-12 05:54:43 +0800
commite65e2873a6d8407e9a8801e8667085ec10fa261f (patch)
tree2eb4b45b8dba349176873574678e8eca50640754 /lib
parent7a6c09572386c98b7b57d5543a1e36f6642d425b (diff)
downloadgsoc2013-epiphany-e65e2873a6d8407e9a8801e8667085ec10fa261f.tar
gsoc2013-epiphany-e65e2873a6d8407e9a8801e8667085ec10fa261f.tar.gz
gsoc2013-epiphany-e65e2873a6d8407e9a8801e8667085ec10fa261f.tar.bz2
gsoc2013-epiphany-e65e2873a6d8407e9a8801e8667085ec10fa261f.tar.lz
gsoc2013-epiphany-e65e2873a6d8407e9a8801e8667085ec10fa261f.tar.xz
gsoc2013-epiphany-e65e2873a6d8407e9a8801e8667085ec10fa261f.tar.zst
gsoc2013-epiphany-e65e2873a6d8407e9a8801e8667085ec10fa261f.zip
Sync with upstream GeditOverlay code
Diffstat (limited to 'lib')
-rw-r--r--lib/widgets/Makefile.am23
-rw-r--r--lib/widgets/gedit-enum-types.c.template39
-rw-r--r--lib/widgets/gedit-enum-types.h.template27
-rw-r--r--lib/widgets/gedit-overlay.c259
-rw-r--r--lib/widgets/gedit-overlay.h36
-rw-r--r--lib/widgets/gedit-theatrics-animated-widget.c263
-rw-r--r--lib/widgets/gedit-theatrics-animated-widget.h64
7 files changed, 243 insertions, 468 deletions
diff --git a/lib/widgets/Makefile.am b/lib/widgets/Makefile.am
index f41adac18..f1e2f0dbd 100644
--- a/lib/widgets/Makefile.am
+++ b/lib/widgets/Makefile.am
@@ -17,11 +17,13 @@ libephywidgets_la_SOURCES = \
ephy-zoom-control.h \
gedit-overlay.c \
gedit-overlay.h \
- gedit-theatrics-animated-widget.c \
- gedit-theatrics-animated-widget.h
+ gedit-overlay-child.c \
+ gedit-overlay-child.h \
+ $(BUILT_SOURCES)
libephywidgets_la_CPPFLAGS = \
-I$(top_builddir)/lib \
+ -I$(top_builddir)/lib/widgets \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/lib/egg \
-DSHARE_DIR=\"$(pkgdatadir)\" \
@@ -30,3 +32,20 @@ libephywidgets_la_CPPFLAGS = \
libephywidgets_la_CFLAGS = \
$(DEPENDENCIES_CFLAGS) \
$(AM_CFLAGS)
+
+BUILT_SOURCES = \
+ gedit-enum-types.c \
+ gedit-enum-types.h
+
+ENUM_TYPES = \
+ gedit-overlay-child.h
+
+gedit-enum-types.h: gedit-enum-types.h.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+ $(AM_V_GEN)(cd $(srcdir) && $(GLIB_MKENUMS) --template gedit-enum-types.h.template $(ENUM_TYPES)) > $@
+
+gedit-enum-types.c: gedit-enum-types.c.template $(ENUM_TYPES) $(GLIB_MKENUMS)
+ $(AM_V_GEN)(cd $(srcdir) && $(GLIB_MKENUMS) --template gedit-enum-types.c.template $(ENUM_TYPES)) > $@
+
+EXTRA_DIST = \
+ gedit-enum-types.c.template \
+ gedit-enum-types.h.template
diff --git a/lib/widgets/gedit-enum-types.c.template b/lib/widgets/gedit-enum-types.c.template
new file mode 100644
index 000000000..7a67ac798
--- /dev/null
+++ b/lib/widgets/gedit-enum-types.c.template
@@ -0,0 +1,39 @@
+/*** BEGIN file-header ***/
+#include "gedit-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/lib/widgets/gedit-enum-types.h.template b/lib/widgets/gedit-enum-types.h.template
new file mode 100644
index 000000000..78f39ce81
--- /dev/null
+++ b/lib/widgets/gedit-enum-types.h.template
@@ -0,0 +1,27 @@
+/*** BEGIN file-header ***/
+#ifndef __GEDIT_ENUM_TYPES_H__
+#define __GEDIT_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/lib/widgets/gedit-overlay.c b/lib/widgets/gedit-overlay.c
index 1972adaa1..7cff41729 100644
--- a/lib/widgets/gedit-overlay.c
+++ b/lib/widgets/gedit-overlay.c
@@ -2,41 +2,30 @@
* gedit-overlay.c
* This file is part of gedit
*
- * Copyright (C) 2010 - Ignacio Casal Quinteiro
+ * 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 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 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 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
+ * 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-overlay.h"
-#include "gedit-theatrics-animated-widget.h"
+#include "gedit-overlay-child.h"
#define GEDIT_OVERLAY_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GEDIT_TYPE_OVERLAY, GeditOverlayPrivate))
-typedef struct _OverlayChild
-{
- GtkWidget *child;
- GdkGravity gravity;
- guint offset;
-
- guint fixed_position : 1;
- guint is_animated : 1;
-} OverlayChild;
-
struct _GeditOverlayPrivate
{
GtkWidget *main_widget;
@@ -70,31 +59,13 @@ static void gedit_overlay_set_vadjustment (GeditOverlay *overlay,
GtkAdjustment *adjustment);
G_DEFINE_TYPE_WITH_CODE (GeditOverlay, gedit_overlay, GTK_TYPE_CONTAINER,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
-
-static void
-free_container_child (OverlayChild *child)
-{
- g_slice_free (OverlayChild, child);
-}
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL))
static void
add_toplevel_widget (GeditOverlay *overlay,
- GtkWidget *widget,
- gboolean fixed_position,
- gboolean is_animated,
- GdkGravity gravity,
- guint offset)
+ GtkWidget *child)
{
- OverlayChild *child = g_slice_new (OverlayChild);
-
- child->child = widget;
- child->gravity = gravity;
- child->fixed_position = fixed_position;
- child->is_animated = is_animated;
- child->offset = offset;
-
- gtk_widget_set_parent (widget, GTK_WIDGET (overlay));
+ gtk_widget_set_parent (child, GTK_WIDGET (overlay));
overlay->priv->children = g_slist_append (overlay->priv->children,
child);
@@ -199,9 +170,7 @@ gedit_overlay_set_property (GObject *object,
case PROP_MAIN_WIDGET:
overlay->priv->main_widget = g_value_get_object (value);
add_toplevel_widget (overlay,
- overlay->priv->main_widget,
- TRUE, FALSE, GDK_GRAVITY_STATIC,
- 0);
+ overlay->priv->main_widget);
break;
case PROP_HADJUSTMENT:
@@ -287,7 +256,7 @@ gedit_overlay_get_preferred_width (GtkWidget *widget,
gint *natural)
{
GeditOverlayPrivate *priv = GEDIT_OVERLAY (widget)->priv;
- OverlayChild *child;
+ GtkWidget *child;
GSList *children;
gint child_min, child_nat;
@@ -298,10 +267,10 @@ gedit_overlay_get_preferred_width (GtkWidget *widget,
{
child = children->data;
- if (!gtk_widget_get_visible (child->child))
+ if (!gtk_widget_get_visible (child))
continue;
- gtk_widget_get_preferred_width (child->child, &child_min, &child_nat);
+ gtk_widget_get_preferred_width (child, &child_min, &child_nat);
*minimum = MAX (*minimum, child_min);
*natural = MAX (*natural, child_nat);
@@ -314,7 +283,7 @@ gedit_overlay_get_preferred_height (GtkWidget *widget,
gint *natural)
{
GeditOverlayPrivate *priv = GEDIT_OVERLAY (widget)->priv;
- OverlayChild *child;
+ GtkWidget *child;
GSList *children;
gint child_min, child_nat;
@@ -325,10 +294,10 @@ gedit_overlay_get_preferred_height (GtkWidget *widget,
{
child = children->data;
- if (!gtk_widget_get_visible (child->child))
+ if (!gtk_widget_get_visible (child))
continue;
- gtk_widget_get_preferred_height (child->child, &child_min, &child_nat);
+ gtk_widget_get_preferred_height (child, &child_min, &child_nat);
*minimum = MAX (*minimum, child_min);
*natural = MAX (*natural, child_nat);
@@ -343,29 +312,31 @@ set_children_positions (GeditOverlay *overlay)
for (l = overlay->priv->children; l != NULL; l = g_slist_next (l))
{
GeditOverlayPrivate *priv = overlay->priv;
- OverlayChild *child = (OverlayChild *)l->data;
+ GtkWidget *child = GTK_WIDGET (l->data);
GtkRequisition req;
GtkAllocation alloc;
+ guint offset;
- if (child->child == priv->main_widget)
+ if (child == priv->main_widget)
continue;
- gtk_widget_get_preferred_size (child->child, &req, NULL);
+ gtk_widget_get_preferred_size (child, &req, NULL);
+ offset = gedit_overlay_child_get_offset (GEDIT_OVERLAY_CHILD (child));
- /* FIXME: Add all the gravities here */
- switch (child->gravity)
+ /* FIXME: Add all the positions here */
+ switch (gedit_overlay_child_get_position (GEDIT_OVERLAY_CHILD (child)))
{
/* The gravity is treated as position and not as a gravity */
- case GDK_GRAVITY_NORTH_EAST:
- alloc.x = priv->main_alloc.width - req.width - child->offset;
+ case GEDIT_OVERLAY_CHILD_POSITION_NORTH_EAST:
+ alloc.x = priv->main_alloc.width - req.width - offset;
alloc.y = 0;
break;
- case GDK_GRAVITY_NORTH_WEST:
- alloc.x = child->offset;
+ case GEDIT_OVERLAY_CHILD_POSITION_NORTH_WEST:
+ alloc.x = offset;
alloc.y = 0;
break;
- case GDK_GRAVITY_SOUTH_WEST:
- alloc.x = child->offset;
+ case GEDIT_OVERLAY_CHILD_POSITION_SOUTH_WEST:
+ alloc.x = offset;
alloc.y = priv->main_alloc.height - req.height;
break;
default:
@@ -373,7 +344,7 @@ set_children_positions (GeditOverlay *overlay)
alloc.y = 0;
}
- if (!child->fixed_position)
+ if (!gedit_overlay_child_get_fixed (GEDIT_OVERLAY_CHILD (child)))
{
alloc.x *= gtk_adjustment_get_value (priv->hadjustment);
alloc.y *= gtk_adjustment_get_value (priv->vadjustment);
@@ -382,7 +353,7 @@ set_children_positions (GeditOverlay *overlay)
alloc.width = req.width;
alloc.height = req.height;
- gtk_widget_size_allocate (child->child, &alloc);
+ gtk_widget_size_allocate (child, &alloc);
}
}
@@ -404,31 +375,88 @@ gedit_overlay_size_allocate (GtkWidget *widget,
set_children_positions (overlay);
}
+static GeditOverlayChild *
+get_overlay_child (GeditOverlay *overlay,
+ GtkWidget *widget)
+{
+ GeditOverlayChild *overlay_child = NULL;
+ GSList *l;
+
+ for (l = overlay->priv->children; l != NULL; l = g_slist_next (l))
+ {
+ GtkWidget *child = GTK_WIDGET (l->data);
+
+ /* skip the main widget as it is not a OverlayChild */
+ if (child == overlay->priv->main_widget)
+ continue;
+
+ if (child == widget)
+ {
+ overlay_child = GEDIT_OVERLAY_CHILD (child);
+ break;
+ }
+ else
+ {
+ GtkWidget *in_widget;
+
+ /* let's try also with the internal widget */
+ g_object_get (child, "widget", &in_widget, NULL);
+ g_assert (in_widget != NULL);
+
+ if (in_widget == widget)
+ {
+ overlay_child = GEDIT_OVERLAY_CHILD (child);
+ break;
+ }
+ }
+ }
+
+ return overlay_child;
+}
+
static void
overlay_add (GtkContainer *overlay,
GtkWidget *widget)
{
- add_toplevel_widget (GEDIT_OVERLAY (overlay), widget,
- FALSE, FALSE, GDK_GRAVITY_STATIC, 0);
+ GeditOverlayChild *child;
+
+ /* check that the widget is not added yet */
+ child = get_overlay_child (GEDIT_OVERLAY (overlay), widget);
+
+ if (child == NULL)
+ {
+ if (GEDIT_IS_OVERLAY_CHILD (widget))
+ {
+ child = GEDIT_OVERLAY_CHILD (widget);
+ }
+ else
+ {
+ child = gedit_overlay_child_new (widget);
+ gtk_widget_show (GTK_WIDGET (child));
+ }
+
+ add_toplevel_widget (GEDIT_OVERLAY (overlay), GTK_WIDGET (child));
+ }
}
static void
gedit_overlay_remove (GtkContainer *overlay,
GtkWidget *widget)
{
- GeditOverlay *goverlay = GEDIT_OVERLAY (overlay);
+ GeditOverlayPrivate *priv = GEDIT_OVERLAY (overlay)->priv;
GSList *l;
- for (l = goverlay->priv->children; l != NULL; l = g_slist_next (l))
+ for (l = priv->children; l != NULL; l = g_slist_next (l))
{
- OverlayChild *child = (OverlayChild *)l->data;
+ GtkWidget *child = l->data;
- if (child->child == widget)
+ if (child == widget)
{
gtk_widget_unparent (widget);
- goverlay->priv->children = g_slist_remove_link (goverlay->priv->children,
- l);
- free_container_child (child);
+ priv->children = g_slist_remove_link (priv->children,
+ l);
+
+ g_slist_free (l);
break;
}
}
@@ -445,9 +473,9 @@ gedit_overlay_forall (GtkContainer *overlay,
for (l = goverlay->priv->children; l != NULL; l = g_slist_next (l))
{
- OverlayChild *child = (OverlayChild *)l->data;
+ GtkWidget *child = GTK_WIDGET (l->data);
- (* callback) (child->child, callback_data);
+ (* callback) (child, callback_data);
}
}
@@ -598,59 +626,50 @@ gedit_overlay_init (GeditOverlay *overlay)
overlay->priv = GEDIT_OVERLAY_GET_PRIVATE (overlay);
}
+/**
+ * gedit_overlay_new:
+ * @main_widget: a #GtkWidget
+ *
+ * Creates a new #GeditOverlay
+ *
+ * Returns: a new #GeditOverlay object.
+ */
GtkWidget *
gedit_overlay_new (GtkWidget *main_widget)
{
+ g_return_val_if_fail (GTK_IS_WIDGET (main_widget), NULL);
+
return GTK_WIDGET (g_object_new (GEDIT_TYPE_OVERLAY,
"main-widget", main_widget,
NULL));
}
-static GeditTheatricsAnimatedWidget *
-get_animated_widget (GeditOverlay *overlay,
- GtkWidget *widget)
+/**
+ * gedit_overlay_add:
+ * @overlay: a #GeditOverlay
+ * @widget: a #GtkWidget to be added to the container
+ * @position: a #GeditOverlayChildPosition
+ * @offset: offset for @widget
+ *
+ * Adds @widget to @overlay in a specific position.
+ */
+void
+gedit_overlay_add (GeditOverlay *overlay,
+ GtkWidget *widget,
+ GeditOverlayChildPosition position,
+ guint offset)
{
- GSList *l;
-
- for (l = overlay->priv->children; l != NULL; l = g_slist_next (l))
- {
- OverlayChild *child = (OverlayChild *)l->data;
- GtkWidget *in_widget;
+ GeditOverlayChild *child;
- if (!child->is_animated)
- continue;
-
- g_object_get (child->child, "widget", &in_widget, NULL);
- g_assert (in_widget != NULL);
+ g_return_if_fail (GEDIT_IS_OVERLAY (overlay));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
- if (in_widget == widget)
- {
- return GEDIT_THEATRICS_ANIMATED_WIDGET (child->child);
- }
- }
+ gtk_container_add (GTK_CONTAINER (overlay), widget);
- return NULL;
-}
+ /* NOTE: can we improve this without exposing overlay child? */
+ child = get_overlay_child (overlay, widget);
+ g_assert (child != NULL);
-/* Note: see that we use the gravity as a position */
-void
-gedit_overlay_add (GeditOverlay *overlay,
- GtkWidget *widget,
- GtkOrientation orientation,
- GdkGravity gravity,
- guint offset,
- gboolean in)
-{
- GeditTheatricsAnimatedWidget *anim_widget;
-
- anim_widget = get_animated_widget (overlay, widget);
-
- if (anim_widget == NULL)
- {
- anim_widget = gedit_theatrics_animated_widget_new (widget, orientation);
- gtk_widget_show (GTK_WIDGET (anim_widget));
-
- add_toplevel_widget (overlay, GTK_WIDGET (anim_widget), TRUE,
- TRUE, gravity, offset);
- }
+ gedit_overlay_child_set_position (child, position);
+ gedit_overlay_child_set_offset (child, offset);
}
diff --git a/lib/widgets/gedit-overlay.h b/lib/widgets/gedit-overlay.h
index a5335dd37..8817d330a 100644
--- a/lib/widgets/gedit-overlay.h
+++ b/lib/widgets/gedit-overlay.h
@@ -2,22 +2,21 @@
* gedit-overlay.h
* This file is part of gedit
*
- * Copyright (C) 2010 - Ignacio Casal Quinteiro
- *
- * 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.
+ * 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 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
+ * 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_OVERLAY_H__
@@ -25,6 +24,7 @@
#include <glib-object.h>
#include <gtk/gtk.h>
+#include "gedit-overlay-child.h"
G_BEGIN_DECLS
@@ -60,12 +60,10 @@ GType gedit_overlay_get_type (void) G_GNUC_CONST;
GtkWidget *gedit_overlay_new (GtkWidget *main_widget);
-void gedit_overlay_add (GeditOverlay *overlay,
- GtkWidget *widget,
- GtkOrientation orientation,
- GdkGravity gravity,
- guint offset,
- gboolean in);
+void gedit_overlay_add (GeditOverlay *overlay,
+ GtkWidget *widget,
+ GeditOverlayChildPosition position,
+ guint offset);
G_END_DECLS
diff --git a/lib/widgets/gedit-theatrics-animated-widget.c b/lib/widgets/gedit-theatrics-animated-widget.c
deleted file mode 100644
index 8be6a64d0..000000000
--- a/lib/widgets/gedit-theatrics-animated-widget.c
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * gedit-theatrics-animated-widget.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-theatrics-animated-widget.h"
-
-#define GEDIT_THEATRICS_ANIMATED_WIDGET_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GEDIT_TYPE_THEATRICS_ANIMATED_WIDGET, GeditTheatricsAnimatedWidgetPrivate))
-
-struct _GeditTheatricsAnimatedWidgetPrivate
-{
- GtkWidget *widget;
- GtkOrientation orientation;
- GtkAllocation widget_alloc;
-};
-
-enum
-{
- PROP_0,
- PROP_WIDGET,
- PROP_ORIENTATION
-};
-
-G_DEFINE_TYPE_EXTENDED (GeditTheatricsAnimatedWidget,
- gedit_theatrics_animated_widget,
- GTK_TYPE_BIN,
- 0,
- G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE,
- NULL))
-
-static void
-gedit_theatrics_animated_widget_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GeditTheatricsAnimatedWidget *aw = GEDIT_THEATRICS_ANIMATED_WIDGET (object);
-
- switch (prop_id)
- {
- case PROP_WIDGET:
- g_value_set_object (value, aw->priv->widget);
- break;
- case PROP_ORIENTATION:
- g_value_set_enum (value, aw->priv->orientation);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gedit_theatrics_animated_widget_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GeditTheatricsAnimatedWidget *aw = GEDIT_THEATRICS_ANIMATED_WIDGET (object);
-
- switch (prop_id)
- {
- case PROP_WIDGET:
- {
- gtk_container_add (GTK_CONTAINER (aw),
- g_value_get_object (value));
- break;
- }
- case PROP_ORIENTATION:
- aw->priv->orientation = g_value_get_enum (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gedit_theatrics_animated_widget_realize (GtkWidget *widget)
-{
- GdkWindowAttr attributes;
- GdkWindow *parent_window;
- GdkWindow *window;
- GtkStyleContext *context;
-
- gtk_widget_set_realized (widget, TRUE);
-
- parent_window = gtk_widget_get_parent_window (widget);
- context = gtk_widget_get_style_context (widget);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.event_mask = GDK_EXPOSURE_MASK;
-
- window = gdk_window_new (parent_window, &attributes, 0);
- gdk_window_set_user_data (window, widget);
- gtk_widget_set_window (widget, window);
- gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
- gtk_style_context_set_background (context, window);
-}
-
-static void
-gedit_theatrics_animated_widget_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- GeditTheatricsAnimatedWidget *aw = GEDIT_THEATRICS_ANIMATED_WIDGET (widget);
- gint width;
-
- if (aw->priv->widget != NULL)
- {
- gint child_min, child_nat;
-
- gtk_widget_get_preferred_width (aw->priv->widget,
- &child_min, &child_nat);
- aw->priv->widget_alloc.width = child_min;
- }
-
- width = aw->priv->widget_alloc.width;
- *minimum = *natural = width;
-}
-
-static void
-gedit_theatrics_animated_widget_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- GeditTheatricsAnimatedWidget *aw = GEDIT_THEATRICS_ANIMATED_WIDGET (widget);
- gint height;
-
- if (aw->priv->widget != NULL)
- {
- gint child_min, child_nat;
-
- gtk_widget_get_preferred_height (aw->priv->widget,
- &child_min, &child_nat);
- aw->priv->widget_alloc.height = child_min;
- }
-
- height = aw->priv->widget_alloc.height;
- *minimum = *natural = height;
-}
-
-static void
-gedit_theatrics_animated_widget_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GeditTheatricsAnimatedWidget *aw = GEDIT_THEATRICS_ANIMATED_WIDGET (widget);
-
- GTK_WIDGET_CLASS (gedit_theatrics_animated_widget_parent_class)->size_allocate (widget, allocation);
-
- if (aw->priv->widget != NULL)
- {
- if (aw->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- {
- aw->priv->widget_alloc.height = allocation->height;
- aw->priv->widget_alloc.x = 0;
- }
-
- if (aw->priv->widget_alloc.height > 0 && aw->priv->widget_alloc.width > 0)
- {
- gtk_widget_size_allocate (aw->priv->widget,
- &aw->priv->widget_alloc);
- }
- }
-}
-
-static void
-gedit_theatrics_animated_widget_add (GtkContainer *container,
- GtkWidget *widget)
-{
- GeditTheatricsAnimatedWidget *aw = GEDIT_THEATRICS_ANIMATED_WIDGET (container);
-
- aw->priv->widget = widget;
-
- GTK_CONTAINER_CLASS (gedit_theatrics_animated_widget_parent_class)->add (container, widget);
-}
-
-static void
-gedit_theatrics_animated_widget_remove (GtkContainer *container,
- GtkWidget *widget)
-{
- GeditTheatricsAnimatedWidget *aw = GEDIT_THEATRICS_ANIMATED_WIDGET (container);
-
- aw->priv->widget = NULL;
-
- GTK_CONTAINER_CLASS (gedit_theatrics_animated_widget_parent_class)->remove (container, widget);
-}
-
-static void
-gedit_theatrics_animated_widget_class_init (GeditTheatricsAnimatedWidgetClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
-
- object_class->get_property = gedit_theatrics_animated_widget_get_property;
- object_class->set_property = gedit_theatrics_animated_widget_set_property;
-
- widget_class->realize = gedit_theatrics_animated_widget_realize;
- widget_class->get_preferred_width = gedit_theatrics_animated_widget_get_preferred_width;
- widget_class->get_preferred_height = gedit_theatrics_animated_widget_get_preferred_height;
- widget_class->size_allocate = gedit_theatrics_animated_widget_size_allocate;
-
- container_class->add = gedit_theatrics_animated_widget_add;
- container_class->remove = gedit_theatrics_animated_widget_remove;
-
- g_object_class_install_property (object_class, PROP_WIDGET,
- g_param_spec_object ("widget",
- "Widget",
- "The Widget",
- GTK_TYPE_WIDGET,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_override_property (object_class,
- PROP_ORIENTATION,
- "orientation");
-
- g_type_class_add_private (object_class, sizeof (GeditTheatricsAnimatedWidgetPrivate));
-}
-
-static void
-gedit_theatrics_animated_widget_init (GeditTheatricsAnimatedWidget *aw)
-{
- aw->priv = GEDIT_THEATRICS_ANIMATED_WIDGET_GET_PRIVATE (aw);
-
- gtk_widget_set_has_window (GTK_WIDGET (aw), TRUE);
-
- aw->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
-}
-
-GeditTheatricsAnimatedWidget *
-gedit_theatrics_animated_widget_new (GtkWidget *widget,
- GtkOrientation orientation)
-{
- return g_object_new (GEDIT_TYPE_THEATRICS_ANIMATED_WIDGET,
- "widget", widget,
- "orientation", orientation,
- NULL);
-}
-
-/* ex:set ts=8 noet: */
diff --git a/lib/widgets/gedit-theatrics-animated-widget.h b/lib/widgets/gedit-theatrics-animated-widget.h
deleted file mode 100644
index 5fe82760e..000000000
--- a/lib/widgets/gedit-theatrics-animated-widget.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * gedit-theatrics-animated-widget.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_ANIMATED_WIDGET_H__
-#define __GEDIT_THEATRICS_ANIMATED_WIDGET_H__
-
-#include <glib-object.h>
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define GEDIT_TYPE_THEATRICS_ANIMATED_WIDGET (gedit_theatrics_animated_widget_get_type ())
-#define GEDIT_THEATRICS_ANIMATED_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_THEATRICS_ANIMATED_WIDGET, GeditTheatricsAnimatedWidget))
-#define GEDIT_THEATRICS_ANIMATED_WIDGET_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_THEATRICS_ANIMATED_WIDGET, GeditTheatricsAnimatedWidget const))
-#define GEDIT_THEATRICS_ANIMATED_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_THEATRICS_ANIMATED_WIDGET, GeditTheatricsAnimatedWidgetClass))
-#define GEDIT_IS_THEATRICS_ANIMATED_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_THEATRICS_ANIMATED_WIDGET))
-#define GEDIT_IS_THEATRICS_ANIMATED_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_THEATRICS_ANIMATED_WIDGET))
-#define GEDIT_THEATRICS_ANIMATED_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_THEATRICS_ANIMATED_WIDGET, GeditTheatricsAnimatedWidgetClass))
-
-typedef struct _GeditTheatricsAnimatedWidget GeditTheatricsAnimatedWidget;
-typedef struct _GeditTheatricsAnimatedWidgetClass GeditTheatricsAnimatedWidgetClass;
-typedef struct _GeditTheatricsAnimatedWidgetPrivate GeditTheatricsAnimatedWidgetPrivate;
-
-struct _GeditTheatricsAnimatedWidget
-{
- GtkBin parent;
-
- GeditTheatricsAnimatedWidgetPrivate *priv;
-};
-
-struct _GeditTheatricsAnimatedWidgetClass
-{
- GtkBinClass parent_class;
-};
-
-GType gedit_theatrics_animated_widget_get_type (void) G_GNUC_CONST;
-
-GeditTheatricsAnimatedWidget *gedit_theatrics_animated_widget_new (GtkWidget *widget,
- GtkOrientation orientation);
-
-G_END_DECLS
-
-#endif /* __GEDIT_THEATRICS_ANIMATED_WIDGET_H__ */