Commit ef467c87 authored by William Jon McCann's avatar William Jon McCann

Use a list model instead of a tree model

It is the list view after all. Tree models don't work well on
touch and it isn't consistent with the file chooser.

https://bugzilla.gnome.org/show_bug.cgi?id=676531
parent 6aac8892
...@@ -403,39 +403,31 @@ nautilus_list_model_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter, ...@@ -403,39 +403,31 @@ nautilus_list_model_iter_children (GtkTreeModel *tree_model, GtkTreeIter *iter,
{ {
NautilusListModel *model; NautilusListModel *model;
GSequence *files; GSequence *files;
FileEntry *file_entry;
model = (NautilusListModel *)tree_model; model = (NautilusListModel *)tree_model;
if (parent == NULL) {
files = model->details->files;
} else {
file_entry = g_sequence_get (parent->user_data);
files = file_entry->files;
}
if (files == NULL || g_sequence_get_length (files) == 0) { /* this is a list, nodes have no children */
if (parent != NULL) {
iter->stamp = 0;
return FALSE; return FALSE;
} }
iter->stamp = model->details->stamp;
iter->user_data = g_sequence_get_begin_iter (files);
return TRUE; 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;
return FALSE;
}
} }
static gboolean static gboolean
nautilus_list_model_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter) nautilus_list_model_iter_has_child (GtkTreeModel *tree_model, GtkTreeIter *iter)
{ {
FileEntry *file_entry; return FALSE;
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 static int
...@@ -443,15 +435,13 @@ nautilus_list_model_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter ...@@ -443,15 +435,13 @@ nautilus_list_model_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter
{ {
NautilusListModel *model; NautilusListModel *model;
GSequence *files; GSequence *files;
FileEntry *file_entry;
model = (NautilusListModel *)tree_model; model = (NautilusListModel *)tree_model;
if (iter == NULL) { if (iter == NULL) {
files = model->details->files; files = model->details->files;
} else { } else {
file_entry = g_sequence_get (iter->user_data); return 0;
files = file_entry->files;
} }
return g_sequence_get_length (files); return g_sequence_get_length (files);
...@@ -463,17 +453,16 @@ nautilus_list_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, ...@@ -463,17 +453,16 @@ nautilus_list_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter,
NautilusListModel *model; NautilusListModel *model;
GSequenceIter *child; GSequenceIter *child;
GSequence *files; GSequence *files;
FileEntry *file_entry;
model = (NautilusListModel *)tree_model; model = (NautilusListModel *)tree_model;
iter->stamp = 0;
if (parent != NULL) { if (parent != NULL) {
file_entry = g_sequence_get (parent->user_data); return FALSE;
files = file_entry->files;
} else {
files = model->details->files;
} }
files = model->details->files;
child = g_sequence_get_iter_at_pos (files, n); child = g_sequence_get_iter_at_pos (files, n);
if (g_sequence_iter_is_end (child)) { if (g_sequence_iter_is_end (child)) {
...@@ -489,21 +478,9 @@ nautilus_list_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter, ...@@ -489,21 +478,9 @@ nautilus_list_model_iter_nth_child (GtkTreeModel *tree_model, GtkTreeIter *iter,
static gboolean static gboolean
nautilus_list_model_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child) nautilus_list_model_iter_parent (GtkTreeModel *tree_model, GtkTreeIter *iter, GtkTreeIter *child)
{ {
NautilusListModel *model; iter->stamp = 0;
FileEntry *file_entry;
model = (NautilusListModel *)tree_model;
file_entry = g_sequence_get (child->user_data);
if (file_entry->parent == NULL) {
return FALSE;
}
iter->stamp = model->details->stamp; return FALSE;
iter->user_data = file_entry->parent->ptr;
return TRUE;
} }
static GSequenceIter * static GSequenceIter *
......
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