[gnome-builder/wip/libide] libide: add ide_file_hash() and ide_file_equal()



commit ce332c74ce88fb46279cd90b4bcf7152cd6f21e0
Author: Christian Hergert <christian hergert me>
Date:   Wed Feb 11 17:04:10 2015 -0800

    libide: add ide_file_hash() and ide_file_equal()
    
    Helpers for GHashTable.

 libide/ide-file.c |   25 +++++++++++++++++++++++++
 libide/ide-file.h |    3 +++
 2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-file.c b/libide/ide-file.c
index cedcccd..dd3136d 100644
--- a/libide/ide-file.c
+++ b/libide/ide-file.c
@@ -36,6 +36,31 @@ G_DEFINE_TYPE_WITH_PRIVATE (IdeFile, ide_file, IDE_TYPE_OBJECT)
 
 static GParamSpec *gParamSpecs [LAST_PROP];
 
+guint
+ide_file_hash (IdeFile *self)
+{
+  IdeFilePrivate *priv;
+
+  g_return_val_if_fail (IDE_IS_FILE (self), 0);
+
+  priv = ide_file_get_instance_private (self);
+
+  return g_file_hash (priv->file);
+}
+
+gboolean
+ide_file_equal (IdeFile *self,
+                IdeFile *other)
+{
+  IdeFilePrivate *priv1 = ide_file_get_instance_private (self);
+  IdeFilePrivate *priv2 = ide_file_get_instance_private (other);
+
+  g_return_val_if_fail (IDE_IS_FILE (self), FALSE);
+  g_return_val_if_fail (IDE_IS_FILE (other), FALSE);
+
+  return g_file_equal (priv1->file, priv2->file);
+}
+
 GFile *
 ide_file_get_file (IdeFile *self)
 {
diff --git a/libide/ide-file.h b/libide/ide-file.h
index 718631b..796eb86 100644
--- a/libide/ide-file.h
+++ b/libide/ide-file.h
@@ -35,6 +35,9 @@ struct _IdeFile
 IdeLanguage     *ide_file_get_language      (IdeFile *self);
 GFile           *ide_file_get_file          (IdeFile *self);
 const gchar     *ide_file_get_project_path  (IdeFile *self);
+guint            ide_file_hash              (IdeFile *self);
+gboolean         ide_file_equal             (IdeFile *self,
+                                             IdeFile *other);
 //IdeFileSettings *ide_file_get_file_settings (IdeFile *self);
 
 G_END_DECLS


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