mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 13:11:13 +00:00
dnd: Make GtkDragDest and GtkDragSource use GtkTargetList
This gets rid of GtkTargetEntry in the API and consistently uses GtkTargetList.
This commit is contained in:
parent
7efc5a1558
commit
5a1a11bcde
@ -276,7 +276,7 @@ do_clipboard (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (hbox), image);
|
||||
|
||||
/* make image a drag source */
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-begin",
|
||||
G_CALLBACK (drag_begin), image);
|
||||
@ -285,7 +285,7 @@ do_clipboard (GtkWidget *do_widget)
|
||||
|
||||
/* accept drops on image */
|
||||
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
|
||||
NULL, 0, GDK_ACTION_COPY);
|
||||
NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-data-received",
|
||||
G_CALLBACK (drag_data_received), image);
|
||||
@ -300,7 +300,7 @@ do_clipboard (GtkWidget *do_widget)
|
||||
gtk_container_add (GTK_CONTAINER (hbox), image);
|
||||
|
||||
/* make image a drag source */
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-begin",
|
||||
G_CALLBACK (drag_begin), image);
|
||||
@ -309,7 +309,7 @@ do_clipboard (GtkWidget *do_widget)
|
||||
|
||||
/* accept drops on image */
|
||||
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
|
||||
NULL, 0, GDK_ACTION_COPY);
|
||||
NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-data-received",
|
||||
G_CALLBACK (drag_data_received), image);
|
||||
|
@ -430,7 +430,7 @@ get_scalable_image_data (GtkWidget *widget,
|
||||
static void
|
||||
setup_image_dnd (GtkWidget *image)
|
||||
{
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_image_targets (image);
|
||||
g_signal_connect (image, "drag-data-get", G_CALLBACK (get_image_data), NULL);
|
||||
}
|
||||
@ -439,11 +439,14 @@ static void
|
||||
setup_scalable_image_dnd (GtkWidget *image)
|
||||
{
|
||||
GtkWidget *parent;
|
||||
GtkTargetList *targets;
|
||||
|
||||
parent = gtk_widget_get_parent (image);
|
||||
targets = gtk_target_list_new (target_table, G_N_ELEMENTS (target_table));
|
||||
gtk_drag_source_set (parent, GDK_BUTTON1_MASK,
|
||||
target_table, G_N_ELEMENTS (target_table),
|
||||
targets,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
g_signal_connect (parent, "drag-data-get", G_CALLBACK (get_scalable_image_data), NULL);
|
||||
}
|
||||
@ -452,22 +455,16 @@ static void
|
||||
icon_browser_window_init (IconBrowserWindow *win)
|
||||
{
|
||||
GtkTargetList *list;
|
||||
GtkTargetEntry *targets;
|
||||
gint n_targets;
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (win));
|
||||
|
||||
list = gtk_target_list_new (NULL, 0);
|
||||
gtk_target_list_add_text_targets (list, 0);
|
||||
targets = gtk_target_table_new_from_list (list, &n_targets);
|
||||
gtk_target_list_unref (list);
|
||||
|
||||
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (win->list),
|
||||
GDK_BUTTON1_MASK,
|
||||
targets, n_targets,
|
||||
list,
|
||||
GDK_ACTION_COPY);
|
||||
|
||||
gtk_target_table_free (targets, n_targets);
|
||||
gtk_target_list_unref (list);
|
||||
|
||||
setup_image_dnd (win->image1);
|
||||
setup_image_dnd (win->image2);
|
||||
|
@ -758,7 +758,7 @@ gtk_calendar_init (GtkCalendar *calendar)
|
||||
priv->in_drag = 0;
|
||||
priv->drag_highlight = 0;
|
||||
|
||||
gtk_drag_dest_set (widget, 0, NULL, 0, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_set (widget, 0, NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_add_text_targets (widget);
|
||||
|
||||
priv->year_before = 0;
|
||||
|
@ -388,6 +388,7 @@ gtk_color_button_init (GtkColorButton *button)
|
||||
PangoLayout *layout;
|
||||
PangoRectangle rect;
|
||||
GtkStyleContext *context;
|
||||
GtkTargetList *targets;
|
||||
|
||||
gtk_widget_set_has_window (GTK_WIDGET (button), FALSE);
|
||||
|
||||
@ -416,15 +417,18 @@ gtk_color_button_init (GtkColorButton *button)
|
||||
priv->rgba.alpha = 1;
|
||||
priv->use_alpha = FALSE;
|
||||
|
||||
targets = gtk_target_list_new (drop_types, G_N_ELEMENTS (drop_types));
|
||||
gtk_drag_dest_set (priv->button,
|
||||
GTK_DEST_DEFAULT_MOTION |
|
||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||
GTK_DEST_DEFAULT_DROP,
|
||||
drop_types, 1, GDK_ACTION_COPY);
|
||||
targets,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (priv->button,
|
||||
GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
|
||||
drop_types, 1,
|
||||
targets,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_target_list_unref (targets);
|
||||
g_signal_connect (priv->button, "drag-begin",
|
||||
G_CALLBACK (gtk_color_button_drag_begin), button);
|
||||
g_signal_connect (priv->button, "drag-data-received",
|
||||
|
@ -620,10 +620,12 @@ gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
|
||||
|
||||
if (!swatch->priv->has_color)
|
||||
{
|
||||
GtkTargetList *targets = gtk_target_list_new (dnd_targets, G_N_ELEMENTS (dnd_targets));
|
||||
gtk_drag_source_set (GTK_WIDGET (swatch),
|
||||
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
|
||||
dnd_targets, G_N_ELEMENTS (dnd_targets),
|
||||
targets,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
gtk_target_list_unref (targets);
|
||||
}
|
||||
|
||||
swatch->priv->has_color = TRUE;
|
||||
@ -681,12 +683,14 @@ gtk_color_swatch_set_can_drop (GtkColorSwatch *swatch,
|
||||
{
|
||||
if (can_drop)
|
||||
{
|
||||
GtkTargetList *targets = gtk_target_list_new (dnd_targets, G_N_ELEMENTS (dnd_targets));
|
||||
gtk_drag_dest_set (GTK_WIDGET (swatch),
|
||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||
GTK_DEST_DEFAULT_MOTION |
|
||||
GTK_DEST_DEFAULT_DROP,
|
||||
dnd_targets, G_N_ELEMENTS (dnd_targets),
|
||||
targets,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_target_list_unref (targets);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -97,11 +97,9 @@ gtk_drag_dest_set_internal (GtkWidget *widget,
|
||||
* gtk_drag_dest_set: (method)
|
||||
* @widget: a #GtkWidget
|
||||
* @flags: which types of default drag behavior to use
|
||||
* @targets: (allow-none) (array length=n_targets): a pointer to an array of
|
||||
* #GtkTargetEntrys indicating the drop types that this @widget will
|
||||
* @targets: (allow-none): the drop types that this @widget will
|
||||
* accept, or %NULL. Later you can access the list with
|
||||
* gtk_drag_dest_get_target_list() and gtk_drag_dest_find_target().
|
||||
* @n_targets: the number of entries in @targets
|
||||
* @actions: a bitmask of possible actions for a drop onto this @widget.
|
||||
*
|
||||
* Sets a widget as a potential drop destination, and adds default behaviors.
|
||||
@ -145,11 +143,10 @@ gtk_drag_dest_set_internal (GtkWidget *widget,
|
||||
* ]|
|
||||
*/
|
||||
void
|
||||
gtk_drag_dest_set (GtkWidget *widget,
|
||||
GtkDestDefaults flags,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GdkDragAction actions)
|
||||
gtk_drag_dest_set (GtkWidget *widget,
|
||||
GtkDestDefaults flags,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GtkDragDestSite *site;
|
||||
|
||||
@ -160,7 +157,7 @@ gtk_drag_dest_set (GtkWidget *widget,
|
||||
site->flags = flags;
|
||||
site->have_drag = FALSE;
|
||||
if (targets)
|
||||
site->target_list = gtk_target_list_new (targets, n_targets);
|
||||
site->target_list = gtk_target_list_ref (targets);
|
||||
else
|
||||
site->target_list = NULL;
|
||||
site->actions = actions;
|
||||
|
@ -69,8 +69,7 @@ typedef enum {
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_drag_dest_set (GtkWidget *widget,
|
||||
GtkDestDefaults flags,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -125,20 +125,18 @@ gtk_drag_source_site_destroy (gpointer data)
|
||||
* gtk_drag_source_set: (method)
|
||||
* @widget: a #GtkWidget
|
||||
* @start_button_mask: the bitmask of buttons that can start the drag
|
||||
* @targets: (allow-none) (array length=n_targets): the table of targets
|
||||
* that the drag will support, may be %NULL
|
||||
* @n_targets: the number of items in @targets
|
||||
* @targets: (allow-none): the targets that the drag will support,
|
||||
* may be %NULL
|
||||
* @actions: the bitmask of possible actions for a drag from this widget
|
||||
*
|
||||
* Sets up a widget so that GTK+ will start a drag operation when the user
|
||||
* clicks and drags on the widget. The widget must have a window.
|
||||
*/
|
||||
void
|
||||
gtk_drag_source_set (GtkWidget *widget,
|
||||
GdkModifierType start_button_mask,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GdkDragAction actions)
|
||||
gtk_drag_source_set (GtkWidget *widget,
|
||||
GdkModifierType start_button_mask,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GtkDragSourceSite *site;
|
||||
|
||||
@ -179,7 +177,10 @@ gtk_drag_source_set (GtkWidget *widget,
|
||||
|
||||
site->start_button_mask = start_button_mask;
|
||||
|
||||
site->target_list = gtk_target_list_new (targets, n_targets);
|
||||
if (targets)
|
||||
site->target_list = gtk_target_list_ref (targets);
|
||||
else
|
||||
site->target_list = NULL;
|
||||
|
||||
site->actions = actions;
|
||||
}
|
||||
|
@ -40,8 +40,7 @@ G_BEGIN_DECLS
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_drag_source_set (GtkWidget *widget,
|
||||
GdkModifierType start_button_mask,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@ -2466,7 +2466,7 @@ gtk_entry_init (GtkEntry *entry)
|
||||
priv->caps_lock_warning = TRUE;
|
||||
priv->caps_lock_warning_shown = FALSE;
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (entry), 0, NULL, 0,
|
||||
gtk_drag_dest_set (GTK_WIDGET (entry), 0, NULL,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
gtk_drag_dest_add_text_targets (GTK_WIDGET (entry));
|
||||
|
||||
|
@ -377,7 +377,7 @@ gtk_expander_init (GtkExpander *expander)
|
||||
GTK_STYLE_CLASS_HORIZONTAL);
|
||||
gtk_container_add (GTK_CONTAINER (priv->title_widget), priv->arrow_widget);
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (expander), 0, NULL, 0, 0);
|
||||
gtk_drag_dest_set (GTK_WIDGET (expander), 0, NULL, 0);
|
||||
gtk_drag_dest_set_track_motion (GTK_WIDGET (expander), TRUE);
|
||||
|
||||
priv->multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (expander));
|
||||
|
@ -554,14 +554,13 @@ gtk_file_chooser_button_init (GtkFileChooserButton *button)
|
||||
NULL, NULL);
|
||||
|
||||
/* DnD */
|
||||
gtk_drag_dest_set (GTK_WIDGET (button),
|
||||
(GTK_DEST_DEFAULT_ALL),
|
||||
NULL, 0,
|
||||
GDK_ACTION_COPY);
|
||||
target_list = gtk_target_list_new (NULL, 0);
|
||||
gtk_target_list_add_uri_targets (target_list, TEXT_URI_LIST);
|
||||
gtk_target_list_add_text_targets (target_list, TEXT_PLAIN);
|
||||
gtk_drag_dest_set_target_list (GTK_WIDGET (button), target_list);
|
||||
gtk_drag_dest_set (GTK_WIDGET (button),
|
||||
(GTK_DEST_DEFAULT_ALL),
|
||||
target_list,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_target_list_unref (target_list);
|
||||
}
|
||||
|
||||
|
@ -8555,13 +8555,13 @@ post_process_ui (GtkFileChooserWidget *impl)
|
||||
impl, NULL);
|
||||
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (impl->priv->browse_files_tree_view),
|
||||
GDK_BUTTON1_MASK,
|
||||
NULL, 0,
|
||||
NULL,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
gtk_drag_source_add_uri_targets (impl->priv->browse_files_tree_view);
|
||||
|
||||
gtk_drag_dest_set (impl->priv->browse_files_tree_view,
|
||||
GTK_DEST_DEFAULT_ALL,
|
||||
NULL, 0,
|
||||
NULL,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
gtk_drag_dest_add_uri_targets (impl->priv->browse_files_tree_view);
|
||||
|
||||
|
@ -6555,9 +6555,7 @@ gtk_icon_view_drag_data_received (GtkWidget *widget,
|
||||
* gtk_icon_view_enable_model_drag_source:
|
||||
* @icon_view: a #GtkIconView
|
||||
* @start_button_mask: Mask of allowed buttons to start drag
|
||||
* @targets: (array length=n_targets): the table of targets that the drag will
|
||||
* support
|
||||
* @n_targets: the number of items in @targets
|
||||
* @targets: the targets that the drag will support
|
||||
* @actions: the bitmask of possible actions for a drag from this
|
||||
* widget
|
||||
*
|
||||
@ -6569,13 +6567,12 @@ gtk_icon_view_drag_data_received (GtkWidget *widget,
|
||||
void
|
||||
gtk_icon_view_enable_model_drag_source (GtkIconView *icon_view,
|
||||
GdkModifierType start_button_mask,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
|
||||
|
||||
gtk_drag_source_set (GTK_WIDGET (icon_view), 0, targets, n_targets, actions);
|
||||
gtk_drag_source_set (GTK_WIDGET (icon_view), 0, targets, actions);
|
||||
|
||||
icon_view->priv->start_button_mask = start_button_mask;
|
||||
icon_view->priv->source_actions = actions;
|
||||
@ -6588,9 +6585,7 @@ gtk_icon_view_enable_model_drag_source (GtkIconView *icon_view,
|
||||
/**
|
||||
* gtk_icon_view_enable_model_drag_dest:
|
||||
* @icon_view: a #GtkIconView
|
||||
* @targets: (array length=n_targets): the table of targets that the drag will
|
||||
* support
|
||||
* @n_targets: the number of items in @targets
|
||||
* @targets: the targets that the drag will support
|
||||
* @actions: the bitmask of possible actions for a drag to this
|
||||
* widget
|
||||
*
|
||||
@ -6600,14 +6595,13 @@ gtk_icon_view_enable_model_drag_source (GtkIconView *icon_view,
|
||||
* Since: 2.8
|
||||
**/
|
||||
void
|
||||
gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GdkDragAction actions)
|
||||
gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (icon_view), 0, targets, n_targets, actions);
|
||||
gtk_drag_dest_set (GTK_WIDGET (icon_view), 0, targets, actions);
|
||||
|
||||
icon_view->priv->dest_actions = actions;
|
||||
|
||||
@ -6943,15 +6937,15 @@ gtk_icon_view_set_reorderable (GtkIconView *icon_view,
|
||||
|
||||
if (reorderable)
|
||||
{
|
||||
GtkTargetList *targets = gtk_target_list_new (item_targets, G_N_ELEMENTS (item_targets));
|
||||
gtk_icon_view_enable_model_drag_source (icon_view,
|
||||
GDK_BUTTON1_MASK,
|
||||
item_targets,
|
||||
G_N_ELEMENTS (item_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_icon_view_enable_model_drag_dest (icon_view,
|
||||
item_targets,
|
||||
G_N_ELEMENTS (item_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_target_list_unref (targets);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -253,13 +253,11 @@ void gtk_icon_view_scroll_to_path (GtkIconView *icon_
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_icon_view_enable_model_drag_source (GtkIconView *icon_view,
|
||||
GdkModifierType start_button_mask,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_icon_view_unset_model_drag_source (GtkIconView *icon_view);
|
||||
|
@ -218,6 +218,7 @@ gtk_link_button_init (GtkLinkButton *link_button)
|
||||
{
|
||||
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
|
||||
GtkStyleContext *context;
|
||||
GtkTargetList *targets;
|
||||
|
||||
link_button->priv = priv;
|
||||
|
||||
@ -232,10 +233,12 @@ gtk_link_button_init (GtkLinkButton *link_button)
|
||||
G_CALLBACK (gtk_link_button_query_tooltip_cb), NULL);
|
||||
|
||||
/* enable drag source */
|
||||
targets = gtk_target_list_new (link_drop_types, G_N_ELEMENTS (link_drop_types));
|
||||
gtk_drag_source_set (GTK_WIDGET (link_button),
|
||||
GDK_BUTTON1_MASK,
|
||||
link_drop_types, G_N_ELEMENTS (link_drop_types),
|
||||
targets,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
priv->click_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (link_button));
|
||||
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->click_gesture), FALSE);
|
||||
|
@ -1050,6 +1050,7 @@ static void
|
||||
gtk_notebook_init (GtkNotebook *notebook)
|
||||
{
|
||||
GtkNotebookPrivate *priv;
|
||||
GtkTargetList *targets;
|
||||
|
||||
gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE);
|
||||
gtk_widget_set_has_window (GTK_WIDGET (notebook), FALSE);
|
||||
@ -1087,9 +1088,11 @@ gtk_notebook_init (GtkNotebook *notebook)
|
||||
else
|
||||
priv->tabs_reversed = FALSE;
|
||||
|
||||
targets = gtk_target_list_new (dst_notebook_targets, G_N_ELEMENTS (dst_notebook_targets));
|
||||
gtk_drag_dest_set (GTK_WIDGET (notebook), 0,
|
||||
dst_notebook_targets, G_N_ELEMENTS (dst_notebook_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
gtk_drag_dest_set_track_motion (GTK_WIDGET (notebook), TRUE);
|
||||
|
||||
|
@ -1549,7 +1549,7 @@ make_directory_button (GtkPathBar *path_bar,
|
||||
|
||||
gtk_drag_source_set (button_data->button,
|
||||
GDK_BUTTON1_MASK,
|
||||
NULL, 0,
|
||||
NULL,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_uri_targets (button_data->button);
|
||||
g_signal_connect (button_data->button, "drag-data-get",
|
||||
|
@ -4072,7 +4072,7 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
|
||||
/* DND support */
|
||||
gtk_drag_dest_set (sidebar->list_box,
|
||||
0,
|
||||
NULL, 0,
|
||||
NULL,
|
||||
GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
|
||||
target_list = gtk_target_list_new (dnd_drop_targets, G_N_ELEMENTS (dnd_drop_targets));
|
||||
gtk_target_list_add_uri_targets (target_list, DND_TEXT_URI_LIST);
|
||||
|
@ -380,7 +380,7 @@ _gtk_recent_chooser_default_init (GtkRecentChooserDefault *impl)
|
||||
NULL);
|
||||
gtk_drag_source_set (priv->recent_view,
|
||||
GDK_BUTTON1_MASK,
|
||||
NULL, 0,
|
||||
NULL,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_uri_targets (priv->recent_view);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ gtk_stack_switcher_init (GtkStackSwitcher *switcher)
|
||||
|
||||
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_HORIZONTAL);
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (switcher), 0, NULL, 0, 0);
|
||||
gtk_drag_dest_set (GTK_WIDGET (switcher), 0, NULL, 0);
|
||||
gtk_drag_dest_set_track_motion (GTK_WIDGET (switcher), TRUE);
|
||||
}
|
||||
|
||||
|
@ -1659,7 +1659,7 @@ gtk_text_view_init (GtkTextView *text_view)
|
||||
|
||||
priv->scroll_after_paste = TRUE;
|
||||
|
||||
gtk_drag_dest_set (widget, 0, NULL, 0,
|
||||
gtk_drag_dest_set (widget, 0, NULL,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
target_list = gtk_target_list_new (NULL, 0);
|
||||
|
@ -1616,6 +1616,7 @@ gtk_tool_palette_add_drag_dest (GtkToolPalette *palette,
|
||||
{
|
||||
GtkTargetEntry entries[G_N_ELEMENTS (dnd_targets)];
|
||||
gint n_entries = 0;
|
||||
GtkTargetList *list;
|
||||
|
||||
g_return_if_fail (GTK_IS_TOOL_PALETTE (palette));
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
@ -1628,7 +1629,9 @@ gtk_tool_palette_add_drag_dest (GtkToolPalette *palette,
|
||||
if (targets & GTK_TOOL_PALETTE_DRAG_GROUPS)
|
||||
entries[n_entries++] = dnd_targets[1];
|
||||
|
||||
gtk_drag_dest_set (widget, flags, entries, n_entries, actions);
|
||||
list = gtk_target_list_new (entries, n_entries);
|
||||
gtk_drag_dest_set (widget, flags, list, actions);
|
||||
gtk_target_list_unref (list);
|
||||
}
|
||||
|
||||
void
|
||||
@ -1727,6 +1730,8 @@ _gtk_tool_palette_child_set_drag_source (GtkWidget *child,
|
||||
if (GTK_IS_TOOL_ITEM (child) &&
|
||||
(palette->priv->drag_source & GTK_TOOL_PALETTE_DRAG_ITEMS))
|
||||
{
|
||||
GtkTargetList *targets;
|
||||
|
||||
/* Connect to child instead of the item itself,
|
||||
* to work arround bug 510377.
|
||||
*/
|
||||
@ -1736,8 +1741,10 @@ _gtk_tool_palette_child_set_drag_source (GtkWidget *child,
|
||||
if (!child)
|
||||
return;
|
||||
|
||||
targets = gtk_target_list_new (&dnd_targets[0], 1);
|
||||
gtk_drag_source_set (child, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
|
||||
&dnd_targets[0], 1, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
g_signal_connect (child, "drag-data-get",
|
||||
G_CALLBACK (gtk_tool_palette_item_drag_data_get),
|
||||
@ -1746,8 +1753,12 @@ _gtk_tool_palette_child_set_drag_source (GtkWidget *child,
|
||||
else if (GTK_IS_BUTTON (child) &&
|
||||
(palette->priv->drag_source & GTK_TOOL_PALETTE_DRAG_GROUPS))
|
||||
{
|
||||
GtkTargetList *targets;
|
||||
|
||||
targets = gtk_target_list_new (&dnd_targets[1], 1);
|
||||
gtk_drag_source_set (child, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
|
||||
&dnd_targets[1], 1, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
g_signal_connect (child, "drag-data-get",
|
||||
G_CALLBACK (gtk_tool_palette_child_drag_data_get),
|
||||
|
@ -12549,15 +12549,16 @@ gtk_tree_view_set_reorderable (GtkTreeView *tree_view,
|
||||
const GtkTargetEntry row_targets[] = {
|
||||
{ (char *) "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 }
|
||||
};
|
||||
GtkTargetList *targets;
|
||||
|
||||
targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
|
||||
|
||||
gtk_tree_view_enable_model_drag_source (tree_view,
|
||||
GDK_BUTTON1_MASK,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_tree_view_enable_model_drag_dest (tree_view,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
}
|
||||
else
|
||||
@ -13534,8 +13535,7 @@ unset_reorderable (GtkTreeView *tree_view)
|
||||
* gtk_tree_view_enable_model_drag_source:
|
||||
* @tree_view: a #GtkTreeView
|
||||
* @start_button_mask: Mask of allowed buttons to start drag
|
||||
* @targets: (array length=n_targets): the table of targets that the drag will support
|
||||
* @n_targets: the number of items in @targets
|
||||
* @targets: the targets that the drag will support
|
||||
* @actions: the bitmask of possible actions for a drag from this
|
||||
* widget
|
||||
*
|
||||
@ -13543,11 +13543,10 @@ unset_reorderable (GtkTreeView *tree_view)
|
||||
* method sets #GtkTreeView:reorderable to %FALSE.
|
||||
**/
|
||||
void
|
||||
gtk_tree_view_enable_model_drag_source (GtkTreeView *tree_view,
|
||||
GdkModifierType start_button_mask,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GdkDragAction actions)
|
||||
gtk_tree_view_enable_model_drag_source (GtkTreeView *tree_view,
|
||||
GdkModifierType start_button_mask,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
TreeViewDragInfo *di;
|
||||
|
||||
@ -13556,7 +13555,6 @@ gtk_tree_view_enable_model_drag_source (GtkTreeView *tree_view,
|
||||
gtk_drag_source_set (GTK_WIDGET (tree_view),
|
||||
0,
|
||||
targets,
|
||||
n_targets,
|
||||
actions);
|
||||
|
||||
di = ensure_info (tree_view);
|
||||
@ -13571,8 +13569,7 @@ gtk_tree_view_enable_model_drag_source (GtkTreeView *tree_view,
|
||||
/**
|
||||
* gtk_tree_view_enable_model_drag_dest:
|
||||
* @tree_view: a #GtkTreeView
|
||||
* @targets: (array length=n_targets): the table of targets that
|
||||
* the drag will support
|
||||
* @targets: the targets that the drag will support
|
||||
* @n_targets: the number of items in @targets
|
||||
* @actions: the bitmask of possible actions for a drag from this
|
||||
* widget
|
||||
@ -13581,10 +13578,9 @@ gtk_tree_view_enable_model_drag_source (GtkTreeView *tree_view,
|
||||
* this method sets #GtkTreeView:reorderable to %FALSE.
|
||||
**/
|
||||
void
|
||||
gtk_tree_view_enable_model_drag_dest (GtkTreeView *tree_view,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GdkDragAction actions)
|
||||
gtk_tree_view_enable_model_drag_dest (GtkTreeView *tree_view,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
TreeViewDragInfo *di;
|
||||
|
||||
@ -13593,7 +13589,6 @@ gtk_tree_view_enable_model_drag_dest (GtkTreeView *tree_view,
|
||||
gtk_drag_dest_set (GTK_WIDGET (tree_view),
|
||||
0,
|
||||
targets,
|
||||
n_targets,
|
||||
actions);
|
||||
|
||||
di = ensure_info (tree_view);
|
||||
|
@ -382,13 +382,11 @@ gboolean gtk_tree_view_is_blank_at_pos (GtkTreeView
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_tree_view_enable_model_drag_source (GtkTreeView *tree_view,
|
||||
GdkModifierType start_button_mask,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_tree_view_enable_model_drag_dest (GtkTreeView *tree_view,
|
||||
const GtkTargetEntry *targets,
|
||||
gint n_targets,
|
||||
GtkTargetList *targets,
|
||||
GdkDragAction actions);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_tree_view_unset_rows_drag_source (GtkTreeView *tree_view);
|
||||
|
@ -1844,6 +1844,7 @@ gtk_window_init (GtkWindow *window)
|
||||
GtkWidget *widget;
|
||||
GtkCssNode *widget_node;
|
||||
GdkSeat *seat;
|
||||
GtkTargetList *targets;
|
||||
|
||||
widget = GTK_WIDGET (window);
|
||||
|
||||
@ -1905,10 +1906,12 @@ gtk_window_init (GtkWindow *window)
|
||||
|
||||
priv->scale = gtk_widget_get_scale_factor (widget);
|
||||
|
||||
targets = gtk_target_list_new (dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets));
|
||||
gtk_drag_dest_set (GTK_WIDGET (window),
|
||||
GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
|
||||
dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
|
||||
g_signal_connect (seat, "device-removed",
|
||||
|
@ -496,11 +496,13 @@ popup_cb (gpointer data)
|
||||
GtkWidget *button;
|
||||
GtkWidget *grid;
|
||||
int i, j;
|
||||
GtkTargetList *targets;
|
||||
|
||||
popup_window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_window_set_position (GTK_WINDOW (popup_window), GTK_WIN_POS_MOUSE);
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
targets = gtk_target_list_new (target_table, n_targets - 1); /* no rootwin */
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
for (j=0; j<3; j++)
|
||||
@ -514,7 +516,7 @@ popup_cb (gpointer data)
|
||||
|
||||
gtk_drag_dest_set (button,
|
||||
GTK_DEST_DEFAULT_ALL,
|
||||
target_table, n_targets - 1, /* no rootwin */
|
||||
targets,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
g_signal_connect (button, "drag_motion",
|
||||
G_CALLBACK (popup_motion), NULL);
|
||||
@ -522,6 +524,7 @@ popup_cb (gpointer data)
|
||||
G_CALLBACK (popup_leave), NULL);
|
||||
}
|
||||
gtk_container_add (GTK_CONTAINER (popup_window), grid);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
}
|
||||
gtk_widget_show (popup_window);
|
||||
@ -585,6 +588,7 @@ main (int argc, char **argv)
|
||||
GtkWidget *pixmap;
|
||||
GtkWidget *button;
|
||||
GdkPixbuf *drag_icon;
|
||||
GtkTargetList *targets;
|
||||
|
||||
test_init ();
|
||||
|
||||
@ -604,9 +608,10 @@ main (int argc, char **argv)
|
||||
|
||||
label = gtk_label_new ("Drop Here\n");
|
||||
|
||||
targets = gtk_target_list_new (target_table, n_targets - 1); /* no rootwin */
|
||||
gtk_drag_dest_set (label,
|
||||
GTK_DEST_DEFAULT_ALL,
|
||||
target_table, n_targets - 1, /* no rootwin */
|
||||
targets,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
g_signal_connect (label, "drag_data_received",
|
||||
@ -620,7 +625,7 @@ main (int argc, char **argv)
|
||||
|
||||
gtk_drag_dest_set (label,
|
||||
GTK_DEST_DEFAULT_ALL,
|
||||
target_table, n_targets - 1, /* no rootwin */
|
||||
targets,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
@ -631,9 +636,10 @@ main (int argc, char **argv)
|
||||
G_CALLBACK (popsite_motion), NULL);
|
||||
g_signal_connect (label, "drag_leave",
|
||||
G_CALLBACK (popsite_leave), NULL);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
pixmap = gtk_image_new_from_pixbuf (trashcan_closed);
|
||||
gtk_drag_dest_set (pixmap, 0, NULL, 0, 0);
|
||||
gtk_drag_dest_set (pixmap, 0, NULL, 0);
|
||||
gtk_widget_set_hexpand (pixmap, TRUE);
|
||||
gtk_widget_set_vexpand (pixmap, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), pixmap, 1, 0, 1, 1);
|
||||
@ -654,10 +660,12 @@ main (int argc, char **argv)
|
||||
|
||||
button = gtk_button_new_with_label ("Drag Here\n");
|
||||
|
||||
targets = gtk_target_list_new (target_table, n_targets);
|
||||
gtk_drag_source_set (button, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
|
||||
target_table, n_targets,
|
||||
targets,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
gtk_drag_source_set_icon_pixbuf (button, drag_icon);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
g_object_unref (drag_icon);
|
||||
|
||||
|
@ -226,7 +226,7 @@ make_image (const gchar *icon_name, int hotspot)
|
||||
|
||||
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
|
||||
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
||||
update_source_target_list (image);
|
||||
|
||||
g_object_set_data (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
|
||||
@ -234,7 +234,7 @@ make_image (const gchar *icon_name, int hotspot)
|
||||
g_signal_connect (image, "drag-begin", G_CALLBACK (image_drag_begin), image);
|
||||
g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
|
||||
|
||||
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, GDK_ACTION_COPY);
|
||||
g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
|
||||
update_dest_target_list (image);
|
||||
|
||||
@ -248,7 +248,7 @@ make_image2 (const gchar *icon_name, int hotspot)
|
||||
|
||||
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
|
||||
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
||||
update_source_target_list (image);
|
||||
|
||||
g_object_set_data (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
|
||||
@ -256,7 +256,7 @@ make_image2 (const gchar *icon_name, int hotspot)
|
||||
g_signal_connect (image, "drag-begin", G_CALLBACK (window_drag_begin), image);
|
||||
g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
|
||||
|
||||
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, GDK_ACTION_COPY);
|
||||
g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
|
||||
update_dest_target_list (image);
|
||||
|
||||
@ -328,7 +328,7 @@ make_spinner (void)
|
||||
spinner = gtk_spinner_new ();
|
||||
gtk_spinner_start (GTK_SPINNER (spinner));
|
||||
|
||||
gtk_drag_source_set (spinner, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (spinner, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_text_targets (spinner);
|
||||
|
||||
g_signal_connect (spinner, "drag-begin", G_CALLBACK (spinner_drag_begin), spinner);
|
||||
|
@ -425,6 +425,7 @@ main (gint argc, gchar **argv)
|
||||
GtkTreeModel *model;
|
||||
GtkCellRenderer *cell;
|
||||
GtkTreeViewColumn *tvc;
|
||||
GtkTargetList *targets;
|
||||
|
||||
#ifdef GTK_SRCDIR
|
||||
g_chdir (GTK_SRCDIR);
|
||||
@ -527,26 +528,23 @@ main (gint argc, gchar **argv)
|
||||
#endif
|
||||
/* Allow DND between the icon view and the tree view */
|
||||
|
||||
targets = gtk_target_list_new (item_targets, G_N_ELEMENTS (item_targets));
|
||||
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (icon_list),
|
||||
GDK_BUTTON1_MASK,
|
||||
item_targets,
|
||||
G_N_ELEMENTS (item_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_icon_view_enable_model_drag_dest (GTK_ICON_VIEW (icon_list),
|
||||
item_targets,
|
||||
G_N_ELEMENTS (item_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
|
||||
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv),
|
||||
GDK_BUTTON1_MASK,
|
||||
item_targets,
|
||||
G_N_ELEMENTS (item_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (tv),
|
||||
item_targets,
|
||||
G_N_ELEMENTS (item_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), icon_list);
|
||||
|
@ -115,7 +115,7 @@ main (int argc, char **argv)
|
||||
gtk_grid_attach (GTK_GRID (grid), image, 2, 1, 1, 1);
|
||||
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK,
|
||||
NULL, 0,
|
||||
NULL,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_drag_source_add_image_targets (image);
|
||||
g_signal_connect (image, "drag_begin", G_CALLBACK (drag_begin), image);
|
||||
@ -125,7 +125,7 @@ main (int argc, char **argv)
|
||||
GTK_DEST_DEFAULT_MOTION |
|
||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||
GTK_DEST_DEFAULT_DROP,
|
||||
NULL, 0, GDK_ACTION_COPY);
|
||||
NULL, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_add_image_targets (image);
|
||||
g_signal_connect (image, "drag_data_received",
|
||||
G_CALLBACK (drag_data_received), image);
|
||||
|
@ -26,6 +26,7 @@ kinetic_scrolling (void)
|
||||
GtkCellRenderer *renderer;
|
||||
GtkListStore *store;
|
||||
GtkWidget *textview;
|
||||
GtkTargetList *targets;
|
||||
gint i;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
@ -75,15 +76,15 @@ kinetic_scrolling (void)
|
||||
gtk_widget_show (swindow);
|
||||
|
||||
treeview = gtk_tree_view_new ();
|
||||
targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
|
||||
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (treeview),
|
||||
GDK_BUTTON1_MASK,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE | GDK_ACTION_COPY);
|
||||
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (treeview),
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE | GDK_ACTION_COPY);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
g_object_set (renderer, "editable", TRUE, NULL);
|
||||
|
@ -83,6 +83,7 @@ static GtkWidget *
|
||||
create_row (const gchar *text)
|
||||
{
|
||||
GtkWidget *row, *box, *label, *image;
|
||||
GtkTargetList *targets;
|
||||
|
||||
row = gtk_list_box_row_new ();
|
||||
image = gtk_image_new_from_icon_name ("open-menu-symbolic", 1);
|
||||
@ -94,13 +95,17 @@ create_row (const gchar *text)
|
||||
gtk_container_add (GTK_CONTAINER (box), label);
|
||||
gtk_container_add (GTK_CONTAINER (box), image);
|
||||
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, entries, 1, GDK_ACTION_MOVE);
|
||||
targets = gtk_target_list_new (entries, 1);
|
||||
|
||||
gtk_drag_source_set (image, GDK_BUTTON1_MASK, targets, GDK_ACTION_MOVE);
|
||||
g_signal_connect (image, "drag-begin", G_CALLBACK (drag_begin), NULL);
|
||||
g_signal_connect (image, "drag-data-get", G_CALLBACK (drag_data_get), NULL);
|
||||
|
||||
gtk_drag_dest_set (row, GTK_DEST_DEFAULT_ALL, entries, 1, GDK_ACTION_MOVE);
|
||||
gtk_drag_dest_set (row, GTK_DEST_DEFAULT_ALL, targets, GDK_ACTION_MOVE);
|
||||
g_signal_connect (row, "drag-data-received", G_CALLBACK (drag_data_received), NULL);
|
||||
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
|
@ -301,15 +301,17 @@ create_notebook_with_notebooks (gchar **labels,
|
||||
static GtkWidget*
|
||||
create_trash_button (void)
|
||||
{
|
||||
GtkTargetList *targets;
|
||||
GtkWidget *button;
|
||||
|
||||
button = gtk_button_new_with_mnemonic ("_Delete");
|
||||
|
||||
targets = gtk_target_list_new (button_targets, G_N_ELEMENTS (button_targets));
|
||||
gtk_drag_dest_set (button,
|
||||
GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
|
||||
button_targets,
|
||||
G_N_ELEMENTS (button_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
g_signal_connect_after (G_OBJECT (button), "drag-data-received",
|
||||
G_CALLBACK (on_button_drag_data_received), NULL);
|
||||
|
@ -479,6 +479,7 @@ main (gint argc, gchar **argv)
|
||||
GtkWidget *window, *toolbar, *grid, *treeview, *scrolled_window;
|
||||
GtkWidget *hbox, *hbox1, *hbox2, *checkbox, *option_menu, *menu;
|
||||
gint i;
|
||||
GtkTargetList *targets;
|
||||
static const gchar *toolbar_styles[] = { "icons", "text", "both (vertical)",
|
||||
"both (horizontal)" };
|
||||
GtkToolItem *item;
|
||||
@ -712,12 +713,14 @@ main (gint argc, gchar **argv)
|
||||
|
||||
gtk_box_pack_end (GTK_BOX (hbox), checkbox);
|
||||
|
||||
targets = gtk_target_list_new (target_table, G_N_ELEMENTS (target_table));
|
||||
gtk_drag_source_set (button, GDK_BUTTON1_MASK,
|
||||
target_table, G_N_ELEMENTS (target_table),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP,
|
||||
target_table, G_N_ELEMENTS (target_table),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_target_list_unref (targets);
|
||||
g_signal_connect (toolbar, "drag_motion",
|
||||
G_CALLBACK (toolbar_drag_motion), NULL);
|
||||
g_signal_connect (toolbar, "drag_leave",
|
||||
|
@ -718,6 +718,7 @@ main (int argc, char *argv[])
|
||||
GtkCellRenderer *cell;
|
||||
GtkWidget *swindow;
|
||||
GtkTreeModel *sample_model;
|
||||
GtkTargetList *targets;
|
||||
gint i;
|
||||
|
||||
gtk_init ();
|
||||
@ -863,36 +864,31 @@ main (int argc, char *argv[])
|
||||
|
||||
|
||||
/* Drag and Drop */
|
||||
targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
|
||||
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (left_tree_view),
|
||||
GDK_BUTTON1_MASK,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (left_tree_view),
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
|
||||
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (top_right_tree_view),
|
||||
GDK_BUTTON1_MASK,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (top_right_tree_view),
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
|
||||
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (bottom_right_tree_view),
|
||||
GDK_BUTTON1_MASK,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (bottom_right_tree_view),
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE);
|
||||
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
|
||||
|
||||
|
@ -73,6 +73,7 @@ get_dragsource (void)
|
||||
GtkTreeView *tv;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
GtkTargetList *targets;
|
||||
|
||||
tv = (GtkTreeView*) gtk_tree_view_new ();
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
@ -80,7 +81,9 @@ get_dragsource (void)
|
||||
gtk_tree_view_append_column (tv, column);
|
||||
|
||||
gtk_tree_view_set_model (tv, get_model ());
|
||||
gtk_tree_view_enable_model_drag_source (tv, GDK_BUTTON1_MASK, entries, G_N_ELEMENTS (entries), GDK_ACTION_COPY);
|
||||
targets = gtk_target_list_new (entries, G_N_ELEMENTS (entries));
|
||||
gtk_tree_view_enable_model_drag_source (tv, GDK_BUTTON1_MASK, targets, GDK_ACTION_COPY);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
return GTK_WIDGET (tv);
|
||||
}
|
||||
@ -104,10 +107,13 @@ static GtkWidget *
|
||||
get_droptarget (void)
|
||||
{
|
||||
GtkWidget *label;
|
||||
GtkTargetList *targets;
|
||||
|
||||
label = gtk_label_new ("Drop here");
|
||||
gtk_drag_dest_set (label, GTK_DEST_DEFAULT_ALL, entries, G_N_ELEMENTS (entries), GDK_ACTION_COPY);
|
||||
targets = gtk_target_list_new (entries, G_N_ELEMENTS (entries));
|
||||
gtk_drag_dest_set (label, GTK_DEST_DEFAULT_ALL, targets, GDK_ACTION_COPY);
|
||||
g_signal_connect (label, "drag-data-received", G_CALLBACK (data_received), NULL);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
return label;
|
||||
}
|
||||
|
@ -661,6 +661,7 @@ main (int argc,
|
||||
GtkWidget *box;
|
||||
GtkWidget *combo_box;
|
||||
GtkTreeModel *model;
|
||||
GtkTargetList *targets;
|
||||
gint i;
|
||||
|
||||
gtk_init ();
|
||||
@ -702,16 +703,16 @@ main (int argc,
|
||||
tv = gtk_tree_view_new_with_model (models[0]);
|
||||
g_signal_connect (tv, "row-activated", G_CALLBACK (on_row_activated), NULL);
|
||||
|
||||
targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
|
||||
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv),
|
||||
GDK_BUTTON1_MASK,
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE | GDK_ACTION_COPY);
|
||||
|
||||
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (tv),
|
||||
row_targets,
|
||||
G_N_ELEMENTS (row_targets),
|
||||
targets,
|
||||
GDK_ACTION_MOVE | GDK_ACTION_COPY);
|
||||
gtk_target_list_unref (targets);
|
||||
|
||||
/* Model menu */
|
||||
combo_box = gtk_combo_box_text_new ();
|
||||
|
Loading…
Reference in New Issue
Block a user