2
* @file ui_dnd.c everything concerning DnD
2
* @file ui_dnd.c everything concerning Drag&Drop
4
* Copyright (C) 2003-2007 Lars Lindner <lars.lindner@gmail.com>
4
* Copyright (C) 2003-2011 Lars Lindner <lars.lindner@gmail.com>
6
6
* This program is free software; you can redistribute it and/or modify
7
7
* it under the terms of the GNU General Public License as published by
22
22
#include "common.h"
24
24
#include "feedlist.h"
27
#include "ui/ui_feedlist.h"
28
#include "ui/ui_itemlist.h"
27
#include "ui/item_list_view.h"
28
#include "ui/feed_list_view.h"
29
29
#include "ui/ui_node.h"
30
30
#include "ui/ui_dnd.h"
31
31
#include "fl_sources/node_source.h"
81
81
ui_dnd_feed_drop_possible (GtkTreeDragDest *drag_dest, GtkTreePath *dest_path, GtkSelectionData *selection_data)
83
GtkTreeModel *model = NULL;
84
GtkTreePath *src_path = NULL;
86
nodePtr sourceNode, targetNode;
86
88
debug1 (DEBUG_GUI, "DnD check if feed dropping is possible (%d)", dest_path);
88
91
if (!(old_feed_drop_possible) (drag_dest, dest_path, selection_data))
91
94
if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (drag_dest), &iter, dest_path))
94
/* If we get an iterator it's either a possible dropping
97
/* Try to get an iterator, if we get none it means either feed list
98
root or an "Empty" node. Both cases are fine */
99
gtk_tree_model_get (GTK_TREE_MODEL (drag_dest), &iter, FS_PTR, &targetNode, -1);
103
/* If we got an iterator it's either a possible dropping
95
104
candidate (a folder or source node to drop into, or a
96
105
iterator to insert after). In any case we have to check
97
106
if it is a writeable node source. */
99
gtk_tree_model_get (GTK_TREE_MODEL (drag_dest), &iter, FS_PTR, &node, -1);
101
/* never drag nodes of read-only subscription lists */
102
if (node && !(NODE_SOURCE_TYPE (node)->capabilities & NODE_SOURCE_CAPABILITY_WRITABLE_FEEDLIST))
108
/* never drop into read-only subscription node sources */
109
if (!(NODE_SOURCE_TYPE (targetNode)->capabilities & NODE_SOURCE_CAPABILITY_WRITABLE_FEEDLIST))
112
/* never drag folders into non-hierarchic node sources */
113
if (!gtk_tree_get_row_drag_data (selection_data, &model, &src_path))
116
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, src_path)) {
117
gtk_tree_model_get (GTK_TREE_MODEL (model), &iter, FS_PTR, &sourceNode, -1);
119
if (IS_FOLDER(sourceNode) && !(NODE_SOURCE_TYPE (targetNode)->capabilities & NODE_SOURCE_CAPABILITY_HIERARCHIC_FEEDLIST))
123
gtk_tree_path_free (src_path);
132
152
if (gtk_tree_model_iter_parent (GTK_TREE_MODEL (drag_dest), &parentIter, &iter)) {
133
153
gtk_tree_model_get (GTK_TREE_MODEL (drag_dest), &parentIter, FS_PTR, &newParent, -1);
155
debug0 (DEBUG_GUI, "Defaulting to feed list root as drop target");
135
156
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (drag_dest), &parentIter);
136
157
newParent = feedlist_get_root ();