diff options
author | Jon Trowbridge <trow@src.gnome.org> | 2001-07-07 14:39:30 +0800 |
---|---|---|
committer | Jon Trowbridge <trow@src.gnome.org> | 2001-07-07 14:39:30 +0800 |
commit | f9e0870bb8f2cee522b1d74d8d430cd898a420e5 (patch) | |
tree | afe1ea372bafca21d8f328fd861305919fcc97a0 | |
parent | da9c4d10641eed27263f12c7415100348991ef32 (diff) | |
download | gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar.gz gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar.bz2 gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar.lz gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar.xz gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.tar.zst gsoc2013-evolution-f9e0870bb8f2cee522b1d74d8d430cd898a420e5.zip |
CVS is unhappy this evening. My commit keeps dying in the middle.
svn path=/trunk/; revision=10883
9 files changed, 106 insertions, 145 deletions
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 27cc598f5d..2590a8515b 100644 --- a/addressbook/gui/component/select-names/e-select-names-completion.c +++ b/addressbook/gui/component/select-names/e-select-names-completion.c @@ -127,7 +127,7 @@ emailify_match (ECompletionMatch *match) const gchar *email = e_destination_get_email (dest); const gchar *menu_txt = e_completion_match_get_menu_text (match); - if (card && card->email && e_list_length (card->email) > 1) { + if (card && card->email && e_list_length (card->email) > 1 && !e_card_evolution_list (card)) { if (email && strstr (menu_txt, email) == NULL) { gchar *tmp = g_strdup_printf ("%s <%s>", menu_txt, email); @@ -196,7 +196,9 @@ match_email (ESelectNamesCompletion *comp, EDestination *dest) const gchar *email = e_destination_get_email (dest); double score; - if (email && !g_utf8_strncasecmp (comp->priv->query_text, email, len)) { + if (email + && !g_utf8_strncasecmp (comp->priv->query_text, email, len) + && !e_destination_is_evolution_list (dest)) { gchar *name, *str; @@ -367,7 +369,11 @@ match_name (ESelectNamesCompletion *comp, EDestination *dest) have_additional = card->name->additional && *card->name->additional; have_family = card->name->family && *card->name->family; - if (first_match == MATCHED_GIVEN_NAME) { + if (first_match != MATCHED_NOTHING && e_card_evolution_list (card)) { + + menu_text = e_card_name_to_string (card->name); + + } else if (first_match == MATCHED_GIVEN_NAME) { if (have_family) menu_text = g_strdup_printf ("%s %s", card->name->given, card->name->family); @@ -535,7 +541,20 @@ book_query_process_card_list (ESelectNamesCompletion *comp, const GList *cards) while (cards) { ECard *card = E_CARD (cards->data); - if (card->email) { + if (e_card_evolution_list (card)) { + + EDestination *dest = e_destination_new (); + ECompletionMatch *match; + e_destination_set_card (dest, card, 0); + match = book_query_score (comp, dest); + if (match && match->score > 0) { + e_completion_found_match (E_COMPLETION (comp), match); + } else { + e_completion_match_unref (match); + } + gtk_object_unref (GTK_OBJECT (dest)); + + } else if (card->email) { gint i; for (i=0; i<e_list_length (card->email); ++i) { EDestination *dest = e_destination_new (); 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 8c10aa6035..3cdd5913a5 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ b/addressbook/gui/component/select-names/e-select-names-model.c @@ -212,21 +212,6 @@ e_select_names_model_changed (ESelectNamesModel *model) g_free (model->priv->addr_text); model->priv->addr_text = NULL; -#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]); } @@ -276,9 +261,7 @@ e_select_names_model_get_textification (ESelectNamesModel *model) while (iter) { EDestination *dest = E_DESTINATION (iter->data); - strv[i] = (gchar *) e_destination_get_string (dest); - if (strv[i] == NULL) - strv[i] = ""; + strv[i] = (gchar *) e_destination_get_textrep (dest); ++i; iter = g_list_next (iter); } @@ -311,7 +294,7 @@ e_select_names_model_get_address_text (ESelectNamesModel *model) while (iter) { EDestination *dest = E_DESTINATION (iter->data); - strv[i] = (gchar *) e_destination_get_email_verbose (dest); + strv[i] = (gchar *) e_destination_get_address (dest); if (strv[i]) ++i; iter = g_list_next (iter); @@ -421,7 +404,7 @@ e_select_names_model_get_string (ESelectNamesModel *model, gint index) dest = e_select_names_model_get_destination (model, index); - return dest ? e_destination_get_string (dest) : ""; + return dest ? e_destination_get_textrep (dest) : ""; } void @@ -458,6 +441,7 @@ void e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest) { GList *node; + const gchar *new_str, *old_str; gint old_strlen=0, new_strlen=0; g_return_if_fail (model != NULL); @@ -465,7 +449,8 @@ e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination g_return_if_fail (model->priv->data == NULL || (0 <= index && index < g_list_length (model->priv->data))); g_return_if_fail (dest && E_IS_DESTINATION (dest)); - new_strlen = e_destination_get_strlen (dest); + new_str = e_destination_get_textrep (dest); + new_strlen = new_str ? strlen (new_str) : 0; if (model->priv->data == NULL) { @@ -478,7 +463,9 @@ e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination node = g_list_nth (model->priv->data, index); if (node->data != dest) { - old_strlen = e_destination_get_strlen (E_DESTINATION (node->data)); + + old_str = e_destination_get_textrep (E_DESTINATION (node->data)); + old_strlen = old_str ? strlen (old_str) : 0; gtk_object_unref (GTK_OBJECT (node->data)); @@ -560,6 +547,7 @@ e_select_names_model_name_pos (ESelectNamesModel *model, gint index, gint *pos, { gint rp = 0, i, len = 0; GList *iter; + const gchar *str; g_return_if_fail (model != NULL); g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); @@ -568,7 +556,8 @@ e_select_names_model_name_pos (ESelectNamesModel *model, gint index, gint *pos, iter = model->priv->data; while (iter && i <= index) { rp += len + (i > 0 ? SEPLEN : 0); - len = e_destination_get_strlen (E_DESTINATION (iter->data)); + str = e_destination_get_textrep (E_DESTINATION (iter->data)); + len = str ? strlen (str) : 0; ++i; iter = g_list_next (iter); } @@ -588,6 +577,7 @@ void e_select_names_model_text_pos (ESelectNamesModel *model, gint pos, gint *index, gint *start_pos, gint *length) { GList *iter; + const gchar *str; gint len = 0, i = 0, sp = 0, adj = 0; g_return_if_fail (model != NULL); @@ -596,16 +586,10 @@ e_select_names_model_text_pos (ESelectNamesModel *model, gint pos, gint *index, iter = model->priv->data; while (iter != NULL) { - len = e_destination_get_strlen (E_DESTINATION (iter->data)); - -#if 0 - g_print ("text_pos: %d %d %d %d\n", len, sp, pos, adj); -#endif + str = e_destination_get_textrep (E_DESTINATION (iter->data)); + len = str ? strlen (str) : 0; if (sp <= pos && pos <= sp + len + adj) { -#if 0 - g_print ("breaking\n"); -#endif break; } diff --git a/addressbook/gui/component/select-names/e-select-names-popup.c b/addressbook/gui/component/select-names/e-select-names-popup.c index fb05ff686a..aa668884c2 100644 --- a/addressbook/gui/component/select-names/e-select-names-popup.c +++ b/addressbook/gui/component/select-names/e-select-names-popup.c @@ -216,7 +216,6 @@ popup_menu_card (PopupInfo *info) gint i=0; GtkWidget *pop; EIterator *iterator; - gchar *name_str; gint html_toggle; /* @@ -227,10 +226,9 @@ popup_menu_card (PopupInfo *info) memset (radioinfo, 0, sizeof (radioinfo)); card = e_destination_get_card (info->dest); - name_str = e_card_name_to_string (card->name); uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = name_str; + uiinfo[i].label = (gchar *) e_destination_get_name (info->dest); ++i; uiinfo[i].type = GNOME_APP_UI_SEPARATOR; @@ -290,7 +288,6 @@ popup_menu_card (PopupInfo *info) */ pop = gnome_popup_menu_new (uiinfo); - g_free (name_str); if (using_radio) { gint n = e_destination_get_email_num (info->dest); @@ -311,7 +308,7 @@ static void quick_add_cb (GtkWidget *w, gpointer user_data) { PopupInfo *info = (PopupInfo *) user_data; - e_contact_quick_add_free_form (e_destination_get_string (info->dest), NULL, NULL); + e_contact_quick_add_free_form (e_destination_get_address (info->dest), NULL, NULL); } static GtkWidget * @@ -325,7 +322,7 @@ popup_menu_nocard (PopupInfo *info) memset (uiinfo, 0, sizeof (uiinfo)); - str = e_destination_get_string (info->dest); + str = e_destination_get_name (info->dest); uiinfo[i].type = GNOME_APP_UI_ITEM; uiinfo[i].label = (gchar *) str; diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.c b/addressbook/gui/component/select-names/e-select-names-table-model.c index 9d93305396..fee84ce071 100644 --- a/addressbook/gui/component/select-names/e-select-names-table-model.c +++ b/addressbook/gui/component/select-names/e-select-names-table-model.c @@ -129,8 +129,8 @@ fill_in_info (ESelectNamesTableModel *model) model->data[i].email = g_strdup(""); gtk_object_unref(GTK_OBJECT(simple)); } else { - model->data[i].name = g_strdup (e_destination_get_string (dest)); - model->data[i].email = g_strdup (model->data[i].name); + model->data[i].name = g_strdup (e_destination_get_name (dest)); + model->data[i].email = g_strdup (e_destination_get_email (dest)); } } } else { diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.c b/addressbook/gui/component/select-names/e-select-names-text-model.c index 7c87c887f5..50a09bd010 100644 --- a/addressbook/gui/component/select-names/e-select-names-text-model.c +++ b/addressbook/gui/component/select-names/e-select-names-text-model.c @@ -312,7 +312,7 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha if (text[i] == ',' && index >= 0) { /* Is this a quoted or an unquoted comma we are dealing with? */ const EDestination *dest = e_select_names_model_get_destination (source, index); if (dest) { - const gchar *str = e_destination_get_string (dest); + const gchar *str = e_destination_get_textrep (dest); gint j; if (out) fprintf (out, "str=%s pos=%d\n", str, pos); diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 86e283f0f6..805604b722 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -765,9 +765,12 @@ extract_info(EContactListEditor *editor) NULL); for (i = 0; i < e_table_model_row_count (editor->model); i ++) { - char *email = e_contact_list_model_get_email (E_CONTACT_LIST_MODEL(editor->model), i); - e_list_append (email_list, email); - g_free (email); + const EDestination *dest = e_contact_list_model_get_destination (E_CONTACT_LIST_MODEL (editor->model), i); + gchar *dest_xml = e_destination_export (dest); + if (dest_xml) { + e_list_append (email_list, dest_xml); + } + g_free (dest_xml); } } } @@ -802,24 +805,14 @@ fill_in_info(EContactListEditor *editor) email_iter = e_list_get_iterator (email_list); while (e_iterator_is_valid (email_iter)) { - const char *email = e_iterator_get (email_iter); - - if (!strncmp (email, ECARD_UID_LINK_PREFIX, strlen (ECARD_UID_LINK_PREFIX))) { - ECard *card; - const char *uid; - /* it's a serialized uid */ - uid = email + strlen (ECARD_UID_LINK_PREFIX); - card = e_book_get_card (editor->book, uid); - if (card) { - ECardSimple *simple = e_card_simple_new (card); - gtk_object_unref (GTK_OBJECT (card)); - e_contact_list_model_add_card (E_CONTACT_LIST_MODEL (editor->model), - simple); - } - } - else { - e_contact_list_model_add_email (E_CONTACT_LIST_MODEL (editor->model), - email); + const char *dest_xml = e_iterator_get (email_iter); + EDestination *dest; + + g_message ("incoming xml: [%s]", dest_xml); + dest = e_destination_import (dest_xml); + + if (dest != NULL) { + e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL (editor->model), dest); } e_iterator_next (email_iter); diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.c b/addressbook/gui/contact-list-editor/e-contact-list-model.c index 5a966c67d1..eb6f59741b 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-model.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-model.c @@ -29,7 +29,7 @@ contact_list_value_at (ETableModel *etc, int col, int row) { EContactListModel *model = E_CONTACT_LIST_MODEL (etc); - return model->data[row]->string; + return (void *) e_destination_get_address (model->data[row]); } /* This function sets the value at a particular point in our ETableModel. */ @@ -85,10 +85,7 @@ contact_list_model_destroy (GtkObject *o) int i; for (i = 0; i < model->data_count; i ++) { - g_free (model->data[i]->string); - if (model->data[i]->simple) - gtk_object_unref (GTK_OBJECT(model->data[i]->simple)); - g_free (model->data[i]); + gtk_object_unref (GTK_OBJECT (model->data[i])); } g_free (model->data); @@ -124,7 +121,7 @@ e_contact_list_model_init (GtkObject *object) model->data_alloc = 10; model->data_count = 0; - model->data = g_new (EContactListModelRow*, model->data_alloc); + model->data = g_new (EDestination*, model->data_alloc); } GtkType @@ -168,73 +165,49 @@ e_contact_list_model_new () } void -e_contact_list_model_add_email (EContactListModel *model, - const char *email) +e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest) { - EContactListModelRow *new_row; - if (model->data_count + 1 >= model->data_alloc) { model->data_alloc *= 2; - model->data = g_renew (EContactListModelRow*, model->data, model->data_alloc); + model->data = g_renew (EDestination*, model->data, model->data_alloc); } - new_row = g_new (EContactListModelRow, 1); - new_row->type = E_CONTACT_LIST_MODEL_ROW_EMAIL; - new_row->simple = NULL; - new_row->string = g_strdup (email); - - model->data[model->data_count ++] = new_row; + model->data[model->data_count ++] = dest; + gtk_object_ref (GTK_OBJECT (dest)); + gtk_object_sink (GTK_OBJECT (dest)); e_table_model_changed (E_TABLE_MODEL (model)); } void -e_contact_list_model_add_card (EContactListModel *model, - ECardSimple *simple) +e_contact_list_model_add_email (EContactListModel *model, + const char *email) { - EContactListModelRow *new_row; - char *email, *name; - - name = e_card_simple_get (simple, E_CARD_SIMPLE_FIELD_NAME_OR_ORG); - email = e_card_simple_get (simple, E_CARD_SIMPLE_FIELD_EMAIL); - - if (! name && ! email) { - /* what to do here? */ - return; - } - + EDestination *new_dest; - if (model->data_count + 1 >= model->data_alloc) { - model->data_alloc *= 2; - model->data = g_renew (EContactListModelRow*, model->data, model->data_alloc); - } + new_dest = e_destination_new (); + e_destination_set_email (new_dest, email); - new_row = g_new (EContactListModelRow, 1); - - new_row->type = E_CONTACT_LIST_MODEL_ROW_CARD; - new_row->simple = simple; - if (FALSE /* XXX e_card_simple_get (simple, E_CARD_SIMPLE_FIELD_EVOLUTION_LIST)*/) - new_row->string = g_strconcat ("<", name, ">", NULL); - else - new_row->string = g_strconcat (name ? name : "", - email ? " <" : "", email ? email : "", email ? ">" : "", - NULL); + e_contact_list_model_add_destination (model, new_dest); +} - model->data[model->data_count++] = new_row; +void +e_contact_list_model_add_card (EContactListModel *model, + ECardSimple *simple) +{ + EDestination *new_dest; - gtk_object_ref (GTK_OBJECT (simple)); + new_dest = e_destination_new (); + e_destination_set_card (new_dest, simple->card, 0); /* Hard-wired for default e-mail */ - e_table_model_changed (E_TABLE_MODEL (model)); + e_contact_list_model_add_destination (model, new_dest); } void e_contact_list_model_remove_row (EContactListModel *model, int row) { - g_free (model->data[row]->string); - if (model->data[row]->simple) - gtk_object_unref (GTK_OBJECT(model->data[row]->simple)); - g_free (model->data[row]); - memmove (model->data + row, model->data + row + 1, sizeof (EContactListModelRow*) * (model->data_count - row - 1)); + gtk_object_unref (GTK_OBJECT (model->data[row])); + memmove (model->data + row, model->data + row + 1, sizeof (EDestination*) * (model->data_count - row - 1)); model->data_count --; e_table_model_changed (E_TABLE_MODEL (model)); @@ -246,10 +219,7 @@ e_contact_list_model_remove_all (EContactListModel *model) int i; for (i = 0; i < model->data_count; i ++) { - g_free (model->data[i]->string); - if (model->data[i]->simple) - gtk_object_unref (GTK_OBJECT(model->data[i]->simple)); - g_free (model->data[i]); + gtk_object_unref (GTK_OBJECT (model->data[i])); model->data[i] = NULL; } @@ -259,13 +229,8 @@ e_contact_list_model_remove_all (EContactListModel *model) } -char* -e_contact_list_model_get_email (EContactListModel *model, int row) +const EDestination * +e_contact_list_model_get_destination (EContactListModel *model, int row) { - EContactListModelRow *data = model->data[row]; - - if (data->type == E_CONTACT_LIST_MODEL_ROW_EMAIL) - return g_strdup (data->string); - else - return g_strconcat (ECARD_UID_LINK_PREFIX, e_card_simple_get_id (data->simple), NULL); + return model->data[row]; } diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.h b/addressbook/gui/contact-list-editor/e-contact-list-model.h index 7b1e092944..1c2d6ac8d0 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-model.h +++ b/addressbook/gui/contact-list-editor/e-contact-list-model.h @@ -6,6 +6,7 @@ #include "addressbook/backend/ebook/e-book.h" #include "addressbook/backend/ebook/e-book-view.h" #include "addressbook/backend/ebook/e-card-simple.h" +#include "addressbook/backend/ebook/e-destination.h" #define E_CONTACT_LIST_MODEL_TYPE (e_contact_list_model_get_type ()) #define E_CONTACT_LIST_MODEL(o) (GTK_CHECK_CAST ((o), E_CONTACT_LIST_MODEL_TYPE, EContactListModel)) @@ -16,21 +17,10 @@ typedef struct _EContactListModel EContactListModel; typedef struct _EContactListModelClass EContactListModelClass; -typedef enum { - E_CONTACT_LIST_MODEL_ROW_EMAIL, - E_CONTACT_LIST_MODEL_ROW_CARD, -} EContactListModelRowType; - -typedef struct { - EContactListModelRowType type; - ECardSimple *simple; - char *string; -} EContactListModelRow; - struct _EContactListModel { ETableModel parent; - EContactListModelRow **data; + EDestination **data; int data_count; int data_alloc; }; @@ -45,11 +35,13 @@ GtkType e_contact_list_model_get_type (void); void e_contact_list_model_construct (EContactListModel *model); ETableModel *e_contact_list_model_new (void); -void e_contact_list_model_add_email (EContactListModel *model, const char *email); -void e_contact_list_model_add_card (EContactListModel *model, ECardSimple *simple); +void e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest); +void e_contact_list_model_add_email (EContactListModel *model, const char *email); +void e_contact_list_model_add_card (EContactListModel *model, ECardSimple *simple); + void e_contact_list_model_remove_row (EContactListModel *model, int row); void e_contact_list_model_remove_all (EContactListModel *model); -char *e_contact_list_model_get_row (EContactListModel *model, ECardSimple *simple); -char *e_contact_list_model_get_email (EContactListModel *model, int row); + +const EDestination *e_contact_list_model_get_destination (EContactListModel *model, int row); #endif /* _E_CONTACT_LIST_MODEL_H_ */ diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index 2d74280b72..123392df95 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -674,6 +674,17 @@ add_field (EMinicard *e_minicard, ECardSimpleField field, gdouble left_width) name = g_strdup_printf("%s:", e_card_simple_get_name(e_minicard->simple, field)); string = e_card_simple_get(e_minicard->simple, field); + /* Magically convert embedded XML into an address. */ + if (!strncmp (string, "<?xml", 4)) { + EDestination *dest = e_destination_import (string); + if (dest != NULL) { + gchar *new_string = g_strdup (e_destination_get_address (dest)); + g_free (string); + string = new_string; + gtk_object_unref (GTK_OBJECT (dest)); + } + } + new_item = e_minicard_label_new(group); gnome_canvas_item_set( new_item, "width", e_minicard->width - 4.0, |