From 353946a818a6e373773cdfcad543e9d6b65f042d Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 2 Jul 2001 04:54:22 +0000 Subject: Added related_contacts field. 2001-07-02 Christopher James Lahey * backend/ebook/e-card.c, backend/ebook/e-card.h: Added related_contacts field. * gui/component/select-names/e-select-names-model.c, gui/component/select-names/e-select-names-model.h (e_select_names_model_import_destinationv): Added this function. * gui/contact-editor/contact-editor.glade: Replaced the entry here for related contacts with a table which is filled in in the C code. * gui/contact-editor/e-contact-editor.c, gui/contact-editor/e-contact-editor.h (add_lists): Added a select names entry here for the related contacts field. * gui/widgets/Makefile.am: Removed all the test programs here since there are circular dependencies now. svn path=/trunk/; revision=10666 --- .../component/select-names/e-select-names-model.c | 81 ++++++++++----- .../component/select-names/e-select-names-model.h | 2 + .../gui/contact-editor/contact-editor.glade | 82 +++++++-------- addressbook/gui/contact-editor/e-contact-editor.c | 89 ++++++++++++++-- addressbook/gui/contact-editor/e-contact-editor.h | 3 + addressbook/gui/widgets/Makefile.am | 112 +++++++++++---------- 6 files changed, 235 insertions(+), 134 deletions(-) (limited to 'addressbook/gui') 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 d562b40a64..8c10aa6035 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ b/addressbook/gui/component/select-names/e-select-names-model.c @@ -202,6 +202,34 @@ e_select_names_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) } } + +static void +e_select_names_model_changed (ESelectNamesModel *model) +{ + g_free (model->priv->text); + model->priv->text = NULL; + + 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]); +} + /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ ESelectNamesModel * @@ -342,6 +370,32 @@ e_select_names_model_export_destinationv (ESelectNamesModel *model) return str; } +static +void send_changed (EDestination *dest, ECard *card, gpointer closure) +{ + ESelectNamesModel *model = closure; + e_select_names_model_changed (model); +} + +void +e_select_names_model_import_destinationv (ESelectNamesModel *model, + gchar *destinationv) +{ + EDestination **destv; + gint i; + + g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); + + destv = e_destination_importv (destinationv); + + e_select_names_model_delete_all (model); + for (i = 0; destv[i]; i++) { + e_destination_use_card (destv[i], send_changed, model); + e_select_names_model_append (model, destv[i]); + } + g_free (destv); +} + ECard * e_select_names_model_get_card (ESelectNamesModel *model, gint index) { @@ -370,33 +424,6 @@ e_select_names_model_get_string (ESelectNamesModel *model, gint index) return dest ? e_destination_get_string (dest) : ""; } -static void -e_select_names_model_changed (ESelectNamesModel *model) -{ - g_free (model->priv->text); - model->priv->text = NULL; - - 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]); -} - void e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest) { 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 417ec7abb1..989a829223 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.h +++ b/addressbook/gui/component/select-names/e-select-names-model.h @@ -52,6 +52,8 @@ const gchar *e_select_names_model_get_address_text (ESelectNamesModel *model); gint e_select_names_model_count (ESelectNamesModel *model); const EDestination *e_select_names_model_get_destination (ESelectNamesModel *model, gint index); gchar *e_select_names_model_export_destinationv (ESelectNamesModel *model); +void e_select_names_model_import_destinationv (ESelectNamesModel *model, + gchar *destinationv); ECard *e_select_names_model_get_card (ESelectNamesModel *model, gint index); const gchar *e_select_names_model_get_string (ESelectNamesModel *model, gint index); diff --git a/addressbook/gui/contact-editor/contact-editor.glade b/addressbook/gui/contact-editor/contact-editor.glade index af5d17d954..eb351d8bcc 100644 --- a/addressbook/gui/contact-editor/contact-editor.glade +++ b/addressbook/gui/contact-editor/contact-editor.glade @@ -1332,39 +1332,6 @@ - - GtkAlignment - alignment14 - 0.5 - 0.5 - 1 - 0 - - 3 - 4 - 12 - 13 - 0 - 0 - True - False - False - False - True - True - - - - GtkEntry - entry-contacts - True - True - True - 0 - - - - GtkAlignment alignment16 @@ -1651,6 +1618,39 @@ True + + + GtkAlignment + alignment17 + 0.5 + 0.5 + 1 + 0 + + 3 + 4 + 12 + 13 + 0 + 0 + True + False + False + False + True + True + + + + GtkTable + table-contacts + 1 + 1 + False + 0 + 0 + + @@ -2257,16 +2257,16 @@ Custom - dateedit-anniversary + dateedit-birthday e_contact_editor_create_date 0 0 - Tue, 05 Jun 2001 02:36:32 GMT + Tue, 05 Jun 2001 02:36:27 GMT 4 6 - 5 - 6 + 4 + 5 0 0 True @@ -2280,16 +2280,16 @@ Custom - dateedit-birthday + dateedit-anniversary e_contact_editor_create_date 0 0 - Tue, 05 Jun 2001 02:36:27 GMT + Tue, 05 Jun 2001 02:36:32 GMT 4 6 - 4 - 5 + 5 + 6 0 0 True diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index 41a58e0ca4..2b9c22a249 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -37,6 +37,9 @@ #include #include #include +#include + +#include #include "addressbook/printing/e-contact-print.h" #include "addressbook/printing/e-contact-print-envelope.h" @@ -643,10 +646,11 @@ full_addr_clicked(GtkWidget *button, EContactEditor *editor) static void categories_clicked(GtkWidget *button, EContactEditor *editor) { - char *categories; + char *categories = NULL; GnomeDialog *dialog; int result; GtkWidget *entry = glade_xml_get_widget(editor->gui, "entry-categories"); + ECategoriesMasterList *ecml; if (entry && GTK_IS_ENTRY(entry)) categories = e_utf8_gtk_entry_get_text(GTK_ENTRY(entry)); else if (editor->card) @@ -654,9 +658,12 @@ categories_clicked(GtkWidget *button, EContactEditor *editor) "categories", &categories, NULL); dialog = GNOME_DIALOG(e_categories_new(categories)); + ecml = e_categories_master_list_wombat_new (); gtk_object_set(GTK_OBJECT(dialog), "header", _("This contact belongs to these categories:"), + "ecml", ecml, NULL); + gtk_object_unref (GTK_OBJECT (ecml)); gtk_widget_show(GTK_WIDGET(dialog)); result = gnome_dialog_run (dialog); g_free (categories); @@ -673,12 +680,43 @@ categories_clicked(GtkWidget *button, EContactEditor *editor) g_free(categories); } gtk_object_destroy(GTK_OBJECT(dialog)); -#if 0 - if (!entry) - g_free(categories); -#endif } +static void +ensure_select_names_contact (EContactEditor *editor) +{ + if (editor->select_names_contacts == NULL) { + editor->select_names_contacts = e_select_names_manager_new (); + e_select_names_manager_add_section (editor->select_names_contacts, + "contacts", + "Related Contacts"); + } +} + +static void +contacts_clicked (GtkWidget *button, EContactEditor *editor) +{ + ensure_select_names_contact (editor); + e_select_names_manager_activate_dialog (editor->select_names_contacts, + "contacts"); +} + +static void +add_lists (EContactEditor *editor) +{ + GtkWidget *table = glade_xml_get_widget (editor->gui, "table-contacts"); + if (table && GTK_IS_TABLE (table)) { + GtkWidget *entry; + + ensure_select_names_contact (editor); + entry = e_select_names_manager_create_entry (editor->select_names_contacts, + "contacts"); + gtk_table_attach_defaults (GTK_TABLE (table), entry, 0, 1, 0, 1); + gtk_widget_show (entry); + } +} + + typedef struct { EContactEditor *ce; gboolean should_close; @@ -1032,6 +1070,7 @@ e_contact_editor_init (EContactEditor *e_contact_editor) e_contact_editor); _replace_buttons(e_contact_editor); + add_lists (e_contact_editor); set_entry_changed_signals(e_contact_editor); wants_html = glade_xml_get_widget(e_contact_editor->gui, "checkbutton-htmlmail"); @@ -1054,6 +1093,11 @@ e_contact_editor_init (EContactEditor *e_contact_editor) gtk_signal_connect(GTK_OBJECT(widget), "clicked", categories_clicked, e_contact_editor); + widget = glade_xml_get_widget(e_contact_editor->gui, "button-contacts"); + if (widget && GTK_IS_BUTTON(widget)) + gtk_signal_connect(GTK_OBJECT(widget), "clicked", + contacts_clicked, e_contact_editor); + /* Construct the app */ bonobo_win = bonobo_window_new ("contact-editor-dialog", "Contact Editor"); @@ -2080,6 +2124,7 @@ fill_in_info(EContactEditor *editor) ECard *card = editor->card; if (card) { char *file_as; + char *related_contacts; ECardName *name; const ECardDate *anniversary; const ECardDate *bday; @@ -2089,12 +2134,13 @@ fill_in_info(EContactEditor *editor) gboolean wants_html, wants_html_set; gtk_object_get(GTK_OBJECT(card), - "file_as", &file_as, - "name", &name, - "anniversary", &anniversary, - "birth_date", &bday, - "wants_html_set",&wants_html_set, - "wants_html", &wants_html, + "file_as", &file_as, + "related_contacts", &related_contacts, + "name", &name, + "anniversary", &anniversary, + "birth_date", &bday, + "wants_html_set", &wants_html_set, + "wants_html", &wants_html, NULL); for (i = 0; i < sizeof(field_mapping) / sizeof(field_mapping[0]); i++) { @@ -2146,6 +2192,12 @@ fill_in_info(EContactEditor *editor) e_date_edit_set_time (dateedit, -1); } + if (editor->select_names_contacts && related_contacts && *related_contacts) { + ESelectNamesModel *model = e_select_names_manager_get_source (editor->select_names_contacts, + "contacts"); + e_select_names_model_import_destinationv (model, related_contacts); + } + set_fields(editor); } } @@ -2226,6 +2278,21 @@ extract_info(EContactEditor *editor) extract_single_field(editor, list->data); } + if (editor->select_names_contacts) { + ESelectNamesModel *model = e_select_names_manager_get_source (editor->select_names_contacts, + "contacts"); + char *string = e_select_names_model_export_destinationv (model); + if (string && *string) + gtk_object_set (GTK_OBJECT (card), + "related_contacts", string, + NULL); + else + gtk_object_set (GTK_OBJECT (card), + "related_contacts", NULL, + NULL); + g_free (string); + } + if (editor->name) gtk_object_set(GTK_OBJECT(card), "name", editor->name, diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h index d4ebd7d676..5f9ac77435 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.h +++ b/addressbook/gui/contact-editor/e-contact-editor.h @@ -26,6 +26,7 @@ #include #include +#include "addressbook/gui/component/select-names/e-select-names-manager.h" #include "addressbook/backend/ebook/e-book.h" #include "addressbook/backend/ebook/e-card.h" #include "addressbook/backend/ebook/e-card-simple.h" @@ -78,6 +79,8 @@ struct _EContactEditor GList *phone_list; GList *address_list; + ESelectNamesManager *select_names_contacts; + ECardName *name; char *company; diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am index 8d86b99109..dc84125c39 100644 --- a/addressbook/gui/widgets/Makefile.am +++ b/addressbook/gui/widgets/Makefile.am @@ -42,42 +42,43 @@ libeminicard_a_SOURCES = \ gal-view-minicard.c \ gal-view-minicard.h -noinst_PROGRAMS = \ - minicard-widget-test \ - minicard-label-test \ - minicard-test -# reflow-test -# minicard-view-test - -minicard_label_test_SOURCES = \ - test-minicard-label.c - -minicard_label_test_LDADD = \ - libeminicard.a \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_GNOME_LIBS) \ - $(top_builddir)/e-util/libeutil.la - -minicard_test_SOURCES = \ - test-minicard.c - -minicard_test_LDADD = \ - libeminicard.a \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/e-util/ename/libename.la \ - $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \ - $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \ - $(top_builddir)/addressbook/printing/libecontactprint.a \ - $(top_builddir)/addressbook/gui/merging/libecardmerging.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_GNOME_LIBS) \ - $(GNOME_PRINT_LIBS) \ - libeminicard.a - +#noinst_PROGRAMS = \ +# minicard-widget-test \ +# minicard-label-test \ +# minicard-test +## reflow-test +## minicard-view-test +# +#minicard_label_test_SOURCES = \ +# test-minicard-label.c +# +#minicard_label_test_LDADD = \ +# libeminicard.a \ +# $(EXTRA_GNOME_LIBS) \ +# $(BONOBO_GNOME_LIBS) \ +# $(top_builddir)/e-util/libeutil.la +# +#minicard_test_SOURCES = \ +# test-minicard.c +# +#minicard_test_LDADD = \ +# libeminicard.a \ +# $(top_builddir)/addressbook/backend/ebook/libebook.la \ +# $(top_builddir)/e-util/libeutil.la \ +# $(top_builddir)/libversit/libversit.la \ +# $(top_builddir)/e-util/ename/libename.la \ +# $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \ +# $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \ +# $(top_builddir)/addressbook/printing/libecontactprint.a \ +# $(top_builddir)/addressbook/gui/merging/libecardmerging.a \ +# $(top_builddir)/widgets/misc/libemiscwidgets.a \ +# $(top_builddir)/addressbook/gui/component/select-names/libeselectnames.la \ +# $(top_builddir)/e-util/libeutil.la \ +# $(EXTRA_GNOME_LIBS) \ +# $(BONOBO_GNOME_LIBS) \ +# $(GNOME_PRINT_LIBS) \ +# libeminicard.a +# #reflow_test_SOURCES = \ # test-reflow.c # @@ -110,25 +111,26 @@ minicard_test_LDADD = \ # $(top_builddir)/addressbook/printing/libecontactprint.a \ # $(top_builddir)/widgets/misc/libemiscwidgets.a \ # $(top_builddir)/e-util/libeutil.la - -minicard_widget_test_SOURCES = \ - e-minicard-widget-test.c - -minicard_widget_test_LDADD = \ - libeminicard.a \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/e-util/ename/libename.la \ - $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \ - $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \ - $(top_builddir)/addressbook/printing/libecontactprint.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/gui/merging/libecardmerging.a \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_GNOME_LIBS) \ - $(GNOME_PRINT_LIBS) +# +#minicard_widget_test_SOURCES = \ +# e-minicard-widget-test.c +# +#minicard_widget_test_LDADD = \ +# libeminicard.a \ +# $(top_builddir)/addressbook/backend/ebook/libebook.la \ +# $(top_builddir)/e-util/libeutil.la \ +# $(top_builddir)/libversit/libversit.la \ +# $(top_builddir)/e-util/ename/libename.la \ +# $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \ +# $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \ +# $(top_builddir)/addressbook/gui/component/select-names/libeselectnames.la \ +# $(top_builddir)/addressbook/printing/libecontactprint.a \ +# $(top_builddir)/widgets/misc/libemiscwidgets.a \ +# $(top_builddir)/e-util/libeutil.la \ +# $(top_builddir)/addressbook/gui/merging/libecardmerging.a \ +# $(EXTRA_GNOME_LIBS) \ +# $(BONOBO_GNOME_LIBS) \ +# $(GNOME_PRINT_LIBS) gladedir = $(datadir)/evolution/glade glade_DATA = alphabet.glade -- cgit v1.2.3