[Xfce4-commits] r29775 - in thunar/branches/migration-to-gio: . thunar
Jannis Pohlmann
jannis at xfce.org
Sun Apr 12 03:02:59 CEST 2009
Author: jannis
Date: 2009-04-12 01:02:59 +0000 (Sun, 12 Apr 2009)
New Revision: 29775
Modified:
thunar/branches/migration-to-gio/ChangeLog
thunar/branches/migration-to-gio/thunar/thunar-file.c
thunar/branches/migration-to-gio/thunar/thunar-file.h
Log:
* thunar/thunar-file.{c,h}: Re-implement thunar_file_is_local(),
thunar_file_is_ancestor(), thunar_file_is_executable(),
thunar_file_is_readable(), thunar_file_is_writable(),
thunar_file_is_hidden(), thunar_file_is_home(),
thunar_file_is_regular() and thunar_file_dup_uri() based on GIO.
Modified: thunar/branches/migration-to-gio/ChangeLog
===================================================================
--- thunar/branches/migration-to-gio/ChangeLog 2009-04-12 00:33:36 UTC (rev 29774)
+++ thunar/branches/migration-to-gio/ChangeLog 2009-04-12 01:02:59 UTC (rev 29775)
@@ -1,5 +1,14 @@
2009-04-12 Jannis Pohlmann <jannis at xfce.org>
+ * thunar/thunar-file.{c,h}: Re-implement thunar_file_is_local(),
+ thunar_file_is_ancestor(), thunar_file_is_executable(),
+ thunar_file_is_readable(), thunar_file_is_writable(),
+ thunar_file_is_hidden(), thunar_file_is_home(),
+ thunar_file_is_regular() and thunar_file_dup_uri() based on GIO.
+
+
+2009-04-12 Jannis Pohlmann <jannis at xfce.org>
+
* thunar/thunar-file.{c,h}: Add GFileInfo filesystem info member to
ThunarFile. Initialize it in thunar_file_load(), otherwise make sure
it's set to NULL. Make thunar_file_get_default_handler(),
Modified: thunar/branches/migration-to-gio/thunar/thunar-file.c
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.c 2009-04-12 00:33:36 UTC (rev 29774)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.c 2009-04-12 01:02:59 UTC (rev 29775)
@@ -1673,6 +1673,184 @@
/**
+ * thunar_file_is_local:
+ * @file : a #ThunarFile instance.
+ *
+ * Returns %TRUE if @file is a local file with the
+ * file:// URI scheme.
+ *
+ * Return value: %TRUE if @file is local.
+ **/
+gboolean
+thunar_file_is_local (const ThunarFile *file)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+ return g_file_has_uri_scheme (file->gfile, "file");
+}
+
+
+
+/**
+ * thunar_file_is_ancestor:
+ * @file : a #ThunarFile instance.
+ * @ancestor : another #ThunarFile instance.
+ *
+ * Determines whether @file is somewhere inside @ancestor,
+ * possibly with intermediate folders.
+ *
+ * Return value: %TRUE if @ancestor contains @file as a
+ * child, grandchild, great grandchild, etc.
+ **/
+gboolean
+thunar_file_is_ancestor (const ThunarFile *file,
+ const ThunarFile *ancestor)
+{
+ gboolean is_ancestor = FALSE;
+ GFile *current = NULL;
+ GFile *tmp;
+
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (ancestor), FALSE);
+
+ for (current = g_object_ref (file->gfile);
+ is_ancestor == FALSE && current != NULL;
+ tmp = g_file_get_parent (current), g_object_unref (current), current = tmp)
+ {
+ if (G_UNLIKELY (g_file_equal (current, ancestor->gfile)))
+ is_ancestor = TRUE;
+ }
+
+ if (current != NULL)
+ g_object_unref (current);
+
+ return is_ancestor;
+}
+
+
+
+/**
+ * thunar_file_is_executable:
+ * @file : a #ThunarFile instance.
+ *
+ * Determines whether the owner of the current process is allowed
+ * to execute the @file (or enter the directory refered to by
+ * @file).
+ *
+ * Return value: %TRUE if @file can be executed.
+ **/
+gboolean
+thunar_file_is_executable (const ThunarFile *file)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+ _thunar_return_val_if_fail (G_IS_FILE_INFO (file->ginfo), FALSE);
+ return g_file_info_get_attribute_boolean (file->ginfo,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE);
+}
+
+
+
+/**
+ * thunar_file_is_readable:
+ * @file : a #ThunarFile instance.
+ *
+ * Determines whether the owner of the current process is allowed
+ * to read the @file.
+ *
+ * Return value: %TRUE if @file can be read.
+ **/
+gboolean
+thunar_file_is_readable (const ThunarFile *file)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+ _thunar_return_val_if_fail (G_IS_FILE_INFO (file->ginfo), FALSE);
+ return g_file_info_get_attribute_boolean (file->ginfo,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
+}
+
+
+
+/**
+ * thunar_file_is_writable:
+ * @file : a #ThunarFile instance.
+ *
+ * Determines whether the owner of the current process is allowed
+ * to write the @file.
+ *
+ * Return value: %TRUE if @file can be read.
+ **/
+gboolean
+thunar_file_is_writable (const ThunarFile *file)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+ _thunar_return_val_if_fail (G_IS_FILE_INFO (file->ginfo), FALSE);
+ return g_file_info_get_attribute_boolean (file->ginfo,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
+}
+
+
+
+/**
+ * thunar_file_is_hidden:
+ * @file : a #ThunarFile instance.
+ *
+ * Checks whether @file can be considered a hidden file.
+ *
+ * Return value: %TRUE if @file is a hidden file, else %FALSE.
+ **/
+gboolean
+thunar_file_is_hidden (const ThunarFile *file)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+ _thunar_return_val_if_fail (G_IS_FILE_INFO (file->ginfo), FALSE);
+ return g_file_info_get_attribute_boolean (file->ginfo,
+ G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN);
+}
+
+
+
+/**
+ * thunar_file_is_home:
+ * @file : a #ThunarFile.
+ *
+ * Checks whether @file refers to the users home directory.
+ *
+ * Return value: %TRUE if @file is the users home directory.
+ **/
+gboolean
+thunar_file_is_home (const ThunarFile *file)
+{
+ gboolean is_home = FALSE;
+ GFile *home;
+
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+
+ home = g_file_new_for_home ();
+ is_home = g_file_equal (file->gfile, home);
+ g_object_unref (home);
+
+ return is_home;
+}
+
+
+
+/**
+ * thunar_file_is_regular:
+ * @file : a #ThunarFile.
+ *
+ * Checks whether @file refers to a regular file.
+ *
+ * Return value: %TRUE if @file is a regular file.
+ **/
+gboolean
+thunar_file_is_regular (const ThunarFile *file)
+{
+ _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+ return thunar_file_get_kind (file) == G_FILE_TYPE_REGULAR;
+}
+
+
+
+/**
* thunar_file_get_deletion_date:
* @file : a #ThunarFile instance.
* @date_style : the style used to format the date.
Modified: thunar/branches/migration-to-gio/thunar/thunar-file.h
===================================================================
--- thunar/branches/migration-to-gio/thunar/thunar-file.h 2009-04-12 00:33:36 UTC (rev 29774)
+++ thunar/branches/migration-to-gio/thunar/thunar-file.h 2009-04-12 01:02:59 UTC (rev 29775)
@@ -205,6 +205,15 @@
gboolean thunar_file_get_free_space (const ThunarFile *file,
guint64 *free_space_return);
gboolean thunar_file_is_directory (const ThunarFile *file);
+gboolean thunar_file_is_local (const ThunarFile *file);
+gboolean thunar_file_is_ancestor (const ThunarFile *file,
+ const ThunarFile *ancestor);
+gboolean thunar_file_is_executable (const ThunarFile *file);
+gboolean thunar_file_is_readable (const ThunarFile *file);
+gboolean thunar_file_is_writable (const ThunarFile *file);
+gboolean thunar_file_is_hidden (const ThunarFile *file);
+gboolean thunar_file_is_home (const ThunarFile *file);
+gboolean thunar_file_is_regular (const ThunarFile *file);
gchar *thunar_file_get_deletion_date (const ThunarFile *file,
ThunarDateStyle date_style) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
@@ -345,7 +354,7 @@
*
* Return value: the URI for @file.
**/
-#define thunar_file_dup_uri(file) (thunar_vfs_path_dup_uri (thunar_file_get_path ((file))))
+#define thunar_file_dup_uri(file) (g_file_get_uri (THUNAR_FILE ((file))->gfile))
/**
@@ -377,20 +386,7 @@
thunarx_file_info_changed (THUNARX_FILE_INFO ((file))); \
}G_STMT_END
-
-
/**
- * thunar_file_is_local:
- * @file : a #ThunarFile instance.
- *
- * Returns %TRUE if @file is a local file with the
- * %THUNAR_VFS_PATH_SCHEME_FILE scheme.
- *
- * Return value: %TRUE if @file is local.
- **/
-#define thunar_file_is_local(file) (thunar_vfs_path_get_scheme (thunar_file_get_path ((file))) == THUNAR_VFS_PATH_SCHEME_FILE)
-
-/**
* thunar_file_is_trashed:
* @file : a #ThunarFile instance.
*
@@ -403,83 +399,6 @@
#define thunar_file_is_trashed(file) (g_file_is_trashed (THUNAR_FILE ((file))->gfile))
/**
- * thunar_file_is_ancestor:
- * @file : a #ThunarFile instance.
- * @ancestor : another #ThunarFile instance.
- *
- * Determines whether @file is somewhere inside @ancestor,
- * possibly with intermediate folders.
- *
- * Return value: %TRUE if @ancestor contains @file as a
- * child, grandchild, great grandchild, etc.
- **/
-#define thunar_file_is_ancestor(file, ancestor) (thunar_vfs_path_is_ancestor (thunar_file_get_path ((file)), thunar_file_get_path ((ancestor))))
-
-/**
- * thunar_file_is_executable:
- * @file : a #ThunarFile instance.
- *
- * Determines whether the owner of the current process is allowed
- * to execute the @file (or enter the directory refered to by
- * @file).
- *
- * Return value: %TRUE if @file can be executed.
- **/
-#define thunar_file_is_executable(file) (THUNAR_FILE ((file))->info->flags & THUNAR_VFS_FILE_FLAGS_EXECUTABLE)
-
-/**
- * thunar_file_is_readable:
- * @file : a #ThunarFile instance.
- *
- * Determines whether the owner of the current process is allowed
- * to read the @file.
- *
- * Return value: %TRUE if @file can be read.
- **/
-#define thunar_file_is_readable(file) (THUNAR_FILE ((file))->info->flags & THUNAR_VFS_FILE_FLAGS_READABLE)
-
-/**
- * thunar_file_is_writable:
- * @file : a #ThunarFile instance.
- *
- * Determines whether the owner of the current process is allowed
- * to write the @file.
- *
- * Return value: %TRUE if @file can be read.
- **/
-#define thunar_file_is_writable(file) (THUNAR_FILE ((file))->info->flags & THUNAR_VFS_FILE_FLAGS_WRITABLE)
-
-/**
- * thunar_file_is_hidden:
- * @file : a #ThunarFile instance.
- *
- * Checks whether @file can be considered a hidden file.
- *
- * Return value: %TRUE if @file is a hidden file, else %FALSE.
- **/
-#define thunar_file_is_hidden(file) ((THUNAR_FILE ((file))->info->flags & THUNAR_VFS_FILE_FLAGS_HIDDEN) != 0)
-
-/**
- * thunar_file_is_home:
- * @file : a #ThunarFile.
- *
- * Checks whether @file refers to the users home directory.
- *
- * Return value: %TRUE if @file is the users home directory.
- **/
-#define thunar_file_is_home(file) (thunar_vfs_path_is_home (THUNAR_FILE ((file))->info->path))
-
-/**
- * thunar_file_is_regular:
- * @file : a #ThunarFile.
- *
- * Checks whether @file refers to a regular file.
- *
- * Return value: %TRUE if @file is a regular file.
- **/
-#define thunar_file_is_regular(file) (THUNAR_FILE ((file))->info->type == THUNAR_VFS_FILE_TYPE_REGULAR)
-
-/**
* thunar_file_is_desktop_file:
* @file : a #ThunarFile.
*
More information about the Xfce4-commits
mailing list