aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Schaarschmidt <schaarsc@gmx.de>2014-06-26 22:06:59 +0800
committerMilan Crha <mcrha@redhat.com>2014-06-26 22:06:59 +0800
commit1f6ad0e8267f5bba90dca2e94025290080b10298 (patch)
tree13faad94a542c2968001c5d9c91882287113dd0c
parent67ae17f35639fb487c36090c772eba1d5a6aa17e (diff)
downloadgsoc2013-evolution-1f6ad0e8267f5bba90dca2e94025290080b10298.tar
gsoc2013-evolution-1f6ad0e8267f5bba90dca2e94025290080b10298.tar.gz
gsoc2013-evolution-1f6ad0e8267f5bba90dca2e94025290080b10298.tar.bz2
gsoc2013-evolution-1f6ad0e8267f5bba90dca2e94025290080b10298.tar.lz
gsoc2013-evolution-1f6ad0e8267f5bba90dca2e94025290080b10298.tar.xz
gsoc2013-evolution-1f6ad0e8267f5bba90dca2e94025290080b10298.tar.zst
gsoc2013-evolution-1f6ad0e8267f5bba90dca2e94025290080b10298.zip
Bug 729963 - Consistently name EMail/Phone/IM/SIP contact fields in the UI
-rw-r--r--addressbook/gui/contact-editor/e-contact-editor.c227
-rw-r--r--addressbook/gui/widgets/e-minicard.c26
-rw-r--r--addressbook/gui/widgets/eab-contact-merging.c13
-rw-r--r--addressbook/printing/e-contact-print.c68
-rw-r--r--addressbook/util/eab-book-util.c234
-rw-r--r--addressbook/util/eab-book-util.h30
6 files changed, 334 insertions, 264 deletions
diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c
index 93f0828758..52277488d1 100644
--- a/addressbook/gui/contact-editor/e-contact-editor.c
+++ b/addressbook/gui/contact-editor/e-contact-editor.c
@@ -40,6 +40,7 @@
#include "addressbook/printing/e-contact-print.h"
#include "addressbook/gui/widgets/eab-gui-util.h"
+#include "addressbook/util/eab-book-util.h"
#include "eab-contact-merging.h"
@@ -120,31 +121,7 @@ enum {
DYNAMIC_LIST_ADDRESS
};
-static struct {
- EContactField field_id;
- const gchar *type_1;
- const gchar *type_2;
-} phones[] = {
- { E_CONTACT_PHONE_ASSISTANT, EVC_X_ASSISTANT, NULL },
- { E_CONTACT_PHONE_BUSINESS, "WORK", "VOICE" },
- { E_CONTACT_PHONE_BUSINESS_FAX, "WORK", "FAX" },
- { E_CONTACT_PHONE_CALLBACK, EVC_X_CALLBACK, NULL },
- { E_CONTACT_PHONE_CAR, "CAR", NULL },
- { E_CONTACT_PHONE_COMPANY, "X-EVOLUTION-COMPANY", NULL },
- { E_CONTACT_PHONE_HOME, "HOME", "VOICE" },
- { E_CONTACT_PHONE_HOME_FAX, "HOME", "FAX" },
- { E_CONTACT_PHONE_ISDN, "ISDN", NULL },
- { E_CONTACT_PHONE_MOBILE, "CELL", NULL },
- { E_CONTACT_PHONE_OTHER, "VOICE", NULL },
- { E_CONTACT_PHONE_OTHER_FAX, "FAX", NULL },
- { E_CONTACT_PHONE_PAGER, "PAGER", NULL },
- { E_CONTACT_PHONE_PRIMARY, "PREF", NULL },
- { E_CONTACT_PHONE_RADIO, EVC_X_RADIO, NULL },
- { E_CONTACT_PHONE_TELEX, EVC_X_TELEX, NULL },
- { E_CONTACT_PHONE_TTYTDD, EVC_X_TTYTDD, NULL }
-};
-
-/* Defaults from the table above */
+/* Defaults selected from eab_phone_types */
static const gint phones_default[] = { 1, 6, 9, 2, 7, 12, 10, 10 };
static EContactField addresses[] = {
@@ -165,24 +142,9 @@ static const gchar *address_name[] = {
"other"
};
-static struct {
- EContactField field;
- const gchar *pretty_name;
-}
-im_service[] =
-{
- { E_CONTACT_IM_AIM, N_ ("AIM") },
- { E_CONTACT_IM_JABBER, N_ ("Jabber") },
- { E_CONTACT_IM_YAHOO, N_ ("Yahoo") },
- { E_CONTACT_IM_GADUGADU, N_ ("Gadu-Gadu") },
- { E_CONTACT_IM_MSN, N_ ("MSN") },
- { E_CONTACT_IM_ICQ, N_ ("ICQ") },
- { E_CONTACT_IM_GROUPWISE, N_ ("GroupWise") },
- { E_CONTACT_IM_SKYPE, N_ ("Skype") },
- { E_CONTACT_IM_TWITTER, N_ ("Twitter") },
- { E_CONTACT_IM_GOOGLE_TALK, N_ ("Google Talk")}
-};
-
+/*
+ * keep fetch_set in sync with labels from eab_im_service
+ */
static EContactField
im_service_fetch_set[] =
{
@@ -198,19 +160,9 @@ im_service_fetch_set[] =
E_CONTACT_IM_GOOGLE_TALK
};
-/* Defaults from the table above */
+/* Defaults selected from eab_get_im_type_labels */
static const gint im_service_default[] = { 0, 2, 4, 5 };
-static struct {
- const gchar *name;
- const gchar *pretty_name;
-}
-common_location[] =
-{
- { "WORK", N_ ("Work") },
- { "HOME", N_ ("Home") },
- { "OTHER", N_ ("Other") }
-};
/* Default from the table above */
static const gint email_default[] = { 0, 1, 2, 2 };
@@ -905,19 +857,20 @@ init_email_record_location (EContactEditor *editor)
{
GtkWidget *w;
GtkListStore *store;
- gint i;
+ gint i, n_elements;
EContactEditorDynTable *dyntable;
+ const EABTypeLabel *email_types = eab_get_email_type_labels (&n_elements);
w = e_builder_get_widget (editor->priv->builder, "mail-dyntable");
dyntable = E_CONTACT_EDITOR_DYNTABLE (w);
store = e_contact_editor_dyntable_get_combo_store (dyntable);
- for (i = 0; i < G_N_ELEMENTS (common_location); i++) {
+ for (i = 0; i < n_elements; i++) {
GtkTreeIter iter;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- DYNTABLE_COMBO_COLUMN_TEXT, _(common_location[i].pretty_name),
+ DYNTABLE_COMBO_COLUMN_TEXT, _(email_types[i].text),
DYNTABLE_COMBO_COLUMN_SENSITIVE, TRUE,
-1);
}
@@ -925,68 +878,6 @@ init_email_record_location (EContactEditor *editor)
e_contact_editor_dyntable_set_combo_defaults (dyntable, email_default, G_N_ELEMENTS (email_default));
}
-static const gchar *
-email_index_to_location (gint index)
-{
- return common_location[index].name;
-}
-
-static void
-phone_index_to_type (gint index,
- const gchar **type_1,
- const gchar **type_2)
-{
- *type_1 = phones [index].type_1;
- *type_2 = phones [index].type_2;
-}
-
-static void
-sip_index_to_type (gint index,
- const gchar **type_1)
-{
- *type_1 = common_location[index].name;
-}
-
-static gint
-get_email_location (EVCardAttribute *attr)
-{
- gint i;
-
- for (i = 0; i < G_N_ELEMENTS (common_location); i++) {
- if (e_vcard_attribute_has_type (attr, common_location[i].name))
- return i;
- }
-
- return -1;
-}
-
-static gint
-get_phone_type (EVCardAttribute *attr)
-{
- gint i;
-
- for (i = 0; i < G_N_ELEMENTS (phones); i++) {
- if (e_vcard_attribute_has_type (attr, phones[i].type_1) &&
- (phones[i].type_2 == NULL || e_vcard_attribute_has_type (attr, phones[i].type_2)))
- return i;
- }
-
- return -1;
-}
-
-static gint
-get_sip_type (EVCardAttribute *attr)
-{
- gint ii;
-
- for (ii = 0; ii < G_N_ELEMENTS (common_location); ii++) {
- if (e_vcard_attribute_has_type (attr, common_location[ii].name))
- return ii;
- }
-
- return -1;
-}
-
static EVCardAttributeParam *
get_ui_slot_param (EVCardAttribute *attr)
{
@@ -1080,7 +971,7 @@ fill_in_email (EContactEditor *editor)
gint slot;
email_address = e_vcard_attribute_get_value (attr);
- email_location = get_email_location (attr);
+ email_location = eab_get_email_type_index (attr);
slot = get_ui_slot (attr);
if (slot < 1)
slot = EMAIL_SLOTS + 1; //add at the end
@@ -1133,11 +1024,14 @@ extract_email (EContactEditor *editor)
DYNTABLE_STORE_COLUMN_ENTRY_STRING, &address,
-1);
- if (location >= 0)
+ if (location >= 0) {
+ const gchar *type;
+ eab_email_index_to_type (location, &type);
e_vcard_attribute_add_param_with_value (
attr,
e_vcard_attribute_param_new (EVC_TYPE),
- email_index_to_location (location));
+ type);
+ }
e_vcard_attribute_add_value (attr, address);
@@ -1393,7 +1287,7 @@ fill_in_phone (EContactEditor *editor)
if (slot < 0)
slot = PHONE_SLOTS + 1; /* append at the end */
- phone_type = get_phone_type (attr);
+ phone_type = eab_get_phone_type_index (attr);
phone = e_vcard_attribute_get_value (attr);
gtk_list_store_append (data_store, &iter);
@@ -1446,7 +1340,7 @@ extract_phone (EContactEditor *editor)
const gchar *type_1;
const gchar *type_2;
- phone_index_to_type (phone_type, &type_1, &type_2);
+ eab_phone_index_to_type (phone_type, &type_1, &type_2);
e_vcard_attribute_add_param_with_value (
attr, e_vcard_attribute_param_new (EVC_TYPE), type_1);
@@ -1485,19 +1379,21 @@ init_phone_record_type (EContactEditor *editor)
{
GtkWidget *w;
GtkListStore *store;
- gint i;
+ gint i, n_elements;
EContactEditorDynTable *dyntable;
+ const EABTypeLabel *eab_phone_types;
w = e_builder_get_widget (editor->priv->builder, "phone-dyntable");
dyntable = E_CONTACT_EDITOR_DYNTABLE (w);
store = e_contact_editor_dyntable_get_combo_store (dyntable);
+ eab_phone_types = eab_get_phone_type_labels (&n_elements);
- for (i = 0; i < G_N_ELEMENTS (phones); i++) {
+ for (i = 0; i < n_elements; i++) {
GtkTreeIter iter;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- DYNTABLE_COMBO_COLUMN_TEXT, e_contact_pretty_name (phones[i].field_id),
+ DYNTABLE_COMBO_COLUMN_TEXT, _(eab_phone_types[i].text),
DYNTABLE_COMBO_COLUMN_SENSITIVE, TRUE,
-1);
}
@@ -1546,8 +1442,9 @@ sensitize_phone_types (EContactEditor *editor)
GtkListStore *listStore;
GtkTreeModel *model;
GtkTreeIter iter;
- gint i;
+ gint i, n_elements;
gboolean valid;
+ const EABTypeLabel *eab_phone_types;
w = e_builder_get_widget (editor->priv->builder, "phone-dyntable");
listStore = e_contact_editor_dyntable_get_combo_store (E_CONTACT_EDITOR_DYNTABLE (w));
@@ -1555,7 +1452,8 @@ sensitize_phone_types (EContactEditor *editor)
valid = gtk_tree_model_get_iter_first (model, &iter);
- for (i = 0; i < G_N_ELEMENTS (phones); i++) {
+ eab_phone_types = eab_get_phone_type_labels (&n_elements);
+ for (i = 0; i < n_elements; i++) {
if (!valid) {
g_warning (G_STRLOC ": Unexpected end of phone items in combo box");
return;
@@ -1563,7 +1461,7 @@ sensitize_phone_types (EContactEditor *editor)
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
DYNTABLE_COMBO_COLUMN_SENSITIVE,
- is_field_supported (editor, phones[i].field_id),
+ is_field_supported (editor, eab_phone_types[i].field_id),
-1);
valid = gtk_tree_model_iter_next (model, &iter);
@@ -1575,14 +1473,16 @@ sensitize_phone (EContactEditor *editor)
{
GtkWidget *w;
gboolean enabled = FALSE;
- int i;
+ gint i, n_elements;
+ const EABTypeLabel *eab_phone_types;
w = e_builder_get_widget (editor->priv->builder, "phone-dyntable");
+ eab_phone_types = eab_get_phone_type_labels (&n_elements);
if (editor->priv->target_editable) {
enabled = is_field_supported (editor, E_CONTACT_TEL);
- for (i = 0; i < G_N_ELEMENTS (phones) && !enabled; i++) {
- enabled = is_field_supported (editor, phones[i].field_id);
+ for (i = 0; i < n_elements && !enabled; i++) {
+ enabled = is_field_supported (editor, eab_phone_types[i].field_id);
}
}
@@ -1619,7 +1519,7 @@ fill_in_sip (EContactEditor *editor)
gchar *sip;
gint sip_type;
- sip_type = get_sip_type (attr);
+ sip_type = eab_get_sip_type_index (attr);
sip = e_vcard_attribute_get_value (attr);
if (sip_type < 0)
@@ -1673,7 +1573,7 @@ extract_sip (EContactEditor *editor)
if (sip_type >= 0) {
const gchar *type_1;
- sip_index_to_type (sip_type, &type_1);
+ eab_sip_index_to_type (sip_type, &type_1);
e_vcard_attribute_add_param_with_value (
attr, e_vcard_attribute_param_new (EVC_TYPE), type_1);
@@ -1708,19 +1608,20 @@ init_sip_record_type (EContactEditor *editor)
{
GtkWidget *w;
GtkListStore *store;
- gint i;
+ gint i, n_elements;
EContactEditorDynTable *dyntable;
+ const EABTypeLabel *sip_types = eab_get_sip_type_labels (&n_elements);
w = e_builder_get_widget (editor->priv->builder, "sip-dyntable");
dyntable = E_CONTACT_EDITOR_DYNTABLE (w);
store = e_contact_editor_dyntable_get_combo_store (dyntable);
- for (i = 0; i < G_N_ELEMENTS (common_location); i++) {
+ for (i = 0; i < n_elements; i++) {
GtkTreeIter iter;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- DYNTABLE_COMBO_COLUMN_TEXT, _(common_location[i].pretty_name),
+ DYNTABLE_COMBO_COLUMN_TEXT, _(sip_types[i].text),
DYNTABLE_COMBO_COLUMN_SENSITIVE, TRUE,
-1);
}
@@ -1770,8 +1671,9 @@ sensitize_sip_types (EContactEditor *editor)
GtkListStore *listStore;
GtkTreeModel *model;
GtkTreeIter iter;
- gint i;
+ gint i, n_elements;
gboolean valid;
+ const EABTypeLabel *sip_types = eab_get_sip_type_labels (&n_elements);
w = e_builder_get_widget (editor->priv->builder, "sip-dyntable");
listStore = e_contact_editor_dyntable_get_combo_store (E_CONTACT_EDITOR_DYNTABLE (w));
@@ -1779,7 +1681,7 @@ sensitize_sip_types (EContactEditor *editor)
valid = gtk_tree_model_get_iter_first (model, &iter);
- for (i = 0; i < G_N_ELEMENTS (common_location); i++) {
+ for (i = 0; i < n_elements; i++) {
if (!valid) {
g_warning (G_STRLOC ": Unexpected end of sip items in combo box");
return;
@@ -1787,7 +1689,7 @@ sensitize_sip_types (EContactEditor *editor)
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
DYNTABLE_COMBO_COLUMN_SENSITIVE,
- is_field_supported (editor, E_CONTACT_SIP),
+ is_field_supported (editor, sip_types[i].field_id),
-1);
valid = gtk_tree_model_iter_next (model, &iter);
@@ -1822,19 +1724,21 @@ init_im_record_type (EContactEditor *editor)
{
GtkWidget *w;
GtkListStore *store;
- gint i;
+ gint i, n_elements;
EContactEditorDynTable *dyntable;
+ const EABTypeLabel *im_service;
w = e_builder_get_widget (editor->priv->builder, "im-dyntable");
dyntable = E_CONTACT_EDITOR_DYNTABLE (w);
store = e_contact_editor_dyntable_get_combo_store (dyntable);
- for (i = 0; i < G_N_ELEMENTS (im_service); i++) {
+ im_service = eab_get_im_type_labels (&n_elements);
+ for (i = 0; i < n_elements; i++) {
GtkTreeIter iter;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- DYNTABLE_COMBO_COLUMN_TEXT, _(im_service[i].pretty_name),
+ DYNTABLE_COMBO_COLUMN_TEXT, _(im_service[i].text),
DYNTABLE_COMBO_COLUMN_SENSITIVE, TRUE,
-1);
}
@@ -1870,22 +1774,6 @@ init_im (EContactEditor *editor)
expand_im (editor, TRUE);
}
-static gint
-get_service_type (EVCardAttribute *attr)
-{
- gint ii;
- const gchar *name;
- EContactField field;
-
- for (ii = 0; ii < G_N_ELEMENTS (im_service); ii++) {
- name = e_vcard_attribute_get_name (attr);
- field = e_contact_field_id_from_vcard (name);
- if (field == im_service[ii].field)
- return ii;
- }
- return -1;
-}
-
static void
fill_in_im (EContactEditor *editor)
{
@@ -1920,7 +1808,7 @@ fill_in_im (EContactEditor *editor)
gint slot;
im_name = e_vcard_attribute_get_value (attr);
- service_type = get_service_type (attr);
+ service_type = eab_get_im_type_index (attr);
slot = get_ui_slot (attr);
if (slot < 0)
@@ -1966,6 +1854,7 @@ extract_im (EContactEditor *editor)
gint slot;
gchar *im_name;
EVCardAttribute *attr;
+ const EABTypeLabel *im_service = eab_get_im_type_labels (&service_type);
gtk_tree_model_get (tree_model,&iter,
DYNTABLE_STORE_COLUMN_SORTORDER, &slot,
@@ -1975,7 +1864,7 @@ extract_im (EContactEditor *editor)
attr = e_vcard_attribute_new ("",
e_contact_vcard_attribute (
- im_service[service_type].field));
+ im_service[service_type].field_id));
/* older evolution versions (<=3.12) will crash if SLOT>4 is stored,
* but if we don't store the slot we loose sortorder.
@@ -2029,8 +1918,9 @@ sensitize_im_types (EContactEditor *editor)
GtkListStore *list_store;
GtkTreeModel *model;
GtkTreeIter iter;
- gint i;
+ gint i, n_elements;
gboolean valid;
+ const EABTypeLabel *im_service = eab_get_im_type_labels (&n_elements);
w = e_builder_get_widget (editor->priv->builder, "im-dyntable");
list_store = e_contact_editor_dyntable_get_combo_store (E_CONTACT_EDITOR_DYNTABLE (w));
@@ -2038,7 +1928,7 @@ sensitize_im_types (EContactEditor *editor)
valid = gtk_tree_model_get_iter_first (model, &iter);
- for (i = 0; i < G_N_ELEMENTS (im_service); i++) {
+ for (i = 0; i < n_elements; i++) {
if (!valid) {
g_warning (G_STRLOC ": Unexpected end of im items in combo box");
return;
@@ -2047,7 +1937,7 @@ sensitize_im_types (EContactEditor *editor)
gtk_list_store_set (
GTK_LIST_STORE (model), &iter,
DYNTABLE_COMBO_COLUMN_SENSITIVE,
- is_field_supported (editor, im_service[i].field),
+ is_field_supported (editor, im_service[i].field_id),
-1);
valid = gtk_tree_model_iter_next (model, &iter);
@@ -2057,16 +1947,17 @@ sensitize_im_types (EContactEditor *editor)
static void
sensitize_im (EContactEditor *editor)
{
- gint i;
+ gint i, n_elements;
gboolean enabled;
gboolean no_ims_supported;
GtkWidget *w;
+ const EABTypeLabel *im_service = eab_get_im_type_labels (&n_elements);
enabled = editor->priv->target_editable;
no_ims_supported = TRUE;
- for (i = 0; i < G_N_ELEMENTS (im_service); i++)
- if (is_field_supported (editor, im_service[i].field)) {
+ for (i = 0; i < n_elements; i++)
+ if (is_field_supported (editor, im_service[i].field_id)) {
no_ims_supported = FALSE;
break;
}
diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c
index c1226653bc..7166e7de24 100644
--- a/addressbook/gui/widgets/e-minicard.c
+++ b/addressbook/gui/widgets/e-minicard.c
@@ -83,17 +83,6 @@ enum {
LAST_SIGNAL
};
-static struct {
- const gchar *name;
- const gchar *pretty_name;
-}
-common_location[] =
-{
- { "WORK", N_ ("Work Email") },
- { "HOME", N_ ("Home Email") },
- { "OTHER", N_ ("Other Email") }
-};
-
static guint signals[LAST_SIGNAL] = {0, };
G_DEFINE_TYPE (EMinicard, e_minicard, GNOME_TYPE_CANVAS_GROUP)
@@ -815,19 +804,6 @@ add_field (EMinicard *e_minicard,
g_free (string);
}
-static const gchar *
-get_email_location (EVCardAttribute *attr)
-{
- gint i;
-
- for (i = 0; i < G_N_ELEMENTS (common_location); i++) {
- if (e_vcard_attribute_has_type (attr, common_location[i].name))
- return _(common_location[i].pretty_name);
- }
-
- return _("Other Email");
-}
-
static void
add_email_field (EMinicard *e_minicard,
GList *email_list,
@@ -856,7 +832,7 @@ add_email_field (EMinicard *e_minicard,
if (is_list) {
name = (gchar *)"";
} else {
- tmp = get_email_location ((EVCardAttribute *) l->data);
+ tmp = eab_get_email_label_text ((EVCardAttribute *) l->data);
name = g_strdup_printf ("%s:", tmp);
}
diff --git a/addressbook/gui/widgets/eab-contact-merging.c b/addressbook/gui/widgets/eab-contact-merging.c
index ded8240f11..80ce6379b8 100644
--- a/addressbook/gui/widgets/eab-contact-merging.c
+++ b/addressbook/gui/widgets/eab-contact-merging.c
@@ -31,6 +31,7 @@
#include <gtk/gtk.h>
#include <string.h>
#include "addressbook/gui/widgets/eab-contact-display.h"
+#include "addressbook/util/eab-book-util.h"
#include "e-util/e-util.h"
#include "e-util/e-util-private.h"
#include <glib/gi18n.h>
@@ -350,7 +351,7 @@ create_dropdowns_for_multival_attr(GList *match_attr_list,
GList **use_attr_list,
gint *row,
GtkTable *table,
- gchar *label_str)
+ const gchar * (*label_str) (EVCardAttribute*) )
{
GtkWidget *label, *hbox, *dropdown;
GList *miter, *citer;
@@ -389,7 +390,7 @@ create_dropdowns_for_multival_attr(GList *match_attr_list,
e_vcard_attribute_remove_param (attr, EVOLUTION_UI_SLOT_PARAM);
(*row)++;
- label = gtk_label_new (label_str);
+ label = gtk_label_new (label_str (attr));
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (hbox), (GtkWidget *) label, FALSE, FALSE, 0);
gtk_table_attach_defaults (table, (GtkWidget *) hbox, 0, 1, *row, *row + 1);
@@ -530,25 +531,25 @@ mergeit (EContactMergingLookup *lookup)
contact_email_attr_list = e_contact_get_attributes (lookup->contact, E_CONTACT_EMAIL);
use_email_attr_list = NULL;
create_dropdowns_for_multival_attr (match_email_attr_list, contact_email_attr_list,
- &use_email_attr_list, &row, table, _("Email"));
+ &use_email_attr_list, &row, table, eab_get_email_label_text);
match_tel_attr_list = e_contact_get_attributes (lookup->match, E_CONTACT_TEL);
contact_tel_attr_list = e_contact_get_attributes (lookup->contact, E_CONTACT_TEL);
use_tel_attr_list = NULL;
create_dropdowns_for_multival_attr (match_tel_attr_list, contact_tel_attr_list,
- &use_tel_attr_list, &row, table, _("Phone"));
+ &use_tel_attr_list, &row, table, eab_get_phone_label_text);
match_sip_attr_list = e_contact_get_attributes (lookup->match, E_CONTACT_SIP);
contact_sip_attr_list = e_contact_get_attributes (lookup->contact, E_CONTACT_SIP);
use_sip_attr_list = NULL;
create_dropdowns_for_multival_attr (match_sip_attr_list, contact_sip_attr_list,
- &use_sip_attr_list, &row, table, _("SIP"));
+ &use_sip_attr_list, &row, table, eab_get_sip_label_text);
match_im_attr_list = e_contact_get_attributes_set (lookup->match, im_fetch_set, G_N_ELEMENTS (im_fetch_set));
contact_im_attr_list = e_contact_get_attributes_set (lookup->contact, im_fetch_set, G_N_ELEMENTS (im_fetch_set));
use_im_attr_list = NULL;
create_dropdowns_for_multival_attr (match_im_attr_list, contact_im_attr_list,
- &use_im_attr_list, &row, table, _("IM"));
+ &use_im_attr_list, &row, table, eab_get_im_label_text);
gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 300);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), GTK_WIDGET (table));
diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c
index bcd27f879e..93ad9233ec 100644
--- a/addressbook/printing/e-contact-print.c
+++ b/addressbook/printing/e-contact-print.c
@@ -63,61 +63,6 @@ struct _EContactPrintContext
GSList *contact_list;
};
-/* TODO refactor phone_type
- * to avoid build dependency loop, code related to phone types was copied from e-contact-editor.c
- * once e-contact offers some kind of "translation service" code should be removed from here.
- */
-static struct {
- EContactField field_id;
- const gchar *type_1;
- const gchar *type_2;
-} phones[] = {
- { E_CONTACT_PHONE_ASSISTANT, EVC_X_ASSISTANT, NULL },
- { E_CONTACT_PHONE_BUSINESS, "WORK", "VOICE" },
- { E_CONTACT_PHONE_BUSINESS_FAX, "WORK", "FAX" },
- { E_CONTACT_PHONE_CALLBACK, EVC_X_CALLBACK, NULL },
- { E_CONTACT_PHONE_CAR, "CAR", NULL },
- { E_CONTACT_PHONE_COMPANY, "X-EVOLUTION-COMPANY", NULL },
- { E_CONTACT_PHONE_HOME, "HOME", "VOICE" },
- { E_CONTACT_PHONE_HOME_FAX, "HOME", "FAX" },
- { E_CONTACT_PHONE_ISDN, "ISDN", NULL },
- { E_CONTACT_PHONE_MOBILE, "CELL", NULL },
- { E_CONTACT_PHONE_OTHER, "VOICE", NULL },
- { E_CONTACT_PHONE_OTHER_FAX, "FAX", NULL },
- { E_CONTACT_PHONE_PAGER, "PAGER", NULL },
- { E_CONTACT_PHONE_PRIMARY, "PREF", NULL },
- { E_CONTACT_PHONE_RADIO, EVC_X_RADIO, NULL },
- { E_CONTACT_PHONE_TELEX, EVC_X_TELEX, NULL },
- { E_CONTACT_PHONE_TTYTDD, EVC_X_TTYTDD, NULL }
-};
-
-static gint
-get_phone_type (EVCardAttribute *attr)
-{
- gint i;
-
- for (i = 0; i < G_N_ELEMENTS (phones); i++) {
- if (e_vcard_attribute_has_type (attr, phones[i].type_1) &&
- (phones[i].type_2 == NULL || e_vcard_attribute_has_type (attr, phones[i].type_2)))
- return i;
- }
-
- return -1;
-}
-
-static gint
-get_phone_type_field_id (EVCardAttribute *attr)
-{
- gint type_index;
-
- type_index = get_phone_type (attr);
-
- if (type_index >= 0)
- return phones [type_index].field_id;
- else
- return -1;
-}
-
static gdouble
get_font_height (PangoFontDescription *desc)
{
@@ -458,15 +403,14 @@ print_emails (EContact *contact,
EVCardAttribute *attr = l->data;
gchar *email_address;
gchar *formatted_email;
- gchar *pretty_name;
+ const gchar *pretty_name;
email_address = e_vcard_attribute_get_value (attr);
formatted_email = format_email (email_address);
- pretty_name = g_strdup_printf ("%s %2d", N_ ("Email"), i);
+ pretty_name = eab_get_email_label_text (attr);
print_line (ctxt, pretty_name, formatted_email);
- g_free (pretty_name);
g_free (email_address);
g_free (formatted_email);
}
@@ -485,16 +429,10 @@ print_phones (EContact *contact,
for (l = phones; l; l = g_list_next (l)) {
EVCardAttribute *attr = l->data;
gchar *phone;
- gint field_id;
const gchar *pretty_name;
phone = e_vcard_attribute_get_value (attr);
- field_id = get_phone_type_field_id (attr);
- if (field_id >= 0) {
- pretty_name = e_contact_pretty_name (field_id);
- } else {
- pretty_name = N_ ("unknown phone type");
- }
+ pretty_name = eab_get_phone_label_text (attr);
print_line (ctxt, pretty_name, phone);
g_free (phone);
diff --git a/addressbook/util/eab-book-util.c b/addressbook/util/eab-book-util.c
index 6c0b35d277..8d4a0a8de2 100644
--- a/addressbook/util/eab-book-util.c
+++ b/addressbook/util/eab-book-util.c
@@ -24,11 +24,245 @@
#include <config.h>
#endif
+#include <glib/gi18n.h>
#include <string.h>
#include "e-util/e-util.h"
#include "eab-book-util.h"
+static EABTypeLabel
+email_types[] =
+{
+ { -1, "WORK", NULL, N_ ("Work Email") },
+ { -1, "HOME", NULL, N_ ("Home Email") },
+ { -1, "OTHER", NULL, N_ ("Other Email") }
+};
+
+static EABTypeLabel
+sip_types[] =
+{
+ { E_CONTACT_SIP, "WORK", NULL, N_ ("Work SIP") },
+ { E_CONTACT_SIP, "HOME", NULL, N_ ("Home SIP") },
+ { E_CONTACT_SIP, "OTHER", NULL, N_ ("Other SIP") }
+};
+
+static EABTypeLabel
+eab_phone_types[] = {
+ { E_CONTACT_PHONE_ASSISTANT, EVC_X_ASSISTANT, NULL, NULL },
+ { E_CONTACT_PHONE_BUSINESS, "WORK", "VOICE", NULL },
+ { E_CONTACT_PHONE_BUSINESS_FAX, "WORK", "FAX", NULL },
+ { E_CONTACT_PHONE_CALLBACK, EVC_X_CALLBACK, NULL, NULL },
+ { E_CONTACT_PHONE_CAR, "CAR", NULL, NULL },
+ { E_CONTACT_PHONE_COMPANY, "X-EVOLUTION-COMPANY", NULL, NULL },
+ { E_CONTACT_PHONE_HOME, "HOME", "VOICE", NULL },
+ { E_CONTACT_PHONE_HOME_FAX, "HOME", "FAX", NULL },
+ { E_CONTACT_PHONE_ISDN, "ISDN", NULL, NULL },
+ { E_CONTACT_PHONE_MOBILE, "CELL", NULL, NULL },
+ { E_CONTACT_PHONE_OTHER, "VOICE", NULL, NULL },
+ { E_CONTACT_PHONE_OTHER_FAX, "FAX", NULL, NULL },
+ { E_CONTACT_PHONE_PAGER, "PAGER", NULL, NULL },
+ { E_CONTACT_PHONE_PRIMARY, "PREF", NULL, NULL },
+ { E_CONTACT_PHONE_RADIO, EVC_X_RADIO, NULL, NULL },
+ { E_CONTACT_PHONE_TELEX, EVC_X_TELEX, NULL, NULL },
+ { E_CONTACT_PHONE_TTYTDD, EVC_X_TTYTDD, NULL, NULL }
+};
+static gboolean eab_phone_types_init = TRUE;
+
+static EABTypeLabel
+eab_im_service[] =
+{
+ { E_CONTACT_IM_AIM, NULL, NULL, N_ ("AIM") },
+ { E_CONTACT_IM_JABBER, NULL, NULL, N_ ("Jabber") },
+ { E_CONTACT_IM_YAHOO, NULL, NULL, N_ ("Yahoo") },
+ { E_CONTACT_IM_GADUGADU, NULL, NULL, N_ ("Gadu-Gadu") },
+ { E_CONTACT_IM_MSN, NULL, NULL, N_ ("MSN") },
+ { E_CONTACT_IM_ICQ, NULL, NULL, N_ ("ICQ") },
+ { E_CONTACT_IM_GROUPWISE, NULL, NULL, N_ ("GroupWise") },
+ { E_CONTACT_IM_SKYPE, NULL, NULL, N_ ("Skype") },
+ { E_CONTACT_IM_TWITTER, NULL, NULL, N_ ("Twitter") },
+ { E_CONTACT_IM_GOOGLE_TALK, NULL, NULL, N_ ("Google Talk")}
+};
+
+const EABTypeLabel*
+eab_get_email_type_labels (gint *n_elements)
+{
+ *n_elements = G_N_ELEMENTS (email_types);
+ return email_types;
+}
+
+gint
+eab_get_email_type_index (EVCardAttribute *attr)
+{
+ gint ii;
+
+ for (ii = 0; ii < G_N_ELEMENTS (email_types); ii++) {
+ if (e_vcard_attribute_has_type (attr, email_types[ii].type_1))
+ return ii;
+ }
+
+ return -1;
+}
+
+void
+eab_email_index_to_type (gint index, const gchar **type_1)
+{
+ *type_1 = email_types[index].type_1;
+}
+
+const gchar*
+eab_get_email_label_text (EVCardAttribute *attr)
+{
+ const gchar *result;
+ gint n_elements;
+ gint index = eab_get_email_type_index (attr);
+
+ if (index >= 0) {
+ result = _(eab_get_email_type_labels (&n_elements) [index].text);
+ } else {
+ result = _("Email");
+ }
+
+ return result;
+}
+
+const EABTypeLabel*
+eab_get_sip_type_labels (gint *n_elements)
+{
+ *n_elements = G_N_ELEMENTS (sip_types);
+ return sip_types;
+}
+
+gint
+eab_get_sip_type_index (EVCardAttribute *attr)
+{
+ gint ii;
+
+ for (ii = 0; ii < G_N_ELEMENTS (sip_types); ii++) {
+ if (e_vcard_attribute_has_type (attr, sip_types[ii].type_1))
+ return ii;
+ }
+
+ return -1;
+}
+
+void
+eab_sip_index_to_type (gint index, const gchar **type_1)
+{
+ *type_1 = sip_types[index].type_1;
+}
+
+const gchar*
+eab_get_sip_label_text (EVCardAttribute *attr)
+{
+ const gchar *result;
+ gint n_elements;
+ gint index = eab_get_sip_type_index (attr);
+
+ if (index >= 0) {
+ result = _(eab_get_sip_type_labels (&n_elements) [index].text);
+ } else {
+ result = _("SIP");
+ }
+
+ return result;
+}
+
+const EABTypeLabel*
+eab_get_im_type_labels (gint *n_elements)
+{
+ *n_elements = G_N_ELEMENTS (eab_im_service);
+ return eab_im_service;
+}
+
+gint
+eab_get_im_type_index (EVCardAttribute *attr)
+{
+ gint ii;
+ const gchar *name;
+ EContactField field;
+
+ for (ii = 0; ii < G_N_ELEMENTS (eab_im_service); ii++) {
+ name = e_vcard_attribute_get_name (attr);
+ field = e_contact_field_id_from_vcard (name);
+ if (field == eab_im_service[ii].field_id)
+ return ii;
+ }
+ return -1;
+}
+
+const gchar *
+eab_get_im_label_text (EVCardAttribute *attr)
+{
+ const gchar *result;
+ gint index = eab_get_im_type_index (attr);
+
+ if (index >= 0) {
+ result = _(eab_im_service [index].text);
+ } else {
+ result = _("IM");
+ }
+
+ return result;
+}
+
+const EABTypeLabel*
+eab_get_phone_type_labels (gint *n_elements)
+{
+ *n_elements = G_N_ELEMENTS (eab_phone_types);
+
+ if (eab_phone_types_init) {
+ gint i;
+ eab_phone_types_init = FALSE;
+ for (i = 0; i < *n_elements; i++) {
+ eab_phone_types[i].text = e_contact_pretty_name (eab_phone_types[i].field_id);
+ }
+ }
+
+ return eab_phone_types;
+}
+
+/*
+ * return the index within eab_phone_types[]
+ */
+gint
+eab_get_phone_type_index (EVCardAttribute *attr)
+{
+ gint i;
+
+ for (i = 0; i < G_N_ELEMENTS (eab_phone_types); i++) {
+ if (e_vcard_attribute_has_type (attr, eab_phone_types[i].type_1) &&
+ (eab_phone_types[i].type_2 == NULL || e_vcard_attribute_has_type (attr, eab_phone_types[i].type_2)))
+ return i;
+ }
+
+ return -1;
+}
+
+const gchar*
+eab_get_phone_label_text (EVCardAttribute *attr)
+{
+ const gchar *result;
+ gint n_elements;
+ gint index = eab_get_phone_type_index (attr);
+
+ if (index >= 0) {
+ result = _(eab_get_phone_type_labels (&n_elements) [index].text);
+ } else {
+ result = _("Phone");
+ }
+
+ return result;
+}
+
+void
+eab_phone_index_to_type (gint index,
+ const gchar **type_1,
+ const gchar **type_2)
+{
+ *type_1 = eab_phone_types [index].type_1;
+ *type_2 = eab_phone_types [index].type_2;
+}
+
/* Copied from camel_strstrcase */
static gchar *
eab_strstrcase (const gchar *haystack,
diff --git a/addressbook/util/eab-book-util.h b/addressbook/util/eab-book-util.h
index 8b680a828a..b9d2c4e064 100644
--- a/addressbook/util/eab-book-util.h
+++ b/addressbook/util/eab-book-util.h
@@ -27,6 +27,36 @@
G_BEGIN_DECLS
+typedef struct {
+ EContactField field_id;
+ const gchar *type_1;
+ const gchar *type_2;
+ const gchar *text;
+} EABTypeLabel;
+
+const EABTypeLabel *eab_get_phone_type_labels (gint *n_elements);
+const gchar * eab_get_phone_label_text (EVCardAttribute *attr);
+gint eab_get_phone_type_index (EVCardAttribute *attr);
+void eab_phone_index_to_type (gint index,
+ const gchar **type_1,
+ const gchar **type_2);
+
+const EABTypeLabel *eab_get_im_type_labels (gint *n_elements);
+gint eab_get_im_type_index (EVCardAttribute *attr);
+const gchar * eab_get_im_label_text (EVCardAttribute *attr);
+
+const EABTypeLabel *eab_get_email_type_labels (gint *n_elements);
+const gchar * eab_get_email_label_text (EVCardAttribute *attr);
+gint eab_get_email_type_index (EVCardAttribute *attr);
+void eab_email_index_to_type (gint index,
+ const gchar **type_1);
+
+const EABTypeLabel *eab_get_sip_type_labels (gint *n_elements);
+const gchar * eab_get_sip_label_text (EVCardAttribute *attr);
+gint eab_get_sip_type_index (EVCardAttribute *attr);
+void eab_sip_index_to_type (gint index,
+ const gchar **type_1);
+
GSList * eab_contact_list_from_string (const gchar *str);
gchar * eab_contact_list_to_string (const GSList *contacts);