[gnome-contacts] Show notification when copying address to clipboard



commit 1c50be63394b11c969bb248acb4ae4d318ff63aa
Author: Alexander Larsson <alexl redhat com>
Date:   Fri Jun 17 16:03:50 2011 +0200

    Show notification when copying address to clipboard

 configure.ac                   |    3 ++-
 src/contacts-contact-pane.vala |   25 +++++++++++++++++++++++++
 src/main.vala                  |    1 +
 3 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6dcea8a..0c32f64 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,9 +28,10 @@ AM_GLIB_GNU_GETTEXT
 pkg_modules="gtk+-3.0
 	     folks >= 0.5.2
 	     folks-telepathy
+	     libnotify
 	     "
 PKG_CHECK_MODULES(CONTACTS, [$pkg_modules])
-CONTACTS_PACKAGES="--pkg gtk+-3.0 --pkg gio-2.0 --pkg folks --pkg folks-telepathy"
+CONTACTS_PACKAGES="--pkg gtk+-3.0 --pkg gio-2.0 --pkg folks --pkg folks-telepathy --pkg libnotify"
 AC_SUBST(CONTACTS_CFLAGS)
 AC_SUBST(CONTACTS_LIBS)
 AC_SUBST(CONTACTS_PACKAGES)
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index ca96506..f66acde 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -283,6 +283,31 @@ public class Contacts.ContactPane : EventBox {
 	  foreach (var s in strs)
 	    layout.add_detail (s);
 	}
+	var button = layout.add_button ("edit-copy-symbolic");
+	button.clicked.connect ( () => {
+	    string addr_s = "";
+	    foreach (var s in Contact.format_address (addr)) {
+	      addr_s += s + "\n";
+	    }
+	    Clipboard.get_for_display (button.get_screen().get_display(), Gdk.SELECTION_CLIPBOARD).set_text (addr_s, -1);
+	    var notification = new Notify.Notification (_("Address copied to clipboard"), null, "edit-copy");
+	    notification.set_timeout (3000);
+	    notification.set_urgency (Notify.Urgency.CRITICAL);
+	    try {
+	      notification.show ();
+	      Timeout.add (3000, () => {
+		  try {
+		    notification.close ();
+		  }
+		  catch (Error e) {
+		  }
+		  return false;
+		});
+	    } 
+	    catch (Error e) {
+	    }
+	  });
+	
       }
     }
 
diff --git a/src/main.vala b/src/main.vala
index 7df45d1..ed7e274 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -22,6 +22,7 @@ using Contacts;
 
 public static int
 main (string[] args) {
+  Notify.init (_("Contacts"));
   Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
   Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
   Intl.textdomain (Config.GETTEXT_PACKAGE);



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