forked from AuroraMiddleware/gtk
colorswatch: Switch to dragged color during dnd
This is really simple to implement now, so do it.
This commit is contained in:
parent
3f7b401de0
commit
c3fb6ca747
@ -89,25 +89,35 @@ swatch_snapshot (GtkWidget *widget,
|
||||
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
||||
const int width = gtk_widget_get_width (widget);
|
||||
const int height = gtk_widget_get_height (widget);
|
||||
const GdkRGBA *color;
|
||||
|
||||
color = &priv->color;
|
||||
if (priv->dest)
|
||||
{
|
||||
const GValue *value = gtk_drop_target_get_value (priv->dest);
|
||||
|
||||
if (value)
|
||||
color = g_value_get_boxed (value);
|
||||
}
|
||||
|
||||
if (priv->has_color)
|
||||
{
|
||||
if (priv->use_alpha && !gdk_rgba_is_opaque (&priv->color))
|
||||
if (priv->use_alpha && !gdk_rgba_is_opaque (color))
|
||||
{
|
||||
_gtk_color_chooser_snapshot_checkered_pattern (snapshot, width, height);
|
||||
|
||||
gtk_snapshot_append_color (snapshot,
|
||||
&priv->color,
|
||||
color,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkRGBA color = priv->color;
|
||||
GdkRGBA opaque = *color;
|
||||
|
||||
color.alpha = 1.0;
|
||||
opaque.alpha = 1.0;
|
||||
|
||||
gtk_snapshot_append_color (snapshot,
|
||||
&color,
|
||||
&opaque,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height));
|
||||
}
|
||||
}
|
||||
@ -654,7 +664,9 @@ gtk_color_swatch_set_can_drop (GtkColorSwatch *swatch,
|
||||
if (can_drop && !priv->dest)
|
||||
{
|
||||
priv->dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
|
||||
gtk_drop_target_set_preload (priv->dest, TRUE);
|
||||
g_signal_connect (priv->dest, "drop", G_CALLBACK (swatch_drag_drop), swatch);
|
||||
g_signal_connect_swapped (priv->dest, "notify::value", G_CALLBACK (gtk_widget_queue_draw), swatch);
|
||||
gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (priv->dest));
|
||||
}
|
||||
if (!can_drop && priv->dest)
|
||||
|
Loading…
Reference in New Issue
Block a user