[gnome-builder/wip/gtk4-port: 588/1774] libide/gui: add observation helpers for panes
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 588/1774] libide/gui: add observation helpers for panes
- Date: Mon, 11 Jul 2022 22:31:17 +0000 (UTC)
commit fc2d89ec482a6b6e585905246feb2fe844469175
Author: Christian Hergert <chergert redhat com>
Date: Mon Apr 18 06:08:55 2022 -0700
libide/gui: add observation helpers for panes
This can be useful so we can track panes without all the manual signal
connection wiring. We will still use signals for that with the new
destroyed signal on PanelWidget, but the helpers mean we are more likely
to get the tracking right in plugins where the panels might need to be
released or could have otherwise already been released.
src/libide/gui/ide-pane.c | 39 +++++++++++++++++++++++++++++++++++++++
src/libide/gui/ide-pane.h | 12 ++++++++++--
2 files changed, 49 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/gui/ide-pane.c b/src/libide/gui/ide-pane.c
index 63aabd011..6405bf321 100644
--- a/src/libide/gui/ide-pane.c
+++ b/src/libide/gui/ide-pane.c
@@ -62,3 +62,42 @@ ide_pane_destroy (IdePane *self)
if ((frame = gtk_widget_get_ancestor (GTK_WIDGET (self), PANEL_TYPE_FRAME)))
panel_frame_remove (PANEL_FRAME (frame), PANEL_WIDGET (self));
}
+
+void
+ide_pane_observe (IdePane *self,
+ IdePane **location)
+{
+ g_return_if_fail (IDE_IS_PANE (self));
+ g_return_if_fail (location != NULL);
+
+ *location = self;
+ g_signal_connect_swapped (self,
+ "destroyed",
+ G_CALLBACK (g_nullify_pointer),
+ location);
+}
+
+void
+ide_pane_unobserve (IdePane *self,
+ IdePane **location)
+{
+ g_return_if_fail (IDE_IS_PANE (self));
+ g_return_if_fail (location != NULL);
+
+ g_signal_handlers_disconnect_by_func (self,
+ G_CALLBACK (g_nullify_pointer),
+ location);
+ *location = NULL;
+}
+
+void
+ide_clear_pane (IdePane **location)
+{
+ IdePane *self = *location;
+
+ if (self == NULL)
+ return;
+
+ ide_pane_unobserve (self, location);
+ ide_pane_destroy (self);
+}
diff --git a/src/libide/gui/ide-pane.h b/src/libide/gui/ide-pane.h
index 7f52d5420..e2bfc09f4 100644
--- a/src/libide/gui/ide-pane.h
+++ b/src/libide/gui/ide-pane.h
@@ -41,8 +41,16 @@ struct _IdePaneClass
};
IDE_AVAILABLE_IN_ALL
-GtkWidget *ide_pane_new (void);
+GtkWidget *ide_pane_new (void);
IDE_AVAILABLE_IN_ALL
-void ide_pane_destroy (IdePane *self);
+void ide_pane_destroy (IdePane *self);
+IDE_AVAILABLE_IN_ALL
+void ide_pane_observe (IdePane *self,
+ IdePane **location);
+IDE_AVAILABLE_IN_ALL
+void ide_pane_unobserve (IdePane *self,
+ IdePane **location);
+IDE_AVAILABLE_IN_ALL
+void ide_clear_pane (IdePane **location);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]