diff --git a/src/gs-common.c b/src/gs-common.c index 1e5a135423dede92145a1a23fb334c4f45c98473..4a9fabb781655e4dc7fbc6f567d915463960f923 100644 --- a/src/gs-common.c +++ b/src/gs-common.c @@ -155,7 +155,7 @@ unmap_cb (GtkDialog *dialog, } static void -response_cb (AdwMessageDialog *self, +response_cb (AdwAlertDialog *self, const gchar *response, RunInfo *run_info) { @@ -185,10 +185,10 @@ gs_common_app_is_from_official_repository (GsApp *app, } GtkResponseType -gs_app_notify_unavailable (GsApp *app, GtkWindow *parent) +gs_app_notify_unavailable (GsApp *app, GtkWidget *parent) { GsAppLicenseHint hint = GS_APP_LICENSE_FREE; - GtkWidget *dialog; + AdwDialog *dialog; const gchar *license; gboolean already_enabled = FALSE; /* FIXME */ g_autofree gchar *origin_ui = NULL; @@ -291,29 +291,27 @@ gs_app_notify_unavailable (GsApp *app, GtkWindow *parent) } } - dialog = adw_message_dialog_new (parent, - title, - body->str); - adw_message_dialog_set_body_use_markup (ADW_MESSAGE_DIALOG (dialog), TRUE); + dialog = adw_alert_dialog_new (title, body->str); + adw_alert_dialog_set_body_use_markup (ADW_ALERT_DIALOG (dialog), TRUE); - adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (dialog), - "cancel", _("_Cancel")); + adw_alert_dialog_add_response (ADW_ALERT_DIALOG (dialog), + "cancel", _("_Cancel")); /* TRANSLATORS: this is button text to not ask about non-free content again */ - if (0) adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (dialog), "dont-warn-again", _("Don’t _Warn Again")); + if (0) adw_alert_dialog_add_response (ADW_ALERT_DIALOG (dialog), "dont-warn-again", _("Don’t _Warn Again")); if (already_enabled) { - adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (dialog), - /* TRANSLATORS: button text */ - "install", _("_Install")); + adw_alert_dialog_add_response (ADW_ALERT_DIALOG (dialog), + /* TRANSLATORS: button text */ + "install", _("_Install")); } else { - adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (dialog), - /* TRANSLATORS: button text */ - "install", _("Enable and _Install")); + adw_alert_dialog_add_response (ADW_ALERT_DIALOG (dialog), + /* TRANSLATORS: button text */ + "install", _("Enable and _Install")); } /* Run */ - gtk_window_present (GTK_WINDOW (dialog)); + adw_dialog_present (dialog, parent); g_signal_connect (dialog, "response", G_CALLBACK (response_cb), &run_info); g_signal_connect (dialog, "unmap", G_CALLBACK (unmap_cb), &run_info); @@ -496,20 +494,17 @@ unset_focus (GtkWidget *widget, gpointer data) * Inserts a widget displaying the detailed message into the message dialog. */ static void -insert_details_widget (AdwMessageDialog *dialog, - const gchar *details, - gboolean add_prefix) +insert_details_widget (AdwAlertDialog *dialog, + const gchar *details, + gboolean add_prefix) { - GtkWidget *box, *sw, *label; - GtkWidget *tv; + GtkWidget *group, *sw, *tv; GtkTextBuffer *buffer; g_autoptr(GString) msg = NULL; - g_assert (ADW_IS_MESSAGE_DIALOG (dialog)); + g_assert (ADW_IS_ALERT_DIALOG (dialog)); g_assert (details != NULL); - gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE); - if (add_prefix) { msg = g_string_new (""); g_string_append_printf (msg, "%s\n\n%s", @@ -520,32 +515,36 @@ insert_details_widget (AdwMessageDialog *dialog, details); } - box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - adw_message_dialog_set_extra_child (ADW_MESSAGE_DIALOG (dialog), box); - - label = gtk_label_new (_("Details")); - gtk_widget_set_halign (label, GTK_ALIGN_START); - gtk_widget_set_visible (label, TRUE); - gtk_box_append (GTK_BOX (box), label); + group = adw_preferences_group_new (); + adw_preferences_group_set_title (ADW_PREFERENCES_GROUP (group), _("Details")); + adw_alert_dialog_set_extra_child (ADW_ALERT_DIALOG (dialog), group); sw = gtk_scrolled_window_new (); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 150); - gtk_widget_set_visible (sw, TRUE); + gtk_widget_set_overflow (sw, GTK_OVERFLOW_HIDDEN); + gtk_widget_set_vexpand (sw, TRUE); + gtk_widget_add_css_class (sw, "card"); tv = gtk_text_view_new (); buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tv)); gtk_text_view_set_editable (GTK_TEXT_VIEW (tv), FALSE); gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (tv), GTK_WRAP_WORD); - gtk_widget_add_css_class (tv, "update-failed-details"); + gtk_text_view_set_monospace (GTK_TEXT_VIEW (tv), TRUE); + gtk_widget_add_css_class (tv, "inline"); + gtk_widget_add_css_class (tv, "monospace"); + gtk_text_view_set_top_margin (GTK_TEXT_VIEW (tv), 12); + gtk_text_view_set_bottom_margin (GTK_TEXT_VIEW (tv), 12); + gtk_text_view_set_right_margin (GTK_TEXT_VIEW (tv), 12); + gtk_text_view_set_left_margin (GTK_TEXT_VIEW (tv), 12); + gtk_text_buffer_set_text (buffer, msg ? msg->str : details, -1); - gtk_widget_set_visible (tv, TRUE); gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), tv); - gtk_widget_set_vexpand (sw, TRUE); - gtk_box_append (GTK_BOX (box), sw); + + adw_preferences_group_add (ADW_PREFERENCES_GROUP (group), sw); g_signal_connect (dialog, "map", G_CALLBACK (unset_focus), NULL); } @@ -560,20 +559,23 @@ insert_details_widget (AdwMessageDialog *dialog, * Shows a message dialog for displaying error messages. */ void -gs_utils_show_error_dialog (GtkWindow *parent, +gs_utils_show_error_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *details) { - GtkWidget *dialog; + AdwDialog *dialog; - dialog = adw_message_dialog_new (parent, title, msg); - if (details != NULL) - insert_details_widget (ADW_MESSAGE_DIALOG (dialog), details, TRUE); - adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (dialog), - /* TRANSLATORS: button text */ - "close", _("_Close")); - gtk_window_present (GTK_WINDOW (dialog)); + dialog = adw_alert_dialog_new (title, msg); + if (details != NULL) { + insert_details_widget (ADW_ALERT_DIALOG (dialog), details, TRUE); + adw_dialog_set_follows_content_size (dialog, FALSE); + adw_dialog_set_content_width (dialog, 500); + } + adw_alert_dialog_add_response (ADW_ALERT_DIALOG (dialog), + /* TRANSLATORS: button text */ + "close", _("_Close")); + adw_dialog_present (dialog, parent); } #ifndef TESTDATADIR @@ -650,16 +652,15 @@ gs_utils_show_error_dialog_simple (GtkWidget *parent, * Since: 42 **/ gboolean -gs_utils_ask_user_accepts (GtkWindow *parent, +gs_utils_ask_user_accepts (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *details, const gchar *accept_label) { - GtkWidget *dialog; + AdwDialog *dialog; RunInfo run_info; - g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE); g_return_val_if_fail (title != NULL, FALSE); g_return_val_if_fail (msg != NULL, FALSE); @@ -668,21 +669,21 @@ gs_utils_ask_user_accepts (GtkWindow *parent, accept_label = _("_Accept"); } - dialog = adw_message_dialog_new (parent, title, msg); + dialog = adw_alert_dialog_new (title, msg); if (details != NULL) - insert_details_widget (ADW_MESSAGE_DIALOG (dialog), details, FALSE); - adw_message_dialog_add_responses (ADW_MESSAGE_DIALOG (dialog), - /* TRANSLATORS: button text */ - "cancel", _("_Cancel"), - /* TRANSLATORS: button text */ - "accept", accept_label, - NULL); + insert_details_widget (ADW_ALERT_DIALOG (dialog), details, FALSE); + adw_alert_dialog_add_responses (ADW_ALERT_DIALOG (dialog), + /* TRANSLATORS: button text */ + "cancel", _("_Cancel"), + /* TRANSLATORS: button text */ + "accept", accept_label, + NULL); run_info.response_id = GTK_RESPONSE_NONE; run_info.loop = g_main_loop_new (NULL, FALSE); /* Run */ - gtk_window_present (GTK_WINDOW (dialog)); + adw_dialog_present (dialog, parent); g_signal_connect (dialog, "response", G_CALLBACK (response_cb), &run_info); g_signal_connect (dialog, "unmap", G_CALLBACK (unmap_cb), &run_info); diff --git a/src/gs-common.h b/src/gs-common.h index b78f7aea09d2fa8716ca3701af5bd9c458c64da0..ee01adf342f3bdde30b869fc7c69802a02cf0b4f 100644 --- a/src/gs-common.h +++ b/src/gs-common.h @@ -26,7 +26,7 @@ void gs_grab_focus_when_mapped (GtkWidget *widget); void gs_app_notify_installed (GsApp *app); GtkResponseType gs_app_notify_unavailable (GsApp *app, - GtkWindow *parent); + GtkWidget *parent); gboolean gs_utils_is_current_desktop (const gchar *name); gchar *gs_utils_set_key_colors_in_css (const gchar *css, @@ -35,15 +35,15 @@ void gs_utils_widget_set_css (GtkWidget *widget, GtkCssProvider **provider, const gchar *css); const gchar *gs_utils_get_error_value (const GError *error); -void gs_utils_show_error_dialog (GtkWindow *parent, +void gs_utils_show_error_dialog (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *details); void gs_utils_show_error_dialog_simple - (GtkWidget *parent, + (GtkWidget *parent, const gchar *title, const gchar *text); -gboolean gs_utils_ask_user_accepts (GtkWindow *parent, +gboolean gs_utils_ask_user_accepts (GtkWidget *parent, const gchar *title, const gchar *msg, const gchar *details, diff --git a/src/gs-dkms-dialog.c b/src/gs-dkms-dialog.c index fa0a9ecde878600103ec712daf2dbd2b724da749..2736008e798f59c8976e4fa794d1290852ba4a80 100644 --- a/src/gs-dkms-dialog.c +++ b/src/gs-dkms-dialog.c @@ -62,8 +62,7 @@ gs_dkms_dialog_prepare_reboot_cb (GObject *source_object, g_debug ("dkms-dialog: Failed to prepare reboot: %s", local_error->message); /* The code 126 is returned when the admin/root password prompt is dismissed */ if (!g_error_matches (local_error, G_SPAWN_EXIT_ERROR, 126)) { - GtkWidget *window = gtk_widget_get_ancestor (GTK_WIDGET (source_object), GTK_TYPE_WINDOW); - gs_utils_show_error_dialog (window != NULL ? GTK_WINDOW (window) : NULL, + gs_utils_show_error_dialog (GTK_WIDGET (source_object), _("Failed to prepare reboot"), "", local_error->message); diff --git a/src/gs-page.c b/src/gs-page.c index 6a9c2ed5388bab26c344b33fab7cbad329ae0639..9b3d70e97a145014335eda462c6decdb16e84bdc 100644 --- a/src/gs-page.c +++ b/src/gs-page.c @@ -266,7 +266,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, GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (page), GTK_TYPE_WINDOW))); + response = gs_app_notify_unavailable (app, GTK_WIDGET (page)); if (response != GTK_RESPONSE_OK) { g_autoptr(GError) error_local = NULL; g_set_error_literal (&error_local, G_IO_ERROR, G_IO_ERROR_CANCELLED, _("User declined installation")); diff --git a/src/gs-shell.c b/src/gs-shell.c index 893d38fb633705652d75f5da3508e4713a2b5848..c917efaa22221887ef15b564e48a9a28b4ed3090 100644 --- a/src/gs-shell.c +++ b/src/gs-shell.c @@ -413,7 +413,7 @@ gs_shell_ask_untrusted_cb (GsPluginLoader *plugin_loader, const gchar *accept_label, GsShell *shell) { - return gs_utils_ask_user_accepts (GTK_WINDOW (shell), title, msg, details, accept_label); + return gs_utils_ask_user_accepts (GTK_WIDGET (shell), title, msg, details, accept_label); } static void diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c index 050ec1d896672f6ca92d8675ac663dfc99e92295..77e534018b2d03cd3212558bce2c5bf776e8f878 100644 --- a/src/gs-update-monitor.c +++ b/src/gs-update-monitor.c @@ -1373,7 +1373,7 @@ gs_update_monitor_show_error (GsUpdateMonitor *monitor, GtkWindow *window) show_detailed_error = TRUE; } - gs_utils_show_error_dialog (window, + gs_utils_show_error_dialog (GTK_WIDGET (window), title, msg, show_detailed_error ? monitor->last_offline_error->message : NULL); diff --git a/src/style.css b/src/style.css index fd3921c1fac243184a84b0a83520b7f9faae3fb7..40cf858608e9bc690e9049c8fdb7ac6853833e57 100644 --- a/src/style.css +++ b/src/style.css @@ -323,12 +323,6 @@ star-image > image.non-starred { opacity: 0.25; } -.update-failed-details { - font-family: Monospace; - font-size: smaller; - padding: 16px; -} - .gs-rounded { border-radius: 8px; }