[gtk: 1/2] gtk: Have GtkCenterLayout hold a reference to its widgets
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 1/2] gtk: Have GtkCenterLayout hold a reference to its widgets
- Date: Thu, 3 Mar 2022 19:38:29 +0000 (UTC)
commit 4a2a76c2317aa5f1ecc1e5c9a212faf2716eca48
Author: Jason Francis <jafrancis999 gmail com>
Date: Wed Mar 2 19:49:39 2022 -0500
gtk: Have GtkCenterLayout hold a reference to its widgets
gtk/gtkcenterlayout.c | 38 ++++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/gtk/gtkcenterlayout.c b/gtk/gtkcenterlayout.c
index 18bed9ddb9..72db233550 100644
--- a/gtk/gtkcenterlayout.c
+++ b/gtk/gtkcenterlayout.c
@@ -523,11 +523,26 @@ gtk_center_layout_allocate (GtkLayoutManager *layout_manager,
}
}
+static void
+gtk_center_layout_dispose (GObject *object)
+{
+ GtkCenterLayout *self = GTK_CENTER_LAYOUT (object);
+
+ g_clear_object (&self->start_widget);
+ g_clear_object (&self->center_widget);
+ g_clear_object (&self->end_widget);
+
+ G_OBJECT_CLASS (gtk_center_layout_parent_class)->dispose (object);
+}
+
static void
gtk_center_layout_class_init (GtkCenterLayoutClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkLayoutManagerClass *layout_class = GTK_LAYOUT_MANAGER_CLASS (klass);
+ object_class->dispose = gtk_center_layout_dispose;
+
layout_class->get_request_mode = gtk_center_layout_get_request_mode;
layout_class->measure = gtk_center_layout_measure;
layout_class->allocate = gtk_center_layout_allocate;
@@ -641,11 +656,8 @@ gtk_center_layout_set_start_widget (GtkCenterLayout *self,
g_return_if_fail (GTK_IS_CENTER_LAYOUT (self));
g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
- if (self->start_widget == widget)
- return;
-
- self->start_widget = widget;
- gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
+ if (g_set_object (&self->start_widget, widget))
+ gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
}
/**
@@ -680,11 +692,8 @@ gtk_center_layout_set_center_widget (GtkCenterLayout *self,
g_return_if_fail (GTK_IS_CENTER_LAYOUT (self));
g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
- if (self->center_widget == widget)
- return;
-
- self->center_widget = widget;
- gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
+ if (g_set_object (&self->center_widget, widget))
+ gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
}
/**
@@ -706,7 +715,7 @@ gtk_center_layout_get_center_widget (GtkCenterLayout *self)
/**
* gtk_center_layout_set_end_widget:
* @self: a `GtkCenterLayout`
- * @widget: (nullable) (transfer none): the new end widget
+ * @widget: (nullable): the new end widget
*
* Sets the new end widget of @self.
*
@@ -719,11 +728,8 @@ gtk_center_layout_set_end_widget (GtkCenterLayout *self,
g_return_if_fail (GTK_IS_CENTER_LAYOUT (self));
g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
- if (self->end_widget == widget)
- return;
-
- self->end_widget = widget;
- gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
+ if (g_set_object (&self->end_widget, widget))
+ gtk_layout_manager_layout_changed (GTK_LAYOUT_MANAGER (self));
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]