diff options
author | George Lebl <jirka@5z.com> | 2001-03-06 20:25:01 +0000 |
---|---|---|
committer | George Lebl <jirka@src.gnome.org> | 2001-03-06 20:25:01 +0000 |
commit | d0ad9778eba03aa490306c8431222a17f8c6a007 (patch) | |
tree | db3cbbe75c1c2aa492745bb9c629a2af0b6eb3b4 | |
parent | f590eb526b25ab65a4faae5201d9c483b050a16e (diff) | |
download | nautilus-d0ad9778eba03aa490306c8431222a17f8c6a007.tar.gz |
Darin <darin@eazel.com> said that while this patch causes fungal growth
Tue Mar 06 12:24:24 2001 George Lebl <jirka@5z.com>
Darin <darin@eazel.com> said that while this patch causes fungal
growth between the toes, it is ok to apply.
* components/tree/nautilus-tree-view-dnd.c (do_get_data)
(nautilus_tree_view_drag_drop)
(nautilus_tree_view_ensure_drag_data)
libnautilus-extensions/nautilus-icon-dnd.c (do_get_data)
(nautilus_icon_container_ensure_drag_data)
(drag_drop_callback)
libnautilus-extensions/nautilus-list.c (do_get_data)
(nautilus_list_ensure_drag_data)
(nautilus_list_drag_drop):
When doing gtk_drag_get_data, first find a target we support rather
then just grabbing the first one. We need to make a target list
and do some gtk voodoo. At some later date, this should be more
generalized and stuffed somewhere in libnautilus-extentions.
Fixes #7312
* libnautilus-extensions/nautilus-file-operations.c
(parse_previous_duplicate_name): s/strdup/g_strdup/ as the
string will be later g_free'd
Fixes #7440
-rw-r--r-- | ChangeLog | 25 | ||||
-rw-r--r-- | components/tree/nautilus-tree-view-dnd.c | 36 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-file-operations.c | 2 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-icon-dnd.c | 36 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-list.c | 35 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file-operations.c | 2 | ||||
-rw-r--r-- | libnautilus-private/nautilus-icon-dnd.c | 36 | ||||
-rw-r--r-- | libnautilus-private/nautilus-list.c | 35 |
8 files changed, 175 insertions, 32 deletions
@@ -1,3 +1,28 @@ +Tue Mar 06 12:24:24 2001 George Lebl <jirka@5z.com> + + Darin <darin@eazel.com> said that while this patch causes fungal + growth between the toes, it is ok to apply. + + * components/tree/nautilus-tree-view-dnd.c (do_get_data) + (nautilus_tree_view_drag_drop) + (nautilus_tree_view_ensure_drag_data) + libnautilus-extensions/nautilus-icon-dnd.c (do_get_data) + (nautilus_icon_container_ensure_drag_data) + (drag_drop_callback) + libnautilus-extensions/nautilus-list.c (do_get_data) + (nautilus_list_ensure_drag_data) + (nautilus_list_drag_drop): + When doing gtk_drag_get_data, first find a target we support rather + then just grabbing the first one. We need to make a target list + and do some gtk voodoo. At some later date, this should be more + generalized and stuffed somewhere in libnautilus-extentions. + Fixes #7312 + + * libnautilus-extensions/nautilus-file-operations.c + (parse_previous_duplicate_name): s/strdup/g_strdup/ as the + string will be later g_free'd + Fixes #7440 + 2001-03-06 Eric Fischer <eric@eazel.com> reviewed by: Christian Meyer <chrisime@gnome.org> diff --git a/components/tree/nautilus-tree-view-dnd.c b/components/tree/nautilus-tree-view-dnd.c index 8c773127b..2d397f275 100644 --- a/components/tree/nautilus-tree-view-dnd.c +++ b/components/tree/nautilus-tree-view-dnd.c @@ -153,6 +153,8 @@ static GtkTargetEntry nautilus_tree_view_dnd_target_table[] = { { NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST } }; +static GtkTargetList *nautilus_tree_view_dnd_target_list = NULL; + static void tree_view_realize_callback (GtkWidget *widget, gpointer user_data) @@ -394,6 +396,30 @@ nautilus_tree_view_drag_motion (GtkWidget *widget, GdkDragContext *context, return TRUE; } +/* FIXME bugzilla.eazel.com 7445: Needs to become a shared function */ +static void +get_data_on_first_target_we_support (GtkWidget *widget, GdkDragContext *context, guint32 time) +{ + GList *target; + + if (nautilus_tree_view_dnd_target_list == NULL) + nautilus_tree_view_dnd_target_list = gtk_target_list_new (nautilus_tree_view_dnd_target_table, + NAUTILUS_N_ELEMENTS (nautilus_tree_view_dnd_target_table)); + + for (target = context->targets; target != NULL; target = target->next) { + guint dummy_info; + GdkAtom target_atom = GPOINTER_TO_UINT (target->data); + + if (gtk_target_list_find (nautilus_tree_view_dnd_target_list, + target_atom, + &dummy_info)) { + gtk_drag_get_data (GTK_WIDGET (widget), context, + target_atom, + time); + break; + } + } +} static gboolean nautilus_tree_view_drag_drop (GtkWidget *widget, @@ -413,9 +439,7 @@ nautilus_tree_view_drag_drop (GtkWidget *widget, * drop occured. */ dnd->drag_info->drop_occured = TRUE; - gtk_drag_get_data (GTK_WIDGET (widget), context, - GPOINTER_TO_INT (context->targets->data), - time); + get_data_on_first_target_we_support (widget, context, time); gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "drag_drop"); @@ -1045,9 +1069,9 @@ nautilus_tree_view_ensure_drag_data (NautilusTreeView *tree_view, drag_info = tree_view->details->dnd->drag_info; if (!drag_info->got_drop_data_type) { - gtk_drag_get_data (GTK_WIDGET (tree_view->details->tree), context, - GPOINTER_TO_INT (context->targets->data), - time); + get_data_on_first_target_we_support (GTK_WIDGET (tree_view->details->tree), + context, + time); } } diff --git a/libnautilus-extensions/nautilus-file-operations.c b/libnautilus-extensions/nautilus-file-operations.c index 2677d7938..073288c9d 100644 --- a/libnautilus-extensions/nautilus-file-operations.c +++ b/libnautilus-extensions/nautilus-file-operations.c @@ -1344,7 +1344,7 @@ parse_previous_duplicate_name (const char *name, if (**suffix != '\0') { *name_base = extract_string_until (name, *suffix); } else { - *name_base = strdup (name); + *name_base = g_strdup (name); } } diff --git a/libnautilus-extensions/nautilus-icon-dnd.c b/libnautilus-extensions/nautilus-icon-dnd.c index e4455ed79..7b2896201 100644 --- a/libnautilus-extensions/nautilus-icon-dnd.c +++ b/libnautilus-extensions/nautilus-icon-dnd.c @@ -107,6 +107,8 @@ static GtkTargetEntry drop_types [] = { { NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD } }; +static GtkTargetList *drop_types_list = NULL; + static GnomeCanvasItem * create_selection_shadow (NautilusIconContainer *container, @@ -461,6 +463,31 @@ drag_data_received_callback (GtkWidget *widget, } +/* FIXME bugzilla.eazel.com 7445: Needs to become a shared function */ +static void +get_data_on_first_target_we_support (GtkWidget *widget, GdkDragContext *context, guint32 time) +{ + GList *target; + + if (drop_types_list == NULL) + drop_types_list = gtk_target_list_new (drop_types, + NAUTILUS_N_ELEMENTS (drop_types)); + + for (target = context->targets; target != NULL; target = target->next) { + guint dummy_info; + GdkAtom target_atom = GPOINTER_TO_UINT (target->data); + + if (gtk_target_list_find (drop_types_list, + target_atom, + &dummy_info)) { + gtk_drag_get_data (GTK_WIDGET (widget), context, + target_atom, + time); + break; + } + } +} + static void nautilus_icon_container_ensure_drag_data (NautilusIconContainer *container, GdkDragContext *context, @@ -471,9 +498,7 @@ nautilus_icon_container_ensure_drag_data (NautilusIconContainer *container, dnd_info = container->details->dnd_info; if (!dnd_info->drag_info.got_drop_data_type) { - gtk_drag_get_data (GTK_WIDGET (container), context, - GPOINTER_TO_INT (context->targets->data), - time); + get_data_on_first_target_we_support (GTK_WIDGET (container), context, time); } } @@ -1339,9 +1364,8 @@ drag_drop_callback (GtkWidget *widget, make sure it is going to be called at least once. */ dnd_info->drag_info.drop_occured = TRUE; - gtk_drag_get_data (GTK_WIDGET (widget), context, - GPOINTER_TO_INT (context->targets->data), - time); + + get_data_on_first_target_we_support (widget, context, time); return FALSE; } diff --git a/libnautilus-extensions/nautilus-list.c b/libnautilus-extensions/nautilus-list.c index be2fae6f3..1d8544840 100644 --- a/libnautilus-extensions/nautilus-list.c +++ b/libnautilus-extensions/nautilus-list.c @@ -207,6 +207,8 @@ static GtkTargetEntry nautilus_list_dnd_target_table[] = { { NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD } }; +static GtkTargetList *nautilus_list_dnd_target_list = NULL; + static void activate_row (NautilusList *list, int row); static int get_cell_horizontal_start_position (NautilusCList *clist, @@ -3170,6 +3172,31 @@ nautilus_list_column_resize_track_end (GtkWidget *widget, int column_index) clist->drag_pos = -1; } +/* FIXME bugzilla.eazel.com 7445: Needs to become a shared function */ +static void +get_data_on_first_target_we_support (GtkWidget *widget, GdkDragContext *context, guint32 time) +{ + GList *target; + + if (nautilus_list_dnd_target_list == NULL) + nautilus_list_dnd_target_list = gtk_target_list_new (nautilus_list_dnd_target_table, + NAUTILUS_N_ELEMENTS (nautilus_list_dnd_target_table)); + + for (target = context->targets; target != NULL; target = target->next) { + guint dummy_info; + GdkAtom target_atom = GPOINTER_TO_UINT (target->data); + + if (gtk_target_list_find (nautilus_list_dnd_target_list, + target_atom, + &dummy_info)) { + gtk_drag_get_data (GTK_WIDGET (widget), context, + target_atom, + time); + break; + } + } +} + static void nautilus_list_ensure_drag_data (NautilusList *list, @@ -3177,9 +3204,7 @@ nautilus_list_ensure_drag_data (NautilusList *list, guint32 time) { if (!list->details->drag_info->got_drop_data_type) { - gtk_drag_get_data (GTK_WIDGET (list), context, - GPOINTER_TO_INT (context->targets->data), - time); + get_data_on_first_target_we_support (GTK_WIDGET (list), context, time); } } @@ -3377,9 +3402,7 @@ nautilus_list_drag_drop (GtkWidget *widget, GdkDragContext *context, /* make sure that drag_data_received is going to be called after this event and will do the actual actions */ list->details->drag_info->drop_occured = TRUE; - gtk_drag_get_data (GTK_WIDGET (widget), context, - GPOINTER_TO_INT (context->targets->data), - time); + get_data_on_first_target_we_support (widget, context, time); return FALSE; } diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c index 2677d7938..073288c9d 100644 --- a/libnautilus-private/nautilus-file-operations.c +++ b/libnautilus-private/nautilus-file-operations.c @@ -1344,7 +1344,7 @@ parse_previous_duplicate_name (const char *name, if (**suffix != '\0') { *name_base = extract_string_until (name, *suffix); } else { - *name_base = strdup (name); + *name_base = g_strdup (name); } } diff --git a/libnautilus-private/nautilus-icon-dnd.c b/libnautilus-private/nautilus-icon-dnd.c index e4455ed79..7b2896201 100644 --- a/libnautilus-private/nautilus-icon-dnd.c +++ b/libnautilus-private/nautilus-icon-dnd.c @@ -107,6 +107,8 @@ static GtkTargetEntry drop_types [] = { { NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD } }; +static GtkTargetList *drop_types_list = NULL; + static GnomeCanvasItem * create_selection_shadow (NautilusIconContainer *container, @@ -461,6 +463,31 @@ drag_data_received_callback (GtkWidget *widget, } +/* FIXME bugzilla.eazel.com 7445: Needs to become a shared function */ +static void +get_data_on_first_target_we_support (GtkWidget *widget, GdkDragContext *context, guint32 time) +{ + GList *target; + + if (drop_types_list == NULL) + drop_types_list = gtk_target_list_new (drop_types, + NAUTILUS_N_ELEMENTS (drop_types)); + + for (target = context->targets; target != NULL; target = target->next) { + guint dummy_info; + GdkAtom target_atom = GPOINTER_TO_UINT (target->data); + + if (gtk_target_list_find (drop_types_list, + target_atom, + &dummy_info)) { + gtk_drag_get_data (GTK_WIDGET (widget), context, + target_atom, + time); + break; + } + } +} + static void nautilus_icon_container_ensure_drag_data (NautilusIconContainer *container, GdkDragContext *context, @@ -471,9 +498,7 @@ nautilus_icon_container_ensure_drag_data (NautilusIconContainer *container, dnd_info = container->details->dnd_info; if (!dnd_info->drag_info.got_drop_data_type) { - gtk_drag_get_data (GTK_WIDGET (container), context, - GPOINTER_TO_INT (context->targets->data), - time); + get_data_on_first_target_we_support (GTK_WIDGET (container), context, time); } } @@ -1339,9 +1364,8 @@ drag_drop_callback (GtkWidget *widget, make sure it is going to be called at least once. */ dnd_info->drag_info.drop_occured = TRUE; - gtk_drag_get_data (GTK_WIDGET (widget), context, - GPOINTER_TO_INT (context->targets->data), - time); + + get_data_on_first_target_we_support (widget, context, time); return FALSE; } diff --git a/libnautilus-private/nautilus-list.c b/libnautilus-private/nautilus-list.c index be2fae6f3..1d8544840 100644 --- a/libnautilus-private/nautilus-list.c +++ b/libnautilus-private/nautilus-list.c @@ -207,6 +207,8 @@ static GtkTargetEntry nautilus_list_dnd_target_table[] = { { NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD } }; +static GtkTargetList *nautilus_list_dnd_target_list = NULL; + static void activate_row (NautilusList *list, int row); static int get_cell_horizontal_start_position (NautilusCList *clist, @@ -3170,6 +3172,31 @@ nautilus_list_column_resize_track_end (GtkWidget *widget, int column_index) clist->drag_pos = -1; } +/* FIXME bugzilla.eazel.com 7445: Needs to become a shared function */ +static void +get_data_on_first_target_we_support (GtkWidget *widget, GdkDragContext *context, guint32 time) +{ + GList *target; + + if (nautilus_list_dnd_target_list == NULL) + nautilus_list_dnd_target_list = gtk_target_list_new (nautilus_list_dnd_target_table, + NAUTILUS_N_ELEMENTS (nautilus_list_dnd_target_table)); + + for (target = context->targets; target != NULL; target = target->next) { + guint dummy_info; + GdkAtom target_atom = GPOINTER_TO_UINT (target->data); + + if (gtk_target_list_find (nautilus_list_dnd_target_list, + target_atom, + &dummy_info)) { + gtk_drag_get_data (GTK_WIDGET (widget), context, + target_atom, + time); + break; + } + } +} + static void nautilus_list_ensure_drag_data (NautilusList *list, @@ -3177,9 +3204,7 @@ nautilus_list_ensure_drag_data (NautilusList *list, guint32 time) { if (!list->details->drag_info->got_drop_data_type) { - gtk_drag_get_data (GTK_WIDGET (list), context, - GPOINTER_TO_INT (context->targets->data), - time); + get_data_on_first_target_we_support (GTK_WIDGET (list), context, time); } } @@ -3377,9 +3402,7 @@ nautilus_list_drag_drop (GtkWidget *widget, GdkDragContext *context, /* make sure that drag_data_received is going to be called after this event and will do the actual actions */ list->details->drag_info->drop_occured = TRUE; - gtk_drag_get_data (GTK_WIDGET (widget), context, - GPOINTER_TO_INT (context->targets->data), - time); + get_data_on_first_target_we_support (widget, context, time); return FALSE; } |