forked from AuroraMiddleware/gtk
dragdest: Make gtk_drop_target_new() args be transfer full
Saves tons of code.
This commit is contained in:
parent
91d91a29e8
commit
80ba7fd682
@ -273,7 +273,6 @@ do_clipboard (GtkWidget *do_widget)
|
||||
GActionGroup *actions;
|
||||
GtkDragSource *source;
|
||||
GtkDropTarget *dest;
|
||||
GdkContentFormats *formats;
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_display (GTK_WINDOW (window),
|
||||
@ -342,9 +341,7 @@ do_clipboard (GtkWidget *do_widget)
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
|
||||
|
||||
/* accept drops on image */
|
||||
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE);
|
||||
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
|
||||
gdk_content_formats_unref (formats);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE), GDK_ACTION_COPY);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
@ -373,9 +370,7 @@ do_clipboard (GtkWidget *do_widget)
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
|
||||
|
||||
/* accept drops on image */
|
||||
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE);
|
||||
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
|
||||
gdk_content_formats_unref (formats);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new_for_gtype (GDK_TYPE_TEXTURE), GDK_ACTION_COPY);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
|
@ -536,7 +536,6 @@ gtk_calendar_init (GtkCalendar *calendar)
|
||||
#else
|
||||
gchar *week_start;
|
||||
#endif
|
||||
GdkContentFormats *formats;
|
||||
GtkDropTarget *dest;
|
||||
int min_year_width;
|
||||
GDateTime *now;
|
||||
@ -718,9 +717,8 @@ gtk_calendar_init (GtkCalendar *calendar)
|
||||
|
||||
priv->in_drag = 0;
|
||||
|
||||
formats = gdk_content_formats_new_for_gtype (G_TYPE_STRING);
|
||||
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
|
||||
gdk_content_formats_unref (formats);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new_for_gtype (G_TYPE_STRING),
|
||||
GDK_ACTION_COPY);
|
||||
|
||||
g_signal_connect (dest, "accept", G_CALLBACK (gtk_calendar_drag_accept), calendar);
|
||||
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_calendar_drag_leave), calendar);
|
||||
|
@ -295,7 +295,6 @@ gtk_color_button_init (GtkColorButton *button)
|
||||
GtkColorButtonPrivate *priv = gtk_color_button_get_instance_private (button);
|
||||
PangoLayout *layout;
|
||||
PangoRectangle rect;
|
||||
GdkContentFormats *formats;
|
||||
GtkDragSource *source;
|
||||
GtkDropTarget *dest;
|
||||
|
||||
@ -321,11 +320,10 @@ gtk_color_button_init (GtkColorButton *button)
|
||||
priv->rgba.alpha = 1;
|
||||
priv->use_alpha = FALSE;
|
||||
|
||||
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_RGBA);
|
||||
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new_for_gtype (GDK_TYPE_RGBA),
|
||||
GDK_ACTION_COPY);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_color_button_drag_drop), button);
|
||||
gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (dest));
|
||||
gdk_content_formats_unref (formats);
|
||||
|
||||
source = gtk_drag_source_new ();
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (gtk_color_button_drag_prepare), button);
|
||||
|
@ -661,10 +661,8 @@ gtk_color_swatch_set_can_drop (GtkColorSwatch *swatch,
|
||||
|
||||
if (can_drop && !priv->dest)
|
||||
{
|
||||
GdkContentFormats *formats;
|
||||
|
||||
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_RGBA);
|
||||
priv->dest = gtk_drop_target_new (formats, GDK_ACTION_COPY);
|
||||
priv->dest = gtk_drop_target_new (gdk_content_formats_new_for_gtype (GDK_TYPE_RGBA),
|
||||
GDK_ACTION_COPY);
|
||||
g_signal_connect (priv->dest, "drag-drop", G_CALLBACK (swatch_drag_drop), swatch);
|
||||
gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (priv->dest));
|
||||
}
|
||||
|
@ -392,7 +392,7 @@ gtk_drop_target_class_init (GtkDropTargetClass *class)
|
||||
|
||||
/**
|
||||
* gtk_drop_target_new:
|
||||
* @formats: (nullable): the supported data formats
|
||||
* @formats: (nullable) (transfer full): the supported data formats
|
||||
* @actions: the supported actions
|
||||
*
|
||||
* Creates a new #GtkDropTarget object.
|
||||
@ -403,10 +403,16 @@ GtkDropTarget *
|
||||
gtk_drop_target_new (GdkContentFormats *formats,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
return g_object_new (GTK_TYPE_DROP_TARGET,
|
||||
"formats", formats,
|
||||
"actions", actions,
|
||||
NULL);
|
||||
GtkDropTarget *result;
|
||||
|
||||
result = g_object_new (GTK_TYPE_DROP_TARGET,
|
||||
"formats", formats,
|
||||
"actions", actions,
|
||||
NULL);
|
||||
|
||||
g_clear_pointer (&formats, gdk_content_formats_unref);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -348,7 +348,6 @@ gtk_expander_init (GtkExpander *expander)
|
||||
GtkExpanderPrivate *priv = gtk_expander_get_instance_private (expander);
|
||||
GtkGesture *gesture;
|
||||
GtkDropTarget *dest;
|
||||
GdkContentFormats *formats;
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (expander), TRUE);
|
||||
|
||||
@ -373,9 +372,7 @@ gtk_expander_init (GtkExpander *expander)
|
||||
gtk_widget_add_css_class (priv->arrow_widget, GTK_STYLE_CLASS_HORIZONTAL);
|
||||
gtk_container_add (GTK_CONTAINER (priv->title_widget), priv->arrow_widget);
|
||||
|
||||
formats = gdk_content_formats_new (NULL, 0);
|
||||
dest = gtk_drop_target_new (formats, 0);
|
||||
gdk_content_formats_unref (formats);
|
||||
dest = gtk_drop_target_new (NULL, 0);
|
||||
g_signal_connect (dest, "accept", G_CALLBACK (gtk_expander_drag_accept), expander);
|
||||
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_expander_drag_leave), expander);
|
||||
gtk_widget_add_controller (GTK_WIDGET (expander), GTK_EVENT_CONTROLLER (dest));
|
||||
|
@ -446,7 +446,6 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
|
||||
GtkWidget *box;
|
||||
GtkWidget *icon;
|
||||
GdkContentFormatsBuilder *builder;
|
||||
GdkContentFormats *target_list;
|
||||
GtkDropTarget *dest;
|
||||
|
||||
priv->button = gtk_button_new ();
|
||||
@ -502,11 +501,10 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
|
||||
builder = gdk_content_formats_builder_new ();
|
||||
gdk_content_formats_builder_add_gtype (builder, G_TYPE_STRING);
|
||||
gdk_content_formats_builder_add_gtype (builder, GDK_TYPE_FILE_LIST);
|
||||
target_list = gdk_content_formats_builder_free_to_formats (builder);
|
||||
dest = gtk_drop_target_new (target_list, GDK_ACTION_COPY);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_builder_free_to_formats (builder),
|
||||
GDK_ACTION_COPY);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_file_chooser_button_drag_drop), button);
|
||||
gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (dest));
|
||||
gdk_content_formats_unref (target_list);
|
||||
}
|
||||
|
||||
|
||||
|
@ -8362,24 +8362,22 @@ post_process_ui (GtkFileChooserWidget *impl)
|
||||
GList *cells;
|
||||
GFile *file;
|
||||
GtkDropTarget *dest;
|
||||
GdkContentFormats *formats;
|
||||
|
||||
/* Setup file list treeview */
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->browse_files_tree_view));
|
||||
gtk_tree_selection_set_select_function (selection,
|
||||
list_select_func,
|
||||
impl, NULL);
|
||||
formats = gdk_content_formats_new_for_gtype (GDK_TYPE_FILE_LIST);
|
||||
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
||||
GDK_BUTTON1_MASK,
|
||||
formats,
|
||||
gdk_content_formats_new_for_gtype (GDK_TYPE_FILE_LIST),
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new_for_gtype (GDK_TYPE_FILE_LIST),
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
g_signal_connect (dest, "accept", G_CALLBACK (file_list_drag_accept_cb), impl);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (file_list_drag_drop_cb), impl);
|
||||
gtk_widget_add_controller (priv->browse_files_tree_view, GTK_EVENT_CONTROLLER (dest));
|
||||
gdk_content_formats_unref (formats);
|
||||
|
||||
/* File browser treemodel columns are shared between GtkFileChooser implementations,
|
||||
* so we don't set cell renderer attributes in GtkBuilder, but rather keep that
|
||||
|
@ -6453,7 +6453,7 @@ gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
|
||||
g_return_val_if_fail (GTK_IS_ICON_VIEW (icon_view), NULL);
|
||||
GtkCssNode *widget_node;
|
||||
|
||||
icon_view->priv->dest = gtk_drop_target_new (formats, actions);
|
||||
icon_view->priv->dest = gtk_drop_target_new (gdk_content_formats_ref (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);
|
||||
|
@ -1292,7 +1292,6 @@ static void
|
||||
gtk_notebook_init (GtkNotebook *notebook)
|
||||
{
|
||||
GtkNotebookPrivate *priv;
|
||||
GdkContentFormats *targets;
|
||||
GtkEventController *controller;
|
||||
GtkGesture *gesture;
|
||||
GtkLayoutManager *layout;
|
||||
@ -1348,13 +1347,11 @@ gtk_notebook_init (GtkNotebook *notebook)
|
||||
gtk_widget_set_vexpand (priv->stack_widget, TRUE);
|
||||
gtk_widget_set_parent (priv->stack_widget, GTK_WIDGET (notebook));
|
||||
|
||||
targets = gdk_content_formats_new (dst_notebook_targets, G_N_ELEMENTS (dst_notebook_targets));
|
||||
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new (dst_notebook_targets, G_N_ELEMENTS (dst_notebook_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);
|
||||
gtk_widget_add_controller (GTK_WIDGET (priv->tabs_widget), GTK_EVENT_CONTROLLER (dest));
|
||||
gdk_content_formats_unref (targets);
|
||||
|
||||
gesture = gtk_gesture_click_new ();
|
||||
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
|
||||
|
@ -4018,7 +4018,6 @@ shell_shows_desktop_changed (GtkSettings *settings,
|
||||
static void
|
||||
gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
|
||||
{
|
||||
GdkContentFormats *formats;
|
||||
GtkDropTarget *dest;
|
||||
gboolean show_desktop;
|
||||
GtkEventController *controller;
|
||||
@ -4082,9 +4081,8 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
|
||||
builder = gdk_content_formats_builder_new ();
|
||||
gdk_content_formats_builder_add_mime_type (builder, "DND_GTK_SIDEBAR_ROW");
|
||||
gdk_content_formats_builder_add_gtype (builder, GDK_TYPE_FILE_LIST);
|
||||
formats = gdk_content_formats_builder_free_to_formats (builder);
|
||||
dest = gtk_drop_target_new (formats, GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
|
||||
gdk_content_formats_unref (formats);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_builder_free_to_formats (builder),
|
||||
GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
|
||||
g_signal_connect (dest, "drag-motion", G_CALLBACK (drag_motion_callback), sidebar);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop_callback), sidebar);
|
||||
g_signal_connect (dest, "drag-leave", G_CALLBACK (drag_leave_callback), sidebar);
|
||||
|
@ -113,16 +113,13 @@ static void
|
||||
gtk_stack_switcher_init (GtkStackSwitcher *switcher)
|
||||
{
|
||||
GtkStackSwitcherPrivate *priv = gtk_stack_switcher_get_instance_private (switcher);
|
||||
GdkContentFormats *formats;
|
||||
GtkDropTarget *dest;
|
||||
|
||||
priv->buttons = g_hash_table_new_full (g_direct_hash, g_direct_equal, g_object_unref, NULL);
|
||||
|
||||
gtk_widget_add_css_class (GTK_WIDGET (switcher), "linked");
|
||||
|
||||
formats = gdk_content_formats_new (NULL, 0);
|
||||
dest = gtk_drop_target_new (formats, 0);
|
||||
gdk_content_formats_unref (formats);
|
||||
dest = gtk_drop_target_new (NULL, 0);
|
||||
g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_stack_switcher_drag_leave), switcher);
|
||||
g_signal_connect (dest, "accept", G_CALLBACK (gtk_stack_switcher_drag_accept), switcher);
|
||||
g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_stack_switcher_drag_motion), switcher);
|
||||
|
@ -1712,7 +1712,6 @@ gtk_text_init (GtkText *self)
|
||||
GtkEventController *controller;
|
||||
int i;
|
||||
GtkDropTarget *dest;
|
||||
GdkContentFormats *formats;
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (self), TRUE);
|
||||
gtk_widget_set_overflow (GTK_WIDGET (self), GTK_OVERFLOW_HIDDEN);
|
||||
@ -1734,13 +1733,12 @@ gtk_text_init (GtkText *self)
|
||||
priv->selection_content = g_object_new (GTK_TYPE_TEXT_CONTENT, NULL);
|
||||
GTK_TEXT_CONTENT (priv->selection_content)->self = self;
|
||||
|
||||
formats = gdk_content_formats_new_for_gtype (G_TYPE_STRING);
|
||||
dest = gtk_drop_target_new (formats, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new_for_gtype (G_TYPE_STRING),
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
g_signal_connect (dest, "accept", G_CALLBACK (gtk_text_drag_accept), self);
|
||||
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);
|
||||
gdk_content_formats_unref (formats);
|
||||
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
/* This object is completely private. No external entity can gain a reference
|
||||
|
@ -1611,7 +1611,6 @@ static void
|
||||
gtk_text_view_init (GtkTextView *text_view)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (text_view);
|
||||
GdkContentFormats *formats;
|
||||
GtkDropTarget *dest;
|
||||
GtkTextViewPrivate *priv;
|
||||
GtkEventController *controller;
|
||||
@ -1640,9 +1639,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 (formats, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
gdk_content_formats_unref (formats);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new_for_gtype (GTK_TYPE_TEXT_BUFFER), GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
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);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_text_view_drag_drop), text_view);
|
||||
|
@ -12907,7 +12907,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 (formats, actions);
|
||||
di->dest = gtk_drop_target_new (gdk_content_formats_ref (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);
|
||||
|
@ -1774,7 +1774,6 @@ gtk_window_init (GtkWindow *window)
|
||||
GdkSeat *seat;
|
||||
GtkEventController *motion_controller;
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
GdkContentFormats *targets;
|
||||
GtkDropTarget *dest;
|
||||
#endif
|
||||
|
||||
@ -1828,9 +1827,7 @@ gtk_window_init (GtkWindow *window)
|
||||
priv->scale = gtk_widget_get_scale_factor (widget);
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
targets = gdk_content_formats_new (dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets));
|
||||
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
|
||||
gdk_content_formats_unref (targets);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new (dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets)), GDK_ACTION_MOVE);
|
||||
gtk_widget_add_controller (GTK_WIDGET (window), GTK_EVENT_CONTROLLER (dest));
|
||||
#endif
|
||||
|
||||
|
@ -631,7 +631,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 (targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_ref (targets), GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (label_drag_drop), NULL);
|
||||
gtk_widget_add_controller (label, GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
@ -651,16 +651,12 @@ main (int argc, char **argv)
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);
|
||||
|
||||
gdk_content_formats_unref (targets);
|
||||
|
||||
pixmap = gtk_image_new_from_pixbuf (trashcan_closed);
|
||||
targets = gdk_content_formats_new (NULL, 0);
|
||||
dest = gtk_drop_target_new (targets, 0);
|
||||
dest = gtk_drop_target_new (NULL, 0);
|
||||
g_signal_connect (dest, "drag-leave", G_CALLBACK (target_drag_leave), pixmap);
|
||||
g_signal_connect (dest, "accept", G_CALLBACK (target_drag_motion), pixmap);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (target_drag_drop), pixmap);
|
||||
gtk_widget_add_controller (pixmap, GTK_EVENT_CONTROLLER (dest));
|
||||
gdk_content_formats_unref (targets);
|
||||
|
||||
gtk_widget_set_hexpand (pixmap, TRUE);
|
||||
gtk_widget_set_vexpand (pixmap, TRUE);
|
||||
|
@ -416,8 +416,6 @@ make_image (const gchar *icon_name, int hotspot)
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (image_drag_drop), image);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,6 @@ canvas_new (void)
|
||||
GtkWidget *canvas;
|
||||
GtkDragSource *source;
|
||||
GtkDropTarget *dest;
|
||||
GdkContentFormats *formats;
|
||||
|
||||
canvas = gtk_fixed_new ();
|
||||
gtk_widget_set_hexpand (canvas, TRUE);
|
||||
@ -154,11 +153,9 @@ canvas_new (void)
|
||||
g_signal_connect (source, "drag-cancel", G_CALLBACK (drag_cancel), NULL);
|
||||
gtk_widget_add_controller (canvas, GTK_EVENT_CONTROLLER (source));
|
||||
|
||||
formats = gdk_content_formats_new_for_gtype (GTK_TYPE_WIDGET);
|
||||
dest = gtk_drop_target_new (formats, GDK_ACTION_MOVE);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new_for_gtype (GTK_TYPE_WIDGET), GDK_ACTION_MOVE);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), NULL);
|
||||
gtk_widget_add_controller (canvas, GTK_EVENT_CONTROLLER (dest));
|
||||
gdk_content_formats_unref (formats);
|
||||
|
||||
return canvas;
|
||||
}
|
||||
|
@ -77,7 +77,6 @@ static GtkWidget *
|
||||
create_row (const gchar *text)
|
||||
{
|
||||
GtkWidget *row, *box, *label, *image;
|
||||
GdkContentFormats *targets;
|
||||
GtkDragSource *source;
|
||||
GtkDropTarget *dest;
|
||||
|
||||
@ -97,13 +96,10 @@ create_row (const gchar *text)
|
||||
g_signal_connect (source, "prepare", G_CALLBACK (prepare), row);
|
||||
gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
|
||||
|
||||
targets = gdk_content_formats_new_for_gtype (GTK_TYPE_LIST_BOX_ROW);
|
||||
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new_for_gtype (GTK_TYPE_LIST_BOX_ROW), GDK_ACTION_MOVE);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), row);
|
||||
gtk_widget_add_controller (GTK_WIDGET (row), GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
gdk_content_formats_unref (targets);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
|
@ -293,17 +293,14 @@ create_notebook_with_notebooks (gchar **labels,
|
||||
static GtkWidget*
|
||||
create_trash_button (void)
|
||||
{
|
||||
GdkContentFormats *targets;
|
||||
GtkWidget *button;
|
||||
GtkDropTarget *dest;
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Delete");
|
||||
|
||||
targets = gdk_content_formats_new (button_targets, G_N_ELEMENTS (button_targets));
|
||||
dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new (button_targets, G_N_ELEMENTS (button_targets)), GDK_ACTION_MOVE);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (on_button_drag_drop), NULL);
|
||||
gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (dest));
|
||||
gdk_content_formats_unref (targets);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
@ -121,15 +121,12 @@ static GtkWidget *
|
||||
get_droptarget (void)
|
||||
{
|
||||
GtkWidget *label;
|
||||
GdkContentFormats *targets;
|
||||
GtkDropTarget *dest;
|
||||
|
||||
label = gtk_label_new ("Drop here");
|
||||
targets = gdk_content_formats_new (entries, G_N_ELEMENTS (entries));
|
||||
dest = gtk_drop_target_new (targets, GDK_ACTION_COPY);
|
||||
dest = gtk_drop_target_new (gdk_content_formats_new (entries, G_N_ELEMENTS (entries)), GDK_ACTION_COPY);
|
||||
g_signal_connect (dest, "drag-drop", G_CALLBACK (drag_drop), NULL);
|
||||
gtk_widget_add_controller (label, GTK_EVENT_CONTROLLER (dest));
|
||||
gdk_content_formats_unref (targets);
|
||||
|
||||
return label;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user