[gnome-contacts/wip/exalm/stuff: 4/4] Port to AdwMessageDialog




commit 0401dfa8966badab873d816b97ecbb42de5daa09
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Wed Jun 29 02:44:34 2022 +0400

    Port to AdwMessageDialog
    
    Depend on libadwaita 1.2.alpha

 meson.build                    |  2 +-
 src/contacts-app.vala          | 20 ++++++++++----------
 src/contacts-contact-pane.vala | 10 +++-------
 src/contacts-utils.vala        |  9 +++------
 4 files changed, 17 insertions(+), 24 deletions(-)
---
diff --git a/meson.build b/meson.build
index 2c7bac0b..c6b3b1cd 100644
--- a/meson.build
+++ b/meson.build
@@ -50,7 +50,7 @@ gmodule_export = dependency('gmodule-export-2.0', version: '>=' + min_glib_versi
 # gnome_desktop = dependency('gnome-desktop-3.0')
 goa = dependency('goa-1.0')
 gtk4_dep = dependency('gtk4', version: '>= 4.6')
-libadwaita_dep = dependency('libadwaita-1')
+libadwaita_dep = dependency('libadwaita-1', version: '>= 1.2.alpha')
 # E-D-S
 libebook = dependency('libebook-1.2', version: '>=' + min_eds_version)
 libedataserver = dependency('libedataserver-1.2', version: '>=' + min_eds_version)
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 7696736f..43d60ed7 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -106,11 +106,11 @@ public class Contacts.App : Adw.Application {
     if (pos != Gtk.INVALID_LIST_POSITION) {
       this.contacts_store.selection.selected = pos;
     } else {
-      var dialog = new Gtk.MessageDialog (this.window, Gtk.DialogFlags.DESTROY_WITH_PARENT,
-                                          Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
-                                          _("No contact with id %s found"), id);
-      dialog.set_title (_("Contact not found"));
-      dialog.response.connect ((_) => { dialog.close (); });
+      var dialog = new Adw.MessageDialog (this.window,
+                                          _("Contact not found"),
+                                          _("No contact with id %s found").printf (id));
+      dialog.add_response ("close", _("_Close"));
+      dialog.default_response = "close";
       dialog.show ();
     }
   }
@@ -182,11 +182,11 @@ public class Contacts.App : Adw.Application {
     if (pos != Gtk.INVALID_LIST_POSITION) {
       this.contacts_store.selection.selected = pos;
     } else {
-      var dialog = new Gtk.MessageDialog (this.window, Gtk.DialogFlags.DESTROY_WITH_PARENT,
-                                          Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE,
-                                          _("No contact with email address %s found"), email_address);
-      dialog.set_title (_("Contact not found"));
-      dialog.response.connect ((_) => dialog.close ());
+      var dialog = new Adw.MessageDialog (this.window,
+                                          _("Contact not found"),
+                                          _("No contact with email address %s found").printf 
(email_address));
+      dialog.add_response ("close", _("_Close"));
+      dialog.default_response = "close";
       dialog.show ();
     }
   }
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 8e4012db..5cbbc845 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -257,13 +257,9 @@ public class Contacts.ContactPane : Adw.Bin {
   }
 
   private void show_message_dialog (string message) {
-    var dialog =
-      new Gtk.MessageDialog (this.get_root () as Gtk.Window,
-                             Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL,
-                             Gtk.MessageType.ERROR,
-                             Gtk.ButtonsType.OK,
-                             "%s", message);
-    dialog.response.connect ((_) => dialog.close ());
+    var dialog = new Adw.MessageDialog (this.get_root () as Gtk.Window, null, message);
+    dialog.add_response ("close", _("_Close"));
+    dialog.default_response = "close";
     dialog.show ();
   }
 
diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala
index 2003dfa5..a5c28c05 100644
--- a/src/contacts-utils.vala
+++ b/src/contacts-utils.vala
@@ -132,12 +132,9 @@ namespace Contacts.Utils {
 
 
   public void show_error_dialog (string error, Gtk.Window toplevel) {
-    var dialog = new Gtk.MessageDialog (toplevel,
-                                        Gtk.DialogFlags.MODAL,
-                                        Gtk.MessageType.ERROR,
-                                        Gtk.ButtonsType.OK,
-                                        "%s", error);
-    dialog.response.connect(() => { dialog.destroy(); });
+    var dialog = new Adw.MessageDialog (toplevel, null, error);
+    dialog.add_response ("close", _("_Close"));
+    dialog.default_response = "close";
     dialog.show();
   }
 


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