[nautilus/wip/antoniof/flow-box-preparation: 11/13] view-item-model: Cleanup properties
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/flow-box-preparation: 11/13] view-item-model: Cleanup properties
- Date: Mon, 25 Oct 2021 19:17:13 +0000 (UTC)
commit c77c9e27d2c514b91ecd008012b2c300ceb46ba0
Author: António Fernandes <antoniof gnome org>
Date: Sun Aug 29 00:00:02 2021 +0100
view-item-model: Cleanup properties
Drop unused .label member.
Don't explicitly ::notify property changes.
Don't leak properties on destruction.
Make :file a contruct-only property and drop unused setter.
src/nautilus-view-item-model.c | 45 ++++++++++++++++++++----------------------
src/nautilus-view-item-model.h | 3 ---
2 files changed, 21 insertions(+), 27 deletions(-)
---
diff --git a/src/nautilus-view-item-model.c b/src/nautilus-view-item-model.c
index 1513aa45f..98d3de4a7 100644
--- a/src/nautilus-view-item-model.c
+++ b/src/nautilus-view-item-model.c
@@ -6,7 +6,6 @@ struct _NautilusViewItemModel
GObject parent_instance;
guint icon_size;
NautilusFile *file;
- GtkLabel *label;
GtkWidget *item_ui;
};
@@ -29,9 +28,23 @@ enum
static guint signals[LAST_SIGNAL];
+static void
+nautilus_view_item_model_dispose (GObject *object)
+{
+ NautilusViewItemModel *self = NAUTILUS_VIEW_ITEM_MODEL (object);
+
+ g_clear_object (&self->item_ui);
+
+ G_OBJECT_CLASS (nautilus_view_item_model_parent_class)->dispose (object);
+}
+
static void
nautilus_view_item_model_finalize (GObject *object)
{
+ NautilusViewItemModel *self = NAUTILUS_VIEW_ITEM_MODEL (object);
+
+ g_clear_object (&self->file);
+
G_OBJECT_CLASS (nautilus_view_item_model_parent_class)->finalize (object);
}
@@ -82,19 +95,19 @@ nautilus_view_item_model_set_property (GObject *object,
{
case PROP_FILE:
{
- nautilus_view_item_model_set_file (self, g_value_get_object (value));
+ self->file = g_value_dup_object (value);
}
break;
case PROP_ICON_SIZE:
{
- nautilus_view_item_model_set_icon_size (self, g_value_get_int (value));
+ self->icon_size = g_value_get_int (value);
}
break;
case PROP_ITEM_UI:
{
- nautilus_view_item_model_set_item_ui (self, g_value_get_object (value));
+ g_set_object (&self->item_ui, g_value_get_object (value));
}
break;
@@ -115,6 +128,7 @@ nautilus_view_item_model_class_init (NautilusViewItemModelClass *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;
@@ -134,7 +148,7 @@ nautilus_view_item_model_class_init (NautilusViewItemModelClass *klass)
"File",
"The file the icon item represents",
NAUTILUS_TYPE_FILE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_ITEM_UI,
@@ -177,9 +191,7 @@ nautilus_view_item_model_set_icon_size (NautilusViewItemModel *self,
{
g_return_if_fail (NAUTILUS_IS_VIEW_ITEM_MODEL (self));
- self->icon_size = icon_size;
-
- g_object_notify (G_OBJECT (self), "icon-size");
+ g_object_set (self, "icon-size", icon_size, NULL);
}
NautilusFile *
@@ -190,18 +202,6 @@ nautilus_view_item_model_get_file (NautilusViewItemModel *self)
return self->file;
}
-void
-nautilus_view_item_model_set_file (NautilusViewItemModel *self,
- NautilusFile *file)
-{
- g_return_if_fail (NAUTILUS_IS_VIEW_ITEM_MODEL (self));
-
- g_clear_object (&self->file);
- self->file = g_object_ref (file);
-
- g_object_notify (G_OBJECT (self), "file");
-}
-
GtkWidget *
nautilus_view_item_model_get_item_ui (NautilusViewItemModel *self)
{
@@ -216,10 +216,7 @@ nautilus_view_item_model_set_item_ui (NautilusViewItemModel *self,
{
g_return_if_fail (NAUTILUS_IS_VIEW_ITEM_MODEL (self));
- g_clear_object (&self->item_ui);
- self->item_ui = g_object_ref (item_ui);
-
- g_object_notify (G_OBJECT (self), "item-ui");
+ g_object_set (self, "item-ui", item_ui, NULL);
}
void
diff --git a/src/nautilus-view-item-model.h b/src/nautilus-view-item-model.h
index 9ee99c48f..a7986c9c3 100644
--- a/src/nautilus-view-item-model.h
+++ b/src/nautilus-view-item-model.h
@@ -19,9 +19,6 @@ void nautilus_view_item_model_set_icon_size (NautilusViewItemModel *self,
guint nautilus_view_item_model_get_icon_size (NautilusViewItemModel *self);
-void nautilus_view_item_model_set_file (NautilusViewItemModel *self,
- NautilusFile *file);
-
NautilusFile * nautilus_view_item_model_get_file (NautilusViewItemModel *self);
void nautilus_view_item_model_set_item_ui (NautilusViewItemModel *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]