Add VIM modelines to new files
[geeqie.git] / src / filecluster.c
index 2b7ebcc..7c5d9d0 100644 (file)
@@ -62,12 +62,14 @@ FileClusterList *fileclusterlist_new()
 {
        FileClusterList *fcl = g_new0(FileClusterList, 1);
        fcl->clusters = g_hash_table_new(&filecluster_fd_hash, &filecluster_fd_equal);
+       return fcl;
 }
 
 FileCluster *filecluster_new()
 {
        FileCluster *fc = g_new0(FileCluster, 1);
        fc->show_children = FALSE;
+       return fc;
 }
 
 void fileclusterlist_free(FileClusterList *fcl)
@@ -120,26 +122,40 @@ FileCluster *fileclusterlist_create_cluster(FileClusterList *fcl, GList *fd_item
        return new_fc;
 }
 
+gboolean filecluster_has_head(FileCluster *fc, FileData *fd)
+{
+       if (!fd) return FALSE;
+       return filecluster_fd_equal(fc->head->data, fd);
+}
+
+gboolean filecluster_has_child(FileCluster *fc, FileData *fd)
+{
+       if (!fd) return FALSE;
+       return !filecluster_fd_equal(fc->head->data, fd);
+}
+
 gboolean fileclusterlist_has_head(FileClusterList *fcl, FileData *fd)
 {
        FileCluster *fc = g_hash_table_lookup(fcl->clusters, fd);
        if (!fc) return FALSE;
-       return fc->head->data == fd;
+       return filecluster_has_head(fc, fd);
 }
 
 gboolean fileclusterlist_has_child(FileClusterList *fcl, FileData *fd)
 {
        FileCluster *fc = g_hash_table_lookup(fcl->clusters, fd);
        if (!fc) return FALSE;
-       return fc->head->data != fd;
+       return filecluster_has_child(fc, fd);
 }
 
 static gboolean fileclusterlist_should_hide(FileClusterList *fcl, FileData *fd)
 {
        FileCluster *fc = g_hash_table_lookup(fcl->clusters, fd);
        if (!fc) return FALSE;
-       if (fc->show_children) return FALSE;  // TODO(xsdg): new function "should_show"
-       return fc->head->data != fd;
+       // Only difference vs. fileclusterlist_has_child.  Basically, if the node is a child, but
+       // we're showing children, then don't hide.
+       if (fc->show_children) return FALSE;
+       return filecluster_has_child(fc, fd);
 }
 
 // TODO(xsdg): pick a better name for this function
@@ -179,3 +195,5 @@ GList *fileclusterlist_remove_children_from_list(FileClusterList *fcl, GList *li
 
        return list;
 }
+
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */