[nautilus/wip/cdavis/use-adw-message-dialog: 1/2] mime-actions: Use AdwMessageDialog instead of eel dialogs




commit 3eaa90b3a52b7eb052f0f8fe7bb702c1976a9b5c
Author: Christopher Davis <christopherdavis gnome org>
Date:   Wed Jul 6 19:53:52 2022 -0400

    mime-actions: Use AdwMessageDialog instead of eel dialogs

 src/nautilus-mime-actions.c | 58 ++++++++++++++++++++++-----------------------
 1 file changed, 29 insertions(+), 29 deletions(-)
---
diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c
index 3ceb0a953..0219d88e6 100644
--- a/src/nautilus-mime-actions.c
+++ b/src/nautilus-mime-actions.c
@@ -556,7 +556,7 @@ typedef struct
 
 static void
 trash_symbolic_link_cb (GtkDialog *dialog,
-                        gint       response_id,
+                        char      *response,
                         gpointer   user_data)
 {
     g_autofree TrashBrokenSymbolicLinkData *data = NULL;
@@ -565,7 +565,7 @@ trash_symbolic_link_cb (GtkDialog *dialog,
     data = user_data;
     gtk_window_destroy (GTK_WINDOW (dialog));
 
-    if (response_id == GTK_RESPONSE_YES)
+    if (g_strcmp0 (response, "move-to-trash") == 0)
     {
         file_as_list.data = data->file;
         file_as_list.next = NULL;
@@ -582,7 +582,7 @@ report_broken_symbolic_link (GtkWindow    *parent_window,
     char *display_name;
     char *prompt;
     char *detail;
-    GtkDialog *dialog;
+    GtkWidget *dialog;
     TrashBrokenSymbolicLinkData *data;
 
     gboolean can_trash;
@@ -592,16 +592,6 @@ report_broken_symbolic_link (GtkWindow    *parent_window,
     display_name = nautilus_file_get_display_name (file);
     can_trash = nautilus_file_can_trash (file) && !nautilus_file_is_in_trash (file);
 
-    if (can_trash)
-    {
-        prompt = g_strdup_printf (_("The link “%s” is broken. Move it to Trash?"), display_name);
-    }
-    else
-    {
-        prompt = g_strdup_printf (_("The link “%s” is broken."), display_name);
-    }
-    g_free (display_name);
-
     target_path = nautilus_file_get_symbolic_link_target_path (file);
     if (target_path == NULL)
     {
@@ -615,16 +605,21 @@ report_broken_symbolic_link (GtkWindow    *parent_window,
 
     if (can_trash)
     {
-        dialog = eel_show_yes_no_dialog (prompt, detail, _("Mo_ve to Trash"), _("_Cancel"),
-                                         parent_window);
+        prompt = g_strdup_printf (_("The link “%s” is broken. Move it to Trash?"), display_name);
+        dialog = adw_message_dialog_new (parent_window, prompt, detail);
+        adw_message_dialog_add_responses (ADW_MESSAGE_DIALOG (dialog),
+                                          "cancel", _("_Cancel"),
+                                          "move-to-trash", _("Mo_ve to Trash"),
+                                          NULL);
     }
     else
     {
-        dialog = eel_show_simple_dialog (GTK_WIDGET (parent_window), GTK_MESSAGE_WARNING,
-                                         prompt, detail, _("_Cancel"), NULL);
+        prompt = g_strdup_printf (_("The link “%s” is broken."), display_name);
+        dialog = adw_message_dialog_new (parent_window, prompt, detail);
+        adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (dialog),
+                                         "cancel", _("Cancel"));
     }
-
-    gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+    g_free (display_name);
 
     /* Make this modal to avoid problems with reffing the view & file
      * to keep them around in case the view changes, which would then
@@ -984,12 +979,12 @@ activate_mount_op_active (GtkMountOperation  *operation,
     }
 }
 
-static GtkDialog *
+static GtkWidget*
 show_confirm_multiple (GtkWindow *parent_window,
                        int        window_count,
                        int        tab_count)
 {
-    GtkDialog *dialog;
+    GtkWidget *dialog;
     char *prompt;
     char *detail;
 
@@ -1010,9 +1005,15 @@ show_confirm_multiple (GtkWindow *parent_window,
         detail = g_strdup_printf (ngettext ("This will open %d separate window.",
                                             "This will open %d separate windows.", window_count), 
window_count);
     }
-    dialog = eel_show_yes_no_dialog (prompt, detail,
-                                     _("_OK"), _("_Cancel"),
-                                     parent_window);
+
+    dialog = adw_message_dialog_new (parent_window, prompt, detail);
+    adw_message_dialog_add_responses (ADW_MESSAGE_DIALOG (dialog),
+                                      "cancel", _("_Cancel"),
+                                      "open-files", _("_Open Files"),
+                                      NULL);
+
+    adw_message_dialog_set_default_response (ADW_MESSAGE_DIALOG (dialog), "open-files");
+
     g_free (detail);
 
     return dialog;
@@ -1020,12 +1021,10 @@ show_confirm_multiple (GtkWindow *parent_window,
 
 static void
 on_confirm_multiple_windows_response (GtkDialog          *dialog,
-                                      int                 response_id,
+                                      gchar              *response,
                                       ActivateParameters *parameters)
 {
-    gtk_window_destroy (GTK_WINDOW (dialog));
-
-    if (response_id == GTK_RESPONSE_YES)
+    if (g_strcmp0 (response, "open-files") == 0)
     {
         unpause_activation_timed_cancel (parameters);
         activate_files_internal (parameters);
@@ -1586,12 +1585,13 @@ activate_files (ActivateParameters *parameters)
     if (parameters->user_confirmation &&
         num_tabs + num_windows > SILENT_OPEN_LIMIT)
     {
-        GtkDialog *dialog;
+        GtkWidget *dialog;
 
         pause_activation_timed_cancel (parameters);
         dialog = show_confirm_multiple (parameters->parent_window, num_windows, num_tabs);
         g_signal_connect (dialog, "response",
                           G_CALLBACK (on_confirm_multiple_windows_response), parameters);
+        gtk_window_present (GTK_WINDOW (dialog));
     }
     else
     {


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