[sysprof/wip/gtk4-port: 61/125] display: add helper to destroy from external sources




commit 2a99644d87616b142711f6fa6e847eedfe42aeb7
Author: Christian Hergert <chergert redhat com>
Date:   Fri Oct 1 10:25:56 2021 -0700

    display: add helper to destroy from external sources

 src/libsysprof-ui/sysprof-display-private.h | 29 +++++++++++++++++++++++++++++
 src/libsysprof-ui/sysprof-display.c         | 20 ++++++++++++++------
 2 files changed, 43 insertions(+), 6 deletions(-)
---
diff --git a/src/libsysprof-ui/sysprof-display-private.h b/src/libsysprof-ui/sysprof-display-private.h
new file mode 100644
index 00000000..2ca6ad64
--- /dev/null
+++ b/src/libsysprof-ui/sysprof-display-private.h
@@ -0,0 +1,29 @@
+/* sysprof-display-private.h
+ *
+ * Copyright 2021 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include "sysprof-display.h"
+
+G_BEGIN_DECLS
+
+void _sysprof_display_destroy (SysprofDisplay *self);
+
+G_END_DECLS
diff --git a/src/libsysprof-ui/sysprof-display.c b/src/libsysprof-ui/sysprof-display.c
index 55b9483b..8faa08e4 100644
--- a/src/libsysprof-ui/sysprof-display.c
+++ b/src/libsysprof-ui/sysprof-display.c
@@ -25,7 +25,7 @@
 #include <glib/gi18n.h>
 
 #include "sysprof-details-page.h"
-#include "sysprof-display.h"
+#include "sysprof-display-private.h"
 #include "sysprof-profiler-assistant.h"
 #include "sysprof-failed-state-view.h"
 #include "sysprof-recording-state-view.h"
@@ -1070,7 +1070,6 @@ sysprof_display_open (SysprofDisplay *self,
 
   if (!(reader = sysprof_capture_reader_new_with_error (path, &error)))
     {
-      GtkWidget *parent;
       GtkWidget *dialog;
       GtkWidget *window;
 
@@ -1094,10 +1093,7 @@ sysprof_display_open (SysprofDisplay *self,
       gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
       gtk_window_present (GTK_WINDOW (dialog));
 
-      if ((parent = gtk_widget_get_parent (GTK_WIDGET (self))) &&
-          GTK_IS_NOTEBOOK (parent))
-        gtk_notebook_remove_page (GTK_NOTEBOOK (parent),
-                                  gtk_notebook_page_num (GTK_NOTEBOOK (parent), GTK_WIDGET (self)));
+      _sysprof_display_destroy (self);
 
       return;
     }
@@ -1309,3 +1305,15 @@ sysprof_display_add_to_selection (SysprofDisplay *self,
   selection = sysprof_visualizers_frame_get_selection (priv->visualizers);
   sysprof_selection_select_range (selection, begin_time, end_time);
 }
+
+void
+_sysprof_display_destroy (SysprofDisplay *self)
+{
+  GtkWidget *parent;
+
+  g_return_if_fail (SYSPROF_IS_DISPLAY (self));
+
+  if ((parent = gtk_widget_get_parent (GTK_WIDGET (self))) && GTK_IS_NOTEBOOK (parent))
+    gtk_notebook_remove_page (GTK_NOTEBOOK (parent),
+                              gtk_notebook_page_num (GTK_NOTEBOOK (parent), GTK_WIDGET (self)));
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]