[gtk/dnd-gestures-2: 154/242] Drop GTK_DEST_DEFAULT_HIGHLIGHT
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/dnd-gestures-2: 154/242] Drop GTK_DEST_DEFAULT_HIGHLIGHT
- Date: Tue, 7 Jan 2020 19:56:19 +0000 (UTC)
commit 8cde680384c9b3e7b3d5eec478e18bc71e44d75f
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jan 5 09:49:45 2020 -0500
Drop GTK_DEST_DEFAULT_HIGHLIGHT
Redo highlight handling slightly. GtkDropTarget now has
a ::armed property that can be tracked to do custom highlighting,
and we always add the dnd style class to armed drop sites.
gtk/gtkdnd.c | 11 +----------
gtk/gtkdragdest.c | 29 +++++++++++++++++++++++++++++
gtk/gtkdragdest.h | 5 ++---
3 files changed, 32 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 71ae8405b5..5e31546b89 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -357,9 +357,6 @@ gtk_drag_dest_leave (GtkWidget *widget,
track_motion = gtk_drop_target_get_track_motion (dest);
armed = gtk_drop_target_get_armed (dest);
- if ((flags & GTK_DEST_DEFAULT_HIGHLIGHT) && armed)
- gtk_drag_unhighlight (widget);
-
if (!(flags & GTK_DEST_DEFAULT_MOTION) || armed || track_motion)
gtk_drop_target_emit_drag_leave (dest, drop, time);
@@ -400,13 +397,7 @@ gtk_drag_dest_motion (GtkWidget *widget,
if (actions && target)
{
- if (!gtk_drop_target_get_armed (dest))
- {
- gtk_drop_target_set_armed (dest, TRUE);
- if (flags & GTK_DEST_DEFAULT_HIGHLIGHT)
- gtk_drag_highlight (widget);
- }
-
+ gtk_drop_target_set_armed (dest, TRUE);
gdk_drop_status (drop, dest_actions);
}
else
diff --git a/gtk/gtkdragdest.c b/gtk/gtkdragdest.c
index b8d66334a0..0c1b86c10e 100644
--- a/gtk/gtkdragdest.c
+++ b/gtk/gtkdragdest.c
@@ -73,6 +73,7 @@ enum {
PROP_ACTIONS,
PROP_DEFAULTS,
PROP_TRACK_MOTION,
+ PROP_ARMED,
NUM_PROPERTIES
};
@@ -163,6 +164,10 @@ gtk_drop_target_get_property (GObject *object,
g_value_set_boolean (value, gtk_drop_target_get_track_motion (dest));
break;
+ case PROP_ARMED:
+ g_value_set_boolean (value, gtk_drop_target_get_armed (dest));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -218,6 +223,17 @@ gtk_drop_target_class_init (GtkDropTargetClass *class)
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * GtkDropTarget:armmed:
+ *
+ * Whether the drop target is currently the targed of an ongoing drag operation,
+ * and highlighted.
+ */
+ properties[PROP_ARMED] =
+ g_param_spec_boolean ("armed", P_("Armed"), P_("Armed"),
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
/**
@@ -713,7 +729,20 @@ void
gtk_drop_target_set_armed (GtkDropTarget *target,
gboolean armed)
{
+ if (target->armed == armed)
+ return;
+
target->armed = armed;
+
+ if (target->widget)
+ {
+ if (armed)
+ gtk_drag_highlight (target->widget);
+ else
+ gtk_drag_unhighlight (target->widget);
+ }
+
+ g_object_notify_by_pspec (G_OBJECT (target), properties[PROP_ARMED]);
}
gboolean
diff --git a/gtk/gtkdragdest.h b/gtk/gtkdragdest.h
index e28d5b3aa9..2854eef2c3 100644
--- a/gtk/gtkdragdest.h
+++ b/gtk/gtkdragdest.h
@@ -45,9 +45,8 @@ typedef struct _GtkDropTarget GtkDropTarget;
* widget will check if the drag matches this widget’s list of possible formats
* and actions.
* GTK+ will then call gdk_drag_status() as appropriate.
- * @GTK_DEST_DEFAULT_HIGHLIGHT: If set for a widget, GTK+ will draw a highlight on
- * this widget as long as a drag is over this widget and the widget drag format
- * and action are acceptable.
+ * @GTK_DEST_DEFAULT_HIGHLIGHT: Does not do anything now. GTK always adds
+ * the dnd style class to armed drop sites.
* @GTK_DEST_DEFAULT_DROP: Does not do anything now.
* @GTK_DEST_DEFAULT_ALL: If set, specifies that all default actions should
* be taken.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]