[gnome-calendar/wip/cdavis/use-adw-message-dialog: 2/2] gcal-utils: Use AdwMessageDialog




commit a55549c7cca96572512a24932f598fa2233deaf2
Author: Christopher Davis <christopherdavis gnome org>
Date:   Wed Jul 6 18:26:44 2022 -0400

    gcal-utils: Use AdwMessageDialog
    
    Use the new adaptive AdwMessageDialog widget
    where we previously used GtkMessageDialog.

 src/utils/gcal-utils.c | 54 ++++++++++++++++----------------------------------
 1 file changed, 17 insertions(+), 37 deletions(-)
---
diff --git a/src/utils/gcal-utils.c b/src/utils/gcal-utils.c
index 2b9f26f3..ab3818f3 100644
--- a/src/utils/gcal-utils.c
+++ b/src/utils/gcal-utils.c
@@ -1264,31 +1264,19 @@ typedef struct
 
 static void
 on_message_dialog_response_cb (GtkDialog         *dialog,
-                               gint               response,
+                               char              *response,
                                AskRecurrenceData *data)
 {
   GcalRecurrenceModType mod_type;
 
-  switch (response)
-    {
-      case GTK_RESPONSE_CANCEL:
-        mod_type = GCAL_RECURRENCE_MOD_NONE;
-        break;
-      case GTK_RESPONSE_ACCEPT:
-        mod_type = GCAL_RECURRENCE_MOD_THIS_ONLY;
-        break;
-      case GTK_RESPONSE_OK:
-        mod_type = GCAL_RECURRENCE_MOD_THIS_AND_FUTURE;
-        break;
-      case GTK_RESPONSE_YES:
-        mod_type = GCAL_RECURRENCE_MOD_ALL;
-        break;
-      default:
-        mod_type = GCAL_RECURRENCE_MOD_NONE;
-        break;
-    }
-
-  gtk_window_destroy (GTK_WINDOW (dialog));
+  if (g_strcmp0 (response, "this-only") == 0)
+    mod_type = GCAL_RECURRENCE_MOD_THIS_ONLY;
+  else if (g_strcmp0 (response, "subsequent-events") == 0)
+    mod_type = GCAL_RECURRENCE_MOD_THIS_AND_FUTURE;
+  else if (g_strcmp0 (response, "all-events") == 0)
+    mod_type = GCAL_RECURRENCE_MOD_ALL;
+  else
+    mod_type = GCAL_RECURRENCE_MOD_NONE;
 
   data->callback (data->event, mod_type, data->user_data);
   g_clear_object (&data->event);
@@ -1302,7 +1290,6 @@ gcal_utils_ask_recurrence_modification_type (GtkWidget                 *parent,
                                              gpointer                   user_data)
 {
   AskRecurrenceData *data;
-  GtkDialogFlags flags;
   ECalClient *client;
   GtkWidget *dialog;
 
@@ -1311,28 +1298,21 @@ gcal_utils_ask_recurrence_modification_type (GtkWidget                 *parent,
   data->callback = callback;
   data->user_data = user_data;
 
-  flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
-
-  dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_native (parent)),
-                                   flags,
-                                   GTK_MESSAGE_QUESTION,
-                                   GTK_BUTTONS_NONE,
+  dialog = adw_message_dialog_new (GTK_WINDOW (gtk_widget_get_native (parent)),
+                                   NULL,
                                    _("The event you are trying to modify is recurring. The changes you have 
selected should be applied to:"));
 
-  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
-                          _("_Cancel"),
-                          GTK_RESPONSE_CANCEL,
-                          _("_Only This Event"),
-                          GTK_RESPONSE_ACCEPT,
-                          NULL);
+  adw_message_dialog_add_responses (ADW_MESSAGE_DIALOG (dialog),
+                                    "close", _("_Cancel"),
+                                    "this-only", _("_Only This Event"),
+                                    NULL);
 
   client = gcal_calendar_get_client (gcal_event_get_calendar (event));
 
   if (!e_client_check_capability (E_CLIENT (client), E_CAL_STATIC_CAPABILITY_NO_THISANDFUTURE))
-    gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Subsequent events"), GTK_RESPONSE_OK);
+    adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (dialog), "subsequent-events", _("_Subsequent 
events"));
 
-  gtk_dialog_add_button (GTK_DIALOG (dialog), _("_All events"), GTK_RESPONSE_YES);
-  gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (gtk_widget_get_native (parent)));
+  adw_message_dialog_add_response (ADW_MESSAGE_DIALOG (dialog), "all-events",  _("_All events"));
   g_signal_connect (dialog, "response", G_CALLBACK (on_message_dialog_response_cb), data);
 
   gtk_window_present (GTK_WINDOW (dialog));


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