diff options
author | Darin Adler <darin@src.gnome.org> | 2000-04-26 01:42:22 +0000 |
---|---|---|
committer | Darin Adler <darin@src.gnome.org> | 2000-04-26 01:42:22 +0000 |
commit | 284b99c4ffd95cc543526c9da4d3e9bcbbfb9d81 (patch) | |
tree | 0e0a301ce2e9d58a592ca4622ffd8371abbfb8ac | |
parent | 841ac7b5bb19f970ab77fdf2c6ff92c662e20dc7 (diff) | |
download | nautilus-284b99c4ffd95cc543526c9da4d3e9bcbbfb9d81.tar.gz |
This change requires a new gnome-vfs.
* HACKING: Updated URL for popt.
* components/rpmview/nautilus-rpm-view.c:
(nautilus_rpm_view_update_from_uri):
Changed to use FD_t for real instead of casting a pointer to a
raw file descriptor to it.
* libnautilus-extensions/nautilus-directory-async.c:
Told it to load 32 items at a time instead of 1.
I think it's time we try this. It seems to work.
* src/ntl-uri-map.c (my_notify_when_ready),
(got_metadata_callback): Change to use the new version of
async. get_file_info.
-rw-r--r-- | ChangeLog | 21 | ||||
-rw-r--r-- | HACKING | 2 | ||||
-rw-r--r-- | components/rpmview/nautilus-rpm-view.c | 34 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-directory-async.c | 4 | ||||
-rw-r--r-- | libnautilus-private/nautilus-directory-async.c | 4 | ||||
-rw-r--r-- | src/nautilus-applicable-views.c | 61 | ||||
-rw-r--r-- | src/ntl-uri-map.c | 61 |
7 files changed, 134 insertions, 53 deletions
@@ -1,3 +1,22 @@ +2000-04-25 Darin Adler <darin@eazel.com> + + This change requires a new gnome-vfs. + + * HACKING: Updated URL for popt. + + * components/rpmview/nautilus-rpm-view.c: + (nautilus_rpm_view_update_from_uri): + Changed to use FD_t for real instead of casting a pointer to a + raw file descriptor to it. + + * libnautilus-extensions/nautilus-directory-async.c: + Told it to load 32 items at a time instead of 1. + I think it's time we try this. It seems to work. + + * src/ntl-uri-map.c (my_notify_when_ready), + (got_metadata_callback): Change to use the new version of + async. get_file_info. + 2000-04-25 Andy Hertzfeld <andy@eazel.com> made drag and drop to and from the location bar work properly @@ -9,7 +28,7 @@ the result from gtk_entry_get_text, since it's not a copy. Made it actually go to the dropped in uri by emitting the location changed signal. - + 2000-04-25 John Sullivan <sullivan@eazel.com> * data/mime/nautilus.keys @@ -30,7 +30,7 @@ gnet: HEAD ORBit requires you to install popt-1.5, which can be fetched from: - ftp://ftp.valinux.com/pub/mirrors/redhat/rawhide/i386/RedHat/RPMS/popt-1.5-0.36.i386.rpm + ftp://ftp.valinux.com/pub/mirrors/redhat/rawhide/i386/RedHat/RPMS/popt-1.5-0.45.i386.rpm * Build and install nautilus into your selected prefix. diff --git a/components/rpmview/nautilus-rpm-view.c b/components/rpmview/nautilus-rpm-view.c index 03f6889e7..c926187d1 100644 --- a/components/rpmview/nautilus-rpm-view.c +++ b/components/rpmview/nautilus-rpm-view.c @@ -378,10 +378,10 @@ check_installed(gchar *package_name, gchar *package_version, gchar *package_rele gint result = 0; gchar *version_ptr, *release_ptr; - rpmReadConfigFiles(NULL, NULL); - rpm_result = rpmdbOpen("", &rpm_db, O_RDONLY, 0644); + rpmReadConfigFiles (NULL, NULL); + rpm_result = rpmdbOpen ("", &rpm_db, O_RDONLY, 0644); if (rpm_result != 0) { - g_message("couldn't open package database: %d", rpm_result); + g_message ("couldn't open package database: %d", rpm_result); return 0; } @@ -429,7 +429,7 @@ nautilus_rpm_view_update_from_uri (NautilusRPMView *rpm_view, const char *uri) gint iterator_tag, type, data_size, result, index, file_count; gchar *data_ptr, *temp_str; gboolean is_installed; - gint file_descriptor; + FD_t file_descriptor; gint *integer_ptr; gchar **path = NULL; @@ -440,12 +440,12 @@ nautilus_rpm_view_update_from_uri (NautilusRPMView *rpm_view, const char *uri) const char *path_name = uri + 7; - file_descriptor = open(path_name, O_RDONLY, 0644); + file_descriptor = fdOpen (path_name, O_RDONLY, 0644); - if (file_descriptor >= 0) { + if (fdValid (file_descriptor)) { /* read out the appropriate fields, and set them up in the view */ - result = rpmReadPackageInfo((FD_t)&file_descriptor, &signature, &header_info); + result = rpmReadPackageInfo (file_descriptor, &signature, &header_info); if (result) { g_message("couldnt read package!"); return; @@ -456,9 +456,9 @@ nautilus_rpm_view_update_from_uri (NautilusRPMView *rpm_view, const char *uri) integer_ptr = (int*) data_ptr; switch (iterator_tag) { case RPMTAG_NAME: - package_name = strdup(data_ptr); + package_name = g_strdup(data_ptr); temp_str = g_strdup_printf("Package \"%s\" ", data_ptr); - gtk_label_set (GTK_LABEL (rpm_view->details->package_title), temp_str); + gtk_label_set (GTK_LABEL (rpm_view->details->package_title), temp_str); g_free(temp_str); break; case RPMTAG_VERSION: @@ -468,14 +468,14 @@ nautilus_rpm_view_update_from_uri (NautilusRPMView *rpm_view, const char *uri) temp_release = g_strdup(data_ptr); break; case RPMTAG_SUMMARY: - gtk_label_set (GTK_LABEL (rpm_view->details->package_summary), data_ptr+4); + gtk_label_set (GTK_LABEL (rpm_view->details->package_summary), data_ptr+4); break; case RPMTAG_DESCRIPTION: - gtk_label_set (GTK_LABEL (rpm_view->details->package_description), data_ptr+4); + gtk_label_set (GTK_LABEL (rpm_view->details->package_description), data_ptr+4); break; case RPMTAG_SIZE: temp_str = gnome_vfs_file_size_to_string (*integer_ptr); - gtk_label_set (GTK_LABEL (rpm_view->details->package_size), temp_str); + gtk_label_set (GTK_LABEL (rpm_view->details->package_size), temp_str); g_free(temp_str); break; case RPMTAG_DISTRIBUTION: @@ -508,21 +508,21 @@ nautilus_rpm_view_update_from_uri (NautilusRPMView *rpm_view, const char *uri) } if (temp_version) { - temp_str = g_strdup_printf("version %s-%s", temp_version, temp_release); + temp_str = g_strdup_printf ("version %s-%s", temp_version, temp_release); gtk_label_set (GTK_LABEL (rpm_view->details->package_release), temp_str); - g_free(temp_str); + g_free (temp_str); } - headerFreeIterator(iterator); + headerFreeIterator (iterator); + /* close the package */ - close(file_descriptor); + fdClose (file_descriptor); } /* determine if the package is installed */ is_installed = check_installed(package_name, temp_version, temp_release); /* set up the install message and buttons */ - if (is_installed) gtk_label_set(GTK_LABEL(rpm_view->details->package_installed_message), "This package is currently installed"); else diff --git a/libnautilus-extensions/nautilus-directory-async.c b/libnautilus-extensions/nautilus-directory-async.c index a27fff927..424c1db8c 100644 --- a/libnautilus-extensions/nautilus-directory-async.c +++ b/libnautilus-extensions/nautilus-directory-async.c @@ -40,7 +40,7 @@ | GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_GROUP_WRITE \ | GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_OTHER_WRITE) -#define DIRECTORY_LOAD_ITEMS_PER_CALLBACK 1 +#define DIRECTORY_LOAD_ITEMS_PER_CALLBACK 32 struct MetafileReadState { GnomeVFSAsyncHandle *handle; @@ -678,7 +678,7 @@ nautilus_directory_file_monitor_add_internal (NautilusDirectory *directory, | GNOME_VFS_DIRECTORY_FILTER_NOPARENTDIR), NULL, /* filter_pattern */ DIRECTORY_LOAD_ITEMS_PER_CALLBACK, /* items_per_notification */ - directory_load_callback, /* callback */ + directory_load_callback, /* callback */ directory); } diff --git a/libnautilus-private/nautilus-directory-async.c b/libnautilus-private/nautilus-directory-async.c index a27fff927..424c1db8c 100644 --- a/libnautilus-private/nautilus-directory-async.c +++ b/libnautilus-private/nautilus-directory-async.c @@ -40,7 +40,7 @@ | GNOME_VFS_PERM_GROUP_READ | GNOME_VFS_PERM_GROUP_WRITE \ | GNOME_VFS_PERM_OTHER_READ | GNOME_VFS_PERM_OTHER_WRITE) -#define DIRECTORY_LOAD_ITEMS_PER_CALLBACK 1 +#define DIRECTORY_LOAD_ITEMS_PER_CALLBACK 32 struct MetafileReadState { GnomeVFSAsyncHandle *handle; @@ -678,7 +678,7 @@ nautilus_directory_file_monitor_add_internal (NautilusDirectory *directory, | GNOME_VFS_DIRECTORY_FILTER_NOPARENTDIR), NULL, /* filter_pattern */ DIRECTORY_LOAD_ITEMS_PER_CALLBACK, /* items_per_notification */ - directory_load_callback, /* callback */ + directory_load_callback, /* callback */ directory); } diff --git a/src/nautilus-applicable-views.c b/src/nautilus-applicable-views.c index 9ecc689f3..78214fcfa 100644 --- a/src/nautilus-applicable-views.c +++ b/src/nautilus-applicable-views.c @@ -186,16 +186,21 @@ set_initial_content_iid (NautilusNavigationInfo *navinfo, static void my_notify_when_ready (GnomeVFSAsyncHandle *ah, - GnomeVFSResult result, - GnomeVFSFileInfo *vfs_fileinfo, + GList *result_list, gpointer data) { + GnomeVFSGetFileInfoResult *file_result; + GnomeVFSResult vfs_result_code; NautilusNavigationInfo *navinfo; NautilusNavigationCallback notify_ready; gpointer notify_ready_data; const char *fallback_iid; NautilusNavigationResult result_code; + g_assert (result_list != NULL); + g_assert (result_list->data != NULL); + g_assert (result_list->next == NULL); + navinfo = data; navinfo->ah = NULL; @@ -204,31 +209,34 @@ my_notify_when_ready (GnomeVFSAsyncHandle *ah, notify_ready_data = navinfo->callback_data; /* Get the content type. */ - if (result == GNOME_VFS_OK) { - navinfo->navinfo.content_type = g_strdup (gnome_vfs_file_info_get_mime_type (vfs_fileinfo)); - } else if (result == GNOME_VFS_ERROR_NOTSUPPORTED - || result == GNOME_VFS_ERROR_INVALIDURI) { + file_result = result_list->data; + vfs_result_code = file_result->result; + if (vfs_result_code == GNOME_VFS_OK) { + navinfo->navinfo.content_type = g_strdup + (gnome_vfs_file_info_get_mime_type (file_result->file_info)); + } else if (vfs_result_code == GNOME_VFS_ERROR_NOTSUPPORTED + || vfs_result_code == GNOME_VFS_ERROR_INVALIDURI) { /* Special scheme mapping stuff */ if (nautilus_str_has_prefix (navinfo->navinfo.requested_uri, "irc://")) { navinfo->navinfo.content_type = g_strdup ("special/x-irc-session"); - result = GNOME_VFS_OK; + vfs_result_code = GNOME_VFS_OK; } else if (nautilus_str_has_prefix (navinfo->navinfo.requested_uri, "eazel:")) { navinfo->navinfo.content_type = g_strdup ("special/eazel-service"); - result = GNOME_VFS_OK; + vfs_result_code = GNOME_VFS_OK; } else if (nautilus_str_has_prefix (navinfo->navinfo.requested_uri, "hardware:")) { navinfo->navinfo.content_type = g_strdup ("special/hardware"); - result = GNOME_VFS_OK; + vfs_result_code = GNOME_VFS_OK; /* FIXME: This mozilla-hack should be short lived until http issues are solved */ } else if (nautilus_str_has_prefix (navinfo->navinfo.requested_uri, "moz:")) { navinfo->navinfo.content_type = g_strdup ("special/mozilla-hack"); - result = GNOME_VFS_OK; + vfs_result_code = GNOME_VFS_OK; } } /* Map GnomeVFSResult to one of the types that Nautilus knows how to handle. */ - result_code = get_nautilus_navigation_result_from_gnome_vfs_result (result); + result_code = get_nautilus_navigation_result_from_gnome_vfs_result (vfs_result_code); - if (result != GNOME_VFS_OK) { + if (vfs_result_code != GNOME_VFS_OK) { /* Leave navinfo intact so notify_ready function can access the uri. * (notify_ready function is responsible for freeing navinfo). */ @@ -316,8 +324,7 @@ my_notify_when_ready (GnomeVFSAsyncHandle *ah, /* FIXME: for now, we just do this for directories but it should apply to all places with available metadata */ add_components_from_metadata (navinfo); - } - else if (strcmp (navinfo->navinfo.content_type, "application/x-rpm") == 0 + } else if (strcmp (navinfo->navinfo.content_type, "application/x-rpm") == 0 || nautilus_str_has_suffix (navinfo->navinfo.requested_uri, ".rpm")) { fallback_iid = "OAFIID:nautilus_rpm_view:22ea002c-11e6-44fd-b13c-9445175a5e70"; navinfo->content_identifiers = g_slist_append @@ -445,17 +452,41 @@ got_metadata_callback (NautilusDirectory *directory, gpointer callback_data) { NautilusNavigationInfo *info; + GnomeVFSURI *vfs_uri; + GList uri_list; + GList result_list; + GnomeVFSGetFileInfoResult result_item; info = callback_data; g_assert (info->directory == directory); + vfs_uri = gnome_vfs_uri_new (info->navinfo.requested_uri); + if (vfs_uri == NULL) { + /* Report the error. */ + + result_item.uri = NULL; + result_item.result = GNOME_VFS_ERROR_INVALIDURI; + result_item.file_info = NULL; + + result_list.data = &result_item; + result_list.next = NULL; + + my_notify_when_ready (NULL, &result_list, info); + + return; + } + + uri_list.data = vfs_uri; + uri_list.next = NULL; gnome_vfs_async_get_file_info (&info->ah, - info->navinfo.requested_uri, + &uri_list, (GNOME_VFS_FILE_INFO_GETMIMETYPE | GNOME_VFS_FILE_INFO_FOLLOWLINKS), NULL, my_notify_when_ready, info); + + gnome_vfs_uri_unref (vfs_uri); } /* NautilusNavigationInfo */ diff --git a/src/ntl-uri-map.c b/src/ntl-uri-map.c index 9ecc689f3..78214fcfa 100644 --- a/src/ntl-uri-map.c +++ b/src/ntl-uri-map.c @@ -186,16 +186,21 @@ set_initial_content_iid (NautilusNavigationInfo *navinfo, static void my_notify_when_ready (GnomeVFSAsyncHandle *ah, - GnomeVFSResult result, - GnomeVFSFileInfo *vfs_fileinfo, + GList *result_list, gpointer data) { + GnomeVFSGetFileInfoResult *file_result; + GnomeVFSResult vfs_result_code; NautilusNavigationInfo *navinfo; NautilusNavigationCallback notify_ready; gpointer notify_ready_data; const char *fallback_iid; NautilusNavigationResult result_code; + g_assert (result_list != NULL); + g_assert (result_list->data != NULL); + g_assert (result_list->next == NULL); + navinfo = data; navinfo->ah = NULL; @@ -204,31 +209,34 @@ my_notify_when_ready (GnomeVFSAsyncHandle *ah, notify_ready_data = navinfo->callback_data; /* Get the content type. */ - if (result == GNOME_VFS_OK) { - navinfo->navinfo.content_type = g_strdup (gnome_vfs_file_info_get_mime_type (vfs_fileinfo)); - } else if (result == GNOME_VFS_ERROR_NOTSUPPORTED - || result == GNOME_VFS_ERROR_INVALIDURI) { + file_result = result_list->data; + vfs_result_code = file_result->result; + if (vfs_result_code == GNOME_VFS_OK) { + navinfo->navinfo.content_type = g_strdup + (gnome_vfs_file_info_get_mime_type (file_result->file_info)); + } else if (vfs_result_code == GNOME_VFS_ERROR_NOTSUPPORTED + || vfs_result_code == GNOME_VFS_ERROR_INVALIDURI) { /* Special scheme mapping stuff */ if (nautilus_str_has_prefix (navinfo->navinfo.requested_uri, "irc://")) { navinfo->navinfo.content_type = g_strdup ("special/x-irc-session"); - result = GNOME_VFS_OK; + vfs_result_code = GNOME_VFS_OK; } else if (nautilus_str_has_prefix (navinfo->navinfo.requested_uri, "eazel:")) { navinfo->navinfo.content_type = g_strdup ("special/eazel-service"); - result = GNOME_VFS_OK; + vfs_result_code = GNOME_VFS_OK; } else if (nautilus_str_has_prefix (navinfo->navinfo.requested_uri, "hardware:")) { navinfo->navinfo.content_type = g_strdup ("special/hardware"); - result = GNOME_VFS_OK; + vfs_result_code = GNOME_VFS_OK; /* FIXME: This mozilla-hack should be short lived until http issues are solved */ } else if (nautilus_str_has_prefix (navinfo->navinfo.requested_uri, "moz:")) { navinfo->navinfo.content_type = g_strdup ("special/mozilla-hack"); - result = GNOME_VFS_OK; + vfs_result_code = GNOME_VFS_OK; } } /* Map GnomeVFSResult to one of the types that Nautilus knows how to handle. */ - result_code = get_nautilus_navigation_result_from_gnome_vfs_result (result); + result_code = get_nautilus_navigation_result_from_gnome_vfs_result (vfs_result_code); - if (result != GNOME_VFS_OK) { + if (vfs_result_code != GNOME_VFS_OK) { /* Leave navinfo intact so notify_ready function can access the uri. * (notify_ready function is responsible for freeing navinfo). */ @@ -316,8 +324,7 @@ my_notify_when_ready (GnomeVFSAsyncHandle *ah, /* FIXME: for now, we just do this for directories but it should apply to all places with available metadata */ add_components_from_metadata (navinfo); - } - else if (strcmp (navinfo->navinfo.content_type, "application/x-rpm") == 0 + } else if (strcmp (navinfo->navinfo.content_type, "application/x-rpm") == 0 || nautilus_str_has_suffix (navinfo->navinfo.requested_uri, ".rpm")) { fallback_iid = "OAFIID:nautilus_rpm_view:22ea002c-11e6-44fd-b13c-9445175a5e70"; navinfo->content_identifiers = g_slist_append @@ -445,17 +452,41 @@ got_metadata_callback (NautilusDirectory *directory, gpointer callback_data) { NautilusNavigationInfo *info; + GnomeVFSURI *vfs_uri; + GList uri_list; + GList result_list; + GnomeVFSGetFileInfoResult result_item; info = callback_data; g_assert (info->directory == directory); + vfs_uri = gnome_vfs_uri_new (info->navinfo.requested_uri); + if (vfs_uri == NULL) { + /* Report the error. */ + + result_item.uri = NULL; + result_item.result = GNOME_VFS_ERROR_INVALIDURI; + result_item.file_info = NULL; + + result_list.data = &result_item; + result_list.next = NULL; + + my_notify_when_ready (NULL, &result_list, info); + + return; + } + + uri_list.data = vfs_uri; + uri_list.next = NULL; gnome_vfs_async_get_file_info (&info->ah, - info->navinfo.requested_uri, + &uri_list, (GNOME_VFS_FILE_INFO_GETMIMETYPE | GNOME_VFS_FILE_INFO_FOLLOWLINKS), NULL, my_notify_when_ready, info); + + gnome_vfs_uri_unref (vfs_uri); } /* NautilusNavigationInfo */ |