diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2013-02-11 15:17:07 -0500 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2013-02-11 19:48:18 -0500 |
commit | 9fd0e21817ef1392a2d1f81308ec835dd2fa373d (patch) | |
tree | cc1730031f6c3b78b8dc1271c6c4e84e8156d9b4 /src/nautilus-list-model.c | |
parent | d2c4cad5946de685ee567365e0c86d9343c6ad6b (diff) | |
download | nautilus-9fd0e21817ef1392a2d1f81308ec835dd2fa373d.tar.gz |
list-view: add back a treeview option
Re-add most of the code that handled the tree view in NautilusListModel
and NautilusListView, cleaned up and rebased to master.
The tree mode will be activated by a checkbox in the Preferences dialog.
Diffstat (limited to 'src/nautilus-list-model.c')
-rw-r--r-- | src/nautilus-list-model.c | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/src/nautilus-list-model.c b/src/nautilus-list-model.c index 6ddcac6a0..74faf7f14 100644 --- a/src/nautilus-list-model.c +++ b/src/nautilus-list-model.c @@ -397,31 +397,39 @@ nautilus_list_model_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, { NautilusListModel *model; GSequence *files; + FileEntry *file_entry; model = (NautilusListModel *)tree_model; - /* this is a list, nodes have no children */ - if (parent != NULL) { - iter->stamp = 0; - return FALSE; + if (parent == NULL) { + files = model->details->files; + } else { + file_entry = g_sequence_get (parent->user_data); + files = file_entry->files; } - files = model->details->files; - - if (g_sequence_get_length (files) > 0) { - iter->stamp = model->details->stamp; - iter->user_data = g_sequence_get_begin_iter (files); - return TRUE; - } else { - iter->stamp = 0; + if (files == NULL || g_sequence_get_length (files) == 0) { return FALSE; } + + iter->stamp = model->details->stamp; + iter->user_data = g_sequence_get_begin_iter (files); + + return TRUE; } static gboolean nautilus_list_model_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter) { - return FALSE; + FileEntry *file_entry; + + if (iter == NULL) { + return !nautilus_list_model_is_empty (NAUTILUS_LIST_MODEL (tree_model)); + } + + file_entry = g_sequence_get (iter->user_data); + + return (file_entry->files != NULL && g_sequence_get_length (file_entry->files) > 0); } static int @@ -429,13 +437,15 @@ nautilus_list_model_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter { NautilusListModel *model; GSequence *files; + FileEntry *file_entry; model = (NautilusListModel *)tree_model; if (iter == NULL) { files = model->details->files; } else { - return 0; + file_entry = g_sequence_get (iter->user_data); + files = file_entry->files; } return g_sequence_get_length (files); @@ -447,16 +457,17 @@ nautilus_list_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, NautilusListModel *model; GSequenceIter *child; GSequence *files; + FileEntry *file_entry; model = (NautilusListModel *)tree_model; - iter->stamp = 0; - if (parent != NULL) { - return FALSE; + file_entry = g_sequence_get (parent->user_data); + files = file_entry->files; + } else { + files = model->details->files; } - files = model->details->files; child = g_sequence_get_iter_at_pos (files, n); if (g_sequence_iter_is_end (child)) { @@ -472,9 +483,21 @@ nautilus_list_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, static gboolean nautilus_list_model_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child) { - iter->stamp = 0; + NautilusListModel *model; + FileEntry *file_entry; - return FALSE; + model = (NautilusListModel *)tree_model; + + file_entry = g_sequence_get (child->user_data); + + if (file_entry->parent == NULL) { + return FALSE; + } + + iter->stamp = model->details->stamp; + iter->user_data = file_entry->parent->ptr; + + return TRUE; } static GSequenceIter * |