diff options
author | Alexander Larsson <alexl@redhat.com> | 2011-06-17 16:03:50 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2011-06-17 16:05:38 +0200 |
commit | 1c50be63394b11c969bb248acb4ae4d318ff63aa (patch) | |
tree | 070fec5856af50c4f49e591e1b99232e1ca60093 /src | |
parent | 2c60c6f096a857d3a5309de54a021f0658d65c8e (diff) | |
download | gnome-contacts-1c50be63394b11c969bb248acb4ae4d318ff63aa.tar.gz |
Show notification when copying address to clipboard
Diffstat (limited to 'src')
-rw-r--r-- | src/contacts-contact-pane.vala | 25 | ||||
-rw-r--r-- | src/main.vala | 1 |
2 files changed, 26 insertions, 0 deletions
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); |