diff options
author | Tristan Van Berkom <tvb@src.gnome.org> | 2006-08-24 15:54:11 +0000 |
---|---|---|
committer | Tristan Van Berkom <tvb@src.gnome.org> | 2006-08-24 15:54:11 +0000 |
commit | b3661ef778350e4a9b88949450f68157f992e257 (patch) | |
tree | d46228b2c73261eda504d344e5ed5214d60b8b6d | |
parent | 9178f3caacc54680987feca2bb6c90e2ce2703bb (diff) | |
download | glade-b3661ef778350e4a9b88949450f68157f992e257.tar.gz |
Remove glade_util_uri_list_parse().
* src/glade-utils.[ch]: Remove glade_util_uri_list_parse().
* src/glade-project-window.c: Rewrite gpw_drag_data_received()
(fixing bug 352458).
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/glade-project-window.c | 40 | ||||
-rw-r--r-- | src/glade-utils.c | 69 | ||||
-rw-r--r-- | src/glade-utils.h | 3 |
4 files changed, 30 insertions, 91 deletions
@@ -1,4 +1,11 @@ -2006-08-18 Juan Pablo Ugarte <juanpablougarte@gmail.com> +2006-08-24 Vincent Geddes <vincent.geddes@gmail.com> + + * src/glade-utils.[ch]: Remove glade_util_uri_list_parse(). + + * src/glade-project-window.c: Rewrite gpw_drag_data_received() + (fixing bug 352458). + +2006-08-23 Juan Pablo Ugarte <juanpablougarte@gmail.com> * src/glade-widget-class.c: glade_widget_class_add_signals() simplification. diff --git a/src/glade-project-window.c b/src/glade-project-window.c index a2abee83..da3f824f 100644 --- a/src/glade-project-window.c +++ b/src/glade-project-window.c @@ -1659,33 +1659,37 @@ gpw_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, - guint info, guint time, GladeProjectWindow *gpw) + guint info, guint time, GladeProjectWindow *window) { - gchar *uri_list; - GList *list = NULL; + gchar **uris, **str; + gchar *data; if (info != TARGET_URI_LIST) return; - /* - * Mmh... it looks like on Windows selection_data->data is not - * NULL terminated, so we need to make sure our local copy is. - */ - uri_list = g_new (gchar, selection_data->length + 1); - memcpy (uri_list, selection_data->data, selection_data->length); - uri_list[selection_data->length] = 0; + /* On MS-Windows, it looks like `selection_data->data' is not NULL terminated. */ + data = g_new (gchar, selection_data->length + 1); + memcpy (data, selection_data->data, selection_data->length); + data[selection_data->length] = 0; + + uris = g_uri_list_extract_uris (data); - list = glade_util_uri_list_parse (uri_list); - for (; list; list = list->next) + for (str = uris; *str; str++) { - if (list->data) - glade_project_window_open_project (gpw, list->data); + GError *error = NULL; + gchar *path = g_filename_from_uri (*str, NULL, &error); - /* we can now free each string in the list */ - g_free (list->data); - } + if (path) + glade_project_window_open_project (window, path); + else + { + g_warning ("Could not convert uri to local path: %s", error->message); - g_list_free (list); + g_error_free (error); + } + g_free (path); + } + g_strfreev (uris); } static gboolean diff --git a/src/glade-utils.c b/src/glade-utils.c index 98dbd470..8bc49294 100644 --- a/src/glade-utils.c +++ b/src/glade-utils.c @@ -992,75 +992,6 @@ glade_util_container_get_all_children (GtkContainer *container) } /** - * glade_util_uri_list_parse: - * @uri_list: the text/urilist, must be NULL terminated. - * - * Extracts a list of file names from a standard text/uri-list, - * such as one you would get on a drop operation. - * This is mostly stolen from gnome-vfs-uri.c. - * - * Returns: a #GList of gchars. - */ -GList * -glade_util_uri_list_parse (const gchar *uri_list) -{ - const gchar *p, *q; - 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) - { - if (*p != '#') - { - gchar *retval; - gchar *path; - - 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_new (gchar, q - p + 2); - memcpy (retval, p, q - p + 1); - retval[q - p + 1] = '\0'; - - path = g_filename_from_uri (retval, NULL, NULL); - if (!path) - { - g_free (retval); - continue; - } - - result = g_list_prepend (result, path); - - g_free (retval); - } - } - p = strchr (p, '\n'); - if (p) - p++; - } - - return g_list_reverse (result); -} - -/** * glade_util_gtkcontainer_relation: * @widget: a GladeWidget * @parent: a GladeWidget diff --git a/src/glade-utils.h b/src/glade-utils.h index 51d212bc..527cf699 100644 --- a/src/glade-utils.h +++ b/src/glade-utils.h @@ -82,9 +82,6 @@ LIBGLADEUI_API GList *glade_util_container_get_all_children (GtkContainer *container); LIBGLADEUI_API -GList *glade_util_uri_list_parse (const gchar* uri_list); - -LIBGLADEUI_API gboolean glade_util_gtkcontainer_relation (GladeWidget *parent, GladeWidget *widget); LIBGLADEUI_API |