contacts-contact: Add method to geocode a contact
https://bugzilla.gnome.org/show_bug.cgi?id=658553
This commit is contained in:
parent
511df2cf5b
commit
697be63f78
2 changed files with 36 additions and 1 deletions
|
@ -50,10 +50,11 @@ pkg_modules="gtk+-3.0 >= 3.12.0
|
||||||
libedataserver-1.2 >= 3.5.3
|
libedataserver-1.2 >= 3.5.3
|
||||||
goa-1.0
|
goa-1.0
|
||||||
gee-0.8
|
gee-0.8
|
||||||
|
geocode-glib-1.0
|
||||||
"
|
"
|
||||||
PKG_CHECK_MODULES(CONTACTS, [$pkg_modules])
|
PKG_CHECK_MODULES(CONTACTS, [$pkg_modules])
|
||||||
|
|
||||||
CONTACTS_PACKAGES="--pkg gtk+-3.0 --pkg gio-2.0 --pkg gio-unix-2.0 --pkg folks --pkg folks-telepathy --pkg folks-eds --pkg libnotify"
|
CONTACTS_PACKAGES="--pkg gtk+-3.0 --pkg gio-2.0 --pkg gio-unix-2.0 --pkg folks --pkg folks-telepathy --pkg folks-eds --pkg libnotify --pkg geocode-glib-1.0"
|
||||||
AC_SUBST(CONTACTS_PACKAGES)
|
AC_SUBST(CONTACTS_PACKAGES)
|
||||||
|
|
||||||
# Optional dependency for the user accounts panel
|
# Optional dependency for the user accounts panel
|
||||||
|
|
|
@ -20,6 +20,7 @@ using Gtk;
|
||||||
using Folks;
|
using Folks;
|
||||||
using Gee;
|
using Gee;
|
||||||
using TelepathyGLib;
|
using TelepathyGLib;
|
||||||
|
using Geocode;
|
||||||
|
|
||||||
public errordomain ContactError {
|
public errordomain ContactError {
|
||||||
NOT_IMPLEMENTED,
|
NOT_IMPLEMENTED,
|
||||||
|
@ -672,6 +673,39 @@ public class Contacts.Contact : GLib.Object {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Place geocode_address (PostalAddress addr) {
|
||||||
|
SourceFunc callback = geocode_address.callback;
|
||||||
|
var params = new HashTable<string, GLib.Value?>(str_hash, str_equal);
|
||||||
|
|
||||||
|
if (is_set (addr.street))
|
||||||
|
params.insert("street", addr.street);
|
||||||
|
|
||||||
|
if (is_set (addr.locality))
|
||||||
|
params.insert("locality", addr.locality);
|
||||||
|
|
||||||
|
if (is_set (addr.region))
|
||||||
|
params.insert("region", addr.region);
|
||||||
|
|
||||||
|
if (is_set (addr.country))
|
||||||
|
params.insert("country", addr.country);
|
||||||
|
|
||||||
|
Place? place = null;
|
||||||
|
var forward = new Forward.for_params (params);
|
||||||
|
forward.search_async.begin (null, (object, res) => {
|
||||||
|
try {
|
||||||
|
var places = forward.search_async.end (res);
|
||||||
|
|
||||||
|
place = places.nth_data (0);
|
||||||
|
callback ();
|
||||||
|
} catch (GLib.Error e) {
|
||||||
|
debug ("No geocode result found for contact");
|
||||||
|
callback ();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
yield;
|
||||||
|
return place;
|
||||||
|
}
|
||||||
|
|
||||||
public static string[] format_address (PostalAddress addr) {
|
public static string[] format_address (PostalAddress addr) {
|
||||||
string[] lines = {};
|
string[] lines = {};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue