Compare commits

...

1 Commits

Author SHA1 Message Date
Matthias Clasen
ee001feb91 dnd: Style no-drop icons differently
Add a .no-drop style class to drag icons if there is no selected
action, and style the icon to be translucent in that case, to
indicate 'no drop'.

Related: #6337
2024-08-31 22:42:17 +00:00
2 changed files with 18 additions and 0 deletions

View File

@@ -399,6 +399,17 @@ gtk_drag_icon_init (GtkDragIcon *self)
gtk_widget_set_can_target (GTK_WIDGET (self), FALSE);
}
static void
selected_action_changed (GdkDrag *drag,
GParamSpec *pspec,
GtkWidget *self)
{
if (gdk_drag_get_selected_action (drag) == 0)
gtk_widget_add_css_class (self, "no-drop");
else
gtk_widget_remove_css_class (self, "no-drop");
}
/**
* gtk_drag_icon_get_for_drag: (constructor)
* @drag: a `GdkDrag`
@@ -428,6 +439,9 @@ gtk_drag_icon_get_for_drag (GdkDrag *drag)
GTK_DRAG_ICON (self)->surface = g_object_ref (gdk_drag_get_drag_surface (drag));
g_signal_connect_object (drag, "notify::selected-action", G_CALLBACK (selected_action_changed), self, 0);
selected_action_changed (drag, NULL, self);
g_object_set_qdata_full (G_OBJECT (drag), drag_icon_quark, g_object_ref_sink (self), g_object_unref);
if (GTK_DRAG_ICON (self)->child != NULL)

View File

@@ -31,6 +31,10 @@ dnd {
color: $fg-color;
}
dnd.no-drop {
filter: opacity(0.5);
}
.normal-icons {
-gtk-icon-size: 16px;
}