[gnome-contacts] Fix nice names for eds contact stores
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Fix nice names for eds contact stores
- Date: Thu, 20 Oct 2011 10:04:33 +0000 (UTC)
commit ff1f9b5c029eba930beefdfc3e449abdd6e7b390
Author: Alexander Larsson <alexl redhat com>
Date: Thu Oct 20 12:03:48 2011 +0200
Fix nice names for eds contact stores
This fixes the name of the store for e.g. google contacts.
po/POTFILES.in | 1 +
src/contacts-contact.vala | 9 +++------
src/contacts-esd-setup.c | 27 +++++++++++++++++++++++++++
src/contacts-esd-setup.h | 1 +
vapi/custom.vapi | 2 ++
5 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 777ae4c..b29f6d9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,6 +2,7 @@ data/gnome-contacts.desktop.in.in
src/contacts-app.vala
src/contacts-contact-pane.vala
src/contacts-contact.vala
+src/contacts-esd-setup.c
src/contacts-link-dialog.vala
src/contacts-list-pane.vala
src/contacts-menu-button.vala
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 9ab8290..82693bd 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -934,12 +934,9 @@ public class Contacts.Contact : GLib.Object {
public static string format_persona_store_name (PersonaStore store) {
if (store.type_id == "eds") {
- if (store.id == eds_local_store) {
- return _("Local Contact");
- }
- if (store.id.has_suffix ("@gmail.com")) {
- return _("Google");
- }
+ unowned string? eds_name = lookup_esource_name_by_uid (store.id);
+ if (eds_name != null)
+ return eds_name;
}
if (store.type_id == "telepathy") {
var account = (store as Tpf.PersonaStore).account;
diff --git a/src/contacts-esd-setup.c b/src/contacts-esd-setup.c
index bdb379d..86955a2 100644
--- a/src/contacts-esd-setup.c
+++ b/src/contacts-esd-setup.c
@@ -16,6 +16,7 @@
*
*/
+#include "config.h"
#define GOA_API_IS_SUBJECT_TO_CHANGE
#include <goa/goa.h>
#include <libebook/e-book.h>
@@ -24,12 +25,14 @@
#include <libedataserver/e-source.h>
#include <libedataserver/e-source-group.h>
#include <libedataserver/e-uid.h>
+#include <glib/gi18n-lib.h>
char *contacts_eds_local_store = NULL;
static gboolean created_local = FALSE;
static GMainLoop *goa_loop;
static GoaClient *goa_client;
static GHashTable *accounts;
+static ESourceList *contacts_source_list;
/* This whole file is a gigantic hack that copies and pastes stuff from
* evolution to create evolution-data-server addressbooks as needed.
@@ -554,6 +557,7 @@ void contacts_ensure_eds_accounts (void)
created_local = ensure_local_addressbook ();
+ g_print ("contacts_eds_local_store: %s\n", contacts_eds_local_store);
goa_loop = g_main_loop_new (NULL, TRUE);
online_accounts_connect ();
@@ -563,4 +567,27 @@ void contacts_ensure_eds_accounts (void)
g_main_loop_unref (goa_loop);
goa_loop = NULL;
+
+ contacts_source_list = NULL;
+ e_book_get_addressbooks (&contacts_source_list, NULL);
+}
+
+
+const char *
+contacts_lookup_esource_name_by_uid (const char *uid)
+{
+ if (strcmp (uid, contacts_eds_local_store) == 0)
+ return _("Local Contact");
+
+ if (contacts_source_list) {
+ ESource *source = e_source_list_peek_source_by_uid (contacts_source_list, uid);
+ if (source) {
+ const char *relative_uri = e_source_peek_relative_uri (source);
+ if (relative_uri && g_str_has_suffix (relative_uri, "@gmail.com"))
+ return _("Google");
+
+ return e_source_peek_name (source);
+ }
+ }
+ return NULL;
}
diff --git a/src/contacts-esd-setup.h b/src/contacts-esd-setup.h
index 71db7a5..d71a9e4 100644
--- a/src/contacts-esd-setup.h
+++ b/src/contacts-esd-setup.h
@@ -1,2 +1,3 @@
void contacts_ensure_eds_accounts (void);
extern char *contacts_eds_local_store;
+const char *contacts_lookup_esource_name_by_uid (const char *uid);
diff --git a/vapi/custom.vapi b/vapi/custom.vapi
index 9354f14..1e73b83 100644
--- a/vapi/custom.vapi
+++ b/vapi/custom.vapi
@@ -29,4 +29,6 @@ namespace Contacts {
public static void ensure_eds_accounts ();
[CCode (cname = "contacts_eds_local_store")]
public static string? eds_local_store;
+ [CCode (cname = "contacts_lookup_esource_name_by_uid")]
+ public static unowned string? lookup_esource_name_by_uid (string uid);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]