[nautilus/wip/antoniof/new-list-view-without-expanders: 19/27] view-item-model: Rename to NautilusViewItem
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/new-list-view-without-expanders: 19/27] view-item-model: Rename to NautilusViewItem
- Date: Tue, 21 Jun 2022 18:55:19 +0000 (UTC)
commit 18d24be0b0beac53b0d0f3cca8eeea0c0067a6d6
Author: António Fernandes <antoniof gnome org>
Date: Fri Jun 10 19:44:39 2022 +0100
view-item-model: Rename to NautilusViewItem
This is both shorter and more aligned with the convention to call
GListModel elements "item".
Also add missing copyright notices with SPDX licence id.
src/meson.build | 4 +-
src/nautilus-grid-cell.c | 16 +--
src/nautilus-grid-view.c | 16 +--
src/nautilus-list-base.c | 118 ++++++++++-----------
src/nautilus-view-cell.c | 14 +--
src/nautilus-view-cell.h | 6 +-
src/nautilus-view-item-model.h | 32 ------
...ilus-view-item-model.c => nautilus-view-item.c} | 99 +++++++++--------
src/nautilus-view-item.h | 38 +++++++
src/nautilus-view-model.c | 42 ++++----
src/nautilus-view-model.h | 10 +-
11 files changed, 203 insertions(+), 192 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 7cb59efc4..910b64842 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -130,8 +130,8 @@ libnautilus_sources = [
'nautilus-view.h',
'nautilus-view-cell.c',
'nautilus-view-cell.h',
- 'nautilus-view-item-model.c',
- 'nautilus-view-item-model.h',
+ 'nautilus-view-item.c',
+ 'nautilus-view-item.h',
'nautilus-view-model.c',
'nautilus-view-model.h',
'nautilus-window-slot.c',
diff --git a/src/nautilus-grid-cell.c b/src/nautilus-grid-cell.c
index 3b6d5d2e5..b692475a2 100644
--- a/src/nautilus-grid-cell.c
+++ b/src/nautilus-grid-cell.c
@@ -29,7 +29,7 @@ G_DEFINE_TYPE (NautilusGridCell, nautilus_grid_cell, NAUTILUS_TYPE_VIEW_CELL)
static void
update_icon (NautilusGridCell *self)
{
- NautilusViewItemModel *item;
+ NautilusViewItem *item;
NautilusFileIconFlags flags;
g_autoptr (GdkPaintable) icon_paintable = NULL;
GtkStyleContext *style_context;
@@ -39,8 +39,8 @@ update_icon (NautilusGridCell *self)
item = nautilus_view_cell_get_item (NAUTILUS_VIEW_CELL (self));
g_return_if_fail (item != NULL);
- file = nautilus_view_item_model_get_file (item);
- icon_size = nautilus_view_item_model_get_icon_size (item);
+ file = nautilus_view_item_get_file (item);
+ icon_size = nautilus_view_item_get_icon_size (item);
flags = NAUTILUS_FILE_ICON_FLAGS_USE_THUMBNAILS |
NAUTILUS_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE |
NAUTILUS_FILE_ICON_FLAGS_USE_EMBLEMS |
@@ -74,7 +74,7 @@ update_icon (NautilusGridCell *self)
static void
update_captions (NautilusGridCell *self)
{
- NautilusViewItemModel *item;
+ NautilusViewItem *item;
NautilusFile *file;
GtkWidget * const caption_labels[] =
{
@@ -86,7 +86,7 @@ update_captions (NautilusGridCell *self)
item = nautilus_view_cell_get_item (NAUTILUS_VIEW_CELL (self));
g_return_if_fail (item != NULL);
- file = nautilus_view_item_model_get_file (item);
+ file = nautilus_view_item_get_file (item);
for (guint i = 0; i < NAUTILUS_GRID_CELL_N_CAPTIONS; i++)
{
GQuark attribute_q = self->caption_attributes[i];
@@ -106,12 +106,12 @@ update_captions (NautilusGridCell *self)
static void
on_file_changed (NautilusGridCell *self)
{
- NautilusViewItemModel *item;
+ NautilusViewItem *item;
NautilusFile *file;
item = nautilus_view_cell_get_item (NAUTILUS_VIEW_CELL (self));
g_return_if_fail (item != NULL);
- file = nautilus_view_item_model_get_file (item);
+ file = nautilus_view_item_get_file (item);
update_icon (self);
@@ -178,7 +178,7 @@ nautilus_grid_cell_init (NautilusGridCell *self)
gtk_widget_init_template (GTK_WIDGET (self));
/* Connect automatically to an item. */
- self->item_signal_group = g_signal_group_new (NAUTILUS_TYPE_VIEW_ITEM_MODEL);
+ self->item_signal_group = g_signal_group_new (NAUTILUS_TYPE_VIEW_ITEM);
g_signal_group_connect_swapped (self->item_signal_group, "notify::icon-size",
(GCallback) on_item_size_changed, self);
g_signal_group_connect_swapped (self->item_signal_group, "notify::is-cut",
diff --git a/src/nautilus-grid-view.c b/src/nautilus-grid-view.c
index d4ab61d6a..dd263ac5a 100644
--- a/src/nautilus-grid-view.c
+++ b/src/nautilus-grid-view.c
@@ -40,8 +40,8 @@ nautilus_grid_view_sort (gconstpointer a,
NautilusFile *file_a;
NautilusFile *file_b;
- file_a = nautilus_view_item_model_get_file (NAUTILUS_VIEW_ITEM_MODEL ((gpointer) a));
- file_b = nautilus_view_item_model_get_file (NAUTILUS_VIEW_ITEM_MODEL ((gpointer) b));
+ file_a = nautilus_view_item_get_file (NAUTILUS_VIEW_ITEM ((gpointer) a));
+ file_b = nautilus_view_item_get_file (NAUTILUS_VIEW_ITEM ((gpointer) b));
return nautilus_file_compare_for_sort (file_a, file_b,
self->sort_type,
@@ -349,12 +349,12 @@ bind_cell (GtkSignalListItemFactory *factory,
gpointer user_data)
{
GtkWidget *cell;
- NautilusViewItemModel *item_model;
+ NautilusViewItem *item;
cell = gtk_list_item_get_child (listitem);
- item_model = NAUTILUS_VIEW_ITEM_MODEL (gtk_list_item_get_item (listitem));
+ item = NAUTILUS_VIEW_ITEM (gtk_list_item_get_item (listitem));
- nautilus_view_item_model_set_item_ui (item_model, cell);
+ nautilus_view_item_set_item_ui (item, cell);
if (nautilus_view_cell_once (NAUTILUS_VIEW_CELL (cell)))
{
@@ -378,11 +378,11 @@ unbind_cell (GtkSignalListItemFactory *factory,
GtkListItem *listitem,
gpointer user_data)
{
- NautilusViewItemModel *item_model;
+ NautilusViewItem *item;
- item_model = NAUTILUS_VIEW_ITEM_MODEL (gtk_list_item_get_item (listitem));
+ item = NAUTILUS_VIEW_ITEM (gtk_list_item_get_item (listitem));
- nautilus_view_item_model_set_item_ui (item_model, NULL);
+ nautilus_view_item_set_item_ui (item, NULL);
}
static void
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c
index 4d35df869..2ced625b3 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -8,7 +8,7 @@
#include "nautilus-clipboard.h"
#include "nautilus-view-cell.h"
-#include "nautilus-view-item-model.h"
+#include "nautilus-view-item.h"
#include "nautilus-view-model.h"
#include "nautilus-files-view.h"
#include "nautilus-file.h"
@@ -93,11 +93,11 @@ static const SortConstants sorts_constants[] =
},
};
-static inline NautilusViewItemModel *
+static inline NautilusViewItem *
get_view_item (GListModel *model,
guint position)
{
- return NAUTILUS_VIEW_ITEM_MODEL (g_list_model_get_item (model, position));
+ return NAUTILUS_VIEW_ITEM (g_list_model_get_item (model, position));
}
static const SortConstants *
@@ -219,10 +219,10 @@ nautilus_list_base_set_icon_size (NautilusListBase *self,
n_items = g_list_model_get_n_items (model);
for (guint i = 0; i < n_items; i++)
{
- g_autoptr (NautilusViewItemModel) current_item_model = NULL;
+ g_autoptr (NautilusViewItem) current_item = NULL;
- current_item_model = get_view_item (model, i);
- nautilus_view_item_model_set_icon_size (current_item_model, icon_size);
+ current_item = get_view_item (model, i);
+ nautilus_view_item_set_icon_size (current_item, icon_size);
}
}
@@ -231,8 +231,8 @@ nautilus_list_base_set_icon_size (NautilusListBase *self,
* or open its context menu. This helper should be used in these situations if
* it's desirable to act on a multi-item selection, because it preserves it. */
static void
-select_single_item_if_not_selected (NautilusListBase *self,
- NautilusViewItemModel *item)
+select_single_item_if_not_selected (NautilusListBase *self,
+ NautilusViewItem *item)
{
NautilusViewModel *model;
guint position;
@@ -272,7 +272,7 @@ on_item_click_pressed (GtkGestureClick *gesture,
NautilusViewCell *cell = user_data;
NautilusListBase *self = NAUTILUS_LIST_BASE (nautilus_view_cell_get_view (cell));
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
- NautilusViewItemModel *item;
+ NautilusViewItem *item;
guint button;
GdkModifierType modifiers;
gboolean selection_mode;
@@ -334,7 +334,7 @@ on_item_click_released (GtkGestureClick *gesture,
if (priv->activate_on_release)
{
NautilusViewModel *model;
- NautilusViewItemModel *item;
+ NautilusViewItem *item;
guint i;
model = nautilus_list_base_get_model (NAUTILUS_LIST_BASE (self));
@@ -556,10 +556,10 @@ real_file_changed (NautilusFilesView *files_view,
{
NautilusListBase *self = NAUTILUS_LIST_BASE (files_view);
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
- NautilusViewItemModel *item_model;
+ NautilusViewItem *item;
- item_model = nautilus_view_model_get_item_from_file (priv->model, file);
- nautilus_view_item_model_file_changed (item_model);
+ item = nautilus_view_model_get_item_from_file (priv->model, file);
+ nautilus_view_item_file_changed (item);
}
static GList *
@@ -575,11 +575,11 @@ real_get_selection (NautilusFilesView *files_view)
n_selected = g_list_model_get_n_items (G_LIST_MODEL (selection));
for (guint i = 0; i < n_selected; i++)
{
- g_autoptr (NautilusViewItemModel) item_model = NULL;
+ g_autoptr (NautilusViewItem) item = NULL;
- item_model = get_view_item (G_LIST_MODEL (selection), i);
+ item = get_view_item (G_LIST_MODEL (selection), i);
selected_files = g_list_prepend (selected_files,
- g_object_ref (nautilus_view_item_model_get_file (item_model)));
+ g_object_ref (nautilus_view_item_get_file (item)));
}
return selected_files;
@@ -606,12 +606,12 @@ real_remove_file (NautilusFilesView *files_view,
{
NautilusListBase *self = NAUTILUS_LIST_BASE (files_view);
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
- NautilusViewItemModel *item_model;
+ NautilusViewItem *item;
- item_model = nautilus_view_model_get_item_from_file (priv->model, file);
- if (item_model != NULL)
+ item = nautilus_view_model_get_item_from_file (priv->model, file);
+ if (item != NULL)
{
- nautilus_view_model_remove_item (priv->model, item_model);
+ nautilus_view_model_remove_item (priv->model, item);
}
}
@@ -631,8 +631,8 @@ convert_glist_to_queue (GList *list)
}
static GQueue *
-convert_files_to_item_models (NautilusListBase *self,
- GQueue *files)
+convert_files_to_items (NautilusListBase *self,
+ GQueue *files)
{
GList *l;
GQueue *models;
@@ -640,11 +640,11 @@ convert_files_to_item_models (NautilusListBase *self,
models = g_queue_new ();
for (l = g_queue_peek_head_link (files); l != NULL; l = l->next)
{
- NautilusViewItemModel *item_model;
+ NautilusViewItem *item;
- item_model = nautilus_view_item_model_new (NAUTILUS_FILE (l->data),
- nautilus_list_base_get_icon_size (self));
- g_queue_push_tail (models, item_model);
+ item = nautilus_view_item_new (NAUTILUS_FILE (l->data),
+ nautilus_list_base_get_icon_size (self));
+ g_queue_push_tail (models, item);
}
return models;
@@ -657,7 +657,7 @@ real_set_selection (NautilusFilesView *files_view,
NautilusListBase *self = NAUTILUS_LIST_BASE (files_view);
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
g_autoptr (GQueue) selection_files = NULL;
- g_autoptr (GQueue) selection_item_models = NULL;
+ g_autoptr (GQueue) selection_items = NULL;
g_autoptr (GtkBitset) update_set = NULL;
g_autoptr (GtkBitset) selection_set = NULL;
@@ -666,8 +666,8 @@ real_set_selection (NautilusFilesView *files_view,
/* Convert file list into set of model indices */
selection_files = convert_glist_to_queue (selection);
- selection_item_models = nautilus_view_model_get_items_from_files (priv->model, selection_files);
- for (GList *l = g_queue_peek_head_link (selection_item_models); l != NULL; l = l->next)
+ selection_items = nautilus_view_model_get_items_from_files (priv->model, selection_files);
+ for (GList *l = g_queue_peek_head_link (selection_items); l != NULL; l = l->next)
{
gtk_bitset_add (selection_set,
nautilus_view_model_get_index (priv->model, l->data));
@@ -716,7 +716,7 @@ get_first_selected_item (NautilusListBase *self)
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
g_autolist (NautilusFile) selection = NULL;
NautilusFile *file;
- NautilusViewItemModel *item_model;
+ NautilusViewItem *item;
selection = nautilus_view_get_selection (NAUTILUS_VIEW (self));
if (selection == NULL)
@@ -725,9 +725,9 @@ get_first_selected_item (NautilusListBase *self)
}
file = NAUTILUS_FILE (selection->data);
- item_model = nautilus_view_model_get_item_from_file (priv->model, file);
+ item = nautilus_view_model_get_item_from_file (priv->model, file);
- return nautilus_view_model_get_index (priv->model, item_model);
+ return nautilus_view_model_get_index (priv->model, item);
}
static void
@@ -788,8 +788,8 @@ real_compare_files (NautilusFilesView *files_view,
NautilusListBase *self = NAUTILUS_LIST_BASE (files_view);
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
GtkSorter *sorter;
- g_autoptr (NautilusViewItemModel) item1 = NULL;
- g_autoptr (NautilusViewItemModel) item2 = NULL;
+ g_autoptr (NautilusViewItem) item1 = NULL;
+ g_autoptr (NautilusViewItem) item2 = NULL;
sorter = nautilus_view_model_get_sorter (priv->model);
if (sorter == NULL)
@@ -798,8 +798,8 @@ real_compare_files (NautilusFilesView *files_view,
}
/* Generate fake model items for sorter use only. */
- item1 = nautilus_view_item_model_new (file1, NAUTILUS_GRID_ICON_SIZE_SMALL);
- item2 = nautilus_view_item_model_new (file2, NAUTILUS_GRID_ICON_SIZE_SMALL);
+ item1 = nautilus_view_item_new (file1, NAUTILUS_GRID_ICON_SIZE_SMALL);
+ item2 = nautilus_view_item_new (file2, NAUTILUS_GRID_ICON_SIZE_SMALL);
return gtk_sorter_compare (sorter, item1, item2);
}
@@ -813,14 +813,14 @@ on_clipboard_contents_received (GObject *source_object,
NautilusListBase *self = NAUTILUS_LIST_BASE (files_view);
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
NautilusClipboard *clip;
- NautilusViewItemModel *item;
+ NautilusViewItem *item;
for (GList *l = priv->cut_files; l != NULL; l = l->next)
{
item = nautilus_view_model_get_item_from_file (priv->model, l->data);
if (item != NULL)
{
- nautilus_view_item_model_set_cut (item, FALSE);
+ nautilus_view_item_set_cut (item, FALSE);
}
}
g_clear_list (&priv->cut_files, g_object_unref);
@@ -838,7 +838,7 @@ on_clipboard_contents_received (GObject *source_object,
item = nautilus_view_model_get_item_from_file (priv->model, l->data);
if (item != NULL)
{
- nautilus_view_item_model_set_cut (item, TRUE);
+ nautilus_view_item_set_cut (item, TRUE);
}
}
}
@@ -878,11 +878,11 @@ get_first_visible_item (NautilusListBase *self)
view_ui = nautilus_list_base_get_view_ui (self);
for (guint i = 0; i < n_items; i++)
{
- g_autoptr (NautilusViewItemModel) item = NULL;
+ g_autoptr (NautilusViewItem) item = NULL;
GtkWidget *item_ui;
item = get_view_item (G_LIST_MODEL (priv->model), i);
- item_ui = nautilus_view_item_model_get_item_ui (item);
+ item_ui = nautilus_view_item_get_item_ui (item);
if (item_ui != NULL)
{
gdouble y;
@@ -905,14 +905,14 @@ real_get_first_visible_file (NautilusFilesView *files_view)
NautilusListBase *self = NAUTILUS_LIST_BASE (files_view);
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
guint i;
- g_autoptr (NautilusViewItemModel) item = NULL;
+ g_autoptr (NautilusViewItem) item = NULL;
gchar *uri = NULL;
i = get_first_visible_item (self);
if (i < G_MAXUINT)
{
item = get_view_item (G_LIST_MODEL (priv->model), i);
- uri = nautilus_file_get_uri (nautilus_view_item_model_get_file (item));
+ uri = nautilus_file_get_uri (nautilus_view_item_get_file (item));
}
return uri;
}
@@ -936,7 +936,7 @@ scroll_to_file_on_idle (ScrollToFileData *data)
NautilusListBase *self = data->view;
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
g_autoptr (NautilusFile) file = NULL;
- NautilusViewItemModel *item;
+ NautilusViewItem *item;
guint i;
file = nautilus_file_get_existing_by_uri (data->uri);
@@ -975,12 +975,12 @@ real_add_files (NautilusFilesView *files_view,
NautilusListBase *self = NAUTILUS_LIST_BASE (files_view);
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
g_autoptr (GQueue) files_queue = NULL;
- g_autoptr (GQueue) item_models = NULL;
+ g_autoptr (GQueue) items = NULL;
gdouble adjustment_value;
files_queue = convert_glist_to_queue (files);
- item_models = convert_files_to_item_models (self, files_queue);
- nautilus_view_model_add_items (priv->model, item_models);
+ items = convert_files_to_items (self, files_queue);
+ nautilus_view_model_add_items (priv->model, items);
/* GtkListBase anchoring doesn't cope well with our lazy loading.
* Assuming that GtkListBase|list.scroll-to-item resets the anchor to 0, use
@@ -997,7 +997,7 @@ real_select_first (NautilusFilesView *files_view)
{
NautilusListBase *self = NAUTILUS_LIST_BASE (files_view);
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
- g_autoptr (NautilusViewItemModel) item = NULL;
+ g_autoptr (NautilusViewItem) item = NULL;
NautilusFile *file;
g_autoptr (GList) selection = NULL;
@@ -1006,7 +1006,7 @@ real_select_first (NautilusFilesView *files_view)
{
return;
}
- file = nautilus_view_item_model_get_file (item);
+ file = nautilus_view_item_get_file (item);
selection = g_list_prepend (selection, file);
nautilus_view_set_selection (NAUTILUS_VIEW (files_view), selection);
}
@@ -1038,12 +1038,12 @@ real_compute_rename_popover_pointing_to (NautilusFilesView *files_view)
{
NautilusListBase *self = NAUTILUS_LIST_BASE (files_view);
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
- g_autoptr (NautilusViewItemModel) item = NULL;
+ g_autoptr (NautilusViewItem) item = NULL;
GtkWidget *item_ui;
/* We only allow one item to be renamed with a popover */
item = get_view_item (G_LIST_MODEL (priv->model), get_first_selected_item (self));
- item_ui = nautilus_view_item_model_get_item_ui (item);
+ item_ui = nautilus_view_item_get_item_ui (item);
g_return_val_if_fail (item_ui != NULL, NULL);
return get_rectangle_for_item_ui (self, item_ui);
@@ -1069,10 +1069,10 @@ real_reveal_for_selection_context_menu (NautilusFilesView *files_view)
focus_child = gtk_widget_get_focus_child (nautilus_list_base_get_view_ui (self));
for (i = 0; i < n_selected; i++)
{
- g_autoptr (NautilusViewItemModel) item = NULL;
+ g_autoptr (NautilusViewItem) item = NULL;
item = get_view_item (G_LIST_MODEL (selection), i);
- item_ui = nautilus_view_item_model_get_item_ui (item);
+ item_ui = nautilus_view_item_get_item_ui (item);
if (item_ui != NULL && gtk_widget_get_parent (item_ui) == focus_child)
{
break;
@@ -1141,7 +1141,7 @@ prioritize_thumbnailing_on_idle (NautilusListBase *self)
guint next_index;
gdouble y;
guint last_index;
- g_autoptr (NautilusViewItemModel) first_item = NULL;
+ g_autoptr (NautilusViewItem) first_item = NULL;
NautilusFile *file;
priv->prioritize_thumbnailing_handle_id = 0;
@@ -1155,14 +1155,14 @@ prioritize_thumbnailing_on_idle (NautilusListBase *self)
first_item = get_view_item (G_LIST_MODEL (priv->model), first_index);
- first_visible_child = nautilus_view_item_model_get_item_ui (first_item);
+ first_visible_child = nautilus_view_item_get_item_ui (first_item);
for (next_index = first_index + 1; next_index < g_list_model_get_n_items (G_LIST_MODEL (priv->model));
next_index++)
{
- g_autoptr (NautilusViewItemModel) next_item = NULL;
+ g_autoptr (NautilusViewItem) next_item = NULL;
next_item = get_view_item (G_LIST_MODEL (priv->model), next_index);
- next_child = nautilus_view_item_model_get_item_ui (next_item);
+ next_child = nautilus_view_item_get_item_ui (next_item);
if (next_child == NULL)
{
break;
@@ -1181,12 +1181,12 @@ prioritize_thumbnailing_on_idle (NautilusListBase *self)
/* Do the iteration in reverse to give higher priority to the top */
for (gint i = 0; i <= last_index - first_index; i++)
{
- g_autoptr (NautilusViewItemModel) item = NULL;
+ g_autoptr (NautilusViewItem) item = NULL;
item = get_view_item (G_LIST_MODEL (priv->model), last_index - i);
g_return_val_if_fail (item != NULL, G_SOURCE_REMOVE);
- file = nautilus_view_item_model_get_file (NAUTILUS_VIEW_ITEM_MODEL (item));
+ file = nautilus_view_item_get_file (NAUTILUS_VIEW_ITEM (item));
if (file != NULL && nautilus_file_is_thumbnailing (file))
{
g_autofree gchar *uri = nautilus_file_get_uri (file);
diff --git a/src/nautilus-view-cell.c b/src/nautilus-view-cell.c
index 0a184f0d0..bd5fb30d8 100644
--- a/src/nautilus-view-cell.c
+++ b/src/nautilus-view-cell.c
@@ -25,7 +25,7 @@ struct _NautilusViewCellPrivate
AdwBin parent_instance;
NautilusListBase *view; /* Unowned */
- NautilusViewItemModel *item; /* Owned reference */
+ NautilusViewItem *item; /* Owned reference */
gboolean called_once;
};
@@ -134,7 +134,7 @@ nautilus_view_cell_class_init (NautilusViewCellClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS);
properties[PROP_ITEM] = g_param_spec_object ("item",
"", "",
- NAUTILUS_TYPE_VIEW_ITEM_MODEL,
+ NAUTILUS_TYPE_VIEW_ITEM,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties);
@@ -167,19 +167,19 @@ nautilus_view_cell_get_view (NautilusViewCell *self)
}
void
-nautilus_view_cell_set_item (NautilusViewCell *self,
- NautilusViewItemModel *item)
+nautilus_view_cell_set_item (NautilusViewCell *self,
+ NautilusViewItem *item)
{
g_return_if_fail (NAUTILUS_IS_VIEW_CELL (self));
- g_return_if_fail (item == NULL || NAUTILUS_IS_VIEW_ITEM_MODEL (item));
+ g_return_if_fail (item == NULL || NAUTILUS_IS_VIEW_ITEM (item));
g_object_set (self, "item", item, NULL);
}
-NautilusViewItemModel *
+NautilusViewItem *
nautilus_view_cell_get_item (NautilusViewCell *self)
{
- NautilusViewItemModel *item;
+ NautilusViewItem *item;
g_return_val_if_fail (NAUTILUS_IS_VIEW_CELL (self), NULL);
diff --git a/src/nautilus-view-cell.h b/src/nautilus-view-cell.h
index 6093752eb..78297b82d 100644
--- a/src/nautilus-view-cell.h
+++ b/src/nautilus-view-cell.h
@@ -9,7 +9,7 @@
#include <libadwaita-1/adwaita.h>
#include "nautilus-types.h"
-#include "nautilus-view-item-model.h"
+#include "nautilus-view-item.h"
G_BEGIN_DECLS
@@ -24,8 +24,8 @@ struct _NautilusViewCellClass
NautilusListBase *nautilus_view_cell_get_view (NautilusViewCell *self);
void nautilus_view_cell_set_item (NautilusViewCell *self,
- NautilusViewItemModel *item);
-NautilusViewItemModel *nautilus_view_cell_get_item (NautilusViewCell *self);
+ NautilusViewItem *item);
+NautilusViewItem *nautilus_view_cell_get_item (NautilusViewCell *self);
gboolean nautilus_view_cell_once (NautilusViewCell *self);
G_END_DECLS
diff --git a/src/nautilus-view-item-model.c b/src/nautilus-view-item.c
similarity index 62%
rename from src/nautilus-view-item-model.c
rename to src/nautilus-view-item.c
index 6cc3f54f5..daf186399 100644
--- a/src/nautilus-view-item-model.c
+++ b/src/nautilus-view-item.c
@@ -1,7 +1,12 @@
-#include "nautilus-view-item-model.h"
-#include "nautilus-file.h"
+/*
+ * Copyright (C) 2022 The GNOME project contributors
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
-struct _NautilusViewItemModel
+#include "nautilus-view-item.h"
+
+struct _NautilusViewItem
{
GObject parent_instance;
guint icon_size;
@@ -10,7 +15,7 @@ struct _NautilusViewItemModel
GtkWidget *item_ui;
};
-G_DEFINE_TYPE (NautilusViewItemModel, nautilus_view_item_model, G_TYPE_OBJECT)
+G_DEFINE_TYPE (NautilusViewItem, nautilus_view_item, G_TYPE_OBJECT)
enum
{
@@ -31,32 +36,32 @@ enum
static guint signals[LAST_SIGNAL];
static void
-nautilus_view_item_model_dispose (GObject *object)
+nautilus_view_item_dispose (GObject *object)
{
- NautilusViewItemModel *self = NAUTILUS_VIEW_ITEM_MODEL (object);
+ NautilusViewItem *self = NAUTILUS_VIEW_ITEM (object);
g_clear_object (&self->item_ui);
- G_OBJECT_CLASS (nautilus_view_item_model_parent_class)->dispose (object);
+ G_OBJECT_CLASS (nautilus_view_item_parent_class)->dispose (object);
}
static void
-nautilus_view_item_model_finalize (GObject *object)
+nautilus_view_item_finalize (GObject *object)
{
- NautilusViewItemModel *self = NAUTILUS_VIEW_ITEM_MODEL (object);
+ NautilusViewItem *self = NAUTILUS_VIEW_ITEM (object);
g_clear_object (&self->file);
- G_OBJECT_CLASS (nautilus_view_item_model_parent_class)->finalize (object);
+ G_OBJECT_CLASS (nautilus_view_item_parent_class)->finalize (object);
}
static void
-nautilus_view_item_model_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+nautilus_view_item_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- NautilusViewItemModel *self = NAUTILUS_VIEW_ITEM_MODEL (object);
+ NautilusViewItem *self = NAUTILUS_VIEW_ITEM (object);
switch (prop_id)
{
@@ -92,12 +97,12 @@ nautilus_view_item_model_get_property (GObject *object,
}
static void
-nautilus_view_item_model_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+nautilus_view_item_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- NautilusViewItemModel *self = NAUTILUS_VIEW_ITEM_MODEL (object);
+ NautilusViewItem *self = NAUTILUS_VIEW_ITEM (object);
switch (prop_id)
{
@@ -133,19 +138,19 @@ nautilus_view_item_model_set_property (GObject *object,
}
static void
-nautilus_view_item_model_init (NautilusViewItemModel *self)
+nautilus_view_item_init (NautilusViewItem *self)
{
}
static void
-nautilus_view_item_model_class_init (NautilusViewItemModelClass *klass)
+nautilus_view_item_class_init (NautilusViewItemClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = nautilus_view_item_model_dispose;
- object_class->finalize = nautilus_view_item_model_finalize;
- object_class->get_property = nautilus_view_item_model_get_property;
- object_class->set_property = nautilus_view_item_model_set_property;
+ object_class->dispose = nautilus_view_item_dispose;
+ object_class->finalize = nautilus_view_item_finalize;
+ object_class->get_property = nautilus_view_item_get_property;
+ object_class->set_property = nautilus_view_item_set_property;
g_object_class_install_property (object_class,
PROP_ICON_SIZE,
@@ -187,71 +192,71 @@ nautilus_view_item_model_class_init (NautilusViewItemModelClass *klass)
G_TYPE_NONE, 0);
}
-NautilusViewItemModel *
-nautilus_view_item_model_new (NautilusFile *file,
- guint icon_size)
+NautilusViewItem *
+nautilus_view_item_new (NautilusFile *file,
+ guint icon_size)
{
- return g_object_new (NAUTILUS_TYPE_VIEW_ITEM_MODEL,
+ return g_object_new (NAUTILUS_TYPE_VIEW_ITEM,
"file", file,
"icon-size", icon_size,
NULL);
}
guint
-nautilus_view_item_model_get_icon_size (NautilusViewItemModel *self)
+nautilus_view_item_get_icon_size (NautilusViewItem *self)
{
- g_return_val_if_fail (NAUTILUS_IS_VIEW_ITEM_MODEL (self), -1);
+ g_return_val_if_fail (NAUTILUS_IS_VIEW_ITEM (self), -1);
return self->icon_size;
}
void
-nautilus_view_item_model_set_icon_size (NautilusViewItemModel *self,
- guint icon_size)
+nautilus_view_item_set_icon_size (NautilusViewItem *self,
+ guint icon_size)
{
- g_return_if_fail (NAUTILUS_IS_VIEW_ITEM_MODEL (self));
+ g_return_if_fail (NAUTILUS_IS_VIEW_ITEM (self));
g_object_set (self, "icon-size", icon_size, NULL);
}
void
-nautilus_view_item_model_set_cut (NautilusViewItemModel *self,
- gboolean is_cut)
+nautilus_view_item_set_cut (NautilusViewItem *self,
+ gboolean is_cut)
{
- g_return_if_fail (NAUTILUS_IS_VIEW_ITEM_MODEL (self));
+ g_return_if_fail (NAUTILUS_IS_VIEW_ITEM (self));
g_object_set (self, "is-cut", is_cut, NULL);
}
NautilusFile *
-nautilus_view_item_model_get_file (NautilusViewItemModel *self)
+nautilus_view_item_get_file (NautilusViewItem *self)
{
- g_return_val_if_fail (NAUTILUS_IS_VIEW_ITEM_MODEL (self), NULL);
+ g_return_val_if_fail (NAUTILUS_IS_VIEW_ITEM (self), NULL);
return self->file;
}
GtkWidget *
-nautilus_view_item_model_get_item_ui (NautilusViewItemModel *self)
+nautilus_view_item_get_item_ui (NautilusViewItem *self)
{
- g_return_val_if_fail (NAUTILUS_IS_VIEW_ITEM_MODEL (self), NULL);
+ g_return_val_if_fail (NAUTILUS_IS_VIEW_ITEM (self), NULL);
return self->item_ui;
}
void
-nautilus_view_item_model_set_item_ui (NautilusViewItemModel *self,
- GtkWidget *item_ui)
+nautilus_view_item_set_item_ui (NautilusViewItem *self,
+ GtkWidget *item_ui)
{
- g_return_if_fail (NAUTILUS_IS_VIEW_ITEM_MODEL (self));
+ g_return_if_fail (NAUTILUS_IS_VIEW_ITEM (self));
g_object_set (self, "item-ui", item_ui, NULL);
}
void
-nautilus_view_item_model_file_changed (NautilusViewItemModel *self)
+nautilus_view_item_file_changed (NautilusViewItem *self)
{
- g_return_if_fail (NAUTILUS_IS_VIEW_ITEM_MODEL (self));
+ g_return_if_fail (NAUTILUS_IS_VIEW_ITEM (self));
g_signal_emit (self, signals[FILE_CHANGED], 0);
}
diff --git a/src/nautilus-view-item.h b/src/nautilus-view-item.h
new file mode 100644
index 000000000..5e620520a
--- /dev/null
+++ b/src/nautilus-view-item.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2022 The GNOME project contributors
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "nautilus-file.h"
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_VIEW_ITEM (nautilus_view_item_get_type())
+
+G_DECLARE_FINAL_TYPE (NautilusViewItem, nautilus_view_item, NAUTILUS, VIEW_ITEM, GObject)
+
+NautilusViewItem * nautilus_view_item_new (NautilusFile *file,
+ guint icon_size);
+
+void nautilus_view_item_set_icon_size (NautilusViewItem *self,
+ guint icon_size);
+
+guint nautilus_view_item_get_icon_size (NautilusViewItem *self);
+void nautilus_view_item_set_cut (NautilusViewItem *self,
+ gboolean is_cut);
+
+NautilusFile * nautilus_view_item_get_file (NautilusViewItem *self);
+
+void nautilus_view_item_set_item_ui (NautilusViewItem *self,
+ GtkWidget *item_ui);
+
+GtkWidget * nautilus_view_item_get_item_ui (NautilusViewItem *self);
+void nautilus_view_item_file_changed (NautilusViewItem *self);
+
+G_END_DECLS
diff --git a/src/nautilus-view-model.c b/src/nautilus-view-model.c
index 3b7c793cd..72fd8a79e 100644
--- a/src/nautilus-view-model.c
+++ b/src/nautilus-view-model.c
@@ -1,5 +1,5 @@
#include "nautilus-view-model.h"
-#include "nautilus-view-item-model.h"
+#include "nautilus-view-item.h"
#include "nautilus-global-preferences.h"
struct _NautilusViewModel
@@ -16,7 +16,7 @@ struct _NautilusViewModel
static GType
nautilus_view_model_get_item_type (GListModel *list)
{
- return NAUTILUS_TYPE_VIEW_ITEM_MODEL;
+ return NAUTILUS_TYPE_VIEW_ITEM;
}
static guint
@@ -215,7 +215,7 @@ constructed (GObject *object)
G_OBJECT_CLASS (nautilus_view_model_parent_class)->constructed (object);
- self->internal_model = g_list_store_new (NAUTILUS_TYPE_VIEW_ITEM_MODEL);
+ self->internal_model = g_list_store_new (NAUTILUS_TYPE_VIEW_ITEM);
self->selection_model = gtk_multi_selection_new (g_object_ref (G_LIST_MODEL (self->internal_model)));
self->map_files_to_model = g_hash_table_new (NULL, NULL);
@@ -306,10 +306,10 @@ nautilus_view_model_get_items_from_files (NautilusViewModel *self,
{
GList *l;
guint n_items;
- GQueue *item_models;
+ GQueue *items;
n_items = g_list_model_get_n_items (G_LIST_MODEL (self->internal_model));
- item_models = g_queue_new ();
+ items = g_queue_new ();
for (l = g_queue_peek_head_link (files); l != NULL; l = l->next)
{
NautilusFile *file1;
@@ -317,27 +317,27 @@ nautilus_view_model_get_items_from_files (NautilusViewModel *self,
file1 = NAUTILUS_FILE (l->data);
for (guint i = 0; i < n_items; i++)
{
- g_autoptr (NautilusViewItemModel) item_model = NULL;
+ g_autoptr (NautilusViewItem) item = NULL;
NautilusFile *file2;
g_autofree gchar *file1_uri = NULL;
g_autofree gchar *file2_uri = NULL;
- item_model = g_list_model_get_item (G_LIST_MODEL (self->internal_model), i);
- file2 = nautilus_view_item_model_get_file (item_model);
+ item = g_list_model_get_item (G_LIST_MODEL (self->internal_model), i);
+ file2 = nautilus_view_item_get_file (item);
file1_uri = nautilus_file_get_uri (file1);
file2_uri = nautilus_file_get_uri (file2);
if (g_strcmp0 (file1_uri, file2_uri) == 0)
{
- g_queue_push_tail (item_models, item_model);
+ g_queue_push_tail (items, item);
break;
}
}
}
- return item_models;
+ return items;
}
-NautilusViewItemModel *
+NautilusViewItem *
nautilus_view_model_get_item_from_file (NautilusViewModel *self,
NautilusFile *file)
{
@@ -345,8 +345,8 @@ nautilus_view_model_get_item_from_file (NautilusViewModel *self,
}
void
-nautilus_view_model_remove_item (NautilusViewModel *self,
- NautilusViewItemModel *item)
+nautilus_view_model_remove_item (NautilusViewModel *self,
+ NautilusViewItem *item)
{
guint i;
@@ -354,7 +354,7 @@ nautilus_view_model_remove_item (NautilusViewModel *self,
{
NautilusFile *file;
- file = nautilus_view_item_model_get_file (item);
+ file = nautilus_view_item_get_file (item);
g_list_store_remove (self->internal_model, i);
g_hash_table_remove (self->map_files_to_model, file);
}
@@ -368,11 +368,11 @@ nautilus_view_model_remove_all_items (NautilusViewModel *self)
}
void
-nautilus_view_model_add_item (NautilusViewModel *self,
- NautilusViewItemModel *item)
+nautilus_view_model_add_item (NautilusViewModel *self,
+ NautilusViewItem *item)
{
g_hash_table_insert (self->map_files_to_model,
- nautilus_view_item_model_get_file (item),
+ nautilus_view_item_get_file (item),
item);
g_list_store_insert_sorted (self->internal_model, item, compare_data_func, self);
}
@@ -386,13 +386,13 @@ nautilus_view_model_add_items (NautilusViewModel *self,
int i = 0;
array = g_malloc_n (g_queue_get_length (items),
- sizeof (NautilusViewItemModel *));
+ sizeof (NautilusViewItem *));
for (l = g_queue_peek_head_link (items); l != NULL; l = l->next)
{
array[i] = l->data;
g_hash_table_insert (self->map_files_to_model,
- nautilus_view_item_model_get_file (l->data),
+ nautilus_view_item_get_file (l->data),
l->data);
i++;
}
@@ -405,8 +405,8 @@ nautilus_view_model_add_items (NautilusViewModel *self,
}
guint
-nautilus_view_model_get_index (NautilusViewModel *self,
- NautilusViewItemModel *item)
+nautilus_view_model_get_index (NautilusViewModel *self,
+ NautilusViewItem *item)
{
guint i = G_MAXUINT;
gboolean found;
diff --git a/src/nautilus-view-model.h b/src/nautilus-view-model.h
index d76c3987d..839c6d2c7 100644
--- a/src/nautilus-view-model.h
+++ b/src/nautilus-view-model.h
@@ -2,7 +2,7 @@
#include <glib.h>
#include "nautilus-file.h"
-#include "nautilus-view-item-model.h"
+#include "nautilus-view-item.h"
G_BEGIN_DECLS
@@ -15,20 +15,20 @@ NautilusViewModel * nautilus_view_model_new (void);
GtkSorter *nautilus_view_model_get_sorter (NautilusViewModel *self);
void nautilus_view_model_set_sorter (NautilusViewModel *self,
GtkSorter *sorter);
-NautilusViewItemModel * nautilus_view_model_get_item_from_file (NautilusViewModel *self,
+NautilusViewItem * nautilus_view_model_get_item_from_file (NautilusViewModel *self,
NautilusFile *file);
GQueue * nautilus_view_model_get_items_from_files (NautilusViewModel *self,
GQueue *files);
/* Don't use inside a loop, use nautilus_view_model_remove_all_items instead. */
void nautilus_view_model_remove_item (NautilusViewModel *self,
- NautilusViewItemModel *item);
+ NautilusViewItem *item);
void nautilus_view_model_remove_all_items (NautilusViewModel *self);
/* Don't use inside a loop, use nautilus_view_model_add_items instead. */
void nautilus_view_model_add_item (NautilusViewModel *self,
- NautilusViewItemModel *item);
+ NautilusViewItem *item);
void nautilus_view_model_add_items (NautilusViewModel *self,
GQueue *items);
guint nautilus_view_model_get_index (NautilusViewModel *self,
- NautilusViewItemModel *item);
+ NautilusViewItem *item);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]