[gnome-software: 13/29] src: Use widget’s parent window rather than gs_shell_get_window()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 13/29] src: Use widget’s parent window rather than gs_shell_get_window()
- Date: Wed, 31 Mar 2021 16:03:46 +0000 (UTC)
commit 5abfa483faa67df4cf62ef52d449a9f35fda85a6
Author: Philip Withnall <pwithnall endlessos org>
Date: Thu Jan 21 00:32:17 2021 +0000
src: Use widget’s parent window rather than gs_shell_get_window()
In practice this refers to the same widget, but by accessing it via the
widget’s ancestors, we eliminate some situations where widgets are
hard-coding that they will be used within a `GsShell` and that the
`GsShell` provides a window.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
src/gs-details-page.c | 2 +-
src/gs-page.c | 8 ++++----
src/gs-update-monitor.c | 4 ++--
src/gs-update-monitor.h | 2 +-
src/gs-updates-page.c | 5 +++--
5 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 8355930e4..b8010416c 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1569,7 +1569,7 @@ version_history_list_row_activated_cb (GtkListBox *list_box,
if (GS_IS_APP_VERSION_HISTORY_ROW (row))
return;
- dialog = gs_app_version_history_dialog_new (gs_shell_get_window (self->shell),
+ 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_DIALOG (dialog));
diff --git a/src/gs-page.c b/src/gs-page.c
index 6fd1c5e0e..30fb303b2 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -75,7 +75,7 @@ gs_page_show_update_message (GsPageHelper *helper, AsScreenshot *ss)
GtkWidget *dialog;
g_autofree gchar *escaped = NULL;
- dialog = gtk_message_dialog_new (gs_shell_get_window (priv->shell),
+ dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (helper->page),
GTK_TYPE_WINDOW)),
GTK_DIALOG_MODAL |
GTK_DIALOG_USE_HEADER_BAR,
GTK_MESSAGE_INFO,
@@ -248,7 +248,7 @@ gs_page_install_app (GsPage *page,
if (gs_app_get_state (app) == GS_APP_STATE_UNAVAILABLE) {
GtkResponseType response;
- response = gs_app_notify_unavailable (app, gs_shell_get_window (priv->shell));
+ response = gs_app_notify_unavailable (app, GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET
(page), GTK_TYPE_WINDOW)));
if (response != GTK_RESPONSE_OK)
return;
}
@@ -318,7 +318,7 @@ gs_page_needs_user_action (GsPageHelper *helper, AsScreenshot *ss)
g_autofree gchar *escaped = NULL;
GsPagePrivate *priv = gs_page_get_instance_private (helper->page);
- dialog = gtk_message_dialog_new (gs_shell_get_window (priv->shell),
+ dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (helper->page),
GTK_TYPE_WINDOW)),
GTK_DIALOG_MODAL |
GTK_DIALOG_USE_HEADER_BAR,
GTK_MESSAGE_INFO,
@@ -483,7 +483,7 @@ gs_page_remove_app (GsPage *page, GsApp *app, GCancellable *cancellable)
}
/* ask for confirmation */
- dialog = gtk_message_dialog_new (gs_shell_get_window (priv->shell),
+ dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (page),
GTK_TYPE_WINDOW)),
GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_CANCEL,
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index c1d12a72c..f22b5eb28 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -1122,7 +1122,7 @@ cleanup_notifications_cb (gpointer user_data)
}
void
-gs_update_monitor_show_error (GsUpdateMonitor *monitor, GsShell *shell)
+gs_update_monitor_show_error (GsUpdateMonitor *monitor, GtkWindow *window)
{
const gchar *title;
const gchar *msg;
@@ -1174,7 +1174,7 @@ gs_update_monitor_show_error (GsUpdateMonitor *monitor, GsShell *shell)
break;
}
- gs_utils_show_error_dialog (gs_shell_get_window (shell),
+ gs_utils_show_error_dialog (window,
title,
msg,
show_detailed_error ? monitor->last_offline_error->message : NULL);
diff --git a/src/gs-update-monitor.h b/src/gs-update-monitor.h
index bee6c21dc..db8c36336 100644
--- a/src/gs-update-monitor.h
+++ b/src/gs-update-monitor.h
@@ -23,6 +23,6 @@ G_DECLARE_FINAL_TYPE (GsUpdateMonitor, gs_update_monitor, GS, UPDATE_MONITOR, GO
GsUpdateMonitor *gs_update_monitor_new (GsApplication *app);
void gs_update_monitor_autoupdate (GsUpdateMonitor *monitor);
void gs_update_monitor_show_error (GsUpdateMonitor *monitor,
- GsShell *shell);
+ GtkWindow *window);
G_END_DECLS
diff --git a/src/gs-updates-page.c b/src/gs-updates-page.c
index 89992d498..2c0c5291f 100644
--- a/src/gs-updates-page.c
+++ b/src/gs-updates-page.c
@@ -781,6 +781,7 @@ gs_updates_page_button_refresh_cb (GtkWidget *widget,
GsUpdatesPage *self)
{
GtkWidget *dialog;
+ GtkWindow *parent_window = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_WINDOW));
/* cancel existing action? */
if (self->state == GS_UPDATES_PAGE_STATE_ACTION_REFRESH) {
@@ -801,7 +802,7 @@ gs_updates_page_button_refresh_cb (GtkWidget *widget,
gs_updates_page_get_new_updates (self);
return;
}
- dialog = gtk_message_dialog_new (gs_shell_get_window (self->shell),
+ dialog = gtk_message_dialog_new (parent_window,
GTK_DIALOG_MODAL |
GTK_DIALOG_USE_HEADER_BAR |
GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -825,7 +826,7 @@ gs_updates_page_button_refresh_cb (GtkWidget *widget,
/* no network connection */
} else {
- dialog = gtk_message_dialog_new (gs_shell_get_window (self->shell),
+ dialog = gtk_message_dialog_new (parent_window,
GTK_DIALOG_MODAL |
GTK_DIALOG_USE_HEADER_BAR |
GTK_DIALOG_DESTROY_WITH_PARENT,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]