[libhandy] window-mixin: Implement destroy()
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy] window-mixin: Implement destroy()
- Date: Wed, 10 Jun 2020 11:44:03 +0000 (UTC)
commit 86c1e2457aa7e3846757209f8c77bc6e9764c905
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Jun 10 09:11:00 2020 +0500
window-mixin: Implement destroy()
GtkContainer only automatically removes non-internal children, i.e. in case
of Hdy(Application)Window the child inside the HdyDeck, but leaves the deck
and the titlebar intact. This causes problems, remove them on destroy()
explicitly.
Fixes https://gitlab.gnome.org/GNOME/libhandy/-/issues/289
Signed-off-by: Alexander Mikhaylenko <alexm gnome org>
src/hdy-application-window.c | 7 +++++++
src/hdy-window-mixin-private.h | 1 +
src/hdy-window-mixin.c | 17 +++++++++++++++++
src/hdy-window.c | 7 +++++++
4 files changed, 32 insertions(+)
---
diff --git a/src/hdy-application-window.c b/src/hdy-application-window.c
index e0e9b464..d3979cf3 100644
--- a/src/hdy-application-window.c
+++ b/src/hdy-application-window.c
@@ -72,6 +72,12 @@ hdy_application_window_draw (GtkWidget *widget,
return hdy_window_mixin_draw (HDY_GET_WINDOW_MIXIN (widget), cr);
}
+static void
+hdy_application_window_destroy (GtkWidget *widget)
+{
+ hdy_window_mixin_destroy (HDY_GET_WINDOW_MIXIN (widget));
+}
+
static void
hdy_application_window_finalize (GObject *object)
{
@@ -92,6 +98,7 @@ hdy_application_window_class_init (HdyApplicationWindowClass *klass)
object_class->finalize = hdy_application_window_finalize;
widget_class->draw = hdy_application_window_draw;
+ widget_class->destroy = hdy_application_window_destroy;
container_class->add = hdy_application_window_add;
container_class->remove = hdy_application_window_remove;
container_class->forall = hdy_application_window_forall;
diff --git a/src/hdy-window-mixin-private.h b/src/hdy-window-mixin-private.h
index c02962f8..27ce713c 100644
--- a/src/hdy-window-mixin-private.h
+++ b/src/hdy-window-mixin-private.h
@@ -32,6 +32,7 @@ void hdy_window_mixin_forall (HdyWindowMixin *self,
gboolean hdy_window_mixin_draw (HdyWindowMixin *self,
cairo_t *cr);
+void hdy_window_mixin_destroy (HdyWindowMixin *self);
void hdy_window_mixin_buildable_add_child (HdyWindowMixin *self,
GtkBuilder *builder,
diff --git a/src/hdy-window-mixin.c b/src/hdy-window-mixin.c
index 5de0350b..a765d267 100644
--- a/src/hdy-window-mixin.c
+++ b/src/hdy-window-mixin.c
@@ -467,6 +467,23 @@ hdy_window_mixin_draw (HdyWindowMixin *self,
return GDK_EVENT_PROPAGATE;
}
+void
+hdy_window_mixin_destroy (HdyWindowMixin *self)
+{
+ if (self->titlebar) {
+ hdy_window_mixin_remove (self, self->titlebar);
+ self->titlebar = NULL;
+ }
+
+ if (self->content) {
+ hdy_window_mixin_remove (self, self->content);
+ self->content = NULL;
+ self->child = NULL;
+ }
+
+ GTK_WIDGET_CLASS (self->klass)->destroy (GTK_WIDGET (self->window));
+}
+
void
hdy_window_mixin_buildable_add_child (HdyWindowMixin *self,
GtkBuilder *builder,
diff --git a/src/hdy-window.c b/src/hdy-window.c
index bccea242..5165b552 100644
--- a/src/hdy-window.c
+++ b/src/hdy-window.c
@@ -118,6 +118,12 @@ hdy_window_draw (GtkWidget *widget,
return hdy_window_mixin_draw (HDY_GET_WINDOW_MIXIN (widget), cr);
}
+static void
+hdy_window_destroy (GtkWidget *widget)
+{
+ hdy_window_mixin_destroy (HDY_GET_WINDOW_MIXIN (widget));
+}
+
static void
hdy_window_finalize (GObject *object)
{
@@ -138,6 +144,7 @@ hdy_window_class_init (HdyWindowClass *klass)
object_class->finalize = hdy_window_finalize;
widget_class->draw = hdy_window_draw;
+ widget_class->destroy = hdy_window_destroy;
container_class->add = hdy_window_add;
container_class->remove = hdy_window_remove;
container_class->forall = hdy_window_forall;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]