[nautilus/wip/antoniof/flow-box-preparation: 39/70] icon-item-ui: Drop item model getter
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/flow-box-preparation: 39/70] icon-item-ui: Drop item model getter
- Date: Thu, 23 Dec 2021 01:06:25 +0000 (UTC)
commit f46c0929f9f8d0d4af835349c42a953ed5b2ab36
Author: António Fernandes <antoniof gnome org>
Date: Sat Dec 11 11:18:41 2021 +0000
icon-item-ui: Drop item model getter
In the GTK 4 list widgets paradigm, we are going to identify items by
either by pointer or by their position in the list model.
With GtkFlowBox we can get the position from GtkFlowBoxChild:index.
Therefore, we don't need a getter for the pointer.
src/nautilus-view-icon-controller.c | 23 +++++++++++++----------
src/nautilus-view-icon-item-ui.c | 6 ------
src/nautilus-view-icon-item-ui.h | 2 --
3 files changed, 13 insertions(+), 18 deletions(-)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index f8282d876..2094d8a48 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -286,7 +286,8 @@ real_get_selection (NautilusFilesView *files_view)
{
NautilusViewItemModel *item_model;
- item_model = nautilus_view_icon_item_ui_get_model (NAUTILUS_VIEW_ICON_ITEM_UI (l->data));
+ item_model = g_list_model_get_item (G_LIST_MODEL (self->model),
+ gtk_flow_box_child_get_index (l->data));
selected_files = g_list_prepend (selected_files,
g_object_ref (nautilus_view_item_model_get_file (item_model)));
}
@@ -704,7 +705,7 @@ on_button_press_event (GtkGestureMultiPress *gesture,
GdkEventSequence *sequence;
const GdkEvent *event;
g_autolist (NautilusFile) selection = NULL;
- GtkWidget *child_at_pos;
+ GtkFlowBoxChild *child_at_pos;
self = NAUTILUS_VIEW_ICON_CONTROLLER (user_data);
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
@@ -713,14 +714,14 @@ on_button_press_event (GtkGestureMultiPress *gesture,
/* Need to update the selection so the popup has the right actions enabled */
selection = nautilus_view_get_selection (NAUTILUS_VIEW (self));
- child_at_pos = GTK_WIDGET (gtk_flow_box_get_child_at_pos (self->view_ui,
- x, y));
+ child_at_pos = gtk_flow_box_get_child_at_pos (self->view_ui, x, y);
if (child_at_pos != NULL)
{
NautilusFile *selected_file;
NautilusViewItemModel *item_model;
- item_model = nautilus_view_icon_item_ui_get_model (NAUTILUS_VIEW_ICON_ITEM_UI (child_at_pos));
+ item_model = g_list_model_get_item (G_LIST_MODEL (self->model),
+ gtk_flow_box_child_get_index (child_at_pos));
selected_file = nautilus_view_item_model_get_file (item_model);
if (g_list_find (selection, selected_file) == NULL)
{
@@ -759,7 +760,7 @@ on_longpress_gesture_pressed_callback (GtkGestureLongPress *gesture,
{
NautilusViewIconController *self;
g_autoptr (GList) selection = NULL;
- GtkWidget *child_at_pos;
+ GtkFlowBoxChild *child_at_pos;
GdkEventButton *event_button;
GdkEventSequence *event_sequence;
GdkEvent *event;
@@ -772,14 +773,15 @@ on_longpress_gesture_pressed_callback (GtkGestureLongPress *gesture,
/* Need to update the selection so the popup has the right actions enabled */
selection = nautilus_view_get_selection (NAUTILUS_VIEW (self));
- child_at_pos = GTK_WIDGET (gtk_flow_box_get_child_at_pos (self->view_ui,
- event_button->x, event_button->y));
+ child_at_pos = gtk_flow_box_get_child_at_pos (self->view_ui,
+ event_button->x, event_button->y);
if (child_at_pos != NULL)
{
NautilusFile *selected_file;
NautilusViewItemModel *item_model;
- item_model = nautilus_view_icon_item_ui_get_model (NAUTILUS_VIEW_ICON_ITEM_UI (child_at_pos));
+ item_model = g_list_model_get_item (G_LIST_MODEL (self->model),
+ gtk_flow_box_child_get_index (child_at_pos));
selected_file = nautilus_view_item_model_get_file (item_model);
if (g_list_find (selection, selected_file) == NULL)
{
@@ -990,7 +992,8 @@ on_child_activated (GtkFlowBox *flow_box,
guint keyval;
gboolean is_preview = FALSE;
- item_model = nautilus_view_icon_item_ui_get_model (NAUTILUS_VIEW_ICON_ITEM_UI (child));
+ item_model = g_list_model_get_item (G_LIST_MODEL (self->model),
+ gtk_flow_box_child_get_index (child));
file = nautilus_view_item_model_get_file (item_model);
list = g_list_append (list, file);
diff --git a/src/nautilus-view-icon-item-ui.c b/src/nautilus-view-icon-item-ui.c
index 4a534e864..157c3e680 100644
--- a/src/nautilus-view-icon-item-ui.c
+++ b/src/nautilus-view-icon-item-ui.c
@@ -204,9 +204,3 @@ nautilus_view_icon_item_ui_new (NautilusViewItemModel *model)
"model", model,
NULL);
}
-
-NautilusViewItemModel *
-nautilus_view_icon_item_ui_get_model (NautilusViewIconItemUi *self)
-{
- return self->model;
-}
diff --git a/src/nautilus-view-icon-item-ui.h b/src/nautilus-view-icon-item-ui.h
index 55b09b1f1..577769a92 100644
--- a/src/nautilus-view-icon-item-ui.h
+++ b/src/nautilus-view-icon-item-ui.h
@@ -13,6 +13,4 @@ G_DECLARE_FINAL_TYPE (NautilusViewIconItemUi, nautilus_view_icon_item_ui, NAUTIL
NautilusViewIconItemUi * nautilus_view_icon_item_ui_new (NautilusViewItemModel *item_model);
-NautilusViewItemModel * nautilus_view_icon_item_ui_get_model (NautilusViewIconItemUi *self);
-
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]