[gtk/dnd-gestures-2: 160/175] iconview: Use a named subnode for dnd highlight
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/dnd-gestures-2: 160/175] iconview: Use a named subnode for dnd highlight
- Date: Wed, 8 Jan 2020 16:51:18 +0000 (UTC)
commit c563fa31f9fa90f5c8adad792552905b467f7f84
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 7 17:29:44 2020 -0500
iconview: Use a named subnode for dnd highlight
This is necessary because we want to style the
iconview itself and the item highlighting differently.
gtk/gtkiconview.c | 14 ++++++++++++--
gtk/gtkiconviewprivate.h | 1 +
2 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 85f90a2991..7ba475b09e 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -1754,8 +1754,7 @@ gtk_icon_view_snapshot (GtkWidget *widget,
break;
}
-
- gtk_style_context_save (context);
+ gtk_style_context_save_to_node (context, icon_view->priv->dndnode);
gtk_style_context_set_state (context, gtk_style_context_get_state (context) |
GTK_STATE_FLAG_DROP_ACTIVE);
gtk_snapshot_render_frame (snapshot, context,
@@ -6450,6 +6449,7 @@ gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
GdkDragAction actions)
{
g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), NULL);
+ GtkCssNode *widget_node;
icon_view->priv->dest = gtk_drop_target_new (formats, actions);
g_signal_connect (icon_view->priv->dest, "drag-leave", G_CALLBACK (gtk_icon_view_drag_leave), icon_view);
@@ -6463,6 +6463,13 @@ gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
unset_reorderable (icon_view);
+ widget_node = gtk_widget_get_css_node (GTK_WIDGET (icon_view));
+ icon_view->priv->dndnode = gtk_css_node_new ();
+ gtk_css_node_set_name (icon_view->priv->dndnode, I_("dndtarget"));
+ gtk_css_node_set_parent (icon_view->priv->dndnode, widget_node);
+ gtk_css_node_set_state (icon_view->priv->dndnode, gtk_css_node_get_state (widget_node));
+ g_object_unref (icon_view->priv->dndnode);
+
return icon_view->priv->dest;
}
@@ -6504,6 +6511,9 @@ gtk_icon_view_unset_model_drag_dest (GtkIconView *icon_view)
gtk_widget_remove_controller (GTK_WIDGET (icon_view), GTK_EVENT_CONTROLLER (icon_view->priv->dest));
icon_view->priv->dest = NULL;
icon_view->priv->dest_set = FALSE;
+
+ gtk_css_node_set_parent (icon_view->priv->dndnode, NULL);
+ icon_view->priv->dndnode = NULL;
}
unset_reorderable (icon_view);
diff --git a/gtk/gtkiconviewprivate.h b/gtk/gtkiconviewprivate.h
index aaa9210be5..97ceed2986 100644
--- a/gtk/gtkiconviewprivate.h
+++ b/gtk/gtkiconviewprivate.h
@@ -135,6 +135,7 @@ struct _GtkIconViewPrivate
GdkContentFormats *source_formats;
GtkDropTarget *dest;
+ GtkCssNode *dndnode;
GdkDrag *drag;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]