diff options
author | António Fernandes <antoniof@gnome.org> | 2022-04-06 01:22:53 +0100 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2023-01-10 01:11:33 +0000 |
commit | d5ce96240ac0fc55ec64d3fcf756c84502f4e441 (patch) | |
tree | 3fc0ea463a1e3d6ed4ed05ace82021c29ad6098c /src/nautilus-view-model.c | |
parent | 510a4202d25b82323a1307918b382aab603190eb (diff) | |
download | nautilus-d5ce96240ac0fc55ec64d3fcf756c84502f4e441.tar.gz |
view-model: Expose row objects to the view
This is going to allow us to reuse the model for a GtkColumnView-based
list view with expanding trees support.
As documented, GtkTreeViewRow:item may be NULL when the item it held
is destroyed. So, we must take care to handle the NULL case when
expected and also warn and return when not expected.
Diffstat (limited to 'src/nautilus-view-model.c')
-rw-r--r-- | src/nautilus-view-model.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/nautilus-view-model.c b/src/nautilus-view-model.c index 3642d39f8..ba75d1649 100644 --- a/src/nautilus-view-model.c +++ b/src/nautilus-view-model.c @@ -49,7 +49,7 @@ get_child_row (NautilusViewModel *self, static GType nautilus_view_model_get_item_type (GListModel *list) { - return NAUTILUS_TYPE_VIEW_ITEM; + return GTK_TYPE_TREE_LIST_ROW; } static guint @@ -70,15 +70,13 @@ nautilus_view_model_get_item (GListModel *list, guint position) { NautilusViewModel *self = NAUTILUS_VIEW_MODEL (list); - g_autoptr (GtkTreeListRow) row = NULL; if (self->sort_model == NULL) { return NULL; } - row = g_list_model_get_item (G_LIST_MODEL (self->sort_model), position); - return gtk_tree_list_row_get_item (row); + return g_list_model_get_item (G_LIST_MODEL (self->sort_model), position); } static void @@ -338,7 +336,7 @@ nautilus_view_model_get_sorter (NautilusViewModel *self) row_sorter = GTK_TREE_LIST_ROW_SORTER (gtk_sort_list_model_get_sorter (self->sort_model)); - return gtk_tree_list_row_sorter_get_sorter (row_sorter); + return row_sorter != NULL ? gtk_tree_list_row_sorter_get_sorter (row_sorter) : NULL; } void |