[Xfce4-commits] <thunar:master> Add function thunar_file_is_parent().

Jannis Pohlmann noreply at xfce.org
Mon Oct 4 17:32:02 CEST 2010


Updating branch refs/heads/master
         to 3a01c1e75fd4ee9a73565946b0fc927dc3c383f7 (commit)
       from 14d505a1aa9d95ffe290bb3b3f207e827f321417 (commit)

commit 3a01c1e75fd4ee9a73565946b0fc927dc3c383f7
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Mon Oct 4 17:23:49 2010 +0200

    Add function thunar_file_is_parent().

 thunar/thunar-file.c |   31 +++++++++++++++++++++++++++++++
 thunar/thunar-file.h |    2 ++
 2 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index b9b30dc..b8b80fb 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -2009,6 +2009,37 @@ thunar_file_is_local (const ThunarFile *file)
 
 
 /**
+ * thunar_file_is_parent:
+ * @file  : a #ThunarFile instance.
+ * @child : another #ThunarFile instance.
+ *
+ * Determines whether @file is the parent directory of @child.
+ *
+ * Return value: %TRUE if @file is the parent of @child.
+ **/
+gboolean
+thunar_file_is_parent (const ThunarFile *file,
+                       const ThunarFile *child)
+{
+  gboolean is_parent = FALSE;
+  GFile   *parent;
+
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
+  _thunar_return_val_if_fail (THUNAR_IS_FILE (child), FALSE);
+
+  parent = g_file_get_parent (child->gfile);
+  if (parent != NULL)
+    {
+      is_parent = g_file_equal (file->gfile, parent);
+      g_object_unref (parent);
+    }
+
+  return is_parent;
+}
+
+
+
+/**
  * thunar_file_is_ancestor:
  * @file     : a #ThunarFile instance.
  * @ancestor : another #ThunarFile instance.
diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h
index f67475a..d289402 100644
--- a/thunar/thunar-file.h
+++ b/thunar/thunar-file.h
@@ -190,6 +190,8 @@ gboolean          thunar_file_is_directory         (const ThunarFile       *file
 gboolean          thunar_file_is_shortcut          (const ThunarFile       *file);
 gboolean          thunar_file_is_mountable         (const ThunarFile       *file);
 gboolean          thunar_file_is_local             (const ThunarFile       *file);
+gboolean          thunar_file_is_parent            (const ThunarFile       *file,
+                                                    const ThunarFile       *child);
 gboolean          thunar_file_is_ancestor          (const ThunarFile       *file, 
                                                     const ThunarFile       *ancestor);
 gboolean          thunar_file_is_executable        (const ThunarFile       *file);



More information about the Xfce4-commits mailing list