Commit ef2bbd05 authored by Mathieu Lacage's avatar Mathieu Lacage Committed by Mathieu Lacage
Browse files

port to new shared function. port to new shared function. add a new

2000-09-09  Mathieu Lacage  <mathieu@eazel.com>

	* components/tree/nautilus-tree-view.c: port to new
	shared function.
	* libnautilus-extensions/nautilus-icon-dnd.c: port to
	new shared function.
	* libnautilus-extensions/nautilus-drag.c:
	(nautilus_drag_autoscroll_calculate_delta),
	(nautilus_drag_file_receive_dropped_keyword): add a new
	fucntion to be shared.
	* libnautilus-extensions/nautilus-drag.h: add prototype
	* libnautilus-extensions/nautilus-list.c:
	(nautilus_list_get_drop_action),
	(nautilus_list_receive_dropped_icons),
	(nautilus_list_receive_dropped_keyword),
	(nautilus_list_drag_data_received):
	use the above function and add support to the list view
	for many new drop types. Need to fix bug 2485 properly
	to get 2874 fully implemented.
parent 27b08dc5
2000-09-09 Mathieu Lacage <mathieu@eazel.com>
* components/tree/nautilus-tree-view.c: port to new
shared function.
* libnautilus-extensions/nautilus-icon-dnd.c: port to
new shared function.
* libnautilus-extensions/nautilus-drag.c:
(nautilus_drag_autoscroll_calculate_delta),
(nautilus_drag_file_receive_dropped_keyword): add a new
fucntion to be shared.
* libnautilus-extensions/nautilus-drag.h: add prototype
* libnautilus-extensions/nautilus-list.c:
(nautilus_list_get_drop_action),
(nautilus_list_receive_dropped_icons),
(nautilus_list_receive_dropped_keyword),
(nautilus_list_drag_data_received):
use the above function and add support to the list view
for many new drop types. Need to fix bug 2485 properly
to get 2874 fully implemented.
2000-09-09 Mathieu Lacage <mathieu@eazel.com>
* components/tree/nautilus-tree-view.c: fix bug 2417.
......
......@@ -776,13 +776,13 @@ nautilus_tree_view_load_from_filesystem (NautilusTreeView *view)
static GtkTargetEntry nautilus_tree_view_dnd_target_table[] = {
{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR },
{ NAUTILUS_ICON_DND_BGIMAGE_TYPE, 0, NAUTILUS_ICON_DND_BGIMAGE },
{ NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD }
{ NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD },
{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR }
};
static void
tree_view_realize_callback (GtkWidget *widget, gpointer user_data)
{
......@@ -1504,8 +1504,6 @@ nautilus_tree_view_drag_motion (GtkWidget *widget, GdkDragContext *context,
/* auto scroll */
nautilus_tree_view_start_auto_scroll (tree_view);
/* update dragging cursor. */
nautilus_tree_view_get_drop_action (tree_view, context, x, y,
&default_action,
......@@ -1545,10 +1543,8 @@ nautilus_tree_view_drag_drop (GtkWidget *widget,
GPOINTER_TO_INT (context->targets->data),
time);
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget),
"drag_drop");
return TRUE;
}
......@@ -1617,13 +1613,13 @@ nautilus_tree_view_drag_data_received (GtkWidget *widget,
nautilus_background_receive_dropped_background_image
(nautilus_get_widget_background (widget),
(char *)data->data);
gtk_drag_finish (context, FALSE, FALSE, time);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
case NAUTILUS_ICON_DND_KEYWORD:
nautilus_tree_view_receive_dropped_keyword
(NAUTILUS_TREE_VIEW (tree_view),
(char *)data->data, x, y);
gtk_drag_finish (context, FALSE, FALSE, time);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
default:
gtk_drag_finish (context, FALSE, FALSE, time);
......@@ -2344,6 +2340,7 @@ nautilus_tree_view_get_drop_action (NautilusTreeView *tree_view,
switch (drag_info->data_type) {
case NAUTILUS_ICON_DND_GNOME_ICON_LIST:
case NAUTILUS_ICON_DND_URI_LIST:
if (drag_info->selection_list == NULL) {
*default_action = 0;
*non_default_action = 0;
......@@ -2363,6 +2360,8 @@ nautilus_tree_view_get_drop_action (NautilusTreeView *tree_view,
non_default_action);
break;
case NAUTILUS_ICON_DND_COLOR:
case NAUTILUS_ICON_DND_KEYWORD:
case NAUTILUS_ICON_DND_BGIMAGE:
/* FIXME bugzilla.eazel.com 2572: Doesn't handle dropped keywords in list view? Do we need to support this? */
*default_action = context->suggested_action;
*non_default_action = context->suggested_action;
......@@ -2448,7 +2447,7 @@ nautilus_tree_view_receive_dropped_icons (NautilusTreeView *view,
static void
nautilus_tree_view_receive_dropped_keyword (NautilusTreeView *tree_view, char* keyword, int x, int y)
{
GList *keywords, *word;
GtkCTreeNode *view_node;
NautilusTreeNode *model_node;
......@@ -2463,24 +2462,5 @@ nautilus_tree_view_receive_dropped_keyword (NautilusTreeView *tree_view, char* k
file = nautilus_tree_node_get_file (model_node);
/* special case the erase emblem */
if (!nautilus_strcmp (keyword, ERASE_KEYWORD)) {
keywords = NULL;
} else {
keywords = nautilus_file_get_keywords (file);
word = g_list_find_custom (keywords, keyword, (GCompareFunc) strcmp);
if (word == NULL) {
keywords = g_list_append (keywords, g_strdup (keyword));
} else {
keywords = g_list_remove_link (keywords, word);
g_free (word->data);
g_list_free (word);
}
}
nautilus_file_set_keywords (file, keywords);
#if 0
nautilus_icon_container_update_icon (container, drop_target_icon);
#endif
nautilus_drag_file_receive_dropped_keyword (NAUTILUS_FILE (file), keyword);
}
......@@ -38,6 +38,7 @@
#include "nautilus-glib-extensions.h"
#include "nautilus-link.h"
#include <libnautilus-extensions/nautilus-string.h>
void
nautilus_drag_init (NautilusDragInfo *drag_info,
......@@ -565,3 +566,29 @@ nautilus_drag_autoscroll_calculate_delta (GtkWidget *widget, float *x_scroll_del
}
}
void
nautilus_drag_file_receive_dropped_keyword (NautilusFile *file, char *keyword)
{
GList *keywords, *word;
g_assert (keyword != NULL);
/* special case the erase emblem */
if (!nautilus_strcmp (keyword, ERASE_KEYWORD)) {
keywords = NULL;
} else {
keywords = nautilus_file_get_keywords (file);
word = g_list_find_custom (keywords, keyword, (GCompareFunc) strcmp);
if (word == NULL) {
keywords = g_list_append (keywords, g_strdup (keyword));
} else {
keywords = g_list_remove_link (keywords, word);
g_free (word->data);
g_list_free (word);
}
}
nautilus_file_set_keywords (file, keywords);
}
......@@ -141,6 +141,8 @@ GdkDragAction nautilus_drag_drop_action_ask (GdkDragAction possible_actions);
void nautilus_drag_autoscroll_calculate_delta (GtkWidget *widget,
float *x_scroll_delta,
float *y_scroll_delta);
void nautilus_drag_file_receive_dropped_keyword (NautilusFile *file,
char *keyword);
#endif
......
......@@ -548,7 +548,6 @@ receive_dropped_tile_image (NautilusIconContainer *container, GtkSelectionData *
static void
receive_dropped_keyword (NautilusIconContainer *container, char* keyword, int x, int y)
{
GList *keywords, *word;
char *uri;
double world_x, world_y;
......@@ -575,22 +574,8 @@ receive_dropped_keyword (NautilusIconContainer *container, char* keyword, int x,
file = nautilus_file_get (uri);
g_free (uri);
/* special case the erase emblem */
if (!nautilus_strcmp (keyword, ERASE_KEYWORD)) {
keywords = NULL;
} else {
keywords = nautilus_file_get_keywords (file);
word = g_list_find_custom (keywords, keyword, (GCompareFunc) strcmp);
if (word == NULL) {
keywords = g_list_append (keywords, g_strdup (keyword));
} else {
keywords = g_list_remove_link (keywords, word);
g_free (word->data);
g_list_free (word);
}
}
nautilus_file_set_keywords (file, keywords);
nautilus_drag_file_receive_dropped_keyword (file, keyword);
nautilus_file_unref (file);
nautilus_icon_container_update_icon (container, drop_target_icon);
}
......
......@@ -181,7 +181,9 @@ static GtkTargetEntry nautilus_list_dnd_target_table[] = {
{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR }
{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR },
{ NAUTILUS_ICON_DND_BGIMAGE_TYPE, 0, NAUTILUS_ICON_DND_BGIMAGE },
{ NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD }
};
static void activate_row (NautilusList *list,
......@@ -2845,20 +2847,17 @@ nautilus_list_get_drop_action (NautilusList *list,
nautilus_drag_default_drop_action_for_icons (context, drop_target,
drag_info->selection_list,
default_action, non_default_action);
break;
case NAUTILUS_ICON_DND_COLOR:
case NAUTILUS_ICON_DND_BGIMAGE:
case NAUTILUS_ICON_DND_KEYWORD:
/* FIXME bugzilla.eazel.com 2572: Doesn't handle dropped keywords in list view? Do we need to support this? */
*default_action = context->suggested_action;
*non_default_action = context->suggested_action;
break;
default:
}
}
......@@ -2976,6 +2975,39 @@ nautilus_list_drag_drop (GtkWidget *widget, GdkDragContext *context,
return FALSE;
}
static void
nautilus_list_receive_dropped_icons (NautilusList *list,
GdkDragContext *context,
int x, int y)
{
NautilusDragInfo *drag_info;
GList * selected_items;
g_assert (NAUTILUS_IS_LIST (list));
drag_info = list->details->drag_info;
/* Put selection list in local variable and NULL the global one
* so it doesn't get munged in a modal popup-menu event loop
* in the handle_dropped_icons handler.
*/
selected_items = drag_info->selection_list;
drag_info->selection_list = NULL;
gtk_signal_emit (GTK_OBJECT (list), list_signals[HANDLE_DROPPED_ICONS],
selected_items, x, y, context->action);
nautilus_drag_destroy_selection_list (selected_items);
}
static void
nautilus_list_receive_dropped_keyword (NautilusList *list,
char *keyword, int x, int y)
{
}
static void
nautilus_list_drag_data_received (GtkWidget *widget, GdkDragContext *context,
int x, int y, GtkSelectionData *data,
......@@ -2987,35 +3019,40 @@ nautilus_list_drag_data_received (GtkWidget *widget, GdkDragContext *context,
list = NAUTILUS_LIST (widget);
drag_info = list->details->drag_info;
drag_info->data_type = info;
drag_info->got_drop_data_type = TRUE;
switch (info) {
case NAUTILUS_ICON_DND_GNOME_ICON_LIST:
drag_info->selection_list = nautilus_drag_build_selection_list (data);
drag_info->got_drop_data_type = TRUE;
drag_info->data_type = info;
break;
case NAUTILUS_ICON_DND_URI_LIST:
drag_info->selection_list = nautilus_drag_build_selection_list (data);
break;
case NAUTILUS_ICON_DND_COLOR:
drag_info->got_drop_data_type = TRUE;
drag_info->data_type = info;
break;
case NAUTILUS_ICON_DND_BGIMAGE:
break;
case NAUTILUS_ICON_DND_KEYWORD:
break;
default:
break;
}
if (drag_info->drop_occured == TRUE) {
GList *selected_items;
switch (info) {
case NAUTILUS_ICON_DND_GNOME_ICON_LIST:
/* Put selection list in local variable and NULL the global one
* so it doesn't get munged in a modal popup-menu event loop
* in the handle_dropped_icons handler.
*/
selected_items = drag_info->selection_list;
drag_info->selection_list = NULL;
gtk_signal_emit (GTK_OBJECT (list), list_signals[HANDLE_DROPPED_ICONS],
selected_items, x, y, context->action);
nautilus_drag_destroy_selection_list (selected_items);
nautilus_list_receive_dropped_icons
(NAUTILUS_LIST (list),
context, x, y);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
case NAUTILUS_ICON_DND_URI_LIST:
nautilus_list_receive_dropped_icons
(NAUTILUS_LIST (list),
context, x, y);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
case NAUTILUS_ICON_DND_COLOR:
......@@ -3025,6 +3062,18 @@ nautilus_list_drag_data_received (GtkWidget *widget, GdkDragContext *context,
nautilus_list_setup_style_colors (NAUTILUS_LIST (list));
gtk_drag_finish (context, TRUE, FALSE, time);
break;
case NAUTILUS_ICON_DND_BGIMAGE:
nautilus_background_receive_dropped_background_image
(nautilus_get_widget_background (widget),
(char *)data->data);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
case NAUTILUS_ICON_DND_KEYWORD:
nautilus_list_receive_dropped_keyword
(NAUTILUS_LIST (list),
(char *)data->data, x, y);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
default:
gtk_drag_finish (context, FALSE, FALSE, time);
break;
......
......@@ -38,6 +38,7 @@
#include "nautilus-glib-extensions.h"
#include "nautilus-link.h"
#include <libnautilus-extensions/nautilus-string.h>
void
nautilus_drag_init (NautilusDragInfo *drag_info,
......@@ -565,3 +566,29 @@ nautilus_drag_autoscroll_calculate_delta (GtkWidget *widget, float *x_scroll_del
}
}
void
nautilus_drag_file_receive_dropped_keyword (NautilusFile *file, char *keyword)
{
GList *keywords, *word;
g_assert (keyword != NULL);
/* special case the erase emblem */
if (!nautilus_strcmp (keyword, ERASE_KEYWORD)) {
keywords = NULL;
} else {
keywords = nautilus_file_get_keywords (file);
word = g_list_find_custom (keywords, keyword, (GCompareFunc) strcmp);
if (word == NULL) {
keywords = g_list_append (keywords, g_strdup (keyword));
} else {
keywords = g_list_remove_link (keywords, word);
g_free (word->data);
g_list_free (word);
}
}
nautilus_file_set_keywords (file, keywords);
}
......@@ -141,6 +141,8 @@ GdkDragAction nautilus_drag_drop_action_ask (GdkDragAction possible_actions);
void nautilus_drag_autoscroll_calculate_delta (GtkWidget *widget,
float *x_scroll_delta,
float *y_scroll_delta);
void nautilus_drag_file_receive_dropped_keyword (NautilusFile *file,
char *keyword);
#endif
......
......@@ -548,7 +548,6 @@ receive_dropped_tile_image (NautilusIconContainer *container, GtkSelectionData *
static void
receive_dropped_keyword (NautilusIconContainer *container, char* keyword, int x, int y)
{
GList *keywords, *word;
char *uri;
double world_x, world_y;
......@@ -575,22 +574,8 @@ receive_dropped_keyword (NautilusIconContainer *container, char* keyword, int x,
file = nautilus_file_get (uri);
g_free (uri);
/* special case the erase emblem */
if (!nautilus_strcmp (keyword, ERASE_KEYWORD)) {
keywords = NULL;
} else {
keywords = nautilus_file_get_keywords (file);
word = g_list_find_custom (keywords, keyword, (GCompareFunc) strcmp);
if (word == NULL) {
keywords = g_list_append (keywords, g_strdup (keyword));
} else {
keywords = g_list_remove_link (keywords, word);
g_free (word->data);
g_list_free (word);
}
}
nautilus_file_set_keywords (file, keywords);
nautilus_drag_file_receive_dropped_keyword (file, keyword);
nautilus_file_unref (file);
nautilus_icon_container_update_icon (container, drop_target_icon);
}
......
......@@ -181,7 +181,9 @@ static GtkTargetEntry nautilus_list_dnd_target_table[] = {
{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR }
{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR },
{ NAUTILUS_ICON_DND_BGIMAGE_TYPE, 0, NAUTILUS_ICON_DND_BGIMAGE },
{ NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD }
};
static void activate_row (NautilusList *list,
......@@ -2845,20 +2847,17 @@ nautilus_list_get_drop_action (NautilusList *list,
nautilus_drag_default_drop_action_for_icons (context, drop_target,
drag_info->selection_list,
default_action, non_default_action);
break;
case NAUTILUS_ICON_DND_COLOR:
case NAUTILUS_ICON_DND_BGIMAGE:
case NAUTILUS_ICON_DND_KEYWORD:
/* FIXME bugzilla.eazel.com 2572: Doesn't handle dropped keywords in list view? Do we need to support this? */
*default_action = context->suggested_action;
*non_default_action = context->suggested_action;
break;
default:
}
}
......@@ -2976,6 +2975,39 @@ nautilus_list_drag_drop (GtkWidget *widget, GdkDragContext *context,
return FALSE;
}
static void
nautilus_list_receive_dropped_icons (NautilusList *list,
GdkDragContext *context,
int x, int y)
{
NautilusDragInfo *drag_info;
GList * selected_items;
g_assert (NAUTILUS_IS_LIST (list));
drag_info = list->details->drag_info;
/* Put selection list in local variable and NULL the global one
* so it doesn't get munged in a modal popup-menu event loop
* in the handle_dropped_icons handler.
*/
selected_items = drag_info->selection_list;
drag_info->selection_list = NULL;
gtk_signal_emit (GTK_OBJECT (list), list_signals[HANDLE_DROPPED_ICONS],
selected_items, x, y, context->action);
nautilus_drag_destroy_selection_list (selected_items);
}
static void
nautilus_list_receive_dropped_keyword (NautilusList *list,
char *keyword, int x, int y)
{
}
static void
nautilus_list_drag_data_received (GtkWidget *widget, GdkDragContext *context,
int x, int y, GtkSelectionData *data,
......@@ -2987,35 +3019,40 @@ nautilus_list_drag_data_received (GtkWidget *widget, GdkDragContext *context,
list = NAUTILUS_LIST (widget);
drag_info = list->details->drag_info;
drag_info->data_type = info;
drag_info->got_drop_data_type = TRUE;
switch (info) {
case NAUTILUS_ICON_DND_GNOME_ICON_LIST:
drag_info->selection_list = nautilus_drag_build_selection_list (data);
drag_info->got_drop_data_type = TRUE;
drag_info->data_type = info;
break;
case NAUTILUS_ICON_DND_URI_LIST:
drag_info->selection_list = nautilus_drag_build_selection_list (data);
break;
case NAUTILUS_ICON_DND_COLOR:
drag_info->got_drop_data_type = TRUE;
drag_info->data_type = info;
break;
case NAUTILUS_ICON_DND_BGIMAGE:
break;
case NAUTILUS_ICON_DND_KEYWORD:
break;
default:
break;
}
if (drag_info->drop_occured == TRUE) {
GList *selected_items;
switch (info) {
case NAUTILUS_ICON_DND_GNOME_ICON_LIST:
/* Put selection list in local variable and NULL the global one
* so it doesn't get munged in a modal popup-menu event loop
* in the handle_dropped_icons handler.
*/
selected_items = drag_info->selection_list;
drag_info->selection_list = NULL;
gtk_signal_emit (GTK_OBJECT (list), list_signals[HANDLE_DROPPED_ICONS],
selected_items, x, y, context->action);
nautilus_drag_destroy_selection_list (selected_items);
nautilus_list_receive_dropped_icons
(NAUTILUS_LIST (list),
context, x, y);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
case NAUTILUS_ICON_DND_URI_LIST:
nautilus_list_receive_dropped_icons
(NAUTILUS_LIST (list),
context, x, y);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
case NAUTILUS_ICON_DND_COLOR:
......@@ -3025,6 +3062,18 @@ nautilus_list_drag_data_received (GtkWidget *widget, GdkDragContext *context,
nautilus_list_setup_style_colors (NAUTILUS_LIST (list));
gtk_drag_finish (context, TRUE, FALSE, time);
break;
case NAUTILUS_ICON_DND_BGIMAGE:
nautilus_background_receive_dropped_background_image
(nautilus_get_widget_background (widget),
(char *)data->data);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
case NAUTILUS_ICON_DND_KEYWORD:
nautilus_list_receive_dropped_keyword
(NAUTILUS_LIST (list),
(char *)data->data, x, y);
gtk_drag_finish (context, TRUE, FALSE, time);
break;
default:
gtk_drag_finish (context, FALSE, FALSE, time);
break;
......
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