[gnome-software: 20/110] Destroy windows and dialogs with gtk_window_destroy()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 20/110] Destroy windows and dialogs with gtk_window_destroy()
- Date: Tue, 5 Oct 2021 20:32:36 +0000 (UTC)
commit 0f246edd1b385189c0ca7829bbf960cb29cfeb37
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Sat Aug 21 19:42:33 2021 -0300
Destroy windows and dialogs with gtk_window_destroy()
gtk_widget_destroy() is no more. If one wants to destroy a widget, there
are two ways depends on what is being destroyed:
1. Toplevels (GtkWindow subclasses) are destroyed with gtk_window_destroy()
2. Other widgets are destroyed by unparenting them, and/or dropping their
last references with g_object_unref().
This commit covers the 1st case, which fortunately turned out to be the
most common case around (17 out of 22 calls to gtk_widget_destroy).
src/gs-application.c | 2 +-
src/gs-common.c | 4 ++--
src/gs-details-page.c | 8 ++------
src/gs-page.c | 6 +++---
src/gs-repos-dialog.c | 4 ++--
src/gs-review-row.c | 2 +-
src/gs-shell.c | 6 +++---
src/gs-updates-page.c | 4 ++--
8 files changed, 16 insertions(+), 20 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 3344887eb..163e86fab 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -381,7 +381,7 @@ about_activated (GSimpleAction *action,
/* just destroy */
g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
+ G_CALLBACK (gtk_window_destroy), dialog);
}
static void
diff --git a/src/gs-common.c b/src/gs-common.c
index e90b20d02..84fc7620b 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -307,7 +307,7 @@ gs_app_notify_unavailable (GsApp *app, GtkWindow *parent)
response = GTK_RESPONSE_OK;
g_settings_set_boolean (settings, "prompt-for-nonfree", FALSE);
}
- gtk_widget_destroy (dialog);
+ gtk_window_destroy (GTK_WINDOW (dialog));
return response;
}
@@ -571,7 +571,7 @@ gs_utils_show_error_dialog (GtkWindow *parent,
insert_details_widget (GTK_MESSAGE_DIALOG (dialog), details);
g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy),
+ G_CALLBACK (gtk_window_destroy),
dialog);
gtk_widget_show (dialog);
}
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 576e5d1f1..f1b592ee7 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1187,10 +1187,6 @@ version_history_list_row_activated_cb (GtkListBox *list_box,
dialog = gs_app_version_history_dialog_new (GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET
(list_box), GTK_TYPE_WINDOW)),
self->app);
gs_shell_modal_dialog_present (self->shell, GTK_WINDOW (dialog));
-
- /* just destroy */
- g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
}
static void gs_details_page_addon_selected_cb (GsAppAddonRow *row, GParamSpec *pspec, GsDetailsPage *self);
@@ -1962,7 +1958,7 @@ gs_details_page_review_response_cb (GtkDialog *dialog,
/* not agreed */
if (response != GTK_RESPONSE_OK) {
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
return;
}
@@ -1991,7 +1987,7 @@ gs_details_page_review_response_cb (GtkDialog *dialog,
gs_details_page_refresh_reviews (self);
/* unmap the dialog */
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
diff --git a/src/gs-page.c b/src/gs-page.c
index 6528c134c..d8d583db1 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -73,7 +73,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GsPageHelper, gs_page_helper_free);
static void
gs_page_update_app_response_close_cb (GtkDialog *dialog, gint response, gpointer user_data)
{
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -312,7 +312,7 @@ gs_page_update_app_response_cb (GtkDialog *dialog,
g_autoptr(GsPluginJob) plugin_job = NULL;
/* unmap the dialog */
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
/* not agreed */
if (response != GTK_RESPONSE_OK)
@@ -438,7 +438,7 @@ gs_page_remove_app_response_cb (GtkDialog *dialog,
g_autoptr(GsPluginJob) plugin_job = NULL;
/* unmap the dialog */
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
/* not agreed */
if (response != GTK_RESPONSE_OK)
diff --git a/src/gs-repos-dialog.c b/src/gs-repos-dialog.c
index 654e93856..c6cebad9b 100644
--- a/src/gs-repos-dialog.c
+++ b/src/gs-repos-dialog.c
@@ -141,7 +141,7 @@ enable_repo_response_cb (GtkDialog *confirm_dialog,
g_autoptr(InstallRemoveData) install_data = (InstallRemoveData *) user_data;
/* unmap the dialog */
- gtk_widget_destroy (GTK_WIDGET (confirm_dialog));
+ gtk_window_destroy (GTK_WINDOW (confirm_dialog));
/* not agreed */
if (response != GTK_RESPONSE_OK) {
@@ -222,7 +222,7 @@ remove_repo_response_cb (GtkDialog *confirm_dialog,
g_autoptr(GsPluginJob) plugin_job = NULL;
/* unmap the dialog */
- gtk_widget_destroy (GTK_WIDGET (confirm_dialog));
+ gtk_window_destroy (GTK_WINDOW (confirm_dialog));
/* not agreed */
if (response != GTK_RESPONSE_OK) {
diff --git a/src/gs-review-row.c b/src/gs-review-row.c
index 5801053d3..faaa8eeef 100644
--- a/src/gs-review-row.c
+++ b/src/gs-review-row.c
@@ -205,7 +205,7 @@ gs_review_row_confirm_cb (GtkDialog *dialog, gint response_id, GsReviewRow *row)
g_signal_emit (row, signals[SIGNAL_BUTTON_CLICKED], 0,
GS_REVIEW_ACTION_REPORT);
}
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
diff --git a/src/gs-shell.c b/src/gs-shell.c
index cb6aaea44..11f77dd03 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -270,7 +270,7 @@ gs_shell_metered_updates_bar_response_cb (GtkInfoBar *info_bar,
/* just destroy */
g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
+ G_CALLBACK (gtk_window_destroy), dialog);
}
static void
@@ -412,7 +412,7 @@ gs_shell_basic_auth_start_cb (GsPluginLoader *plugin_loader,
/* just destroy */
g_signal_connect_swapped (dialog, "response",
- G_CALLBACK (gtk_widget_destroy), dialog);
+ G_CALLBACK (gtk_window_destroy), dialog);
}
static void
@@ -2630,7 +2630,7 @@ gs_shell_init (GsShell *shell)
adw_search_bar_connect_entry (ADW_SEARCH_BAR (shell->search_bar), GTK_ENTRY (shell->entry_search));
shell->back_entry_stack = g_queue_new ();
- shell->modal_dialogs = g_ptr_array_new_with_free_func ((GDestroyNotify) gtk_widget_destroy);
+ shell->modal_dialogs = g_ptr_array_new_with_free_func ((GDestroyNotify) gtk_window_destroy);
}
GsShell *
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index ba2e2ef57..1eab2c13d 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -804,7 +804,7 @@ gs_updates_page_refresh_confirm_cb (GtkDialog *dialog,
GsUpdatesPage *self)
{
/* unmap the dialog */
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
switch (response_type) {
case GTK_RESPONSE_REJECT:
@@ -1069,7 +1069,7 @@ gs_updates_page_upgrade_confirm_cb (GtkDialog *dialog,
GsUpdatesPage *self)
{
/* unmap the dialog */
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
switch (response_type) {
case GTK_RESPONSE_ACCEPT:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]