aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-04-17 04:28:13 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-04-17 04:28:13 +0800
commita35d86361dbbf29c3b7da3a481c77c6a876ae8f4 (patch)
tree79a784b7f0a5272341c60890ecafe75be47d5b40 /addressbook
parenta8d2769cabc1889fd35e97d8494b824d06c0cde1 (diff)
downloadgsoc2013-evolution-a35d86361dbbf29c3b7da3a481c77c6a876ae8f4.tar
gsoc2013-evolution-a35d86361dbbf29c3b7da3a481c77c6a876ae8f4.tar.gz
gsoc2013-evolution-a35d86361dbbf29c3b7da3a481c77c6a876ae8f4.tar.bz2
gsoc2013-evolution-a35d86361dbbf29c3b7da3a481c77c6a876ae8f4.tar.lz
gsoc2013-evolution-a35d86361dbbf29c3b7da3a481c77c6a876ae8f4.tar.xz
gsoc2013-evolution-a35d86361dbbf29c3b7da3a481c77c6a876ae8f4.tar.zst
gsoc2013-evolution-a35d86361dbbf29c3b7da3a481c77c6a876ae8f4.zip
Added.
2001-04-16 Jon Trowbridge <trow@ximian.com> * backend/ebook/e-destination.c (e_destination_get_name): Added. * gui/component/select-names/e-select-names.c (real_add_address_cb): Use e_select_names_model_append. It's nicer. * gui/component/select-names/e-select-names-model.c (e_select_names_model_append): Added. * gui/component/select-names/e-select-names-completion.c (book_query_process_card_list): Filter out completion matches that don't have an associated e-mail address. (book_query_score): Give a bonus to the primary address, so that it always comes up first in the completion results. * gui/component/e-address-popup.c (e_address_popup_refresh_names): Convert utf8 strings into gtk strings before displaying. svn path=/trunk/; revision=9390
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog20
-rw-r--r--addressbook/backend/ebook/e-destination.c33
-rw-r--r--addressbook/backend/ebook/e-destination.h2
-rw-r--r--addressbook/gui/component/e-address-popup.c8
-rw-r--r--addressbook/gui/component/select-names/e-select-names-completion.c40
-rw-r--r--addressbook/gui/component/select-names/e-select-names-model.c48
-rw-r--r--addressbook/gui/component/select-names/e-select-names-model.h1
-rw-r--r--addressbook/gui/component/select-names/e-select-names.c4
8 files changed, 138 insertions, 18 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index f4bbac447a..1a43fb44a2 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,23 @@
+2001-04-16 Jon Trowbridge <trow@ximian.com>
+
+ * backend/ebook/e-destination.c (e_destination_get_name): Added.
+
+ * gui/component/select-names/e-select-names.c
+ (real_add_address_cb): Use e_select_names_model_append. It's
+ nicer.
+
+ * gui/component/select-names/e-select-names-model.c
+ (e_select_names_model_append): Added.
+
+ * gui/component/select-names/e-select-names-completion.c
+ (book_query_process_card_list): Filter out completion matches that
+ don't have an associated e-mail address.
+ (book_query_score): Give a bonus to the primary address, so that
+ it always comes up first in the completion results.
+
+ * gui/component/e-address-popup.c (e_address_popup_refresh_names):
+ Convert utf8 strings into gtk strings before displaying.
+
2001-04-14 Christopher James Lahey <clahey@ximian.com>
* backend/ebook/e-book-view-listener.c,
diff --git a/addressbook/backend/ebook/e-destination.c b/addressbook/backend/ebook/e-destination.c
index a44ce3ddc8..e6fdb3ee43 100644
--- a/addressbook/backend/ebook/e-destination.c
+++ b/addressbook/backend/ebook/e-destination.c
@@ -36,6 +36,7 @@ struct _EDestinationPrivate {
ECard *card;
gint card_email_num;
+ gchar *name;
gchar *string;
gchar *string_email;
gchar *string_email_verbose;
@@ -147,10 +148,12 @@ e_destination_clear_card (EDestination *dest)
static void
e_destination_clear_strings (EDestination *dest)
{
+ g_free (dest->priv->name);
g_free (dest->priv->string);
g_free (dest->priv->string_email);
g_free (dest->priv->string_email_verbose);
+ dest->priv->name = NULL;
dest->priv->string = NULL;
dest->priv->string_email = NULL;
dest->priv->string_email_verbose = NULL;
@@ -245,6 +248,28 @@ e_destination_get_strlen (const EDestination *dest)
}
const gchar *
+e_destination_get_name (const EDestination *dest)
+{
+ struct _EDestinationPrivate *priv;
+ g_return_val_if_fail (dest && E_IS_DESTINATION (dest), NULL);
+
+ priv = (struct _EDestinationPrivate *)dest->priv; /* cast out const */
+
+ if (priv->name == NULL) {
+
+ if (priv->card) {
+
+ priv->name = e_card_name_to_string (priv->card->name);
+
+ }
+
+ }
+
+ return priv->name;
+
+}
+
+const gchar *
e_destination_get_email (const EDestination *dest)
{
struct _EDestinationPrivate *priv;
@@ -296,10 +321,10 @@ e_destination_get_email_verbose (const EDestination *dest)
const gchar *email = e_destination_get_email (dest);
if (priv->card) {
-
- priv->string_email_verbose = g_strdup_printf ("%s <%s>",
- e_card_name_to_string (priv->card->name),
- email);
+ gchar *n = e_card_name_to_string (priv->card->name);
+ priv->string_email_verbose = g_strdup_printf ("%s <%s>", n, email);
+ g_free (n);
+
} else {
return email;
diff --git a/addressbook/backend/ebook/e-destination.h b/addressbook/backend/ebook/e-destination.h
index d0af6b0d23..3c6de6e316 100644
--- a/addressbook/backend/ebook/e-destination.h
+++ b/addressbook/backend/ebook/e-destination.h
@@ -67,6 +67,8 @@ gint e_destination_get_email_num (const EDestination *);
const gchar *e_destination_get_string (const EDestination *);
gint e_destination_get_strlen (const EDestination *); /* a convenience function... */
+const gchar *e_destination_get_name (const EDestination *);
+
const gchar *e_destination_get_email (const EDestination *);
const gchar *e_destination_get_email_verbose (const EDestination *);
diff --git a/addressbook/gui/component/e-address-popup.c b/addressbook/gui/component/e-address-popup.c
index 19afd29baf..7aebeacf21 100644
--- a/addressbook/gui/component/e-address-popup.c
+++ b/addressbook/gui/component/e-address-popup.c
@@ -167,7 +167,9 @@ e_address_popup_refresh_names (EAddressPopup *pop)
{
if (pop->name_widget) {
if (pop->name && *pop->name) {
- gtk_label_set_text (GTK_LABEL (pop->name_widget), pop->name);
+ gchar *s = e_utf8_to_gtk_string (pop->name_widget, pop->name);
+ gtk_label_set_text (GTK_LABEL (pop->name_widget), s);
+ g_free (s);
gtk_widget_show (pop->name_widget);
} else {
gtk_widget_hide (pop->name_widget);
@@ -176,7 +178,9 @@ e_address_popup_refresh_names (EAddressPopup *pop)
if (pop->email_widget) {
if (pop->email && *pop->email) {
- gtk_label_set_text (GTK_LABEL (pop->email_widget), pop->email);
+ gchar *s = e_utf8_to_gtk_string (pop->email_widget, pop->email);
+ gtk_label_set_text (GTK_LABEL (pop->email_widget), s);
+ g_free (s);
gtk_widget_show (pop->email_widget);
} else {
gtk_widget_hide (pop->email_widget);
diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c
index 88ab176bf6..cebd57791f 100644
--- a/addressbook/gui/component/select-names/e-select-names-completion.c
+++ b/addressbook/gui/component/select-names/e-select-names-completion.c
@@ -36,6 +36,7 @@
#include <addressbook/backend/ebook/e-book-util.h>
#include <addressbook/backend/ebook/e-destination.h>
+#include <addressbook/backend/ebook/e-card-simple.h>
#include "e-select-names-completion.h"
struct _ESelectNamesCompletionPrivate {
@@ -416,12 +417,30 @@ book_query_score (ESelectNamesCompletion *comp, EDestination *dest, double *scor
if (best_string) {
ECard *card = e_destination_get_card (dest);
if (e_list_length (card->email) > 1) {
+ ECardSimple *simp;
const gchar *email = e_destination_get_email (dest);
+ const gchar *simp_email;
+
if (email && strstr (best_string, email) == NULL) {
gchar *tmp = g_strdup_printf ("%s <%s>", best_string, email);
g_free (best_string);
best_string = tmp;
}
+
+ /* Give a small bonus to the primary/secondary e-mail address, so that they will
+ always come in the correct order in the listing. */
+ if (email) {
+ simp = e_card_simple_new (card);
+ simp_email = e_card_simple_get_email (simp, E_CARD_SIMPLE_EMAIL_ID_EMAIL);
+ if (simp_email && !g_strcasecmp (simp_email, email)) {
+ best_score += 0.2;
+ }
+ simp_email = e_card_simple_get_email (simp, E_CARD_SIMPLE_EMAIL_ID_EMAIL_2);
+ if (simp_email && !g_strcasecmp (simp_email, email)) {
+ best_score += 0.1;
+ }
+ gtk_object_unref (GTK_OBJECT (simp));
+ }
}
}
@@ -439,20 +458,27 @@ book_query_process_card_list (ESelectNamesCompletion *comp, const GList *cards)
gint i;
for (i=0; i<e_list_length (card->email); ++i) {
EDestination *dest = e_destination_new ();
+ const gchar *email;
gchar *match_text;
double score = -1;
e_destination_set_card (dest, card, i);
+ email = e_destination_get_email (dest);
+
+ if (email && *email) {
- match_text = book_query_score (comp, dest, &score);
- if (match_text && score > 0) {
-
- e_completion_found_match_full (E_COMPLETION (comp), match_text, score, dest,
- (GtkDestroyNotify) gtk_object_unref);
+ match_text = book_query_score (comp, dest, &score);
+ if (match_text && score > 0) {
+
+ e_completion_found_match_full (E_COMPLETION (comp), match_text, score, dest,
+ (GtkDestroyNotify) gtk_object_unref);
+ } else {
+ gtk_object_unref (GTK_OBJECT (dest));
+ }
+ g_free (match_text);
} else {
gtk_object_unref (GTK_OBJECT (dest));
}
- g_free (match_text);
}
}
@@ -902,7 +928,7 @@ e_select_names_completion_begin (ECompletion *comp, const gchar *text, gint pos,
ESelectNamesCompletion *selcomp = E_SELECT_NAMES_COMPLETION (comp);
const gchar *str;
gint index, j;
-
+
g_return_if_fail (comp != NULL);
g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp));
g_return_if_fail (text != NULL);
diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c
index 59d7bc7c24..1baf729b3e 100644
--- a/addressbook/gui/component/select-names/e-select-names-model.c
+++ b/addressbook/gui/component/select-names/e-select-names-model.c
@@ -355,7 +355,22 @@ e_select_names_model_changed (ESelectNamesModel *model)
g_free (model->priv->addr_text);
model->priv->addr_text = NULL;
- gtk_signal_emit(GTK_OBJECT(model), e_select_names_model_signals[E_SELECT_NAMES_MODEL_CHANGED]);
+#if 0
+ {
+ GList *i = model->priv->data;
+ gint j = 0;
+ g_print ("ESelectNamesModel state:\n");
+ while (i) {
+ EDestination *dest = (EDestination *) i->data;
+ g_print ("%d: %s <%s>\n", j, e_destination_get_string (dest), e_destination_get_email (dest));
+ i = g_list_next (i);
+ ++j;
+ }
+ g_print ("\n");
+ }
+#endif
+
+ gtk_signal_emit (GTK_OBJECT(model), e_select_names_model_signals[E_SELECT_NAMES_MODEL_CHANGED]);
}
void
@@ -375,6 +390,20 @@ e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination
}
void
+e_select_names_model_append (ESelectNamesModel *model, EDestination *dest)
+{
+ g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model));
+ g_return_if_fail (dest && E_IS_DESTINATION (dest));
+
+ model->priv->data = g_list_append (model->priv->data, dest);
+
+ gtk_object_ref (GTK_OBJECT (dest));
+ gtk_object_sink (GTK_OBJECT (dest));
+
+ e_select_names_model_changed (model);
+}
+
+void
e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest)
{
GList *node;
@@ -518,8 +547,16 @@ e_select_names_model_text_pos (ESelectNamesModel *model, gint pos, gint *index,
while (iter != NULL) {
len = e_destination_get_strlen (E_DESTINATION (iter->data));
- if (sp <= pos && pos <= sp + len + adj)
+#if 0
+ g_print ("text_pos: %d %d %d %d\n", len, sp, pos, adj);
+#endif
+
+ if (sp <= pos && pos <= sp + len + adj) {
+#if 0
+ g_print ("breaking\n");
+#endif
break;
+ }
sp += len + adj + 1;
adj = 1;
@@ -532,9 +569,16 @@ e_select_names_model_text_pos (ESelectNamesModel *model, gint pos, gint *index,
++sp; /* skip past "magic space" */
if (iter == NULL) {
+#if 0
+ g_print ("text_pos ended NULL\n");
+#endif
i = -1;
sp = -1;
len = 0;
+ } else {
+#if 0
+ g_print ("text_pos got index %d\n", i);
+#endif
}
if (index)
diff --git a/addressbook/gui/component/select-names/e-select-names-model.h b/addressbook/gui/component/select-names/e-select-names-model.h
index ab7477762c..2e1c970ef7 100644
--- a/addressbook/gui/component/select-names/e-select-names-model.h
+++ b/addressbook/gui/component/select-names/e-select-names-model.h
@@ -55,6 +55,7 @@ ECard *e_select_names_model_get_card (ESelectNamesModel *mod
const gchar *e_select_names_model_get_string (ESelectNamesModel *model, gint index);
void e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest);
+void e_select_names_model_append (ESelectNamesModel *model, EDestination *dest);
void e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest);
void e_select_names_model_delete (ESelectNamesModel *model, gint index);
void e_select_names_model_delete_all (ESelectNamesModel *model);
diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c
index 30dc482e85..b2468402c8 100644
--- a/addressbook/gui/component/select-names/e-select-names.c
+++ b/addressbook/gui/component/select-names/e-select-names.c
@@ -146,9 +146,7 @@ real_add_address_cb (int model_row,
e_destination_set_card (dest, card, 0);
- e_select_names_model_insert (child->source,
- e_select_names_model_count (child->source),
- dest);
+ e_select_names_model_append (child->source, dest);
e_select_names_model_clean (child->source);
gtk_object_unref(GTK_OBJECT(card));