{
FileCluster *fc = g_hash_table_lookup(fcl->clusters, fd);
if (!fc) return FALSE;
- return fc->head->data == fd;
+ return filecluster_fd_equal(fc->head->data, 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_fd_equal(fc->head->data, 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_fd_equal(fc->head->data, fd);
}
// TODO(xsdg): pick a better name for this function
ViewFile *vf = data;
GtkTreePath *tpath;
+ // DO NOT SUBMIT
+ // TODO(xsdg): these key combos should be handled by the standard, configurable mechanism.
+
+ if (event->keyval == GDK_KEY_Insert || event->keyval == GDK_KEY_F2)
+ {
+ // First off, get the selected FDs
+ GList *selected_fds = NULL;
+ {
+ GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vf->listview));
+ if (event->keyval == GDK_KEY_Insert)
+ {
+ if (gtk_tree_selection_count_selected_rows(selection) < 2)
+ {
+ g_warning("Need at least two items selected to create a cluster.");
+ return TRUE;
+ }
+ }
+ else
+ {
+ if (gtk_tree_selection_count_selected_rows(selection) < 1)
+ {
+ g_warning("Must have a node selected to flip show_children.");
+ return TRUE;
+ }
+ }
+
+ // List of GtkTreePath
+ GList *selected_rows = gtk_tree_selection_get_selected_rows(selection, NULL);
+ GtkTreeModel *store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview));
+ GtkTreeIter iter;
+ for (GList *work = selected_rows; work; work = work->next)
+ {
+ FileData *fd;
+ GtkTreePath *select_path = work->data;
+ gtk_tree_model_get_iter(store, &iter, select_path);
+ gtk_tree_model_get(store, &iter, FILE_COLUMN_POINTER, &fd, -1);
+ selected_fds = g_list_prepend(selected_fds, file_data_ref(fd));
+ }
+
+ selected_fds = g_list_reverse(selected_fds);
+ g_list_free_full(selected_rows, (GDestroyNotify)gtk_tree_path_free);
+ }
+
+ if (event->keyval == GDK_KEY_Insert)
+ {
+ g_warning("Starting a cluster!");
+ FileCluster *fc = fileclusterlist_create_cluster(vf->cluster_list, selected_fds);
+ if (fc)
+ {
+ // TODO(xsdg): mark as in a cluster somehow?
+ vf_refresh(vf);
+ }
+ }
+ else if (event->keyval == GDK_KEY_F2)
+ {
+ FileData *fd = selected_fds->data;
+ if (fd)
+ {
+ g_warning("Flipping show_children!");
+ FileCluster *fc = g_hash_table_lookup(vf->cluster_list->clusters, fd);
+ if (fc)
+ {
+ filecluster_toggle_show_children(fc);
+ vf_refresh(vf);
+ }
+ }
+ }
+
+ return TRUE; // Handled event; stop propagating.
+ }
+
if (event->keyval != GDK_KEY_Menu) return FALSE;
gtk_tree_view_get_cursor(GTK_TREE_VIEW(vf->listview), &tpath, NULL);