diff options
author | Jon Trowbridge <trow@ximian.com> | 2001-02-20 06:49:18 +0800 |
---|---|---|
committer | Jon Trowbridge <trow@src.gnome.org> | 2001-02-20 06:49:18 +0800 |
commit | d369e177b199c4c798f0b6ad8972951d8586bcd9 (patch) | |
tree | 492dd3459df5e78e6709e7879a70011f4f729012 /addressbook/gui/component/select-names/e-select-names-manager.c | |
parent | 54105acd4e5283899c1659e64e41341eec8d667c (diff) | |
download | gsoc2013-evolution-d369e177b199c4c798f0b6ad8972951d8586bcd9.tar gsoc2013-evolution-d369e177b199c4c798f0b6ad8972951d8586bcd9.tar.gz gsoc2013-evolution-d369e177b199c4c798f0b6ad8972951d8586bcd9.tar.bz2 gsoc2013-evolution-d369e177b199c4c798f0b6ad8972951d8586bcd9.tar.lz gsoc2013-evolution-d369e177b199c4c798f0b6ad8972951d8586bcd9.tar.xz gsoc2013-evolution-d369e177b199c4c798f0b6ad8972951d8586bcd9.tar.zst gsoc2013-evolution-d369e177b199c4c798f0b6ad8972951d8586bcd9.zip |
When creating the entry, open up an ebook (corresponding to the local
2001-02-19 Jon Trowbridge <trow@ximian.com>
* gui/component/select-names/e-select-names-manager.c
(e_select_names_manager_create_entry): When creating the entry,
open up an ebook (corresponding to the local addressbook) and make
the entry use an EAddressCompletion.
(completion_handler): Added; this is the actual completion
handler, which manipulates the entry when the user selects
something from the drop-down.
* gui/component/select-names/e-select-names-model.c: Various hacks
by clahey to unbreak e_select_names_model_add_item,
e_select_names_model_replace_item (which I added) and
e_select_names_model_remove_item.
* gui/component/select-names/e-select-names-text-model.c
(e_select_names_text_model_obj_count,
e_select_names_text_model_get_nth_obj): Make chunks of text that
correspond to ECards in the ESelectNamesModel be embedded objects.
(e_select_names_text_model_activate_obj): On activation, pop up a
contact editor for the embedded object's card.
(e_select_names_text_model_model_changed): Fixed to work with
ETextModel API changes.
(e_select_names_text_model_set_text): Make const correct.
(e_select_names_text_model_insert): Make const correct.
(e_select_names_text_model_insert_length): Make const correct.
* backend/ebook/e-address-completion.h,
backend/ebook/e-address-completion.c: Added. EAddressCompletion
is a derived class of ECompletion that does asynchronous address
lookups for completions.
svn path=/trunk/; revision=8282
Diffstat (limited to 'addressbook/gui/component/select-names/e-select-names-manager.c')
-rw-r--r-- | addressbook/gui/component/select-names/e-select-names-manager.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c index 3af59611ab..3e629af19d 100644 --- a/addressbook/gui/component/select-names/e-select-names-manager.c +++ b/addressbook/gui/component/select-names/e-select-names-manager.c @@ -16,6 +16,7 @@ #include "e-select-names-model.h" #include "e-select-names-text-model.h" #include "e-select-names.h" +#include <addressbook/backend/ebook/e-address-completion.h> #include <gal/e-text/e-entry.h> /* Object argument IDs */ @@ -242,6 +243,32 @@ entry_destroyed(EEntry *entry, ESelectNamesManager *manager) gtk_object_unref(GTK_OBJECT(manager)); } +static void +completion_handler (EEntry *entry, const gchar *text, gpointer user_data) +{ + ESelectNamesModel *snm = E_SELECT_NAMES_MODEL (gtk_object_get_data (GTK_OBJECT (entry), "select_names_model")); + ESelectNamesModelData *data = g_new0 (ESelectNamesModelData, 1); + EIterator *iterator; + + data->type = E_SELECT_NAMES_MODEL_DATA_TYPE_CARD; + data->card = E_CARD (user_data); + gtk_object_ref (GTK_OBJECT (data->card)); + data->string = g_strdup (text); + + iterator = e_list_get_iterator (snm->data); + e_select_names_model_replace_item (snm, iterator, data); +} + +static void +set_completion (EBook *book, EBookStatus status, EEntry *entry) +{ + ECompletion *addr_comp; + + addr_comp = e_address_completion_new (book); + e_entry_enable_completion_full (entry, addr_comp, -1, completion_handler); + gtk_object_unref (GTK_OBJECT (book)); +} + GtkWidget *e_select_names_manager_create_entry (ESelectNamesManager *manager, const char *id) { @@ -253,11 +280,23 @@ GtkWidget *e_select_names_manager_create_entry ( if (!strcmp(section->id, id)) { ESelectNamesManagerEntry *entry; EEntry *eentry; - eentry = E_ENTRY(e_entry_new()); + gchar *filename = gnome_util_prepend_user_home ("evolution/local/Contacts/addressbook.db"); + gchar *uri = g_strdup_printf ("file://%s", filename); + EBook *book; + eentry = E_ENTRY(e_entry_new()); + gtk_object_set_data (GTK_OBJECT (eentry), "select_names_model", section->model); + + book = e_book_new (); + gtk_object_ref (GTK_OBJECT (book)); + e_book_load_uri (book, uri, (EBookCallback) set_completion, eentry); + g_free (uri); + g_free (filename); + entry = g_new(ESelectNamesManagerEntry, 1); entry->entry = eentry; entry->id = (char *)id; + model = e_select_names_text_model_new(section->model); e_list_append(manager->entries, entry); g_free(entry); |