[gnome-contacts] Show error dialog if email not found
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Show error dialog if email not found
- Date: Mon, 5 Sep 2011 09:54:23 +0000 (UTC)
commit 1e61d0d3f8ed3e273c2a53072c4583fdfcb95f77
Author: Alexander Larsson <alexl redhat com>
Date: Mon Sep 5 11:45:12 2011 +0200
Show error dialog if email not found
src/contacts-app.vala | 34 ++++++++++++----------------------
src/contacts-store.vala | 8 --------
2 files changed, 12 insertions(+), 30 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index d85a62f..d896eaa 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -59,31 +59,21 @@ public class Contacts.App : Gtk.Application {
}
}
- private string show_email = null;
- private void show_email_cb (Contact contact) {
- if (contact.has_email (show_email)) {
- show_email = null;
- contacts_store.changed.disconnect (show_email_cb);
- contacts_store.added.disconnect (show_email_cb);
-
- list_pane.select_contact (contact);
- contacts_pane.show_contact (contact);
- }
- }
-
- public void show_by_email (string email) {
- var contact = contacts_store.find_contact_with_email (email);
+ public async void show_by_email (string email_address) {
+ var contact = yield contacts_store.find_contact ( (c) => {
+ return c.has_email (email_address);
+ });
if (contact != null) {
list_pane.select_contact (contact);
contacts_pane.show_contact (contact);
} else {
- if (show_email == null) {
- contacts_store.changed.connect (show_email_cb);
- contacts_store.added.connect (show_email_cb);
-
- // TODO: Wait for quiescent state to detect no such contact
- }
- show_email = email;
+ var dialog = new MessageDialog (App.app.window, DialogFlags.DESTROY_WITH_PARENT, MessageType.ERROR, ButtonsType.CLOSE,
+ _("No contact with email address %s found").printf (email_address));
+ dialog.set_title(_("Contact not found"));
+ dialog.show ();
+ dialog.response.connect ( (id) => {
+ dialog.destroy ();
+ });
}
}
@@ -174,7 +164,7 @@ public class Contacts.App : Gtk.Application {
if (individual_id != null)
app.show_individual.begin (individual_id);
if (email_address != null)
- app.show_by_email (email_address);
+ app.show_by_email.begin (email_address);
return 0;
}
diff --git a/src/contacts-store.vala b/src/contacts-store.vala
index 742936b..c0e5c4a 100644
--- a/src/contacts-store.vala
+++ b/src/contacts-store.vala
@@ -140,14 +140,6 @@ public class Contacts.Store : GLib.Object {
return matched;
}
- public Contact? find_contact_with_email (string email_address) {
- foreach (var contact in contacts) {
- if (contact.has_email (email_address))
- return contact;
- }
- return null;
- }
-
public Contact? find_contact_with_persona (Persona persona) {
foreach (var contact in contacts) {
if (contact.individual.personas.contains (persona))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]