droptarget: Drop defaults flags

These no longer have any effect.

Update all callers.
This commit is contained in:
Matthias Clasen 2020-01-05 17:23:50 -05:00
parent cb26cd7391
commit 46f42fc53d
23 changed files with 27 additions and 118 deletions

View File

@ -339,7 +339,7 @@ do_clipboard (GtkWidget *do_widget)
/* accept drops on image */
formats = gdk_content_formats_new (NULL, 0);
formats = gtk_content_formats_add_image_targets (formats, FALSE);
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_MOTION|GTK_DEST_DEFAULT_HIGHLIGHT, formats, GDK_ACTION_COPY);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
gtk_drop_target_attach (dest, image);
@ -372,7 +372,7 @@ do_clipboard (GtkWidget *do_widget)
/* accept drops on image */
formats = gdk_content_formats_new (NULL, 0);
formats = gtk_content_formats_add_image_targets (formats, FALSE);
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_MOTION|GTK_DEST_DEFAULT_HIGHLIGHT, formats, GDK_ACTION_COPY);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
gtk_drop_target_attach (dest, image);

View File

@ -784,7 +784,7 @@ gtk_calendar_init (GtkCalendar *calendar)
formats = gdk_content_formats_new (NULL, 0);
formats = gtk_content_formats_add_text_targets (formats);
dest = gtk_drop_target_new (0, formats, GDK_ACTION_COPY);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_calendar_drag_motion), calendar);

View File

@ -326,7 +326,7 @@ gtk_color_button_init (GtkColorButton *button)
priv->use_alpha = FALSE;
targets = gdk_content_formats_new (drop_types, G_N_ELEMENTS (drop_types));
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT, targets, GDK_ACTION_COPY);
dest = gtk_drop_target_new (targets, GDK_ACTION_COPY);
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_color_button_drag_drop), button);
gtk_drop_target_attach (dest, GTK_WIDGET (button));
gdk_content_formats_unref (targets);

View File

