[nautilus/wip/antoniof/flowbox-to-gridview: 5/14] view-icon-item-ui: Don't subclass GtkFlowBoxChild
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/flowbox-to-gridview: 5/14] view-icon-item-ui: Don't subclass GtkFlowBoxChild
- Date: Wed, 2 Feb 2022 18:00:33 +0000 (UTC)
commit b0fe88b9282f8f60da972f0776dca9c831b58060
Author: António Fernandes <antoniof gnome org>
Date: Mon Jan 24 11:14:53 2022 +0000
view-icon-item-ui: Don't subclass GtkFlowBoxChild
In order to ease the transition to GtkGridView.
src/nautilus-view-icon-controller.c | 18 ++-
src/nautilus-view-icon-item-ui.c | 4 +-
src/nautilus-view-icon-item-ui.h | 2 +-
src/resources/ui/nautilus-view-icon-item-ui.ui | 146 ++++++++++++-------------
4 files changed, 86 insertions(+), 84 deletions(-)
---
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index 88d20c22a..f13cabdb1 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -423,7 +423,7 @@ get_first_selected_item_ui (NautilusViewIconController *self)
file = NAUTILUS_FILE (selection->data);
item_model = nautilus_view_model_get_item_from_file (self->model, file);
i = nautilus_view_model_get_index (self->model, item_model);
- return GTK_WIDGET (gtk_flow_box_get_child_at_index (self->view_ui, i));
+ return gtk_flow_box_child_get_child (gtk_flow_box_get_child_at_index (self->view_ui, i));
}
static void
@@ -1008,7 +1008,7 @@ scroll_to_file_on_idle (ScrollToFileData *data)
file = nautilus_file_get_existing_by_uri (data->uri);
item = nautilus_view_model_get_item_from_file (self->model, file);
i = nautilus_view_model_get_index (self->model, item);
- item_ui = GTK_WIDGET (gtk_flow_box_get_child_at_index (self->view_ui, i));
+ item_ui = gtk_flow_box_child_get_child (gtk_flow_box_get_child_at_index (self->view_ui, i));
gtk_widget_translate_coordinates (item_ui, GTK_WIDGET (self->view_ui),
0, 0,
NULL, &item_y);
@@ -1294,7 +1294,11 @@ bind_item_ui (GtkWidget **child,
NautilusViewItemModel *item_model,
gpointer user_data)
{
- nautilus_view_icon_item_ui_set_model (NAUTILUS_VIEW_ICON_ITEM_UI (*child),
+ GtkWidget *item_ui;
+
+ item_ui = gtk_flow_box_child_get_child (GTK_FLOW_BOX_CHILD (*child));
+
+ nautilus_view_icon_item_ui_set_model (NAUTILUS_VIEW_ICON_ITEM_UI (item_ui),
item_model);
nautilus_view_item_model_set_item_ui (item_model, *child);
}
@@ -1309,8 +1313,12 @@ setup_item_ui (GtkWidget **child,
item_ui = nautilus_view_icon_item_ui_new ();
nautilus_view_item_ui_set_caption_attributes (item_ui, self->caption_attributes);
- *child = GTK_WIDGET (item_ui);
- gtk_widget_show (*child);
+ *child = gtk_flow_box_child_new ();
+ gtk_flow_box_child_set_child (GTK_FLOW_BOX_CHILD (*child),
+ GTK_WIDGET (item_ui));
+
+ gtk_widget_set_halign (*child, GTK_ALIGN_CENTER);
+ gtk_widget_set_valign (*child, GTK_ALIGN_START);
}
static GtkWidget *
diff --git a/src/nautilus-view-icon-item-ui.c b/src/nautilus-view-icon-item-ui.c
index 8bb1e2abe..b638f5315 100644
--- a/src/nautilus-view-icon-item-ui.c
+++ b/src/nautilus-view-icon-item-ui.c
@@ -5,7 +5,7 @@
struct _NautilusViewIconItemUi
{
- GtkFlowBoxChild parent_instance;
+ GtkBox parent_instance;
NautilusViewItemModel *model;
GQuark *caption_attributes;
@@ -18,7 +18,7 @@ struct _NautilusViewIconItemUi
GtkWidget *third_caption;
};
-G_DEFINE_TYPE (NautilusViewIconItemUi, nautilus_view_icon_item_ui, GTK_TYPE_FLOW_BOX_CHILD)
+G_DEFINE_TYPE (NautilusViewIconItemUi, nautilus_view_icon_item_ui, GTK_TYPE_BOX)
enum
{
diff --git a/src/nautilus-view-icon-item-ui.h b/src/nautilus-view-icon-item-ui.h
index 5caed4700..09fcf7f0c 100644
--- a/src/nautilus-view-icon-item-ui.h
+++ b/src/nautilus-view-icon-item-ui.h
@@ -17,7 +17,7 @@ enum
#define NAUTILUS_TYPE_VIEW_ICON_ITEM_UI (nautilus_view_icon_item_ui_get_type())
-G_DECLARE_FINAL_TYPE (NautilusViewIconItemUi, nautilus_view_icon_item_ui, NAUTILUS, VIEW_ICON_ITEM_UI,
GtkFlowBoxChild)
+G_DECLARE_FINAL_TYPE (NautilusViewIconItemUi, nautilus_view_icon_item_ui, NAUTILUS, VIEW_ICON_ITEM_UI,
GtkBox)
NautilusViewIconItemUi * nautilus_view_icon_item_ui_new (void);
void nautilus_view_icon_item_ui_set_model (NautilusViewIconItemUi *self,
diff --git a/src/resources/ui/nautilus-view-icon-item-ui.ui b/src/resources/ui/nautilus-view-icon-item-ui.ui
index f23e43964..9ee63b684 100644
--- a/src/resources/ui/nautilus-view-icon-item-ui.ui
+++ b/src/resources/ui/nautilus-view-icon-item-ui.ui
@@ -1,97 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
- <template class="NautilusViewIconItemUi" parent="GtkFlowBoxChild">
+ <template class="NautilusViewIconItemUi" parent="GtkBox">
+ <property name="orientation">vertical</property>
<property name="halign">center</property>
<property name="valign">start</property>
- <property name="child">
- <object class="GtkBox">
+ <child>
+ <object class="GtkBox" id="fixed_height_box">
<property name="orientation">vertical</property>
<property name="halign">center</property>
- <property name="valign">start</property>
+ <property name="height-request">96</property>
+ <property name="valign">center</property>
+ <property name="width-request">96</property>
<child>
- <object class="GtkBox" id="fixed_height_box">
- <property name="orientation">vertical</property>
+ <object class="GtkPicture" id="icon">
<property name="halign">center</property>
- <property name="height-request">96</property>
+ <property name="hexpand">True</property>
<property name="valign">center</property>
- <property name="width-request">96</property>
- <child>
- <object class="GtkPicture" id="icon">
- <property name="halign">center</property>
- <property name="hexpand">True</property>
- <property name="valign">center</property>
- <property name="vexpand">True</property>
- <property name="can-shrink">False</property>
- </object>
- </child>
+ <property name="vexpand">True</property>
+ <property name="can-shrink">False</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="valign">start</property>
+ <style>
+ <class name="icon-ui-labels-box"/>
+ </style>
+ <child>
+ <object class="GtkLabel" id="label">
+ <property name="ellipsize">middle</property>
+ <property name="justify">center</property>
+ <property name="lines">3</property>
+ <property name="max-width-chars">0</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">word-char</property>
+ <attributes>
+ <attribute name="insert-hyphens" value="false"></attribute>
+ </attributes>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="first_caption">
+ <property name="ellipsize">end</property>
+ <property name="justify">center</property>
+ <property name="lines">2</property>
+ <property name="max-width-chars">0</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">word-char</property>
+ <property name="valign">start</property>
+ <style>
+ <class name="caption"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="second_caption">
+ <property name="ellipsize">end</property>
+ <property name="justify">center</property>
+ <property name="lines">2</property>
+ <property name="max-width-chars">0</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">word-char</property>
+ <property name="valign">start</property>
+ <style>
+ <class name="caption"/>
+ </style>
</object>
</child>
<child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
+ <object class="GtkLabel" id="third_caption">
+ <property name="ellipsize">end</property>
+ <property name="justify">center</property>
+ <property name="lines">2</property>
+ <property name="max-width-chars">0</property>
+ <property name="wrap">True</property>
+ <property name="wrap-mode">word-char</property>
<property name="valign">start</property>
<style>
- <class name="icon-ui-labels-box"/>
+ <class name="caption"/>
</style>
- <child>
- <object class="GtkLabel" id="label">
- <property name="ellipsize">middle</property>
- <property name="justify">center</property>
- <property name="lines">3</property>
- <property name="max-width-chars">0</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <attributes>
- <attribute name="insert-hyphens" value="false"></attribute>
- </attributes>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="first_caption">
- <property name="ellipsize">end</property>
- <property name="justify">center</property>
- <property name="lines">2</property>
- <property name="max-width-chars">0</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <property name="valign">start</property>
- <style>
- <class name="caption"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="second_caption">
- <property name="ellipsize">end</property>
- <property name="justify">center</property>
- <property name="lines">2</property>
- <property name="max-width-chars">0</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <property name="valign">start</property>
- <style>
- <class name="caption"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="third_caption">
- <property name="ellipsize">end</property>
- <property name="justify">center</property>
- <property name="lines">2</property>
- <property name="max-width-chars">0</property>
- <property name="wrap">True</property>
- <property name="wrap-mode">word-char</property>
- <property name="valign">start</property>
- <style>
- <class name="caption"/>
- </style>
- </object>
- </child>
</object>
</child>
</object>
- </property>
+ </child>
</template>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]