[gnome-contacts] contacts-address-map: Go to Maps on button press



commit 05343f94fcea0334b1a46c58ad315eb490796b66
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Wed Jan 14 01:59:18 2015 -0500

    contacts-address-map: Go to Maps on button press
    
    https://bugzilla.gnome.org/show_bug.cgi?id=658553

 src/contacts-address-map.vala |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/contacts-address-map.vala b/src/contacts-address-map.vala
index 2915c8b..c8a8167 100644
--- a/src/contacts-address-map.vala
+++ b/src/contacts-address-map.vala
@@ -46,6 +46,8 @@ public class Contacts.AddressMap : Frame {
 
   public AddressMap (Contact c, Set<PostalAddressFieldDetails> postal_addresses) {
     var map = new Embed ();
+    var maps_id = "org.gnome.Maps";
+    var maps_info = new DesktopAppInfo (maps_id + ".desktop");
     var map_factory = MapSourceFactory.dup_default ();
     map_grid.add (map);
 
@@ -60,6 +62,24 @@ public class Contacts.AddressMap : Frame {
     /* Disable all events for the map */
     map.get_stage ().captured_event.connect (() => { return true; });
 
+    if (maps_info != null) {
+      /* Set cursor as HAND1 to indicate the map is clickable */
+      map.realize.connect (() => {
+          map.get_window ().set_cursor (new Cursor (CursorType.HAND1));
+        });
+
+      map.button_press_event.connect(() => {
+          activate_action (maps_id,
+                           "show-contact",
+                           new Variant ("s", c.individual.id),
+                           Gtk.get_current_event_time ());
+          return true;
+      });
+
+    } else {
+      map.set_tooltip_text (_("Install GNOME Maps to open location."));
+    }
+
     addresses = postal_addresses;
     found_places = new GLib.List<Place> ();
     mutex = Mutex ();


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