From 0a52d890e3b75aa2d1fae3da6c206055cd723cc6 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 29 Oct 2001 12:31:45 +0000 Subject: Handle returning dates here. (e_card_simple_get_allow_newlines): New 2001-10-29 Christopher James Lahey * backend/ebook/e-card-simple.c, backend/ebook/e-card-simple.h (e_card_simple_get): Handle returning dates here. (e_card_simple_get_allow_newlines): New function. Returns whether it makes much sense to have newlines in this string. * gui/component/addressbook-config.c, gui/component/addressbook-config.h (addressbook_create_new_source): The first argument here should be const. * gui/component/addressbook-storage.c: Added #include "addressbook-config.h". * gui/widgets/e-minicard-label.c (e_minicard_label_event): On an escape here, cancel editing and remove the focus from the text. * gui/widgets/e-minicard.c (add_field): Set allow_newlines here. (field_activated): Stop editing on the activate signal and remove the focus from the text. Fixes Ximian bug #12286. svn path=/trunk/; revision=14335 --- addressbook/backend/ebook/e-card-simple.c | 37 ++++++++++++++++++++++++++++++- addressbook/backend/ebook/e-card-simple.h | 2 ++ 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'addressbook/backend') diff --git a/addressbook/backend/ebook/e-card-simple.c b/addressbook/backend/ebook/e-card-simple.c index 9e6100b5f3..1a54ab00e6 100644 --- a/addressbook/backend/ebook/e-card-simple.c +++ b/addressbook/backend/ebook/e-card-simple.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "e-card-simple.h" @@ -772,10 +773,19 @@ char *e_card_simple_get (ECardSimple *simple, return NULL; case E_CARD_SIMPLE_INTERNAL_TYPE_DATE: if (simple->card) { + char buf[26]; + struct tm then; gtk_object_get(GTK_OBJECT(simple->card), field_data[field].ecard_field, &date, NULL); - return NULL; /* FIXME!!!! */ + then.tm_year = date->year; + then.tm_mon = date->month - 1; + then.tm_mday = date->day; + then.tm_hour = 12; + then.tm_min = 0; + then.tm_sec = 0; + e_strftime_fix_am_pm (buf, 26, _("%x"), &then); + return g_strdup (buf); } else return NULL; case E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS: @@ -1096,6 +1106,31 @@ const char *e_card_simple_get_name (ECardSimple *simple, return U_(field_data[field].name); } +gboolean +e_card_simple_get_allow_newlines (ECardSimple *simple, + ECardSimpleField field) +{ + ECardSimpleInternalType type = field_data[field].type; + switch(type) { + case E_CARD_SIMPLE_INTERNAL_TYPE_STRING: + case E_CARD_SIMPLE_INTERNAL_TYPE_PHONE: + case E_CARD_SIMPLE_INTERNAL_TYPE_EMAIL: + case E_CARD_SIMPLE_INTERNAL_TYPE_BOOL: + case E_CARD_SIMPLE_INTERNAL_TYPE_DATE: + case E_CARD_SIMPLE_INTERNAL_TYPE_SPECIAL: + default: + switch (field) { + case E_CARD_SIMPLE_FIELD_NOTE: + return TRUE; + default: + return FALSE; + } + + case E_CARD_SIMPLE_INTERNAL_TYPE_ADDRESS: + return TRUE; + } +} + const char *e_card_simple_get_short_name (ECardSimple *simple, ECardSimpleField field) { diff --git a/addressbook/backend/ebook/e-card-simple.h b/addressbook/backend/ebook/e-card-simple.h index 4acc95cab8..1e20085708 100644 --- a/addressbook/backend/ebook/e-card-simple.h +++ b/addressbook/backend/ebook/e-card-simple.h @@ -178,6 +178,8 @@ const char *e_card_simple_get_name (ECardSimple ECardSimpleField field); const char *e_card_simple_get_short_name (ECardSimple *simple, ECardSimpleField field); +gboolean e_card_simple_get_allow_newlines (ECardSimple *simple, + ECardSimpleField field); /* Use these only if building lists of specific types. It should be -- cgit v1.2.3