From bbce4b32b13b3cf6b14a73add7f2c616fdc4f6a1 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 1 Oct 2021 10:25:56 -0700 Subject: [PATCH] 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(-) create mode 100644 src/libsysprof-ui/sysprof-display-private.h 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 + * + * 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 . + * + * 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 #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))); +}