forked from AuroraMiddleware/gtk
placessidebar: Take a GdkDrag in _set_drop_targets_visible()
Since the function is usually called from GtkWidget::drag-{begin,end} handlers, taking a GdkDrop does not work, especially given that ::drag-action-requested is emitted without checking the type. Fixes https://gitlab.gnome.org/GNOME/gtk/issues/1220
This commit is contained in:
parent
6fe0a8c6b3
commit
4b2d63167e
@ -1991,12 +1991,12 @@ file_list_drag_drop_cb (GtkWidget *widget,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
file_list_drag_begin_cb (GtkWidget *widget,
|
file_list_drag_begin_cb (GtkWidget *widget,
|
||||||
GdkDrop *drop,
|
GdkDrag *drag,
|
||||||
GtkFileChooserWidget *impl)
|
GtkFileChooserWidget *impl)
|
||||||
{
|
{
|
||||||
gtk_places_sidebar_set_drop_targets_visible (GTK_PLACES_SIDEBAR (impl->priv->places_sidebar),
|
gtk_places_sidebar_set_drop_targets_visible (GTK_PLACES_SIDEBAR (impl->priv->places_sidebar),
|
||||||
TRUE,
|
TRUE,
|
||||||
drop);
|
drag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable the normal tree drag motion handler, it makes it look like you're
|
/* Disable the normal tree drag motion handler, it makes it look like you're
|
||||||
@ -2014,7 +2014,7 @@ file_list_drag_motion_cb (GtkWidget *widget,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
file_list_drag_end_cb (GtkWidget *widget,
|
file_list_drag_end_cb (GtkWidget *widget,
|
||||||
GdkDrop *drop,
|
GdkDrag *drag,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkFileChooserWidget *impl;
|
GtkFileChooserWidget *impl;
|
||||||
@ -2022,7 +2022,7 @@ file_list_drag_end_cb (GtkWidget *widget,
|
|||||||
impl = GTK_FILE_CHOOSER_WIDGET (user_data);
|
impl = GTK_FILE_CHOOSER_WIDGET (user_data);
|
||||||
gtk_places_sidebar_set_drop_targets_visible (GTK_PLACES_SIDEBAR (impl->priv->places_sidebar),
|
gtk_places_sidebar_set_drop_targets_visible (GTK_PLACES_SIDEBAR (impl->priv->places_sidebar),
|
||||||
FALSE,
|
FALSE,
|
||||||
drop);
|
drag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sensitizes the "Copy file’s location" and other context menu items if there is actually
|
/* Sensitizes the "Copy file’s location" and other context menu items if there is actually
|
||||||
|
@ -389,14 +389,14 @@ emit_unmount_operation (GtkPlacesSidebar *sidebar,
|
|||||||
|
|
||||||
static GdkDragAction
|
static GdkDragAction
|
||||||
emit_drag_action_requested (GtkPlacesSidebar *sidebar,
|
emit_drag_action_requested (GtkPlacesSidebar *sidebar,
|
||||||
GdkDrop *drop,
|
GdkDrag *drag,
|
||||||
GFile *dest_file,
|
GFile *dest_file,
|
||||||
GList *source_file_list)
|
GList *source_file_list)
|
||||||
{
|
{
|
||||||
GdkDragAction ret_action = 0;
|
GdkDragAction ret_action = 0;
|
||||||
|
|
||||||
g_signal_emit (sidebar, places_sidebar_signals[DRAG_ACTION_REQUESTED], 0,
|
g_signal_emit (sidebar, places_sidebar_signals[DRAG_ACTION_REQUESTED], 0,
|
||||||
drop, dest_file, source_file_list, &ret_action);
|
drag, dest_file, source_file_list, &ret_action);
|
||||||
|
|
||||||
return ret_action;
|
return ret_action;
|
||||||
}
|
}
|
||||||
@ -1536,7 +1536,7 @@ update_places (GtkPlacesSidebar *sidebar)
|
|||||||
static gboolean
|
static gboolean
|
||||||
check_valid_drop_target (GtkPlacesSidebar *sidebar,
|
check_valid_drop_target (GtkPlacesSidebar *sidebar,
|
||||||
GtkSidebarRow *row,
|
GtkSidebarRow *row,
|
||||||
GdkDrop *drop)
|
GdkDrag *drag)
|
||||||
{
|
{
|
||||||
GtkPlacesSidebarPlaceType place_type;
|
GtkPlacesSidebarPlaceType place_type;
|
||||||
GtkPlacesSidebarSectionType section_type;
|
GtkPlacesSidebarSectionType section_type;
|
||||||
@ -1592,12 +1592,12 @@ check_valid_drop_target (GtkPlacesSidebar *sidebar,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Dragging a file */
|
/* Dragging a file */
|
||||||
if (drop)
|
if (drag)
|
||||||
{
|
{
|
||||||
if (uri != NULL)
|
if (uri != NULL)
|
||||||
{
|
{
|
||||||
dest_file = g_file_new_for_uri (uri);
|
dest_file = g_file_new_for_uri (uri);
|
||||||
drag_action = emit_drag_action_requested (sidebar, drop, dest_file, sidebar->drag_list);
|
drag_action = emit_drag_action_requested (sidebar, drag, dest_file, sidebar->drag_list);
|
||||||
valid = drag_action > 0;
|
valid = drag_action > 0;
|
||||||
|
|
||||||
g_object_unref (dest_file);
|
g_object_unref (dest_file);
|
||||||
@ -1625,7 +1625,7 @@ check_valid_drop_target (GtkPlacesSidebar *sidebar,
|
|||||||
static void
|
static void
|
||||||
update_possible_drop_targets (GtkPlacesSidebar *sidebar,
|
update_possible_drop_targets (GtkPlacesSidebar *sidebar,
|
||||||
gboolean dragging,
|
gboolean dragging,
|
||||||
GdkDrop *drop)
|
GdkDrag *drag)
|
||||||
{
|
{
|
||||||
GList *rows;
|
GList *rows;
|
||||||
GList *l;
|
GList *l;
|
||||||
@ -1635,7 +1635,7 @@ update_possible_drop_targets (GtkPlacesSidebar *sidebar,
|
|||||||
|
|
||||||
for (l = rows; l != NULL; l = l->next)
|
for (l = rows; l != NULL; l = l->next)
|
||||||
{
|
{
|
||||||
sensitive = !dragging || check_valid_drop_target (sidebar, GTK_SIDEBAR_ROW (l->data), drop);
|
sensitive = !dragging || check_valid_drop_target (sidebar, GTK_SIDEBAR_ROW (l->data), drag);
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (l->data), sensitive);
|
gtk_widget_set_sensitive (GTK_WIDGET (l->data), sensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1677,7 +1677,7 @@ free_drag_data (GtkPlacesSidebar *sidebar)
|
|||||||
static void
|
static void
|
||||||
start_drop_feedback (GtkPlacesSidebar *sidebar,
|
start_drop_feedback (GtkPlacesSidebar *sidebar,
|
||||||
GtkSidebarRow *row,
|
GtkSidebarRow *row,
|
||||||
GdkDrop *drop)
|
GdkDrag *drag)
|
||||||
{
|
{
|
||||||
if (sidebar->drag_data_info != DND_GTK_SIDEBAR_ROW)
|
if (sidebar->drag_data_info != DND_GTK_SIDEBAR_ROW)
|
||||||
{
|
{
|
||||||
@ -1687,7 +1687,7 @@ start_drop_feedback (GtkPlacesSidebar *sidebar,
|
|||||||
sidebar->drop_state = DROP_STATE_NEW_BOOKMARK_ARMED;
|
sidebar->drop_state = DROP_STATE_NEW_BOOKMARK_ARMED;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_possible_drop_targets (sidebar, TRUE, drop);
|
update_possible_drop_targets (sidebar, TRUE, drag);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1766,10 +1766,12 @@ drag_motion_callback (GtkWidget *widget,
|
|||||||
gchar *drop_target_uri = NULL;
|
gchar *drop_target_uri = NULL;
|
||||||
gint row_index;
|
gint row_index;
|
||||||
gint row_placeholder_index;
|
gint row_placeholder_index;
|
||||||
|
GdkDrag *drag;
|
||||||
|
|
||||||
sidebar->dragging_over = TRUE;
|
sidebar->dragging_over = TRUE;
|
||||||
action = 0;
|
action = 0;
|
||||||
row = gtk_list_box_get_row_at_y (GTK_LIST_BOX (sidebar->list_box), y);
|
row = gtk_list_box_get_row_at_y (GTK_LIST_BOX (sidebar->list_box), y);
|
||||||
|
drag = gdk_drop_get_drag (drop);
|
||||||
|
|
||||||
gtk_list_box_drag_unhighlight_row (GTK_LIST_BOX (sidebar->list_box));
|
gtk_list_box_drag_unhighlight_row (GTK_LIST_BOX (sidebar->list_box));
|
||||||
|
|
||||||
@ -1779,7 +1781,7 @@ drag_motion_callback (GtkWidget *widget,
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Nothing to do if the target is not valid drop destination */
|
/* Nothing to do if the target is not valid drop destination */
|
||||||
if (!check_valid_drop_target (sidebar, GTK_SIDEBAR_ROW (row), drop))
|
if (!check_valid_drop_target (sidebar, GTK_SIDEBAR_ROW (row), drag))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (sidebar->drag_data_received &&
|
if (sidebar->drag_data_received &&
|
||||||
@ -1866,7 +1868,7 @@ drag_motion_callback (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
GFile *dest_file = g_file_new_for_uri (drop_target_uri);
|
GFile *dest_file = g_file_new_for_uri (drop_target_uri);
|
||||||
|
|
||||||
action = emit_drag_action_requested (sidebar, drop, dest_file, sidebar->drag_list);
|
action = emit_drag_action_requested (sidebar, drag, dest_file, sidebar->drag_list);
|
||||||
|
|
||||||
g_object_unref (dest_file);
|
g_object_unref (dest_file);
|
||||||
}
|
}
|
||||||
@ -1877,7 +1879,7 @@ drag_motion_callback (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
start_drop_feedback (sidebar, GTK_SIDEBAR_ROW (row), drop);
|
start_drop_feedback (sidebar, GTK_SIDEBAR_ROW (row), drag);
|
||||||
|
|
||||||
g_signal_stop_emission_by_name (sidebar->list_box, "drag-motion");
|
g_signal_stop_emission_by_name (sidebar->list_box, "drag-motion");
|
||||||
|
|
||||||
@ -2023,7 +2025,7 @@ drag_data_received_callback (GtkWidget *list_box,
|
|||||||
|
|
||||||
real_action = 0;
|
real_action = 0;
|
||||||
|
|
||||||
if (!check_valid_drop_target (sidebar, GTK_SIDEBAR_ROW (target_row), drop))
|
if (!check_valid_drop_target (sidebar, GTK_SIDEBAR_ROW (target_row), gdk_drop_get_drag (drop)))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (sidebar->drag_data_info == DND_GTK_SIDEBAR_ROW)
|
if (sidebar->drag_data_info == DND_GTK_SIDEBAR_ROW)
|
||||||
@ -2118,7 +2120,7 @@ drag_leave_callback (GtkWidget *widget,
|
|||||||
|
|
||||||
if (sidebar->drop_state != DROP_STATE_NEW_BOOKMARK_ARMED_PERMANENT)
|
if (sidebar->drop_state != DROP_STATE_NEW_BOOKMARK_ARMED_PERMANENT)
|
||||||
{
|
{
|
||||||
update_possible_drop_targets (sidebar, FALSE, drop);
|
update_possible_drop_targets (sidebar, FALSE, gdk_drop_get_drag (drop));
|
||||||
gtk_sidebar_row_hide (GTK_SIDEBAR_ROW (sidebar->new_bookmark_row), FALSE);
|
gtk_sidebar_row_hide (GTK_SIDEBAR_ROW (sidebar->new_bookmark_row), FALSE);
|
||||||
sidebar->drop_state = DROP_STATE_NORMAL;
|
sidebar->drop_state = DROP_STATE_NORMAL;
|
||||||
}
|
}
|
||||||
@ -4537,7 +4539,7 @@ gtk_places_sidebar_class_init (GtkPlacesSidebarClass *class)
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
_gtk_marshal_INT__OBJECT_OBJECT_POINTER,
|
_gtk_marshal_INT__OBJECT_OBJECT_POINTER,
|
||||||
G_TYPE_INT, 3,
|
G_TYPE_INT, 3,
|
||||||
GDK_TYPE_DROP,
|
GDK_TYPE_DRAG,
|
||||||
G_TYPE_OBJECT,
|
G_TYPE_OBJECT,
|
||||||
G_TYPE_POINTER /* GList of GFile */ );
|
G_TYPE_POINTER /* GList of GFile */ );
|
||||||
|
|
||||||
@ -5356,12 +5358,15 @@ gtk_places_sidebar_get_nth_bookmark (GtkPlacesSidebar *sidebar,
|
|||||||
void
|
void
|
||||||
gtk_places_sidebar_set_drop_targets_visible (GtkPlacesSidebar *sidebar,
|
gtk_places_sidebar_set_drop_targets_visible (GtkPlacesSidebar *sidebar,
|
||||||
gboolean visible,
|
gboolean visible,
|
||||||
GdkDrop *drop)
|
GdkDrag *drag)
|
||||||
{
|
{
|
||||||
|
g_return_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar));
|
||||||
|
g_return_if_fail (GDK_IS_DRAG (drag));
|
||||||
|
|
||||||
if (visible)
|
if (visible)
|
||||||
{
|
{
|
||||||
sidebar->drop_state = DROP_STATE_NEW_BOOKMARK_ARMED_PERMANENT;
|
sidebar->drop_state = DROP_STATE_NEW_BOOKMARK_ARMED_PERMANENT;
|
||||||
start_drop_feedback (sidebar, NULL, drop);
|
start_drop_feedback (sidebar, NULL, drag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,7 @@ GFile * gtk_places_sidebar_get_nth_bookmark (GtkPlacesSideb
|
|||||||
gint n);
|
gint n);
|
||||||
void gtk_places_sidebar_set_drop_targets_visible (GtkPlacesSidebar *sidebar,
|
void gtk_places_sidebar_set_drop_targets_visible (GtkPlacesSidebar *sidebar,
|
||||||
gboolean visible,
|
gboolean visible,
|
||||||
GdkDrop *drop);
|
GdkDrag *drag);
|
||||||
gboolean gtk_places_sidebar_get_show_trash (GtkPlacesSidebar *sidebar);
|
gboolean gtk_places_sidebar_get_show_trash (GtkPlacesSidebar *sidebar);
|
||||||
void gtk_places_sidebar_set_show_trash (GtkPlacesSidebar *sidebar,
|
void gtk_places_sidebar_set_show_trash (GtkPlacesSidebar *sidebar,
|
||||||
gboolean show_trash);
|
gboolean show_trash);
|
||||||
|
Loading…
Reference in New Issue
Block a user