From 64ff5c590db02cddccc6088162747c2b69ccd87d Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Fri, 22 Oct 2004 21:43:02 +0000 Subject: Remove ephy_string_parse_uri_list, and use new glib function 2004-10-22 Christian Persch * lib/ephy-string.c: (ephy_string_double_underscores): * lib/ephy-string.h: * lib/widgets/ephy-node-view.c: (drag_data_received_cb): * src/bookmarks/ephy-bookmarks-editor.c: (node_dropped_cb): * src/ephy-notebook.c: (notebook_drag_data_received_cb): * src/ephy-window.c: (ephy_window_load_in_tabs): * src/ephy-window.h: Remove ephy_string_parse_uri_list, and use new glib function g_uri_list_extract_uris() instead. --- ChangeLog | 13 +++++++++ lib/ephy-string.c | 52 ----------------------------------- lib/ephy-string.h | 2 -- lib/widgets/ephy-node-view.c | 8 +++--- src/bookmarks/ephy-bookmarks-editor.c | 18 ++++++------ src/ephy-notebook.c | 41 +++++++++++++-------------- src/ephy-window.c | 17 +++++------- src/ephy-window.h | 2 +- 8 files changed, 56 insertions(+), 97 deletions(-) diff --git a/ChangeLog b/ChangeLog index 833ed6feb..8b42e1fc3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2004-10-22 Christian Persch + + * lib/ephy-string.c: (ephy_string_double_underscores): + * lib/ephy-string.h: + * lib/widgets/ephy-node-view.c: (drag_data_received_cb): + * src/bookmarks/ephy-bookmarks-editor.c: (node_dropped_cb): + * src/ephy-notebook.c: (notebook_drag_data_received_cb): + * src/ephy-window.c: (ephy_window_load_in_tabs): + * src/ephy-window.h: + + Remove ephy_string_parse_uri_list, and use new glib function + g_uri_list_extract_uris() instead. + 2004-10-22 Christian Persch * src/ephy-notebook.c: (build_tab_label): diff --git a/lib/ephy-string.c b/lib/ephy-string.c index daeac7d2b..dbda76275 100644 --- a/lib/ephy-string.c +++ b/lib/ephy-string.c @@ -191,55 +191,3 @@ ephy_string_double_underscores (const char *string) return escaped; } - -/* taken from libgnomevfs/gnome-vfs-uri.c */ -GList* -ephy_string_parse_uri_list (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); -} diff --git a/lib/ephy-string.h b/lib/ephy-string.h index bc844c09b..f2907219f 100644 --- a/lib/ephy-string.h +++ b/lib/ephy-string.h @@ -37,8 +37,6 @@ char *ephy_string_elide_underscores (const char *original); char *ephy_string_double_underscores (const char *string); -GList *ephy_string_parse_uri_list (const char *uri_list); - G_END_DECLS #endif diff --git a/lib/widgets/ephy-node-view.c b/lib/widgets/ephy-node-view.c index dc23e5efa..acbcf3f27 100644 --- a/lib/widgets/ephy-node-view.c +++ b/lib/widgets/ephy-node-view.c @@ -389,7 +389,7 @@ drag_data_received_cb (GtkWidget *widget, if (view->priv->drop_occurred) { EphyNode *node; - GList *uris; + char **uris; gboolean success = FALSE; GtkTreePath *path; @@ -400,7 +400,7 @@ drag_data_received_cb (GtkWidget *widget, node = get_node_from_path (view, path); - uris = ephy_string_parse_uri_list (selection_data->data); + uris = g_uri_list_extract_uris (selection_data->data); if (uris != NULL) { @@ -408,8 +408,8 @@ drag_data_received_cb (GtkWidget *widget, g_signal_emit (G_OBJECT (view), ephy_node_view_signals[NODE_DROPPED], 0, node, uris); - g_list_foreach (uris, (GFunc) g_free, NULL); - g_list_free (uris); + g_strfreev (uris); + } view->priv->drop_occurred = FALSE; diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c index c97d953c4..c447cb65b 100644 --- a/src/bookmarks/ephy-bookmarks-editor.c +++ b/src/bookmarks/ephy-bookmarks-editor.c @@ -1317,17 +1317,19 @@ delete_event_cb (EphyBookmarksEditor *editor) } static void -node_dropped_cb (EphyNodeView *view, EphyNode *node, - GList *nodes, EphyBookmarksEditor *editor) +node_dropped_cb (EphyNodeView *view, + EphyNode *node, + const char * const *uris, + EphyBookmarksEditor *editor) { - GList *l; + EphyNode *bmk; + int i; - for (l = nodes; l != NULL; l = l->next) - { - const char *url = (const char *) l->data; - EphyNode *bmk; + g_return_if_fail (uris != NULL); - bmk = ephy_bookmarks_find_bookmark (editor->priv->bookmarks, url); + for (i = 0; uris[i] != NULL; i++) + { + bmk = ephy_bookmarks_find_bookmark (editor->priv->bookmarks, uris[i]); if (bmk != NULL) { diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c index 00fa0cd35..fef660489 100644 --- a/src/ephy-notebook.c +++ b/src/ephy-notebook.c @@ -593,8 +593,7 @@ notebook_drag_data_received_cb (GtkWidget* widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint info, guint time, EphyTab *tab) { - GList *uri_list = NULL; - gchar **tmp; + EphyWindow *window; g_signal_stop_emission_by_name (widget, "drag_data_received"); @@ -602,37 +601,39 @@ notebook_drag_data_received_cb (GtkWidget* widget, GdkDragContext *context, if (selection_data->length <= 0 || selection_data->data == NULL) return; + window = EPHY_WINDOW (gtk_widget_get_toplevel (widget)); + if (selection_data->target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE)) { + char *uris[2] = { NULL, NULL }; + char **split; + /* URL_TYPE has format: url \n title */ - tmp = g_strsplit (selection_data->data, "\n", 2); - if (tmp != NULL && tmp[0] != NULL) + split = g_strsplit (selection_data->data, "\n", 2); + if (split != NULL && split[0] != NULL) { - uri_list = g_list_prepend (uri_list, g_strdup (tmp[0])); + uris[0] = split[0]; + ephy_window_load_in_tabs (window, tab, uris); } - - g_strfreev (tmp); + g_strfreev (split); } else if (selection_data->target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE)) { - uri_list = ephy_string_parse_uri_list (selection_data->data); + char **uris; + + uris = g_uri_list_extract_uris (selection_data->data); + + if (uris != NULL) + { + ephy_window_load_in_tabs (window, tab, uris); + + g_strfreev (uris); + } } else { g_return_if_reached (); } - - if (uri_list != NULL) - { - EphyWindow *window; - - window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget))); - - ephy_window_load_in_tabs (window, tab, uri_list); - - g_list_foreach (uri_list, (GFunc) g_free, NULL); - g_list_free (uri_list); - } } /* diff --git a/src/ephy-window.c b/src/ephy-window.c index ee3bb8711..e3733c1a4 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -2978,11 +2978,12 @@ ephy_window_set_zoom (EphyWindow *window, void ephy_window_load_in_tabs (EphyWindow *window, EphyTab *tab, - GList *uri_list) + char **uris) { EphyEmbed *embed = NULL; - GList *l; - guint num = 0; + guint num; + + g_return_if_fail (uris != NULL); if (tab != NULL) { @@ -2990,11 +2991,10 @@ ephy_window_load_in_tabs (EphyWindow *window, g_return_if_fail (EPHY_IS_EMBED (embed)); } - l = uri_list; - while (l != NULL && num < INSANE_NUMBER_OF_URLS) + for (num = 0; uris[num] != NULL && num < INSANE_NUMBER_OF_URLS; num++) { - const char *url = l->data; - + const char *url = uris[num]; + if (num == 0 && embed != NULL) { /** @@ -3012,9 +3012,6 @@ ephy_window_load_in_tabs (EphyWindow *window, (tab ? EPHY_NEW_TAB_APPEND_AFTER : EPHY_NEW_TAB_APPEND_LAST)); } - - l = l->next; - ++num; } } diff --git a/src/ephy-window.h b/src/ephy-window.h index 92ddb4389..73d95b80d 100644 --- a/src/ephy-window.h +++ b/src/ephy-window.h @@ -91,7 +91,7 @@ void ephy_window_load_url (EphyWindow *window, void ephy_window_load_in_tabs (EphyWindow *window, EphyTab *first_tab, - GList *uri_list); + char **uris); void ephy_window_set_zoom (EphyWindow *window, float zoom); -- cgit v1.2.3