[nautilus] Add nautilus_file_is_user_special_directory().



commit e847f4196c5aabb65a1ac43688bcd1b79443b261
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jun 7 14:55:46 2010 +0200

    Add nautilus_file_is_user_special_directory().

 libnautilus-private/nautilus-file.c |   33 +++++++++++++++++++++++++++++++++
 libnautilus-private/nautilus-file.h |    2 ++
 2 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index ff986df..39f8a09 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -6926,6 +6926,39 @@ nautilus_file_is_directory (NautilusFile *file)
 	return nautilus_file_get_file_type (file) == G_FILE_TYPE_DIRECTORY;
 }
 
+/**
+ * nautilus_file_is_user_special_directory
+ *
+ * Check if this file is a special platform directory.
+ * @file: NautilusFile representing the file in question.
+ * @special_directory: GUserDirectory representing the type to test for
+ * 
+ * Returns: TRUE if @file is a special directory of the given kind.
+ */
+gboolean
+nautilus_file_is_user_special_directory (NautilusFile *file,
+					 GUserDirectory special_directory)
+{
+	gboolean is_special_dir;
+	const gchar *special_dir;
+
+	special_dir = g_get_user_special_dir (special_directory);
+	is_special_dir = FALSE;
+
+	if (special_dir) {
+		GFile *loc;
+		GFile *special_gfile;
+
+		loc = nautilus_file_get_location (file);
+		special_gfile = g_file_new_for_path (special_dir);
+		is_special_dir = g_file_equal (loc, special_gfile);
+		g_object_unref (special_gfile);
+		g_object_unref (loc);
+	}
+
+	return is_special_dir;
+}
+
 gboolean
 nautilus_file_is_archive (NautilusFile *file)
 {
diff --git a/libnautilus-private/nautilus-file.h b/libnautilus-private/nautilus-file.h
index 82865c4..098df2f 100644
--- a/libnautilus-private/nautilus-file.h
+++ b/libnautilus-private/nautilus-file.h
@@ -188,6 +188,8 @@ gboolean                nautilus_file_is_broken_symbolic_link           (Nautilu
 gboolean                nautilus_file_is_nautilus_link                  (NautilusFile                   *file);
 gboolean                nautilus_file_is_executable                     (NautilusFile                   *file);
 gboolean                nautilus_file_is_directory                      (NautilusFile                   *file);
+gboolean                nautilus_file_is_user_special_directory         (NautilusFile                   *file,
+									 GUserDirectory                 special_directory);
 gboolean		nautilus_file_is_archive			(NautilusFile			*file);
 gboolean                nautilus_file_is_in_trash                       (NautilusFile                   *file);
 gboolean                nautilus_file_is_in_desktop                     (NautilusFile                   *file);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]