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 filecluster_fd_equal(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 !filecluster_fd_equal(fc->head->data, fd);
+ return filecluster_has_child(fc, fd);
}
static gboolean fileclusterlist_should_hide(FileClusterList *fcl, FileData *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_fd_equal(fc->head->data, fd);
+ return filecluster_has_child(fc, fd);
}
// TODO(xsdg): pick a better name for this function
#include "main.h"
-FileClusterList *fileclusterlist_new();
+// FileCluster methods.
FileCluster *filecluster_new(); // internal?
-void fileclusterlist_free(FileClusterList *fcl);
void filecluster_free(FileCluster *fc);
gboolean filecluster_toggle_show_children(FileCluster *fc);
+gboolean filecluster_has_head(FileCluster *fc, FileData *fd);
+gboolean filecluster_has_child(FileCluster *fc, FileData *fd);
+
+
+// FileClusterList methods.
+
+FileClusterList *fileclusterlist_new();
+void fileclusterlist_free(FileClusterList *fcl);
// Creates a cluster with items that must already be in the cluster list. Will fail (and make no
// changes) if any of the specified items isn't in the list, or if any of the items is already
else
{
if (parent_iter)
- match = filelist_sort_compare_filedata_full(fd, old_fd, SORT_NAME, TRUE); /* always sort sidecars by name */
+ {
+ /* always sort sidecars by name */
+ match = filelist_sort_compare_filedata_full(fd, old_fd, SORT_NAME, TRUE);
+ }
else
+ {
match = filelist_sort_compare_filedata_full(fd, old_fd, vf->sort_method, vf->sort_ascend);
+ }
if (match == 0) g_warning("multiple fd for the same path");
}
{
ViewFile *vf = data;
gboolean set;
+ FileData *fd;
gtk_tree_model_get(tree_model, iter, FILE_COLUMN_COLOR, &set, -1);
+ gtk_tree_model_get(tree_model, iter, FILE_COLUMN_POINTER, &fd, -1);
+ // TODO(xsdg): optimize!
+ if (fd)
+ {
+ FileCluster *fc = g_hash_table_lookup(vf->cluster_list->clusters, fd);
+ if (fc)
+ {
+ if (filecluster_has_head(fc, fd))
+ {
+ GdkColor *color_bg = g_new0(GdkColor, 1);
+ color_bg->blue = 0x4000;
+ color_bg->green = 0x4000;
+ color_bg->red = 0xFFFF;
+
+ g_object_set(G_OBJECT(cell),
+ "cell-background-gdk", color_bg,
+ "cell-background-set", TRUE, NULL);
+ return;
+ }
+ else if (filecluster_has_child(fc, fd))
+ {
+ GdkColor *color_bg = g_new0(GdkColor, 1);
+ color_bg->blue = 0x8000;
+ color_bg->green = 0x8000;
+ color_bg->red = 0xFFFF;
+
+ g_object_set(G_OBJECT(cell),
+ "cell-background-gdk", color_bg,
+ "cell-background-set", TRUE, NULL);
+ return;
+ }
+ }
+ }
+
g_object_set(G_OBJECT(cell),
"cell-background-gdk", vflist_listview_color_shifted(vf->listview),
"cell-background-set", set, NULL);