diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-05-10 00:41:58 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-05-10 00:41:58 +0800 |
commit | 85faea789a7101eccd334b3b8734b9cb697a2d38 (patch) | |
tree | 5b35fb802fb14391b940180602566a03e94f4b11 /addressbook | |
parent | 63687b2a3082e0e8731d6a91ba12aba860194542 (diff) | |
download | gsoc2013-evolution-85faea789a7101eccd334b3b8734b9cb697a2d38.tar.gz gsoc2013-evolution-85faea789a7101eccd334b3b8734b9cb697a2d38.tar.zst gsoc2013-evolution-85faea789a7101eccd334b3b8734b9cb697a2d38.zip |
Make File As change if name or company are changed pretty much anywhere.
2000-05-09 Christopher James Lahey <clahey@helixcode.com>
* backend/ebook/e-card-simple.c: Make File As change if name or
company are changed pretty much anywhere.
* gui/minicard/e-minicard.c: Turned off having minicard editing
effect anything since it's so crashy.
svn path=/trunk/; revision=2947
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 8 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-card-simple.c | 187 | ||||
-rw-r--r-- | addressbook/gui/minicard/e-minicard.c | 2 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard.c | 2 |
4 files changed, 173 insertions, 26 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index de11e3afe9..7148a75373 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,5 +1,13 @@ 2000-05-09 Christopher James Lahey <clahey@helixcode.com> + * backend/ebook/e-card-simple.c: Make File As change if name or + company are changed pretty much anywhere. + + * gui/minicard/e-minicard.c: Turned off having minicard editing + effect anything since it's so crashy. + +2000-05-09 Christopher James Lahey <clahey@helixcode.com> + * backend/pas/pas-backend-ldap.c: Enabled a couple more fields 2000-05-09 Christopher James Lahey <clahey@helixcode.com> diff --git a/addressbook/backend/ebook/e-card-simple.c b/addressbook/backend/ebook/e-card-simple.c index 58c44eb22f..6aac12742c 100644 --- a/addressbook/backend/ebook/e-card-simple.c +++ b/addressbook/backend/ebook/e-card-simple.c @@ -900,6 +900,128 @@ char *e_card_simple_get (ECardSimple *simple, } } +static char * +name_to_style(const ECardName *name, char *company, int style) +{ + char *string; + char *strings[4], **stringptr; + char *substring; + switch (style) { + case 0: + stringptr = strings; + if (name->family && *name->family) + *(stringptr++) = name->family; + if (name->given && *name->given) + *(stringptr++) = name->given; + *stringptr = NULL; + string = g_strjoinv(", ", strings); + break; + case 1: + stringptr = strings; + if (name->given && *name->given) + *(stringptr++) = name->given; + if (name->family && *name->family) + *(stringptr++) = name->family; + *stringptr = NULL; + string = g_strjoinv(" ", strings); + break; + case 2: + string = g_strdup(company); + break; + case 3: /* Fall Through */ + case 4: + stringptr = strings; + if (name->family && *name->family) + *(stringptr++) = name->family; + if (name->given && *name->given) + *(stringptr++) = name->given; + *stringptr = NULL; + substring = g_strjoinv(", ", strings); + if (!(company && *company)) + company = ""; + if (style == 3) + string = g_strdup_printf("%s (%s)", substring, company); + else + string = g_strdup_printf("%s (%s)", company, substring); + g_free(substring); + break; + default: + string = g_strdup(""); + } + return string; +} + +static int +file_as_get_style (ECardSimple *simple) +{ + char *filestring = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_FILE_AS); + char *trystring; + char *full_name = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_FULL_NAME); + char *company = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_ORG); + ECardName *name = NULL; + int i; + int style; + style = 0; + if (!full_name) + full_name = g_strdup(""); + if (!company) + company = g_strdup(""); + if (filestring) { + + name = e_card_name_from_string(full_name); + + if (!name) { + goto end; + } + + style = -1; + + for (i = 0; i < 5; i++) { + trystring = name_to_style(name, company, i); + if (!strcmp(trystring, filestring)) { + g_free(trystring); + style = i; + goto end; + } + g_free(trystring); + } + } + end: + + g_free(filestring); + g_free(full_name); + g_free(company); + if (name) + e_card_name_free(name); + + return style; +} + +static void +file_as_set_style(ECardSimple *simple, int style) +{ + if (style != -1) { + char *string; + char *full_name = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_FULL_NAME); + char *company = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_ORG); + ECardName *name; + + if (!full_name) + full_name = g_strdup(""); + if (!company) + company = g_strdup(""); + name = e_card_name_from_string(full_name); + if (name) { + string = name_to_style(name, company, style); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_FILE_AS, string); + g_free(string); + } + g_free(full_name); + g_free(company); + e_card_name_free(name); + } +} + void e_card_simple_set (ECardSimple *simple, ECardSimpleField field, const char *data) @@ -907,36 +1029,49 @@ void e_card_simple_set (ECardSimple *simple, ECardSimpleInternalType type = field_data[field].type; ECardAddrLabel *address; ECardPhone *phone; - switch(type) { - case E_CARD_SIMPLE_INTERNAL_TYPE_STRING: + int style; + switch (field) { + case E_CARD_SIMPLE_FIELD_FULL_NAME: + case E_CARD_SIMPLE_FIELD_ORG: + style = file_as_get_style(simple); gtk_object_set(GTK_OBJECT(simple->card), field_data[field].ecard_field, data, NULL); + file_as_set_style(simple, style); break; - case E_CARD_SIMPLE_INTERNAL_TYPE_DATE: - break; /* FIXME!!!! */ - case E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS: - address = e_card_address_label_new(); - address->data = (char *) data; - e_card_simple_set_address(simple, - field_data[field].list_type_index, - address); - address->data = NULL; - e_card_address_label_free(address); - break; - case E_CARD_SIMPLE_INTERNAL_TYPE_PHONE: - phone = e_card_phone_new(); - phone->number = (char *) data; - e_card_simple_set_phone(simple, - field_data[field].list_type_index, - phone); - phone->number = NULL; - e_card_phone_free(phone); - break; - case E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL: - e_card_simple_set_email(simple, - field_data[field].list_type_index, - data); + default: + switch(type) { + case E_CARD_SIMPLE_INTERNAL_TYPE_STRING: + gtk_object_set(GTK_OBJECT(simple->card), + field_data[field].ecard_field, data, + NULL); + break; + case E_CARD_SIMPLE_INTERNAL_TYPE_DATE: + break; /* FIXME!!!! */ + case E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS: + address = e_card_address_label_new(); + address->data = (char *) data; + e_card_simple_set_address(simple, + field_data[field].list_type_index, + address); + address->data = NULL; + e_card_address_label_free(address); + break; + case E_CARD_SIMPLE_INTERNAL_TYPE_PHONE: + phone = e_card_phone_new(); + phone->number = (char *) data; + e_card_simple_set_phone(simple, + field_data[field].list_type_index, + phone); + phone->number = NULL; + e_card_phone_free(phone); + break; + case E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL: + e_card_simple_set_email(simple, + field_data[field].list_type_index, + data); + break; + } break; } } diff --git a/addressbook/gui/minicard/e-minicard.c b/addressbook/gui/minicard/e-minicard.c index 7b7b1bcbe5..73eed600c4 100644 --- a/addressbook/gui/minicard/e-minicard.c +++ b/addressbook/gui/minicard/e-minicard.c @@ -337,6 +337,7 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) NULL ); e_minicard->has_focus = TRUE; } else { +#if 0 EBook *book; e_card_simple_sync_card(e_minicard->simple); @@ -350,6 +351,7 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) e_minicard->card, card_changed_cb, NULL); +#endif gnome_canvas_item_set( e_minicard->rect, "outline_color", NULL, diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index 7b7b1bcbe5..73eed600c4 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -337,6 +337,7 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) NULL ); e_minicard->has_focus = TRUE; } else { +#if 0 EBook *book; e_card_simple_sync_card(e_minicard->simple); @@ -350,6 +351,7 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) e_minicard->card, card_changed_cb, NULL); +#endif gnome_canvas_item_set( e_minicard->rect, "outline_color", NULL, |