summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechooserdefault.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2004-08-25 16:01:03 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-08-25 16:01:03 +0000
commit9f055423b73c2109dc5d40bf37702dc08afb7adf (patch)
treeb3fcb4e9e98797017b56da3f8a9382c663bead72 /gtk/gtkfilechooserdefault.c
parent882144878ca9fadb7bd6c2aee156afd3eff96cc4 (diff)
downloadgdk-pixbuf-9f055423b73c2109dc5d40bf37702dc08afb7adf.tar.gz
Use get_file_info() rather than trying get_folder() and checking for an
2004-08-25 Matthias Clasen <mclasen@redhat.com> * gtk/gtkfilechooserdefault.c (check_is_folder): Use get_file_info() rather than trying get_folder() and checking for an error directly because older versions of the gnome-vfs backend don't return an error immediately. (#150852, Zack Cerza )
Diffstat (limited to 'gtk/gtkfilechooserdefault.c')
-rw-r--r--gtk/gtkfilechooserdefault.c52
1 files changed, 36 insertions, 16 deletions
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index e8df25a1c..f6a371d6d 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -69,6 +69,7 @@
#include "gtkfilesystemwin32.h"
#endif
+#include <errno.h>
#include <string.h>
#include <time.h>
@@ -990,22 +991,6 @@ shortcuts_find_current_folder (GtkFileChooserDefault *impl)
gtk_tree_path_free (path);
}
-/* Returns whether a path is a folder */
-static gboolean
-check_is_folder (GtkFileSystem *file_system, const GtkFilePath *path, GError **error)
-{
- GtkFileFolder *folder;
-
- folder = gtk_file_system_get_folder (file_system, path,
- GTK_FILE_INFO_DISPLAY_NAME,
- error);
- if (!folder)
- return FALSE;
-
- g_object_unref (folder);
- return TRUE;
-}
-
/* Convenience function to get the display name and icon info for a path */
static GtkFileInfo *
get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean name_only, GError **error)
@@ -1035,6 +1020,41 @@ get_file_info (GtkFileSystem *file_system, const GtkFilePath *path, gboolean nam
return info;
}
+/* Returns whether a path is a folder */
+static gboolean
+check_is_folder (GtkFileSystem *file_system, const GtkFilePath *path, GError **error)
+{
+ GtkFileInfo *info;
+ gboolean is_folder;
+
+ /* Use get_file_info() rather than trying get_folder() and checking
+ * for an error directly because older versions of the gnome-vfs
+ * backend don't return an error immediately. This way is also
+ * more efficient if we already have the parent folder.
+ */
+ info = get_file_info (file_system, path, FALSE, error);
+
+ if (!info)
+ return FALSE;
+
+ is_folder = gtk_file_info_get_is_folder (info);
+ gtk_file_info_free (info);
+
+ if (!is_folder)
+ {
+ g_set_error (error,
+ GTK_FILE_SYSTEM_ERROR,
+ GTK_FILE_SYSTEM_ERROR_NOT_FOLDER,
+ "%s: %s",
+ gtk_file_info_get_display_name (info),
+ g_strerror (ENOTDIR));
+
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/* Inserts a path in the shortcuts tree, making a copy of it; alternatively,
* inserts a volume. A position of -1 indicates the end of the tree.
*/