@ -676,7 +676,7 @@ gtk_color_swatch_set_can_drop (GtkColorSwatch *swatch,
GdkContentFormats *targets;
targets = gdk_content_formats_new (dnd_targets, G_N_ELEMENTS (dnd_targets));
priv->dest = gtk_drop_target_new (GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT, targets, GDK_ACTION_COPY);
priv->dest = gtk_drop_target_new (targets, GDK_ACTION_COPY);
g_signal_connect (priv->dest, "drag-drop", G_CALLBACK (swatch_drag_drop), swatch);
gtk_drop_target_attach (priv->dest, GTK_WIDGET (swatch));
gdk_content_formats_unref (targets);

View File

@ -55,7 +55,6 @@ struct _GtkDropTarget
GdkContentFormats *formats;
GdkDragAction actions;
GtkDestDefaults defaults;
GtkWidget *widget;
GdkDrop *drop;
@ -76,7 +75,6 @@ struct _GtkDropTargetClass
enum {
PROP_FORMATS = 1,
PROP_ACTIONS,
PROP_DEFAULTS,
PROP_TRACK_MOTION,
PROP_ARMED,
NUM_PROPERTIES
@ -103,7 +101,6 @@ G_DEFINE_TYPE (GtkDropTarget, gtk_drop_target, G_TYPE_OBJECT);
static void
gtk_drop_target_init (GtkDropTarget *dest)
{
dest->defaults = GTK_DEST_DEFAULT_ALL;
}
static void
@ -134,10 +131,6 @@ gtk_drop_target_set_property (GObject *object,
gtk_drop_target_set_actions (dest, g_value_get_flags (value));
break;
case PROP_DEFAULTS:
gtk_drop_target_set_defaults (dest, g_value_get_flags (value));
break;
case PROP_TRACK_MOTION:
gtk_drop_target_set_track_motion (dest, g_value_get_boolean (value));
break;
@ -165,10 +158,6 @@ gtk_drop_target_get_property (GObject *object,
g_value_set_flags (value, gtk_drop_target_get_actions (dest));
break;
case PROP_DEFAULTS:
g_value_set_flags (value, gtk_drop_target_get_defaults (dest));
break;
case PROP_TRACK_MOTION:
g_value_set_boolean (value, gtk_drop_target_get_track_motion (dest));
break;
@ -213,16 +202,6 @@ gtk_drop_target_class_init (GtkDropTargetClass *class)
GDK_TYPE_DRAG_ACTION, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkDropTargets:defaults:
*
* Flags that determine the default behavior
*/
properties[PROP_DEFAULTS] =
g_param_spec_flags ("defaults", P_("Defaults"), P_("Defaults"),
GTK_TYPE_DEST_DEFAULTS, GTK_DEST_DEFAULT_ALL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkDropTarget:track-motion:
*
@ -351,7 +330,6 @@ gtk_drop_target_class_init (GtkDropTargetClass *class)
/**
* gtk_drop_target_new:
* @defaults: flags determining the default behaviour
* @formats: (nullable): the supported data formats
* @actions: the supported actions
*
@ -360,12 +338,10 @@ gtk_drop_target_class_init (GtkDropTargetClass *class)
* Returns: the new #GtkDropTarget
*/
GtkDropTarget *
gtk_drop_target_new (GtkDestDefaults defaults,
GdkContentFormats *formats,
gtk_drop_target_new (GdkContentFormats *formats,
GdkDragAction actions)
{
return g_object_new (GTK_TYPE_DROP_TARGET,
"defaults", defaults,
"formats", formats,
"actions", actions,
NULL);
@ -451,43 +427,6 @@ gtk_drop_target_get_actions (GtkDropTarget *dest)
return dest->actions;
}
/**
* gtk_drop_target_set_defaults:
* @dest: a #GtkDropTarget
* @defaults: flags determining the default behaviour
*
* Sets the flags determining the behavior of the drop target.
*/
void
gtk_drop_target_set_defaults (GtkDropTarget *dest,
GtkDestDefaults defaults)
{
g_return_if_fail (GTK_IS_DROP_TARGET (dest));
if (dest->defaults == defaults)
return;
dest->defaults = defaults;
g_object_notify_by_pspec (G_OBJECT (dest), properties[PROP_DEFAULTS]);
}
/**
* gtk_drop_target_get_defaults:
* @dest: a #GtkDropTarget
*
* Gets the flags determining the behavior of the drop target.
*
* Returns: flags determining the behaviour of the drop target
*/
GtkDestDefaults
gtk_drop_target_get_defaults (GtkDropTarget *dest)
{
g_return_val_if_fail (GTK_IS_DROP_TARGET (dest), GTK_DEST_DEFAULT_ALL);
return dest->defaults;
}
/**
* gtk_drop_target_set_track_motion:
* @dest: a #GtkDropTarget

View File

@ -39,29 +39,6 @@ G_BEGIN_DECLS
typedef struct _GtkDropTarget GtkDropTarget;
/**
* GtkDestDefaults:
* @GTK_DEST_DEFAULT_MOTION: If set for a widget, GTK+, during a drag over this
* widget will check if the drag matches this widgets list of possible formats
* and actions.
* GTK+ will then call gdk_drag_status() as appropriate.
* @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.
*
* The #GtkDestDefaults enumeration specifies the various
* types of action that will be taken on behalf
* of the user for a drag destination site.
*/
typedef enum {
GTK_DEST_DEFAULT_MOTION = 1 << 0,
GTK_DEST_DEFAULT_HIGHLIGHT = 1 << 1,
GTK_DEST_DEFAULT_DROP = 1 << 2,
GTK_DEST_DEFAULT_ALL = 0x7
} GtkDestDefaults;
#define GTK_TYPE_DROP_TARGET (gtk_drop_target_get_type ())
#define GTK_DROP_TARGET(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_DROP_TARGET, GtkDropTarget))
@ -76,8 +53,7 @@ GDK_AVAILABLE_IN_ALL
GType gtk_drop_target_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GtkDropTarget *gtk_drop_target_new (GtkDestDefaults defaults,
GdkContentFormats *formats,
GtkDropTarget *gtk_drop_target_new (GdkContentFormats *formats,
GdkDragAction actions);
GDK_AVAILABLE_IN_ALL
@ -92,12 +68,6 @@ void gtk_drop_target_set_actions (GtkDropTarget *dest,
GDK_AVAILABLE_IN_ALL
GdkDragAction gtk_drop_target_get_actions (GtkDropTarget *dest);
GDK_AVAILABLE_IN_ALL
void gtk_drop_target_set_defaults (GtkDropTarget *dest,
GtkDestDefaults defaults);
GDK_AVAILABLE_IN_ALL
GtkDestDefaults gtk_drop_target_get_defaults (GtkDropTarget *dest);
GDK_AVAILABLE_IN_ALL
void gtk_drop_target_set_track_motion (GtkDropTarget *dest,
gboolean track_motion);

View File

@ -375,7 +375,7 @@ gtk_expander_init (GtkExpander *expander)
gtk_container_add (GTK_CONTAINER (priv->title_widget), priv->arrow_widget);
formats = gdk_content_formats_new (NULL, 0);
dest = gtk_drop_target_new (0, formats, 0);
dest = gtk_drop_target_new (formats, 0);
gtk_drop_target_set_track_motion (dest, TRUE);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_expander_drag_motion), expander);

View File

@ -498,7 +498,7 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
target_list = gdk_content_formats_new (NULL, 0);
target_list = gtk_content_formats_add_uri_targets (target_list);
target_list = gtk_content_formats_add_text_targets (target_list);
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT, target_list, GDK_ACTION_COPY);
dest = gtk_drop_target_new (target_list, GDK_ACTION_COPY);
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_file_chooser_button_drag_drop), button);
gtk_drop_target_attach (dest, GTK_WIDGET (button));
gdk_content_formats_unref (target_list);

View File

@ -8519,7 +8519,7 @@ post_process_ui (GtkFileChooserWidget *impl)
g_signal_connect (source, "drag-end", G_CALLBACK (file_list_drag_end_cb), impl);
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_ALL, formats, GDK_ACTION_COPY | GDK_ACTION_MOVE);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-motion", G_CALLBACK (file_list_drag_motion_cb), impl);
g_signal_connect (dest, "drag-drop", G_CALLBACK (file_list_drag_drop_cb), impl);
gtk_drop_target_attach (dest, priv->browse_files_tree_view);

View File

@ -6495,7 +6495,7 @@ gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
{
g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), NULL);
icon_view->priv->dest = gtk_drop_target_new (0, formats, actions);
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);
g_signal_connect (icon_view->priv->dest, "drag-motion", G_CALLBACK (gtk_icon_view_drag_motion), icon_view);
g_signal_connect (icon_view->priv->dest, "drag-drop", G_CALLBACK (gtk_icon_view_drag_drop), icon_view);

