diff options
Diffstat (limited to 'lib/widgets/ephy-node-view.c')
-rw-r--r-- | lib/widgets/ephy-node-view.c | 59 |
1 files changed, 56 insertions, 3 deletions
diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c index 6949bb404..f5e35d4b0 100644 --- a/lib/widgets/ephy-node-view.c +++ b/lib/widgets/ephy-node-view.c @@ -428,6 +428,58 @@ drag_leave_cb (GtkWidget *widget, remove_scroll_timeout (view); } +/* taken from libgnomevfs/gnome-vfs-uri.c */ +static GList* +uri_list_parse (const gchar* uri_list) +{ + /* Note that this is mostly very stolen from old libgnome/gnome-mime.c */ + + const gchar *p, *q; + gchar *retval; + GList *result = NULL; + + g_return_val_if_fail (uri_list != NULL, NULL); + + p = uri_list; + + /* We don't actually try to validate the URI according to RFC + * 2396, or even check for allowed characters - we just ignore + * comments and trim whitespace off the ends. We also + * allow LF delimination as well as the specified CRLF. + */ + while (p != NULL) { + if (*p != '#') { + while (g_ascii_isspace (*p)) + p++; + + q = p; + while ((*q != '\0') + && (*q != '\n') + && (*q != '\r')) + q++; + + if (q > p) { + q--; + while (q > p + && g_ascii_isspace (*q)) + q--; + + retval = g_malloc (q - p + 2); + strncpy (retval, p, q - p + 1); + retval[q - p + 1] = '\0'; + + if (retval[0] != '\0') + result = g_list_prepend (result, retval); + } + } + p = strchr (p, '\n'); + if (p != NULL) + p++; + } + + return g_list_reverse (result); +} + static void drag_data_received_cb (GtkWidget *widget, GdkDragContext *context, @@ -468,15 +520,16 @@ drag_data_received_cb (GtkWidget *widget, node = get_node_from_path (view, path); - uris = gnome_vfs_uri_list_parse (selection_data->data); - + uris = uri_list_parse (selection_data->data); + if (uris != NULL) { /* FIXME fill success */ g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_DROPPED], 0, node, uris); - gnome_vfs_uri_list_free (uris); + g_list_foreach (uris, (GFunc) g_free, NULL); + g_list_free (uris); } view->priv->drop_occurred = FALSE; |