mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-09-18 21:10:00 +00:00
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
This commit is contained in:
parent
6c88713f82
commit
ee001feb91
@ -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)
|
||||
|
@ -31,6 +31,10 @@ dnd {
|
||||
color: $fg-color;
|
||||
}
|
||||
|
||||
dnd.no-drop {
|
||||
filter: opacity(0.5);
|
||||
}
|
||||
|
||||
.normal-icons {
|
||||
-gtk-icon-size: 16px;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user