display: add helper to destroy from external sources

This commit is contained in:
Christian Hergert
2021-10-01 10:25:56 -07:00
parent 75b4903ad7
commit bbce4b32b1
2 changed files with 43 additions and 6 deletions

View File

@ -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

View File

@ -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)));
}