summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2009-03-31 09:53:40 +0000
committerAlexander Larsson <alexl@src.gnome.org>2009-03-31 09:53:40 +0000
commit2bdb577cd172e66d25d6550c8d2b952d65d45fd4 (patch)
tree9a2d0c1aa3d49f1f14026bd370f2e3061bf14cdd
parente75c597dbc9ce70933601d6c6d848626fbee63bc (diff)
downloadnautilus-2bdb577cd172e66d25d6550c8d2b952d65d45fd4.tar.gz
Check http mimetype asynchronously to avoid hanging
2009-03-31 Alexander Larsson <alexl@redhat.com> * src/file-manager/fm-directory-view.c: (handle_netscape_url_drop_ask_cb): (fm_directory_view_handle_netscape_url_drop): Check http mimetype asynchronously to avoid hanging svn path=/trunk/; revision=15155
-rw-r--r--ChangeLog7
-rw-r--r--src/file-manager/fm-directory-view.c101
2 files changed, 79 insertions, 29 deletions
diff --git a/ChangeLog b/ChangeLog
index 58382e23b..df69377bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-03-31 Alexander Larsson <alexl@redhat.com>
+
+ * src/file-manager/fm-directory-view.c:
+ (handle_netscape_url_drop_ask_cb):
+ (fm_directory_view_handle_netscape_url_drop):
+ Check http mimetype asynchronously to avoid hanging
+
2009-03-30 Alexander Larsson <alexl@redhat.com>
* src/file-manager/fm-error-reporting.c:
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 59c8a71a5..ef5fd5a84 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -9259,6 +9259,64 @@ ask_link_action (FMDirectoryView *view)
return result;
}
+typedef struct {
+ FMDirectoryView *view;
+ char *encoded_url;
+ char *target_uri;
+ int x;
+ int y;
+} NetscapeUrlDropAsk;
+
+static void
+handle_netscape_url_drop_ask_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ NetscapeUrlDropAsk *data;
+ GdkDragAction action;
+ GFileInfo *info;
+ GFile *f;
+ const char *mime_type;
+
+ data = user_data;
+ f = G_FILE (source_object);
+
+ info = g_file_query_info_finish (f, res, NULL);
+ mime_type = NULL;
+
+ if (info) {
+ mime_type = g_file_info_get_content_type (info);
+ }
+
+ if (mime_type != NULL &&
+ (g_content_type_equals (mime_type, "text/html") ||
+ g_content_type_equals (mime_type, "text/xml") ||
+ g_content_type_equals (mime_type, "application/xhtml+xml"))) {
+ action = GDK_ACTION_LINK;
+ } else if (mime_type != NULL &&
+ g_content_type_equals (mime_type, "text/plain")) {
+ action = ask_link_action (data->view);
+ } else {
+ action = GDK_ACTION_COPY;
+ }
+ if (info) {
+ g_object_unref (info);
+ }
+
+ if (action != 0) {
+ fm_directory_view_handle_netscape_url_drop (data->view,
+ data->encoded_url,
+ data->target_uri,
+ action,
+ data->x, data->y);
+ }
+
+ g_object_unref (data->view);
+ g_free (data->encoded_url);
+ g_free (data->target_uri);
+ g_free (data);
+}
+
void
fm_directory_view_handle_netscape_url_drop (FMDirectoryView *view,
const char *encoded_url,
@@ -9316,37 +9374,22 @@ fm_directory_view_handle_netscape_url_drop (FMDirectoryView *view,
}
if (action == GDK_ACTION_ASK) {
- GFileInfo *info;
- GFile *f;
- const char *mime_type;
+ NetscapeUrlDropAsk *data;
f = g_file_new_for_uri (url);
- info = g_file_query_info (f, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0, NULL, NULL);
- mime_type = NULL;
-
- if (info) {
- mime_type = g_file_info_get_content_type (info);
- }
-
- if (mime_type != NULL &&
- (g_content_type_equals (mime_type, "text/html") ||
- g_content_type_equals (mime_type, "text/xml") ||
- g_content_type_equals (mime_type, "application/xhtml+xml"))) {
- action = GDK_ACTION_LINK;
- } else if (mime_type != NULL &&
- g_content_type_equals (mime_type, "text/plain")) {
- action = ask_link_action (view);
- } else {
- action = GDK_ACTION_COPY;
- }
- if (info) {
- g_object_unref (info);
- }
-
- if (action == 0) {
- g_free (container_uri);
- return;
- }
+ data = g_new0 (NetscapeUrlDropAsk, 1);
+ data->view = g_object_ref (view);
+ data->encoded_url = g_strdup (encoded_url);
+ data->target_uri = g_strdup (target_uri);
+ data->x = x;
+ data->y = y;
+ g_file_query_info_async (f,
+ G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, 0,
+ 0, NULL,
+ handle_netscape_url_drop_ask_cb,
+ data);
+ g_free (container_uri);
+ return;
}
/* We don't support GDK_ACTION_ASK or GDK_ACTION_PRIVATE