Commit 589a9ea9 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Add fm_tree_model_iter_compare_roots to compare roots Report dummy rows

2008-02-19  Alexander Larsson  <alexl@redhat.com>

        * src/file-manager/fm-tree-model.[ch]:
        Add fm_tree_model_iter_compare_roots to compare roots
        Report dummy rows added before reporting has_child_toggled.
	
        * src/file-manager/fm-tree-view.c:
        (compare_rows):
	Use fm_tree_model_iter_compare_roots when comparing roots
	to force a stable sort, because GtkTreeModelSort isn't stable.


svn path=/trunk/; revision=13773
parent 69a8b942
2008-02-19 Alexander Larsson <alexl@redhat.com>
* src/file-manager/fm-tree-model.[ch]:
Add fm_tree_model_iter_compare_roots to compare roots
Report dummy rows added before reporting has_child_toggled.
* src/file-manager/fm-tree-view.c:
(compare_rows):
Use fm_tree_model_iter_compare_roots when comparing roots
to force a stable sort, because GtkTreeModelSort isn't stable.
2008-02-19 Cosimo Cecchi <cosimoc@gnome.org>
* libnautilus-private/nautilus-file-operations.c:
......
......@@ -667,12 +667,13 @@ report_node_inserted (FMTreeModel *model, TreeNode *node)
report_row_inserted (model, &iter);
node->inserted = TRUE;
if (tree_node_has_dummy_child (node)) {
report_dummy_row_inserted (model, node);
}
if (node->directory != NULL ||
node->parent == NULL) {
report_row_has_child_toggled (model, &iter);
}
if (tree_node_has_dummy_child (node)) {
report_dummy_row_inserted (model, node);
}
}
......@@ -1767,6 +1768,40 @@ fm_tree_model_iter_get_file (FMTreeModel *model, GtkTreeIter *iter)
return node == NULL ? NULL : nautilus_file_ref (node->file);
}
/* This is used to work around some sort order stability problems
with gtktreemodelsort */
int
fm_tree_model_iter_compare_roots (FMTreeModel *model,
GtkTreeIter *iter_a,
GtkTreeIter *iter_b)
{
TreeNode *a, *b, *n;
g_return_val_if_fail (FM_IS_TREE_MODEL (model), 0);
g_return_val_if_fail (iter_is_valid (model, iter_a), 0);
g_return_val_if_fail (iter_is_valid (model, iter_b), 0);
a = iter_a->user_data;
b = iter_b->user_data;
g_assert (a != NULL && a->parent == NULL);
g_assert (b != NULL && b->parent == NULL);
if (a == b) {
return 0;
}
for (n = model->details->root_node; n != NULL; n = n->next) {
if (n == a) {
return -1;
}
if (n == b) {
return 1;
}
}
g_assert_not_reached ();
}
gboolean
fm_tree_model_iter_is_root (FMTreeModel *model, GtkTreeIter *iter)
{
......
......@@ -81,6 +81,9 @@ void fm_tree_model_remove_root_uri (FMTreeModel *model,
const char *root_uri);
gboolean fm_tree_model_iter_is_root (FMTreeModel *model,
GtkTreeIter *iter);
int fm_tree_model_iter_compare_roots (FMTreeModel *model,
GtkTreeIter *iter_a,
GtkTreeIter *iter_b);
gboolean fm_tree_model_file_get_iter (FMTreeModel *model,
GtkTreeIter *iter,
NautilusFile *file,
......
......@@ -507,9 +507,9 @@ compare_rows (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer call
}
/* don't sort root nodes */
if (fm_tree_model_iter_is_root (FM_TREE_MODEL (model), a)
|| fm_tree_model_iter_is_root (FM_TREE_MODEL (model), b)) {
return 0;
if (fm_tree_model_iter_is_root (FM_TREE_MODEL (model), a) &&
fm_tree_model_iter_is_root (FM_TREE_MODEL (model), b)) {
return fm_tree_model_iter_compare_roots (FM_TREE_MODEL (model), a, b);
}
file_a = fm_tree_model_iter_get_file (FM_TREE_MODEL (model), a);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment