summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2018-07-18 00:23:08 +0000
committerMatthias Clasen <mclasen@redhat.com>2018-07-18 00:23:08 +0000
commit0750b4fd28eedf0782825e1b1f932b912c07c6c7 (patch)
tree664c67dbd18d1469333fdd33b19ca9e5eafb42c3
parent6fe0a8c6b3f51ec953fa59c160b656c91bb65970 (diff)
parent4b2d63167eac2e3c2de25963da2559b349faeddf (diff)
downloadgtk+-0750b4fd28eedf0782825e1b1f932b912c07c6c7.tar.gz
Merge branch 'places-sidebar-dnd' into 'master'
placessidebar: Take a GdkDrag in _set_drop_targets_visible() Closes #1220 See merge request GNOME/gtk!247
-rw-r--r--gtk/gtkfilechooserwidget.c8
-rw-r--r--gtk/gtkplacessidebar.c39
-rw-r--r--gtk/gtkplacessidebarprivate.h2
3 files changed, 27 insertions, 22 deletions
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index c96a92a447..2c1e2ed48b 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -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
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index 090d1d0aa7..3ffe5ec3f1 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -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
{
diff --git a/gtk/gtkplacessidebarprivate.h b/gtk/gtkplacessidebarprivate.h
index 4c08558b5e..d520ee8a01 100644
--- a/gtk/gtkplacessidebarprivate.h
+++ b/gtk/gtkplacessidebarprivate.h
@@ -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);