[nautilus/wip/cdavis/use-adw-message-dialog: 7/8] ui-utilities: Use AdwMessageDialog in show_dialog()




commit eebe3a7a55c6168b9655ff92d5029656856ed340
Author: Christopher Davis <christopherdavis gnome org>
Date:   Thu Jul 7 00:28:40 2022 -0400

    ui-utilities: Use AdwMessageDialog in show_dialog()

 src/nautilus-ui-utilities.c | 22 ++++++----------------
 src/nautilus-ui-utilities.h |  4 ++--
 2 files changed, 8 insertions(+), 18 deletions(-)
---
diff --git a/src/nautilus-ui-utilities.c b/src/nautilus-ui-utilities.c
index 8e5933ee8..8cf1e9bf1 100644
--- a/src/nautilus-ui-utilities.c
+++ b/src/nautilus-ui-utilities.c
@@ -306,7 +306,7 @@ get_text_for_date_range (GPtrArray *date_range,
     return label;
 }
 
-GtkDialog *
+AdwMessageDialog *
 show_dialog (const gchar    *primary_text,
              const gchar    *secondary_text,
              GtkWindow      *parent,
@@ -316,23 +316,13 @@ show_dialog (const gchar    *primary_text,
 
     g_return_val_if_fail (parent != NULL, NULL);
 
-    dialog = gtk_message_dialog_new (parent,
-                                     GTK_DIALOG_MODAL,
-                                     type,
-                                     GTK_BUTTONS_OK,
-                                     "%s", primary_text);
+    dialog = adw_message_dialog_new (parent, primary_text, secondary_text);
+    adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (dialog), "ok", _("_OK"));
+    adw_message_dialog_set_default_response (ADW_MESSAGE_DIALOG (dialog), "ok");
 
-    gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
-                                              "%s", secondary_text);
+    gtk_window_present (GTK_WINDOW (dialog));
 
-    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
-
-    gtk_widget_show (dialog);
-
-    g_signal_connect (GTK_DIALOG (dialog), "response",
-                      G_CALLBACK (gtk_window_destroy), NULL);
-
-    return GTK_DIALOG (dialog);
+    return ADW_MESSAGE_DIALOG (dialog);
 }
 
 static void
diff --git a/src/nautilus-ui-utilities.h b/src/nautilus-ui-utilities.h
index d93cb84a9..44af13586 100644
--- a/src/nautilus-ui-utilities.h
+++ b/src/nautilus-ui-utilities.h
@@ -23,7 +23,7 @@
 #pragma once
 
 #include <gtk/gtk.h>
-
+#include <libadwaita-1/adwaita.h>
 
 void        nautilus_gmenu_set_from_model           (GMenu             *target_menu,
                                                      GMenuModel        *source_model);
@@ -43,7 +43,7 @@ gboolean    nautilus_date_time_is_between_dates     (GDateTime         *date,
 gchar     * get_text_for_date_range                 (GPtrArray         *date_range,
                                                      gboolean           prefix_with_since);
 
-GtkDialog * show_dialog                             (const gchar       *primary_text,
+AdwMessageDialog * show_dialog                      (const gchar       *primary_text,
                                                      const gchar       *secondary_text,
                                                      GtkWindow         *parent,
                                                      GtkMessageType     type);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]