summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@gnome.org>2018-07-25 09:16:58 +0300
committerErnestas Kulik <ekulik@redhat.com>2019-06-29 14:33:41 +0200
commit75752e6c6ac06c0c4e28d24460e18c466b47d9fc (patch)
tree8dd90a69e301929a746a3a880dc0d64212f3e9ba
parent35bc6115c00e33b0f3b574164cd3e1e590827148 (diff)
downloadnautilus-75752e6c6ac06c0c4e28d24460e18c466b47d9fc.tar.gz
canvas-container: Draw DnD highlight in snapshot()
…instead of connecting to GtkWidget::draw, which has been removed.
-rw-r--r--src/nautilus-canvas-container.c31
-rw-r--r--src/nautilus-canvas-dnd.c34
2 files changed, 32 insertions, 33 deletions
diff --git a/src/nautilus-canvas-container.c b/src/nautilus-canvas-container.c
index db91e84a3..ee727d6b3 100644
--- a/src/nautilus-canvas-container.c
+++ b/src/nautilus-canvas-container.c
@@ -3421,6 +3421,36 @@ nautilus_canvas_container_constructor (GType type,
return object;
}
+static void
+nautilus_canvas_container_snapshot (GtkWidget *widget,
+ GtkSnapshot *snapshot)
+{
+ NautilusCanvasContainer *container;
+
+ container = NAUTILUS_CANVAS_CONTAINER (widget);
+
+ GTK_WIDGET_CLASS (nautilus_canvas_container_parent_class)->snapshot (widget, snapshot);
+
+ if (container->details->dnd_info->highlighted)
+ {
+ GtkStyleContext *context;
+ int width;
+ int height;
+
+ context = gtk_widget_get_style_context (widget);
+ width = gtk_widget_get_width (widget);
+ height = gtk_widget_get_height (widget);
+
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_DND);
+ gtk_style_context_set_state (context, GTK_STATE_FLAG_FOCUSED);
+
+ gtk_snapshot_render_frame (snapshot, context, 0, 0, width, height);
+
+ gtk_style_context_restore (context);
+ }
+}
+
/* Initialization. */
static void
@@ -3647,6 +3677,7 @@ nautilus_canvas_container_class_init (NautilusCanvasContainerClass *class)
widget_class->unrealize = unrealize;
widget_class->style_updated = style_updated;
widget_class->grab_notify = grab_notify_cb;
+ widget_class->snapshot = nautilus_canvas_container_snapshot;
gtk_widget_class_set_accessible_type (widget_class, nautilus_canvas_container_accessible_get_type ());
}
diff --git a/src/nautilus-canvas-dnd.c b/src/nautilus-canvas-dnd.c
index 2e9974339..c43ac5e4c 100644
--- a/src/nautilus-canvas-dnd.c
+++ b/src/nautilus-canvas-dnd.c
@@ -1084,32 +1084,6 @@ nautilus_canvas_dnd_begin_drag (NautilusCanvasContainer *container,
dnd_info->drag_info.start_y);
}
-static gboolean
-drag_highlight_draw (GtkWidget *widget,
- cairo_t *cr,
- gpointer user_data)
-{
- gint width, height;
- GdkSurface *surface;
- GtkStyleContext *style;
-
- surface = gtk_widget_get_surface (widget);
- width = gdk_surface_get_width (surface);
- height = gdk_surface_get_height (surface);
-
- style = gtk_widget_get_style_context (widget);
-
- gtk_style_context_save (style);
- gtk_style_context_add_class (style, GTK_STYLE_CLASS_DND);
- gtk_style_context_set_state (style, GTK_STATE_FLAG_FOCUSED);
-
- gtk_render_frame (style, cr, 0, 0, width, height);
-
- gtk_style_context_restore (style);
-
- return FALSE;
-}
-
static void
start_dnd_highlight (GtkWidget *widget)
{
@@ -1120,9 +1094,6 @@ start_dnd_highlight (GtkWidget *widget)
if (!dnd_info->highlighted)
{
dnd_info->highlighted = TRUE;
- g_signal_connect_after (widget, "draw",
- G_CALLBACK (drag_highlight_draw),
- NULL);
gtk_widget_queue_draw (widget);
}
}
@@ -1136,11 +1107,8 @@ stop_dnd_highlight (GtkWidget *widget)
if (dnd_info->highlighted)
{
- g_signal_handlers_disconnect_by_func (widget,
- drag_highlight_draw,
- NULL);
- gtk_widget_queue_draw (widget);
dnd_info->highlighted = FALSE;
+ gtk_widget_queue_draw (widget);
}
}