[nautilus/wip/csoriano/dnd] meh 2
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/csoriano/dnd] meh 2
- Date: Thu, 1 Oct 2015 16:50:34 +0000 (UTC)
commit 79abe496d56f3b70b2f885cc6ee03b273323264c
Author: Carlos Soriano <csoriano gnome org>
Date: Thu Oct 1 18:50:03 2015 +0200
meh 2
libnautilus-private/nautilus-canvas-dnd.c | 14 +++++-
libnautilus-private/nautilus-canvas-dnd.h | 2 +-
libnautilus-private/nautilus-dnd.c | 13 +++--
libnautilus-private/nautilus-dnd.h | 8 ++-
libnautilus-private/nautilus-tree-view-drag-dest.c | 10 ++++
src/nautilus-list-view.c | 52 ++++++++++++++------
src/nautilus-list-view.h | 3 +-
src/nautilus-window.c | 30 +++++++++--
8 files changed, 99 insertions(+), 33 deletions(-)
---
diff --git a/libnautilus-private/nautilus-canvas-dnd.c b/libnautilus-private/nautilus-canvas-dnd.c
index 10192d6..235d49b 100644
--- a/libnautilus-private/nautilus-canvas-dnd.c
+++ b/libnautilus-private/nautilus-canvas-dnd.c
@@ -1080,7 +1080,7 @@ nautilus_canvas_container_receive_dropped_icons (NautilusCanvasContainer *contai
container->details->dnd_info->drag_info.selection_list = NULL;
}
-GList *
+NautilusDragInfo *
nautilus_canvas_container_get_drag_source_data (NautilusCanvasContainer *container,
GdkDragContext *context,
guint32 time)
@@ -1093,7 +1093,7 @@ nautilus_canvas_container_get_drag_source_data (NautilusCanvasContainer *contain
return NULL;
}
- return container->details->dnd_info->drag_info.selection_list;
+ return &container->details->dnd_info->drag_info;
}
static void
@@ -1316,6 +1316,8 @@ drag_begin_callback (GtkWidget *widget,
drag_info = &(container->details->dnd_info->drag_info);
drag_info->selection_cache = nautilus_drag_create_selection_cache (widget,
each_icon_get_data_binder);
+
+ nautilus_window_start_dnd (window, context);
}
void
@@ -1342,6 +1344,7 @@ nautilus_canvas_dnd_begin_drag (NautilusCanvasContainer *container,
dnd_info->drag_info.start_y = start_y -
gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)));
+ dnd_info->drag_info.overrided_actions = actions;
/* start the drag */
gtk_drag_begin_with_coordinates (GTK_WIDGET (container),
dnd_info->drag_info.target_list,
@@ -1511,6 +1514,13 @@ drag_motion_callback (GtkWidget *widget,
guint32 time)
{
int action;
+ NautilusWindow *window;
+ NautilusWindowSlot *slot;
+ NautilusView *view;
+
+ window = NAUTILUS_WINDOW (gtk_widget_get_toplevel (widget));
+ slot = nautilus_window_get_active_slot (window);
+ view = nautilus_window_slot_get_current_view (slot);
nautilus_canvas_container_ensure_drag_data (NAUTILUS_CANVAS_CONTAINER (widget), context, time);
nautilus_canvas_container_position_shadow (NAUTILUS_CANVAS_CONTAINER (widget), x, y);
diff --git a/libnautilus-private/nautilus-canvas-dnd.h b/libnautilus-private/nautilus-canvas-dnd.h
index fcfbe6a..aecf49d 100644
--- a/libnautilus-private/nautilus-canvas-dnd.h
+++ b/libnautilus-private/nautilus-canvas-dnd.h
@@ -54,7 +54,7 @@ void nautilus_canvas_dnd_begin_drag (NautilusCanvasContainer *conta
int start_y);
void nautilus_canvas_dnd_end_drag (NautilusCanvasContainer *container);
-GList* nautilus_canvas_container_get_drag_source_data (NautilusCanvasContainer *container,
+NautilusDragInfo* nautilus_canvas_container_get_drag_source_data (NautilusCanvasContainer *container,
GdkDragContext *context,
guint32 time);
diff --git a/libnautilus-private/nautilus-dnd.c b/libnautilus-private/nautilus-dnd.c
index 5948587..575259b 100644
--- a/libnautilus-private/nautilus-dnd.c
+++ b/libnautilus-private/nautilus-dnd.c
@@ -383,12 +383,12 @@ source_is_deletable (GFile *file)
return ret;
}
-GList *
+NautilusDragInfo *
nautilus_drag_get_source_data (GdkDragContext *context,
guint32 time)
{
GtkWidget *source_widget;
- GList *source_data;
+ NautilusDragInfo *source_data;
source_widget = gtk_drag_get_source_widget (context);
if (source_widget == NULL)
@@ -426,9 +426,10 @@ nautilus_drag_get_source_data (GdkDragContext *context,
void
nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
- const char *target_uri_string,
- const GList *items,
- int *action)
+ const char *target_uri_string,
+ const GList *items,
+ guint32 overrided_actions,
+ int *action)
{
gboolean same_fs;
gboolean target_is_source_parent;
@@ -447,7 +448,7 @@ nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
actions = gdk_drag_context_get_actions (context) & (GDK_ACTION_MOVE | GDK_ACTION_COPY);
g_print ("actions %d\n", gdk_drag_context_get_actions (context));
if (gdk_drag_context_get_actions (context) == 46) {
- G_BREAKPOINT ();
+ //G_BREAKPOINT ();
}
if (actions == 0) {
diff --git a/libnautilus-private/nautilus-dnd.h b/libnautilus-private/nautilus-dnd.h
index d7afc79..574beec 100644
--- a/libnautilus-private/nautilus-dnd.h
+++ b/libnautilus-private/nautilus-dnd.h
@@ -88,7 +88,11 @@ typedef struct {
/* autoscrolling during dragging */
int auto_scroll_timeout_id;
gboolean waiting_to_autoscroll;
- gint64 start_auto_scroll_in;
+ guint64 start_auto_scroll_in;
+
+ /* overrided actions. Used for knowing the actions using a GdkDragContext
+ * source instead of destination */
+ guint32 overrided_actions;
} NautilusDragInfo;
@@ -153,7 +157,7 @@ void nautilus_drag_autoscroll_stop
(NautilusDragInfo *drag_info);
gboolean nautilus_drag_selection_includes_special_link (GList
*selection_list);
-GList * nautilus_drag_get_source_data (GdkDragContext *context,
+NautilusDragInfo * nautilus_drag_get_source_data (GdkDragContext *context,
guint32 time);
#endif
diff --git a/libnautilus-private/nautilus-tree-view-drag-dest.c
b/libnautilus-private/nautilus-tree-view-drag-dest.c
index ee57881..91a13ef 100644
--- a/libnautilus-private/nautilus-tree-view-drag-dest.c
+++ b/libnautilus-private/nautilus-tree-view-drag-dest.c
@@ -36,6 +36,7 @@
#include "nautilus-link.h"
#include <gtk/gtk.h>
+#include <src/nautilus-window.h>
#include <stdio.h>
#include <string.h>
@@ -542,6 +543,7 @@ drag_motion_callback (GtkWidget *widget,
gpointer data)
{
NautilusTreeViewDragDest *dest;
+ NautilusWindow *window;
GtkTreePath *path;
GtkTreePath *drop_path, *old_drop_path;
GtkTreeViewDropPosition pos;
@@ -549,7 +551,9 @@ drag_motion_callback (GtkWidget *widget,
guint action;
gboolean res = TRUE;
+ g_print ("tree view drag motion %p\n", context);
dest = NAUTILUS_TREE_VIEW_DRAG_DEST (data);
+ window = NAUTILUS_WINDOW (gtk_widget_get_toplevel (widget));
gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget),
x, y, &path, &pos);
@@ -613,6 +617,8 @@ drag_motion_callback (GtkWidget *widget,
gdk_drag_status (context, action, time);
+ nautilus_window_start_dnd (window, context);
+
return TRUE;
}
@@ -623,14 +629,18 @@ drag_leave_callback (GtkWidget *widget,
gpointer data)
{
NautilusTreeViewDragDest *dest;
+ NautilusWindow *window;
dest = NAUTILUS_TREE_VIEW_DRAG_DEST (data);
+ window = NAUTILUS_WINDOW (gtk_widget_get_toplevel (widget));
clear_drag_dest_row (dest);
free_drag_data (dest);
remove_scroll_timeout (dest);
+
+ nautilus_window_end_dnd (window, context);
}
static char *
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index a97b567..18fa4ff 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -46,7 +46,6 @@
#include <libnautilus-private/nautilus-clipboard-monitor.h>
#include <libnautilus-private/nautilus-column-chooser.h>
#include <libnautilus-private/nautilus-column-utilities.h>
-#include <libnautilus-private/nautilus-dnd.h>
#include <libnautilus-private/nautilus-file-dnd.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-ui-utilities.h>
@@ -97,6 +96,7 @@ struct NautilusListViewDetails {
gboolean ignore_button_release;
gboolean row_selected_on_button_down;
gboolean active;
+ NautilusDragInfo *drag_info;
GHashTable *columns;
GtkWidget *column_editor;
@@ -108,6 +108,8 @@ struct NautilusListViewDetails {
GQuark last_sort_attr;
GIcon *icon;
+
+ GList *selection_cache;
};
struct SelectionForeachData {
@@ -342,33 +344,32 @@ nautilus_list_view_did_not_drag (NautilusListView *view,
}
-GList *
+NautilusDragInfo *
nautilus_list_view_get_drag_source_data (NautilusListView *list_view,
GdkDragContext *context,
guint32 time)
{
- GtkTreeView *tree_view;
+ GtkTreeView *tree_view;
GtkTreeModel *model;
GList *selection_cache;
+
tree_view = GTK_TREE_VIEW (list_view->details->tree_view);
model = gtk_tree_view_get_model (tree_view);
+ g_print ("data get %p\n", context);
if (model == NULL) {
- g_print ("model null\n");
return NULL;
}
selection_cache = g_object_get_data (G_OBJECT (context), "drag-info");
if (selection_cache == NULL) {
- g_print ("selection cache null \n");
return NULL;
}
g_print ("returning selection cache \n");
- return selection_cache;
-
+ return list_view->details->drag_info;
}
static void
@@ -383,8 +384,9 @@ drag_data_get_callback (GtkWidget *widget,
GList *selection_cache;
tree_view = GTK_TREE_VIEW (widget);
-
+
model = gtk_tree_view_get_model (tree_view);
+ g_print ("data get %p\n", context);
if (model == NULL) {
return;
@@ -520,9 +522,22 @@ drag_end_callback (GtkWidget *widget,
nautilus_window_end_dnd (window, context);
}
+static gboolean
+drag_motion_callback (GtkWidget *widget,
+ GdkDragContext *context,
+ int x,
+ int y,
+ guint32 time,
+ NautilusView *view)
+{
+ NautilusWindow *window;
-static void
-drag_motion_callback ()
+ window = nautilus_files_view_get_window (NAUTILUS_FILES_VIEW (view));
+ g_print ("####### start window dnd %p\n", context);
+ nautilus_window_start_dnd (window, context);
+
+ return TRUE;
+}
static void
drag_begin_callback (GtkWidget *widget,
@@ -531,13 +546,14 @@ drag_begin_callback (GtkWidget *widget,
{
GList *selection_cache;
cairo_surface_t *surface;
- NautilusWindow *window;
GdkDragAction actions;
+ NautilusWindow *window;
window = nautilus_files_view_get_window (NAUTILUS_FILES_VIEW (view));
+
surface = get_drag_surface (view);
actions = gdk_drag_context_get_actions (context);
- g_print ("ACTIONS LIST VIEW %d\n", actions);
+ g_print ("ACTIONS LIST VIEW %p\n", context);
if (surface) {
gtk_drag_set_icon_surface (context, surface);
cairo_surface_destroy (surface);
@@ -551,12 +567,12 @@ drag_begin_callback (GtkWidget *widget,
selection_cache = nautilus_drag_create_selection_cache (view,
each_item_get_data_binder);
+ view->details->drag_info->selection_list = selection_cache;
g_object_set_data_full (G_OBJECT (context),
"drag-info",
selection_cache,
(GDestroyNotify)nautilus_drag_destroy_selection_list);
- g_print ("start window dnd\n");
nautilus_window_start_dnd (window, context);
}
@@ -605,10 +621,14 @@ motion_notify_callback (GtkWidget *widget,
view->details->drag_y,
event->x,
event->y)) {
+ guint32 actions;
+
+ actions = GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK;
+ view->details->drag_info->overrided_actions = actions;
gtk_drag_begin
(widget,
source_target_list,
- GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK,
+ actions,
view->details->drag_button,
(GdkEvent*)event);
}
@@ -1903,8 +1923,6 @@ create_and_set_up_tree_view (NautilusListView *view)
g_signal_connect_object (view->details->tree_view, "drag-begin",
G_CALLBACK (drag_begin_callback), view, 0);
- g_signal_connect_object (view->details->tree_view, "drag-motion",
- G_CALLBACK (drag_motion_callback), view, 0);
g_signal_connect_object (view->details->tree_view, "drag-end",
G_CALLBACK (drag_end_callback), view, 0);
g_signal_connect_object (view->details->tree_view, "drag-data-get",
@@ -3483,6 +3501,8 @@ nautilus_list_view_init (NautilusListView *list_view)
"clipboard-info",
G_CALLBACK (list_view_notify_clipboard_info), list_view);
+ list_view->details->drag_info = g_new0 (NautilusDragInfo, 1);
+
view_action_group = nautilus_files_view_get_action_group (NAUTILUS_FILES_VIEW (list_view));
g_action_map_add_action_entries (G_ACTION_MAP (view_action_group),
list_view_entries,
diff --git a/src/nautilus-list-view.h b/src/nautilus-list-view.h
index 4213968..fd20b1b 100644
--- a/src/nautilus-list-view.h
+++ b/src/nautilus-list-view.h
@@ -27,6 +27,7 @@
#define NAUTILUS_LIST_VIEW_H
#include "nautilus-files-view.h"
+#include <libnautilus-private/nautilus-dnd.h>
#define NAUTILUS_TYPE_LIST_VIEW nautilus_list_view_get_type()
#define NAUTILUS_LIST_VIEW(obj) \
@@ -54,7 +55,7 @@ typedef struct {
GType nautilus_list_view_get_type (void);
NautilusFilesView * nautilus_list_view_new (NautilusWindowSlot *slot);
-GList *
+NautilusDragInfo *
nautilus_list_view_get_drag_source_data (NautilusListView *list_view,
GdkDragContext *context,
guint32 time);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index 7df7fa6..341d94b 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -998,6 +998,20 @@ nautilus_window_end_dnd (NautilusWindow *window,
context);
}
+static void
+on_drag_data_received (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *data,
+ guint info,
+ guint time,
+ gpointer user_data)
+{
+ g_object_set (context, "selection-data", data, NULL);
+ g_print ("setting data on %p\n", context);
+}
+
/* Callback used when the places sidebar needs to know the drag action to suggest */
static GdkDragAction
places_sidebar_drag_action_requested_cb (GtkPlacesSidebar *sidebar,
@@ -1011,17 +1025,23 @@ places_sidebar_drag_action_requested_cb (GtkPlacesSidebar *sidebar,
char *uri;
int action = 0;
GtkWidget *source_widget;
- GdkAtom target;
+ NautilusDragInfo *info;
source_widget = gtk_drag_get_source_widget (context);
- target = gtk_drag_dest_find_target (GTK_WIDGET (sidebar), context, NULL);
- //gtk_drag_get_data (source_widget, context, target, GDK_CURRENT_TIME);
+ g_print ("getting data on %p\n", context);
+
items = build_selection_list_from_gfile_list (source_file_list);
- items_from_nautilus_data = nautilus_drag_get_source_data (context, GDK_CURRENT_TIME);
+ info = nautilus_drag_get_source_data (context, GDK_CURRENT_TIME);
+ items_from_nautilus_data = info->selection_list;
uri = g_file_get_uri (dest_file);
- nautilus_drag_default_drop_action_for_icons (context, uri, items_from_nautilus_data, &action);
+ if (g_list_length (items_from_nautilus_data) < 1) {
+ g_print ("lenght of items <0\n");
+ return 0;
+ }
+
+ nautilus_drag_default_drop_action_for_icons (context, uri, items_from_nautilus_data,
overrided_actions, &action);
g_print ("action %d %s %d %d\n", action, uri, g_list_length (source_file_list), g_list_length
(items_from_nautilus_data));
nautilus_drag_destroy_selection_list (items);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]