View File

@ -1325,7 +1325,7 @@ gtk_notebook_init (GtkNotebook *notebook)
priv->has_scrolled = FALSE;
targets = gdk_content_formats_new (dst_notebook_targets, G_N_ELEMENTS (dst_notebook_targets));
dest = gtk_drop_target_new (0, targets, GDK_ACTION_MOVE);
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_notebook_drag_motion), NULL);
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_notebook_drag_leave), NULL);
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_notebook_drag_drop), NULL);

View File

@ -4094,7 +4094,7 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
/* DND support */
formats = gdk_content_formats_new (dnd_drop_targets, G_N_ELEMENTS (dnd_drop_targets));
formats = gtk_content_formats_add_uri_targets (formats);
dest = gtk_drop_target_new (0, formats, GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
dest = gtk_drop_target_new (formats, GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-motion", G_CALLBACK (drag_motion_callback), sidebar);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop_callback), sidebar);

View File

@ -116,7 +116,7 @@ gtk_stack_switcher_init (GtkStackSwitcher *switcher)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_LINKED);
formats = gdk_content_formats_new (NULL, 0);
dest = gtk_drop_target_new (0, formats, 0);
dest = gtk_drop_target_new (formats, 0);
gdk_content_formats_unref (formats);
gtk_drop_target_set_track_motion (dest, TRUE);
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_stack_switcher_drag_leave), switcher);

View File

@ -1727,7 +1727,7 @@ gtk_text_init (GtkText *self)
formats = gdk_content_formats_new (NULL, 0);
formats = gtk_content_formats_add_text_targets (formats);
dest = gtk_drop_target_new (0, formats, GDK_ACTION_COPY | GDK_ACTION_MOVE);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_text_drag_motion), self);
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_text_drag_leave), self);
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_text_drag_drop), self);

View File

@ -1630,7 +1630,7 @@ gtk_text_view_init (GtkTextView *text_view)
priv->scroll_after_paste = FALSE;
formats = gdk_content_formats_new_for_gtype (GTK_TYPE_TEXT_BUFFER);
dest = gtk_drop_target_new (0, formats, GDK_ACTION_COPY | GDK_ACTION_MOVE);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY | GDK_ACTION_MOVE);
gdk_content_formats_unref (formats);
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_text_view_drag_leave), text_view);
g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_text_view_drag_motion), text_view);

View File

@ -12964,7 +12964,7 @@ gtk_tree_view_enable_model_drag_dest (GtkTreeView *tree_view,
di = ensure_info (tree_view);
di->dest_set = TRUE;
di->dest = gtk_drop_target_new (0, formats, actions);
di->dest = gtk_drop_target_new (formats, actions);
g_signal_connect (di->dest, "drag-leave", G_CALLBACK (gtk_tree_view_drag_leave), tree_view);
g_signal_connect (di->dest, "drag-motion", G_CALLBACK (gtk_tree_view_drag_motion), tree_view);
g_signal_connect (di->dest, "drag-drop", G_CALLBACK (gtk_tree_view_drag_drop), tree_view);

View File

@ -1839,7 +1839,7 @@ gtk_window_init (GtkWindow *window)
#ifdef GDK_WINDOWING_X11
targets = gdk_content_formats_new (dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets));
dest = gtk_drop_target_new ( GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, targets, GDK_ACTION_MOVE);
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
gdk_content_formats_unref (targets);
gtk_drop_target_attach (dest, GTK_WIDGET (window));
#endif

View File

@ -501,7 +501,7 @@ popup_cb (gpointer data)
gtk_widget_set_vexpand (button, TRUE);
gtk_grid_attach (GTK_GRID (grid), button, i, j, 1, 1);
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_ALL, targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
dest = gtk_drop_target_new (targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-motion", G_CALLBACK (popup_motion), NULL);
g_signal_connect (dest, "drag-leave", G_CALLBACK (popup_leave), NULL);
gtk_drop_target_attach (dest, button);
@ -595,7 +595,7 @@ main (int argc, char **argv)
label = gtk_label_new ("Drop Here\n");
targets = gdk_content_formats_new (target_table, n_targets - 1); /* no rootwin */
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT, targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
dest = gtk_drop_target_new (targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-drop", G_CALLBACK (label_drag_drop), NULL);
gtk_drop_target_attach (dest, label);
@ -605,7 +605,7 @@ main (int argc, char **argv)
label = gtk_label_new ("Popup\n");
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_ALL, targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
dest = gtk_drop_target_new (targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-motion", G_CALLBACK (popsite_motion), NULL);
g_signal_connect (dest, "drag-leave", G_CALLBACK (popsite_leave), NULL);
gtk_drop_target_attach (dest, label);
@ -618,7 +618,7 @@ main (int argc, char **argv)
pixmap = gtk_image_new_from_pixbuf (trashcan_closed);
targets = gdk_content_formats_new (NULL, 0);
dest = gtk_drop_target_new (0, targets, 0);
dest = gtk_drop_target_new (targets, 0);
g_signal_connect (dest, "drag-leave", G_CALLBACK (target_drag_leave), pixmap);
g_signal_connect (dest, "drag-motion", G_CALLBACK (target_drag_motion), pixmap);
g_signal_connect (dest, "drag-drop", G_CALLBACK (target_drag_drop), pixmap);

View File

@ -305,7 +305,7 @@ make_image (const gchar *icon_name, int hotspot)
g_signal_connect (source, "drag-failed", G_CALLBACK (drag_failed), NULL);
gtk_drag_source_attach (source, image, GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK);
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT, formats, GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_ASK);
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_ASK);
g_signal_connect (dest, "drag-drop", G_CALLBACK (image_drag_drop), image);
gtk_drop_target_attach (dest, image);

View File

@ -88,7 +88,7 @@ create_row (const gchar *text)
gtk_drag_source_attach (source, image, GDK_BUTTON1_MASK);
targets = gdk_content_formats_new (entries, 1);
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT, targets, GDK_ACTION_MOVE);
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), row);
gtk_drop_target_attach (dest, row);

View File

@ -301,7 +301,7 @@ create_trash_button (void)
button = gtk_button_new_with_mnemonic ("_Delete");
targets = gdk_content_formats_new (button_targets, G_N_ELEMENTS (button_targets));
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_MOTION, targets, GDK_ACTION_MOVE);
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
g_signal_connect (dest, "drag-drop", G_CALLBACK (on_button_drag_drop), NULL);
gtk_drop_target_attach (dest, button);
gdk_content_formats_unref (targets);

View File

@ -621,7 +621,7 @@ main (gint argc, gchar **argv)
source = gtk_drag_source_new (content, GDK_ACTION_MOVE);
g_object_unref (content);
gtk_drag_source_attach (source, button, GDK_BUTTON1_MASK);
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_DROP, targets, GDK_ACTION_MOVE);
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
g_signal_connect (dest, "drag_motion", G_CALLBACK (toolbar_drag_motion), toolbar);
g_signal_connect (dest, "drag_leave", G_CALLBACK (toolbar_drag_leave), toolbar);
g_signal_connect (dest, "drag_drop", G_CALLBACK (toolbar_drag_drop), label);

View File

@ -125,7 +125,7 @@ get_droptarget (void)
label = gtk_label_new ("Drop here");
targets = gdk_content_formats_new (entries, G_N_ELEMENTS (entries));
dest = gtk_drop_target_new (GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT, targets, GDK_ACTION_COPY);
dest = gtk_drop_target_new (targets, GDK_ACTION_COPY);
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), NULL);
gtk_drop_target_attach (dest, label);
gdk_content_formats_unref (targets);