summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2011-06-13 11:17:05 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2011-06-13 11:17:05 -0400
commita28a89ab8112a5207d5413e5f767f191d1d13339 (patch)
tree35dc656895bc655670f312dd2467a546a0be7de3
parent6260482af6804adda242d7a8582ccdd155beb9e0 (diff)
downloadnautilus-a28a89ab8112a5207d5413e5f767f191d1d13339.tar.gz
floating-bar: port to GtkOverlay
-rw-r--r--src/Makefile.am4
-rw-r--r--src/gedit-overlay.c532
-rw-r--r--src/gedit-overlay.h67
-rw-r--r--src/nautilus-floating-bar.c206
-rw-r--r--src/nautilus-floating-bar.h6
-rw-r--r--src/nautilus-icon-view.c1
-rw-r--r--src/nautilus-list-view.c1
-rw-r--r--src/nautilus-window-slot.c24
-rw-r--r--src/nautilus-window-slot.h1
9 files changed, 39 insertions, 803 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 060e4cc54..ed938b1f3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -49,10 +49,6 @@ BUILT_SOURCES = \
$(NULL)
nautilus_SOURCES = \
- gedit-overlay.h \
- gedit-overlay.c \
- gedit-overlay-child.h \
- gedit-overlay-child.c \
nautilus-actions.h \
nautilus-application.c \
nautilus-application.h \
diff --git a/src/gedit-overlay.c b/src/gedit-overlay.c
deleted file mode 100644
index 4b76a5193..000000000
--- a/src/gedit-overlay.c
+++ /dev/null
@@ -1,532 +0,0 @@
-/*
- * gedit-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-overlay.h"
-#include "gedit-overlay-child.h"
-
-#define GEDIT_OVERLAY_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), GEDIT_TYPE_OVERLAY, GeditOverlayPrivate))
-
-typedef struct
-{
- GtkWidget *child;
- GtkWidget *original;
-} ChildContainer;
-
-struct _GeditOverlayPrivate
-{
- GtkWidget *main_widget;
- GtkWidget *relative_widget;
- GSList *children;
-};
-
-enum
-{
- PROP_0,
- PROP_MAIN_WIDGET,
- PROP_RELATIVE_WIDGET
-};
-
-G_DEFINE_TYPE (GeditOverlay, gedit_overlay, GTK_TYPE_CONTAINER)
-
-static ChildContainer *
-child_container_new (GtkWidget *child,
- GtkWidget *original)
-{
- ChildContainer *ret;
-
- ret = g_slice_new (ChildContainer);
- ret->child = child;
- ret->original = original;
-
- return ret;
-}
-
-static void
-child_container_free (ChildContainer *container)
-{
- g_slice_free (ChildContainer, container);
-}
-
-static GtkWidget *
-child_container_get_child (ChildContainer *container)
-{
- GtkWidget *child;
-
- if (container->child != NULL)
- {
- child = container->child;
- }
- else
- {
- child = container->original;
- }
-
- return child;
-}
-
-static void
-add_toplevel_widget (GeditOverlay *overlay,
- GtkWidget *child,
- GtkWidget *original)
-{
- ChildContainer *container;
-
- if (child != NULL)
- {
- gtk_widget_set_parent (child, GTK_WIDGET (overlay));
- }
- else
- {
- gtk_widget_set_parent (original, GTK_WIDGET (overlay));
- }
-
- container = child_container_new (child, original);
-
- overlay->priv->children = g_slist_append (overlay->priv->children,
- container);
-}
-
-static void
-gedit_overlay_dispose (GObject *object)
-{
- G_OBJECT_CLASS (gedit_overlay_parent_class)->dispose (object);
-}
-
-static void
-gedit_overlay_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GeditOverlay *overlay = GEDIT_OVERLAY (object);
- GeditOverlayPrivate *priv = overlay->priv;
-
- switch (prop_id)
- {
- case PROP_MAIN_WIDGET:
- g_value_set_object (value, priv->main_widget);
- break;
-
- case PROP_RELATIVE_WIDGET:
- g_value_set_object (value, priv->relative_widget);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GtkWidget *
-wrap_child_if_needed (GtkWidget *widget)
-{
- GtkWidget *child;
-
- if (GEDIT_IS_OVERLAY_CHILD (widget))
- {
- return widget;
- }
-
- child = GTK_WIDGET (gedit_overlay_child_new (widget));
- gtk_widget_show (child);
-
- g_signal_connect_swapped (widget,
- "destroy",
- G_CALLBACK (gtk_widget_destroy),
- child);
-
- return child;
-}
-
-static void
-gedit_overlay_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GeditOverlay *overlay = GEDIT_OVERLAY (object);
- GeditOverlayPrivate *priv = overlay->priv;
-
- switch (prop_id)
- {
- case PROP_MAIN_WIDGET:
- {
- priv->main_widget = g_value_get_object (value);
-
- add_toplevel_widget (overlay,
- NULL,
- priv->main_widget);
- break;
- }
- case PROP_RELATIVE_WIDGET:
- priv->relative_widget = g_value_get_object (value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gedit_overlay_realize (GtkWidget *widget)
-{
- GtkAllocation allocation;
- GdkWindow *window;
- GdkWindowAttr attributes;
- gint attributes_mask;
- GtkStyleContext *context;
-
- gtk_widget_set_realized (widget, TRUE);
-
- gtk_widget_get_allocation (widget, &allocation);
-
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = allocation.x;
- attributes.y = allocation.y;
- attributes.width = allocation.width;
- attributes.height = allocation.height;
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.visual = gtk_widget_get_visual (widget);
- attributes.event_mask = gtk_widget_get_events (widget);
- attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_LEAVE_NOTIFY_MASK;
-
- attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gtk_widget_set_window (widget, window);
- gdk_window_set_user_data (window, widget);
-
- context = gtk_widget_get_style_context (widget);
- gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
- gtk_style_context_set_background (context, window);
-}
-
-static void
-gedit_overlay_get_preferred_width (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- GeditOverlayPrivate *priv = GEDIT_OVERLAY (widget)->priv;
-
- *minimum = 0;
- *natural = 0;
-
- if (priv->main_widget)
- {
- gtk_widget_get_preferred_width (priv->main_widget, minimum, natural);
- }
-}
-
-static void
-gedit_overlay_get_preferred_height (GtkWidget *widget,
- gint *minimum,
- gint *natural)
-{
- GeditOverlayPrivate *priv = GEDIT_OVERLAY (widget)->priv;
-
- *minimum = 0;
- *natural = 0;
-
- if (priv->main_widget)
- {
- gtk_widget_get_preferred_height (priv->main_widget, minimum, natural);
- }
-}
-
-static void
-gedit_overlay_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
-{
- GeditOverlay *overlay = GEDIT_OVERLAY (widget);
- GeditOverlayPrivate *priv = overlay->priv;
- GtkAllocation main_alloc;
- GSList *l;
-
- GTK_WIDGET_CLASS (gedit_overlay_parent_class)->size_allocate (widget, allocation);
-
- /* main widget allocation */
- main_alloc.x = 0;
- main_alloc.y = 0;
- main_alloc.width = allocation->width;
- main_alloc.height = allocation->height;
-
- gtk_widget_size_allocate (overlay->priv->main_widget, &main_alloc);
-
- /* if a relative widget exists place the floating widgets in relation to it */
- if (priv->relative_widget)
- {
- gtk_widget_get_allocation (priv->relative_widget, &main_alloc);
- }
-
- for (l = priv->children; l != NULL; l = g_slist_next (l))
- {
- ChildContainer *container = l->data;
- GtkWidget *child;
- GtkRequisition req;
- GtkAllocation alloc;
- guint offset;
-
- child = child_container_get_child (container);
-
- if (child == priv->main_widget)
- continue;
-
- gtk_widget_get_preferred_size (child, NULL, &req);
- offset = gedit_overlay_child_get_offset (GEDIT_OVERLAY_CHILD (child));
-
- /* 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 GEDIT_OVERLAY_CHILD_POSITION_NORTH_EAST:
- alloc.x = MAX (main_alloc.x, main_alloc.width - req.width - (gint) offset);
- alloc.y = 0;
- break;
- case GEDIT_OVERLAY_CHILD_POSITION_NORTH_WEST:
- alloc.x = offset;
- alloc.y = 0;
- break;
- case GEDIT_OVERLAY_CHILD_POSITION_SOUTH_WEST:
- alloc.x = offset;
- alloc.y = MAX (main_alloc.y, main_alloc.height - req.height);
- break;
- case GEDIT_OVERLAY_CHILD_POSITION_SOUTH_EAST:
- alloc.x = MAX (main_alloc.x, main_alloc.width - req.width - (gint) offset);
- alloc.y = MAX (main_alloc.y, main_alloc.height - req.height);
- break;
- default:
- alloc.x = 0;
- alloc.y = 0;
- }
-
- alloc.width = MIN (main_alloc.width, req.width);
- alloc.height = MIN (main_alloc.height, req.height);
-
- gtk_widget_size_allocate (child, &alloc);
- }
-}
-
-static GeditOverlayChild *
-get_overlay_child (GeditOverlay *overlay,
- GtkWidget *widget)
-{
- GSList *l;
-
- for (l = overlay->priv->children; l != NULL; l = g_slist_next (l))
- {
- ChildContainer *container = l->data;
-
- if (container->original == widget &&
- GEDIT_IS_OVERLAY_CHILD (container->child))
- {
- return GEDIT_OVERLAY_CHILD (container->child);
- }
- }
-
- return NULL;
-}
-
-static void
-overlay_add (GtkContainer *overlay,
- GtkWidget *widget)
-{
- GeditOverlayChild *child;
-
- /* check that the widget is not added yet */
- child = get_overlay_child (GEDIT_OVERLAY (overlay), widget);
-
- if (child == NULL)
- {
- add_toplevel_widget (GEDIT_OVERLAY (overlay),
- wrap_child_if_needed (widget),
- widget);
- }
-}
-
-static void
-gedit_overlay_remove (GtkContainer *overlay,
- GtkWidget *widget)
-{
- GeditOverlayPrivate *priv = GEDIT_OVERLAY (overlay)->priv;
- GSList *l;
-
- for (l = priv->children; l != NULL; l = g_slist_next (l))
- {
- ChildContainer *container = l->data;
- GtkWidget *original = container->original;
-
- if (original == widget)
- {
- gtk_widget_unparent (widget);
-
- if (container->child != NULL &&
- original != container->child)
- {
- g_signal_handlers_disconnect_by_func (original,
- gtk_widget_destroy,
- container->child);
-
- gtk_widget_destroy (container->child);
- }
-
- child_container_free (container);
- priv->children = g_slist_delete_link (priv->children,
- l);
-
- break;
- }
- }
-}
-
-static void
-gedit_overlay_forall (GtkContainer *overlay,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data)
-{
- GeditOverlayPrivate *priv = GEDIT_OVERLAY (overlay)->priv;
- GSList *children;
-
- children = priv->children;
-
- while (children)
- {
- ChildContainer *container = children->data;
- children = children->next;
- GtkWidget *child;
-
- child = child_container_get_child (container);
-
- (* callback) (child, callback_data);
- }
-}
-
-static GType
-gedit_overlay_child_type (GtkContainer *overlay)
-{
- return GTK_TYPE_WIDGET;
-}
-
-static void
-gedit_overlay_class_init (GeditOverlayClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
-
- object_class->dispose = gedit_overlay_dispose;
- object_class->get_property = gedit_overlay_get_property;
- object_class->set_property = gedit_overlay_set_property;
-
- widget_class->realize = gedit_overlay_realize;
- widget_class->get_preferred_width = gedit_overlay_get_preferred_width;
- widget_class->get_preferred_height = gedit_overlay_get_preferred_height;
- widget_class->size_allocate = gedit_overlay_size_allocate;
-
- container_class->add = overlay_add;
- container_class->remove = gedit_overlay_remove;
- container_class->forall = gedit_overlay_forall;
- container_class->child_type = gedit_overlay_child_type;
-
- g_object_class_install_property (object_class, PROP_MAIN_WIDGET,
- g_param_spec_object ("main-widget",
- "Main Widget",
- "The Main Widget",
- GTK_TYPE_WIDGET,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class, PROP_RELATIVE_WIDGET,
- g_param_spec_object ("relative-widget",
- "Relative Widget",
- "Widget on which the floating widgets are placed",
- GTK_TYPE_WIDGET,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- g_type_class_add_private (object_class, sizeof (GeditOverlayPrivate));
-}
-
-static void
-gedit_overlay_init (GeditOverlay *overlay)
-{
- overlay->priv = GEDIT_OVERLAY_GET_PRIVATE (overlay);
-
- gtk_widget_set_app_paintable (GTK_WIDGET (overlay), TRUE);
-}
-
-/**
- * gedit_overlay_new:
- * @main_widget: a #GtkWidget
- * @relative_widget: (allow-none): a #Gtkwidget
- *
- * Creates a new #GeditOverlay. If @relative_widget is not %NULL the floating
- * widgets will be placed in relation to it, if not @main_widget will be use
- * for this purpose.
- *
- * Returns: a new #GeditOverlay object.
- */
-GtkWidget *
-gedit_overlay_new (GtkWidget *main_widget,
- GtkWidget *relative_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,
- "relative-widget", relative_widget,
- NULL));
-}
-
-/**
- * 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)
-{
- GeditOverlayChild *child;
-
- g_return_if_fail (GEDIT_IS_OVERLAY (overlay));
- g_return_if_fail (GTK_IS_WIDGET (widget));
-
- gtk_container_add (GTK_CONTAINER (overlay), widget);
-
- /* NOTE: can we improve this without exposing overlay child? */
- child = get_overlay_child (overlay, widget);
- g_assert (child != NULL);
-
- gedit_overlay_child_set_position (child, position);
- gedit_overlay_child_set_offset (child, offset);
-}
diff --git a/src/gedit-overlay.h b/src/gedit-overlay.h
deleted file mode 100644
index 9e1c76991..000000000
--- a/src/gedit-overlay.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * gedit-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_OVERLAY_H__
-#define __GEDIT_OVERLAY_H__
-
-#include <glib-object.h>
-#include <gtk/gtk.h>
-#include "gedit-overlay-child.h"
-
-G_BEGIN_DECLS
-
-#define GEDIT_TYPE_OVERLAY (gedit_overlay_get_type ())
-#define GEDIT_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_OVERLAY, GeditOverlay))
-#define GEDIT_OVERLAY_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_OVERLAY, GeditOverlay const))
-#define GEDIT_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEDIT_TYPE_OVERLAY, GeditOverlayClass))
-#define GEDIT_IS_OVERLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_OVERLAY))
-#define GEDIT_IS_OVERLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEDIT_TYPE_OVERLAY))
-#define GEDIT_OVERLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEDIT_TYPE_OVERLAY, GeditOverlayClass))
-
-typedef struct _GeditOverlay GeditOverlay;
-typedef struct _GeditOverlayClass GeditOverlayClass;
-typedef struct _GeditOverlayPrivate GeditOverlayPrivate;
-
-struct _GeditOverlay
-{
- GtkContainer parent;
-
- GeditOverlayPrivate *priv;
-};
-
-struct _GeditOverlayClass
-{
- GtkContainerClass parent_class;
-};
-
-GType gedit_overlay_get_type (void) G_GNUC_CONST;
-
-GtkWidget *gedit_overlay_new (GtkWidget *main_widget,
- GtkWidget *relative_widget);
-
-void gedit_overlay_add (GeditOverlay *overlay,
- GtkWidget *widget,
- GeditOverlayChildPosition position,
- guint offset);
-
-G_END_DECLS
-
-#endif /* __GEDIT_OVERLAY_H__ */
diff --git a/src/nautilus-floating-bar.c b/src/nautilus-floating-bar.c
index 0d092f69e..eb14dbc35 100644
--- a/src/nautilus-floating-bar.c
+++ b/src/nautilus-floating-bar.c
@@ -57,7 +57,7 @@ static GParamSpec *properties[NUM_PROPERTIES] = { NULL, };
static guint signals[NUM_SIGNALS] = { 0, };
G_DEFINE_TYPE (NautilusFloatingBar, nautilus_floating_bar,
- GEDIT_TYPE_OVERLAY_CHILD);
+ GTK_TYPE_BOX);
static void
action_button_clicked_cb (GtkButton *button,
@@ -135,180 +135,47 @@ update_label (NautilusFloatingBar *self)
gtk_label_set_text (GTK_LABEL (self->priv->label_widget), self->priv->label);
}
-/* this is adapted from Epiphany:
- * lib/widgets/ephy-overlay-escaping-child.c
- *
- * License: LGPL v2.1+
- * Copyright © 2011 Igalia S.L.
- */
-
-/* If the pointer leaves the window, restore the widget position */
-static gboolean
-parent_leave_notify_event (GtkWidget *widget,
- GdkEventMotion *event,
- GtkWidget *parent)
-{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
- NautilusFloatingBarDetails *priv = self->priv;
- GtkAllocation alloc;
-
- gtk_widget_get_allocation (widget, &alloc);
- alloc.y = priv->initial_allocation.y;
- gtk_widget_size_allocate (widget, &alloc);
-
- return FALSE;
-}
-
-/* this should be in Gdk...really */
-static gboolean
-is_point_in_rectangle (int point_x,
- int point_y,
- GdkRectangle rectangle)
-{
- int rectangle_x_higher_bound = rectangle.x + rectangle.width;
- int rectangle_y_higher_bound = rectangle.y + rectangle.height;
-
- return point_x >= rectangle.x && point_x < rectangle_x_higher_bound
- && point_y >= rectangle.y && point_y < rectangle_y_higher_bound;
-}
-
-/* Keep the widget-pointer distance at at least
- * EphyOverlayEscapingChildPrivate::escaping_distance by sliding the widget
- * away if needed.
- */
static gboolean
-parent_motion_notify_event (GtkWidget *widget,
- GdkEventMotion *event,
- GtkWidget *parent)
+overlay_enter_notify_cb (GtkWidget *parent,
+ GdkEventCrossing *event,
+ gpointer user_data)
{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
- NautilusFloatingBarDetails *priv = self->priv;
- int distance_x, distance_y;
- GtkAllocation alloc;
+ GtkWidget *widget = user_data;
- gtk_widget_get_allocation (widget, &alloc);
+ if (event->window != gtk_widget_get_window (widget)) {
+ return FALSE;
+ }
- if (is_point_in_rectangle (event->x, event->y, priv->escaping_area)) {
- gtk_widget_get_pointer (widget, &distance_x, &distance_y);
- alloc.y += priv->escaping_distance + distance_y;
+ if (gtk_widget_get_halign (widget) == GTK_ALIGN_START) {
+ gtk_widget_set_halign (widget, GTK_ALIGN_END);
} else {
- /* Put the widget at its original position if we are out of the escaping
- * zone. Do nothing if it is already there.
- */
- if (alloc.y == priv->initial_allocation.y) {
- return FALSE;
- }
-
- alloc.y = priv->initial_allocation.y;
+ gtk_widget_set_halign (widget, GTK_ALIGN_START);
}
- gtk_widget_size_allocate (widget, &alloc);
+ gtk_widget_queue_resize (widget);
return FALSE;
}
-/* When the parent overlay is resized, the child relative position is modified.
- * So we update our initial_allocation to this new value and redefine our
- * escaping area.
- */
-static void
-parent_size_allocate (GtkWidget *widget,
- GdkRectangle *allocation,
- GtkWidget *parent)
-{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
- NautilusFloatingBarDetails *priv = self->priv;
- GtkAllocation initial_allocation;
-
- gtk_widget_get_allocation (widget, &initial_allocation);
- priv->escaping_area = priv->initial_allocation = initial_allocation;
-
- /* Define an escaping area around the widget.
- * Current implementation only handle horizontal lowerside widgets
- */
- priv->escaping_area.height += priv->escaping_distance;
- /* escape on both right and left */
- priv->escaping_area.width += 2 * priv->escaping_distance;
- priv->escaping_area.x -= priv->escaping_distance;
- priv->escaping_area.y -= priv->escaping_distance;
-}
-
-/* Install listeners on our overlay parents to locate the pointer
- * and our relative position.
- */
static void
nautilus_floating_bar_parent_set (GtkWidget *widget,
- GtkWidget *previous_parent)
+ GtkWidget *old_parent)
{
GtkWidget *parent;
- if (previous_parent != NULL) {
- g_signal_handlers_disconnect_by_func (previous_parent,
- G_CALLBACK (parent_motion_notify_event),
- widget);
- g_signal_handlers_disconnect_by_func (previous_parent,
- G_CALLBACK (parent_leave_notify_event),
- widget);
- g_signal_handlers_disconnect_by_func (previous_parent,
- G_CALLBACK (parent_size_allocate),
- widget);
- }
-
parent = gtk_widget_get_parent (widget);
- if (parent == NULL) {
- return;
+ if (old_parent != NULL) {
+ g_signal_handlers_disconnect_by_func (old_parent,
+ overlay_enter_notify_cb, widget);
}
- g_signal_connect_swapped (parent,
- "motion-notify-event",
- G_CALLBACK (parent_motion_notify_event),
- widget);
- g_signal_connect_swapped (parent,
- "leave-notify-event",
- G_CALLBACK (parent_leave_notify_event),
- widget);
- g_signal_connect_swapped (parent,
- "size-allocate",
- G_CALLBACK (parent_size_allocate),
- widget);
-}
-
-/* When the mouse is over us, translate the event coords and slide the widget
- * accordingly
- */
-static gboolean
-nautilus_floating_bar_motion_notify (GtkWidget *widget,
- GdkEventMotion *event)
-{
- NautilusFloatingBar *self = NAUTILUS_FLOATING_BAR (widget);
- NautilusFloatingBarDetails *priv = self->priv;
-
- event->x += priv->initial_allocation.x;
- event->y += priv->initial_allocation.y;
- return parent_motion_notify_event (widget, event, gtk_widget_get_parent (widget));
-}
-
-/* Make our event window propagate mouse motion events, so we can slide the widget,
- * when hovered.
- */
-static void
-nautilus_floating_bar_realize (GtkWidget *widget)
-{
- GdkWindow *window;
- GdkEventMask events;
-
- GTK_WIDGET_CLASS (nautilus_floating_bar_parent_class)->realize (widget);
-
- window = gtk_widget_get_window (widget);
- events = gdk_window_get_events (window);
- events |= GDK_POINTER_MOTION_MASK;
-
- gdk_window_set_events (window, events);
+ if (parent != NULL) {
+ g_signal_connect (parent, "enter-notify-event",
+ G_CALLBACK (overlay_enter_notify_cb), widget);
+ }
}
-/* end of code adapted from Epiphany */
-
static void
nautilus_floating_bar_show (GtkWidget *widget)
{
@@ -333,7 +200,7 @@ nautilus_floating_bar_hide (GtkWidget *widget)
static gboolean
nautilus_floating_bar_draw (GtkWidget *widget,
- cairo_t *cr)
+ cairo_t *cr)
{
GtkStyleContext *context;
@@ -369,10 +236,7 @@ nautilus_floating_bar_constructed (GObject *obj)
G_OBJECT_CLASS (nautilus_floating_bar_parent_class)->constructed (obj);
- g_object_get (self,
- "widget", &box,
- NULL);
- gtk_widget_show (box);
+ box = GTK_WIDGET (obj);
w = gtk_spinner_new ();
gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
@@ -393,8 +257,6 @@ nautilus_floating_bar_constructed (GObject *obj)
NULL);
self->priv->label_widget = w;
gtk_widget_show (w);
-
- g_object_unref (box);
}
static void
@@ -419,8 +281,6 @@ nautilus_floating_bar_class_init (NautilusFloatingBarClass *klass)
wclass->show = nautilus_floating_bar_show;
wclass->hide = nautilus_floating_bar_hide;
wclass->parent_set = nautilus_floating_bar_parent_set;
- wclass->motion_notify_event = nautilus_floating_bar_motion_notify;
- wclass->realize = nautilus_floating_bar_realize;
properties[PROP_LABEL] =
g_param_spec_string ("label",
@@ -490,9 +350,10 @@ nautilus_floating_bar_new (const gchar *label,
gboolean show_spinner)
{
return g_object_new (NAUTILUS_TYPE_FLOATING_BAR,
- "widget", gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8),
"label", label,
"show-spinner", show_spinner,
+ "orientation", GTK_ORIENTATION_HORIZONTAL,
+ "spacing", 8,
NULL);
}
@@ -501,18 +362,14 @@ nautilus_floating_bar_add_action (NautilusFloatingBar *self,
const gchar *stock_id,
gint action_id)
{
- GtkWidget *w, *button, *box;
-
- g_object_get (self,
- "widget", &box,
- NULL);
+ GtkWidget *w, *button;
w = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
gtk_widget_show (w);
button = gtk_button_new ();
gtk_button_set_image (GTK_BUTTON (button), w);
- gtk_box_pack_end (GTK_BOX (box), button, FALSE, FALSE, 0);
+ gtk_box_pack_end (GTK_BOX (self), button, FALSE, FALSE, 0);
gtk_widget_show (button);
g_object_set_data (G_OBJECT (button), "action-id",
@@ -520,22 +377,16 @@ nautilus_floating_bar_add_action (NautilusFloatingBar *self,
g_signal_connect (button, "clicked",
G_CALLBACK (action_button_clicked_cb), self);
-
- g_object_unref (box);
}
void
nautilus_floating_bar_cleanup_actions (NautilusFloatingBar *self)
{
- GtkWidget *box, *widget;
+ GtkWidget *widget;
GList *children, *l;
gpointer data;
- g_object_get (self,
- "widget", &box,
- NULL);
-
- children = gtk_container_get_children (GTK_CONTAINER (box));
+ children = gtk_container_get_children (GTK_CONTAINER (self));
l = children;
while (l != NULL) {
@@ -549,6 +400,5 @@ nautilus_floating_bar_cleanup_actions (NautilusFloatingBar *self)
}
}
- g_object_unref (box);
g_list_free (children);
}
diff --git a/src/nautilus-floating-bar.h b/src/nautilus-floating-bar.h
index 99f88a5f5..03ea0f9e1 100644
--- a/src/nautilus-floating-bar.h
+++ b/src/nautilus-floating-bar.h
@@ -28,8 +28,6 @@
#include <gtk/gtk.h>
-#include "gedit-overlay-child.h"
-
#define NAUTILUS_FLOATING_BAR_ACTION_ID_STOP 1
#define NAUTILUS_TYPE_FLOATING_BAR nautilus_floating_bar_get_type()
@@ -49,12 +47,12 @@ typedef struct _NautilusFloatingBarClass NautilusFloatingBarClass;
typedef struct _NautilusFloatingBarDetails NautilusFloatingBarDetails;
struct _NautilusFloatingBar {
- GeditOverlayChild parent;
+ GtkBox parent;
NautilusFloatingBarDetails *priv;
};
struct _NautilusFloatingBarClass {
- GeditOverlayChildClass parent_class;
+ GtkBoxClass parent_class;
};
/* GObject */
diff --git a/src/nautilus-icon-view.c b/src/nautilus-icon-view.c
index ff8017c3c..ff4591170 100644
--- a/src/nautilus-icon-view.c
+++ b/src/nautilus-icon-view.c
@@ -26,7 +26,6 @@
#include "nautilus-icon-view.h"
-#include "gedit-overlay.h"
#include "nautilus-actions.h"
#include "nautilus-icon-view-container.h"
#include "nautilus-desktop-icon-view.h"
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index f1530b9f8..e958d2ec9 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -28,7 +28,6 @@
#include <config.h>
#include "nautilus-list-view.h"
-#include "gedit-overlay.h"
#include "nautilus-list-model.h"
#include "nautilus-error-reporting.h"
#include "nautilus-view-dnd.h"
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 32823da23..26ca81db4 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -23,7 +23,6 @@
*/
#include "nautilus-window-slot.h"
-#include "gedit-overlay.h"
#include "nautilus-desktop-window.h"
#include "nautilus-floating-bar.h"
#include "nautilus-window-private.h"
@@ -184,17 +183,18 @@ nautilus_window_slot_init (NautilusWindowSlot *slot)
gtk_box_pack_start (GTK_BOX (content_box), extras_vbox, FALSE, FALSE, 0);
gtk_widget_show (extras_vbox);
- slot->view_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- slot->view_overlay = gedit_overlay_new (slot->view_box, NULL);
+ slot->view_overlay = gtk_overlay_new ();
+ gtk_widget_add_events (slot->view_overlay,
+ GDK_ENTER_NOTIFY_MASK |
+ GDK_LEAVE_NOTIFY_MASK);
gtk_box_pack_start (GTK_BOX (content_box), slot->view_overlay, TRUE, TRUE, 0);
gtk_widget_show (slot->view_overlay);
- gtk_widget_show (slot->view_box);
slot->floating_bar = nautilus_floating_bar_new ("", FALSE);
- gedit_overlay_add (GEDIT_OVERLAY (slot->view_overlay),
- slot->floating_bar,
- GEDIT_OVERLAY_CHILD_POSITION_SOUTH_EAST,
- 0);
+ gtk_widget_set_halign (slot->floating_bar, GTK_ALIGN_END);
+ gtk_widget_set_valign (slot->floating_bar, GTK_ALIGN_END);
+ gtk_overlay_add_overlay (GTK_OVERLAY (slot->view_overlay),
+ slot->floating_bar);
g_signal_connect (slot->floating_bar, "action",
G_CALLBACK (floating_bar_action_cb), slot);
@@ -457,18 +457,12 @@ nautilus_window_slot_set_content_view_widget (NautilusWindowSlot *slot,
if (new_view != NULL) {
widget = GTK_WIDGET (new_view);
- gtk_box_pack_start (GTK_BOX (slot->view_box), widget,
- TRUE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (slot->view_overlay), widget);
gtk_widget_show (widget);
slot->content_view = new_view;
g_object_ref (slot->content_view);
- g_object_set (slot->view_overlay,
- "relative-widget",
- gtk_bin_get_child (GTK_BIN (slot->content_view)),
- NULL);
-
/* connect new view */
nautilus_window_connect_content_view (window, new_view);
}
diff --git a/src/nautilus-window-slot.h b/src/nautilus-window-slot.h
index 0342c623d..0a2b9223f 100644
--- a/src/nautilus-window-slot.h
+++ b/src/nautilus-window-slot.h
@@ -72,7 +72,6 @@ struct NautilusWindowSlot {
*/
GtkWidget *content_box;
GtkWidget *extra_location_widgets;
- GtkWidget *view_box;
GtkWidget *view_overlay;
GtkWidget *floating_bar;