Commit 4b2d6316 authored by Ernestas Kulik's avatar Ernestas Kulik 🦑

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 #1220
parent 6fe0a8c6
Pipeline #19982 passed with stages
in 58 minutes and 33 seconds
......@@ -1991,12 +1991,12 @@ file_list_drag_drop_cb (GtkWidget *widget,
static void
file_list_drag_begin_cb (GtkWidget *widget,
GdkDrop *drop,
GdkDrag *drag,
GtkFileChooserWidget *impl)
{
gtk_places_sidebar_set_drop_targets_visible (GTK_PLACES_SIDEBAR (impl->priv->places_sidebar),
TRUE,
drop);
drag);
}
/* 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
file_list_drag_end_cb (GtkWidget *widget,
GdkDrop *drop,
GdkDrag *drag,
gpointer user_data)
{
GtkFileChooserWidget *impl;
......@@ -2022,7 +2022,7 @@ file_list_drag_end_cb (GtkWidget *widget,
impl = GTK_FILE_CHOOSER_WIDGET (user_data);
gtk_places_sidebar_set_drop_targets_visible (GTK_PLACES_SIDEBAR (impl->priv->places_sidebar),
FALSE,
drop);
drag);
}
/* 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
emit_drag_action_requested (GtkPlacesSidebar *sidebar,
GdkDrop *drop,
GdkDrag *drag,
GFile *dest_file,
GList *source_file_list)
{
GdkDragAction ret_action = 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;
}
......@@ -1536,7 +1536,7 @@ update_places (GtkPlacesSidebar *sidebar)
static gboolean
check_valid_drop_target (GtkPlacesSidebar *sidebar,
GtkSidebarRow *row,
GdkDrop *drop)
GdkDrag *drag)
{
GtkPlacesSidebarPlaceType place_type;
GtkPlacesSidebarSectionType section_type;
......@@ -1592,12 +1592,12 @@ check_valid_drop_target (GtkPlacesSidebar *sidebar,
else
{
/* Dragging a file */
if (drop)
if (drag)
{
if (uri != NULL)
{
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;
g_object_unref (dest_file);
......@@ -1625,7 +1625,7 @@ check_valid_drop_target (GtkPlacesSidebar *sidebar,
static void
update_possible_drop_targets (GtkPlacesSidebar *sidebar,
gboolean dragging,
GdkDrop *drop)
GdkDrag *drag)
{
GList *rows;
GList *l;
......@@ -1635,7 +1635,7 @@ update_possible_drop_targets (GtkPlacesSidebar *sidebar,
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);
}
......@@ -1677,7 +1677,7 @@ free_drag_data (GtkPlacesSidebar *sidebar)
static void
start_drop_feedback (GtkPlacesSidebar *sidebar,
GtkSidebarRow *row,
GdkDrop *drop)
GdkDrag *drag)
{
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;
}
update_possible_drop_targets (sidebar, TRUE, drop);
update_possible_drop_targets (sidebar, TRUE, drag);
}
static void
......@@ -1766,10 +1766,12 @@ drag_motion_callback (GtkWidget *widget,
gchar *drop_target_uri = NULL;
gint row_index;
gint row_placeholder_index;
GdkDrag *drag;
sidebar->dragging_over = TRUE;
action = 0;
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));
......@@ -1779,7 +1781,7 @@ drag_motion_callback (GtkWidget *widget,
goto out;
/* 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;
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);
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);
}
......@@ -1877,7 +1879,7 @@ drag_motion_callback (GtkWidget *widget,
}
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");
......@@ -2023,7 +2025,7 @@ drag_data_received_callback (GtkWidget *list_box,
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;
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)
{
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);
sidebar->drop_state = DROP_STATE_NORMAL;
}
......@@ -4537,7 +4539,7 @@ gtk_places_sidebar_class_init (GtkPlacesSidebarClass *class)
NULL, NULL,
_gtk_marshal_INT__OBJECT_OBJECT_POINTER,
G_TYPE_INT, 3,
GDK_TYPE_DROP,
GDK_TYPE_DRAG,
G_TYPE_OBJECT,
G_TYPE_POINTER /* GList of GFile */ );
......@@ -5356,12 +5358,15 @@ gtk_places_sidebar_get_nth_bookmark (GtkPlacesSidebar *sidebar,
void
gtk_places_sidebar_set_drop_targets_visible (GtkPlacesSidebar *sidebar,
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)
{
sidebar->drop_state = DROP_STATE_NEW_BOOKMARK_ARMED_PERMANENT;
start_drop_feedback (sidebar, NULL, drop);
start_drop_feedback (sidebar, NULL, drag);
}
else
{
......
......@@ -103,7 +103,7 @@ GFile * gtk_places_sidebar_get_nth_bookmark (GtkPlacesSideb
gint n);
void gtk_places_sidebar_set_drop_targets_visible (GtkPlacesSidebar *sidebar,
gboolean visible,
GdkDrop *drop);
GdkDrag *drag);
gboolean gtk_places_sidebar_get_show_trash (GtkPlacesSidebar *sidebar);
void gtk_places_sidebar_set_show_trash (GtkPlacesSidebar *sidebar,
gboolean show_trash);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment