static char * get_drop_target_uri_at_pos (NautilusTreeViewDragDest *dest, int x, int y) { char *drop_target = NULL; GtkTreePath *path; GtkTreePath *drop_path; GtkTreeViewDropPosition pos; gtk_tree_view_get_dest_row_at_pos (dest->details->tree_view, x, y, &path, &pos); if (pos == GTK_TREE_VIEW_DROP_BEFORE || pos == GTK_TREE_VIEW_DROP_AFTER) { gtk_tree_path_free (path); path = NULL; } drop_path = get_drop_path (dest, path); drop_target = get_drop_target_uri_for_path (dest, drop_path); if (path != NULL) { gtk_tree_path_free (path); } if (drop_path != NULL) { gtk_tree_path_free (drop_path); } return drop_target; }
static char * get_drop_target_uri_at_pos (NemoTreeViewDragDest *dest, int x, int y) { char *drop_target; GtkTreePath *path; GtkTreePath *drop_path; GtkTreeViewDropPosition pos; gtk_tree_view_get_dest_row_at_pos (dest->details->tree_view, x, y, &path, &pos); drop_path = get_drop_path (dest, path); drop_target = get_drop_target_uri_for_path (dest, drop_path); if (path != NULL) { gtk_tree_path_free (path); } if (drop_path != NULL) { gtk_tree_path_free (drop_path); } return drop_target; }
static gboolean on_drag_motion(GtkWidget *dest_widget, GdkDragContext *drag_context, gint x, gint y, guint time, FmFolderView* fv) { gboolean ret; GdkDragAction action = 0; GdkAtom target = gtk_drag_dest_find_target(dest_widget, drag_context, NULL); if(target == GDK_NONE) return FALSE; ret = FALSE; /* files are being dragged */ if(fm_dnd_dest_is_target_supported(fv->dnd_dest, target)) { GtkTreePath* tp = get_drop_path(fv, x, y); if(tp) { GtkTreeIter it; if(gtk_tree_model_get_iter(fv->model, &it, tp)) { FmFileInfo* fi; gtk_tree_model_get(fv->model, &it, COL_FILE_INFO, &fi, -1); fm_dnd_dest_set_dest_file(fv->dnd_dest, fi); } gtk_tree_path_free(tp); } else { /* FIXME: prevent direct access to data members. */ FmFolderModel* model = (FmFolderModel*)fv->model; FmPath* dir_path = model->dir->dir_path; fm_dnd_dest_set_dest_file(fv->dnd_dest, model->dir->dir_fi); } action = fm_dnd_dest_get_default_action(fv->dnd_dest, drag_context, target); ret = action != 0; } if (action) gdk_drag_status(drag_context, action, time); return ret; }
static gboolean drag_motion_callback (GtkWidget *widget, GdkDragContext *context, int x, int y, guint32 time, gpointer data) { NautilusTreeViewDragDest *dest; GtkTreePath *path; GtkTreePath *drop_path, *old_drop_path; GtkTreeViewDropPosition pos; GdkWindow *bin_window; guint action; gboolean res = TRUE; dest = NAUTILUS_TREE_VIEW_DRAG_DEST (data); gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), x, y, &path, &pos); if (pos == GTK_TREE_VIEW_DROP_BEFORE || pos == GTK_TREE_VIEW_DROP_AFTER) { gtk_tree_path_free (path); path = NULL; } if (!dest->details->have_drag_data) { res = get_drag_data (dest, context, time); } if (!res) { return FALSE; } drop_path = get_drop_path (dest, path); action = 0; bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)); if (bin_window != NULL) { int bin_x, bin_y; gdk_window_get_position (bin_window, &bin_x, &bin_y); if (bin_y <= y) { /* ignore drags on the header */ action = get_drop_action (dest, context, drop_path); } } gtk_tree_view_get_drag_dest_row (GTK_TREE_VIEW (widget), &old_drop_path, NULL); if (action) { set_drag_dest_row (dest, drop_path); check_hover_expand_timer (dest, path, drop_path, old_drop_path); } else { clear_drag_dest_row (dest); remove_hover_timer (dest); remove_expand_timer (dest); } if (path) { gtk_tree_path_free (path); } if (drop_path) { gtk_tree_path_free (drop_path); } if (old_drop_path) { gtk_tree_path_free (old_drop_path); } if (dest->details->scroll_id == 0) { dest->details->scroll_id = g_timeout_add (150, scroll_timeout, dest->details->tree_view); } gdk_drag_status (context, action, time); return TRUE; }
static gboolean drag_motion_callback (GtkWidget *widget, GdkDragContext *context, int x, int y, guint32 time, gpointer data) { NemoTreeViewDragDest *dest; GtkTreePath *path; GtkTreePath *drop_path, *old_drop_path; GtkTreeModel *model; GtkTreeIter drop_iter; GtkTreeViewDropPosition pos; GdkWindow *bin_window; guint action; gboolean res = TRUE; dest = NEMO_TREE_VIEW_DRAG_DEST (data); gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), x, y, &path, &pos); if (!dest->details->have_drag_data) { res = get_drag_data (dest, context, time); } if (!res) { return FALSE; } drop_path = get_drop_path (dest, path); action = 0; bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)); if (bin_window != NULL) { int bin_x, bin_y; gdk_window_get_position (bin_window, &bin_x, &bin_y); if (bin_y <= y) { /* ignore drags on the header */ action = get_drop_action (dest, context, drop_path); } } gtk_tree_view_get_drag_dest_row (GTK_TREE_VIEW (widget), &old_drop_path, NULL); if (action) { set_drag_dest_row (dest, drop_path); model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); if (drop_path == NULL || (old_drop_path != NULL && gtk_tree_path_compare (old_drop_path, drop_path) != 0)) { remove_expand_timeout (dest); } if (dest->details->expand_id == 0 && drop_path != NULL) { gtk_tree_model_get_iter (model, &drop_iter, drop_path); if (gtk_tree_model_iter_has_child (model, &drop_iter)) { dest->details->expand_id = g_timeout_add_seconds (HOVER_EXPAND_TIMEOUT, expand_timeout, dest->details->tree_view); } } } else { clear_drag_dest_row (dest); remove_expand_timeout (dest); } if (path) { gtk_tree_path_free (path); } if (drop_path) { gtk_tree_path_free (drop_path); } if (old_drop_path) { gtk_tree_path_free (old_drop_path); } if (dest->details->scroll_id == 0) { dest->details->scroll_id = g_timeout_add (150, scroll_timeout, dest->details->tree_view); } gdk_drag_status (context, action, time); return TRUE; }